]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #88339 - piegamesde:master, r=joshtriplett
Yuki Okushi [Fri, 17 Sep 2021 05:09:45 +0000 (14:09 +0900)]
Rollup merge of #88339 - piegamesde:master, r=joshtriplett

Add TcpListener::into_incoming and IntoIncoming

The `incoming` method is really useful, however for some use cases the borrow
this introduces is needlessly restricting. Thus, an owned variant is added.

r? ``@joshtriplett``

2 years agoRollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakis
Yuki Okushi [Fri, 17 Sep 2021 05:09:44 +0000 (14:09 +0900)]
Rollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakis

Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types

Fixes #87496. There is also another function in the same file that looks fishy, but I haven't been able to produce an ICE there, and in any case, it's not related to #87496:
https://github.com/rust-lang/rust/blob/fd853c00e255559255885aadff9e93a1760c8728/compiler/rustc_lint/src/types.rs#L720-L734

r? ```@JohnTitor```

2 years agoRollup merge of #86382 - JohnTitor:try-desugar, r=estebank
Yuki Okushi [Fri, 17 Sep 2021 05:09:43 +0000 (14:09 +0900)]
Rollup merge of #86382 - JohnTitor:try-desugar, r=estebank

Make diagnostics clearer for `?` operators

Re-submission of #75029, fixes #71309
This also revives the `content` methods removed by #83185.
r? `@estebank`

2 years agoMake diagnostics clearer for `?` operators
Yuki Okushi [Wed, 16 Jun 2021 21:35:42 +0000 (06:35 +0900)]
Make diagnostics clearer for `?` operators

2 years agoAuto merge of #88832 - pcwalton:debug-unit-variant-fast-path, r=oli-obk
bors [Fri, 17 Sep 2021 01:00:11 +0000 (01:00 +0000)]
Auto merge of #88832 - pcwalton:debug-unit-variant-fast-path, r=oli-obk

Introduce a fast path that avoids the `debug_tuple` abstraction when deriving Debug for unit-like enum variants.

The intent here is to allow LLVM to remove the switch entirely in favor of an
indexed load from a table of constant strings, which is likely what the
programmer would write in C. Unfortunately, LLVM currently doesn't perform this
optimization due to a bug, but there is [a
patch](https://reviews.llvm.org/D109565) that fixes this issue. I've verified
that, with that patch applied on top of this commit, Debug for unit-like tuple
variants becomes a load, reducing the O(n) code bloat to O(1).

Note that inlining `DebugTuple::finish()` wasn't enough to allow LLVM to
optimize the code properly; I had to avoid the abstraction entirely. Not using
the abstraction is likely better for compile time anyway.

Part of #88793.

r? `@oli-obk`

2 years agoAuto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisa
bors [Thu, 16 Sep 2021 22:17:33 +0000 (22:17 +0000)]
Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisa

Point at argument instead of call for their obligations

When an obligation is introduced by a specific `fn` argument, point at
the argument instead of the `fn` call if the obligation fails to be
fulfilled.

Move the information about pointing at the call argument expression in
an unmet obligation span from the `FulfillmentError` to a new
`ObligationCauseCode`.

When giving an error about an obligation introduced by a function call
that an argument doesn't fulfill, and that argument is a block, add a
span_label pointing at the innermost tail expression.

Current output:

```
error[E0425]: cannot find value `x` in this scope
 --> f10.rs:4:14
  |
4 |         Some(x * 2)
  |              ^ not found in this scope

error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
 --> f10.rs:2:31
  |
2 |       let p = Some(45).and_then({
  |  ______________________--------_^
  | |                      |
  | |                      required by a bound introduced by this call
3 | |         |x| println!("doubling {}", x);
4 | |         Some(x * 2)
  | |         -----------
5 | |     });
  | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
  |
  = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
```

Previous output:

```
error[E0425]: cannot find value `x` in this scope
 --> f10.rs:4:14
  |
4 |         Some(x * 2)
  |              ^ not found in this scope

error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
 --> f10.rs:2:22
  |
2 |     let p = Some(45).and_then({
  |                      ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
  |
  = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
```

Partially address #27300. Will require rebasing on top of #88546.

2 years agoAuto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearth
bors [Thu, 16 Sep 2021 19:33:39 +0000 (19:33 +0000)]
Auto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearth

Rollup of 10 pull requests

Successful merges:

 - #88292 (Enable --generate-link-to-definition for rustc's docs)
 - #88729 (Recover from `Foo(a: 1, b: 2)`)
 - #88875 (cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented)
 - #88892 (Move object safety suggestions to the end of the error)
 - #88928 (Document the closure arguments for `reduce`.)
 - #88976 (Clean up and add doc comments for CStr)
 - #88983 (Allow calling `get_body_with_borrowck_facts` without `-Z polonius`)
 - #88985 (Update clobber_abi list to include k[1-7] regs)
 - #88986 (Update the backtrace crate)
 - #89009 (Fix typo in `break` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #89009 - tatami4:master, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:25 +0000 (10:57 -0700)]
Rollup merge of #89009 - tatami4:master, r=Mark-Simulacrum

Fix typo in `break` docs

2 years agoRollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:24 +0000 (10:57 -0700)]
Rollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum

Update the backtrace crate

https://github.com/rust-lang/backtrace-rs/pull/437 fixed backtraces in
OpenBSD -> update it here as well so OpenBSD Rust code can produce
proper backtraces.

2 years agoRollup merge of #88985 - Commeownist:patch-1, r=Amanieu
Manish Goregaokar [Thu, 16 Sep 2021 17:57:23 +0000 (10:57 -0700)]
Rollup merge of #88985 - Commeownist:patch-1, r=Amanieu

Update clobber_abi list to include k[1-7] regs

2 years agoRollup merge of #88983 - willcrichton:allow-single-polonius-call, r=ecstatic-morse
Manish Goregaokar [Thu, 16 Sep 2021 17:57:22 +0000 (10:57 -0700)]
Rollup merge of #88983 - willcrichton:allow-single-polonius-call, r=ecstatic-morse

Allow calling `get_body_with_borrowck_facts` without `-Z polonius`

For my [static analysis tool](https://github.com/willcrichton/flowistry), I need to access the set of outlives-constraints. Recently, #86977 merged a way to access these facts via Polonius. However, the merged implementation requires `-Z polonius` to be provided to use this feature. This uses Polonius for borrow checking on the entire crate, which as described [here](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Polonius.20performance.20in.20a.20rustc.20plugin/near/251301631), is very slow.

This PR allows `get_body_with_borrowck_facts` to be called without `-Z polonius`. This is essential for my tool to run in a sensible length of time. This is a temporary patch as the Polonius-related APIs develop -- I can update my code as future changes happen.

Additionally, this PR also makes public two APIs that were previously public but then became private after `rustc_mir` got broken up: `rustc_mir_dataflow::framework::graphviz` and `rustc_mir_transform::MirPass`. I need both of these for my analysis tool. (I can break this change into a separate PR if necessary.)

2 years agoRollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:21 +0000 (10:57 -0700)]
Rollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Mark-Simulacrum

Clean up and add doc comments for CStr

CC #51430

2 years agoRollup merge of #88928 - lefth:master, r=Mark-Simulacrum
Manish Goregaokar [Thu, 16 Sep 2021 17:57:20 +0000 (10:57 -0700)]
Rollup merge of #88928 - lefth:master, r=Mark-Simulacrum

Document the closure arguments for `reduce`.

See issue #88927.

2 years agoRollup merge of #88892 - estebank:trait-objects, r=petrochenkov
Manish Goregaokar [Thu, 16 Sep 2021 17:57:20 +0000 (10:57 -0700)]
Rollup merge of #88892 - estebank:trait-objects, r=petrochenkov

Move object safety suggestions to the end of the error

2 years agoRollup merge of #88875 - notriddle:notriddle/cleanup-unused-trait-selection, r=Mark...
Manish Goregaokar [Thu, 16 Sep 2021 17:57:19 +0000 (10:57 -0700)]
Rollup merge of #88875 - notriddle:notriddle/cleanup-unused-trait-selection, r=Mark-Simulacrum

cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented

This isn't allowed by the validator, and seems to be unused.
When it was added in ed10a3faae1fd1176b2edf4a61438e0542c103b9,
it was used on `Sized`, and that usage is gone.

2 years agoRollup merge of #88729 - estebank:struct-literal-using-parens, r=oli-obk
Manish Goregaokar [Thu, 16 Sep 2021 17:57:18 +0000 (10:57 -0700)]
Rollup merge of #88729 - estebank:struct-literal-using-parens, r=oli-obk

Recover from `Foo(a: 1, b: 2)`

Detect likely `struct` literal using parentheses as delimiters and emit
targeted suggestion instead of type ascription parse error.

Fix #61326.

2 years agoRollup merge of #88292 - SkiFire13:enable-rustdoc-links, r=jyn514
Manish Goregaokar [Thu, 16 Sep 2021 17:57:17 +0000 (10:57 -0700)]
Rollup merge of #88292 - SkiFire13:enable-rustdoc-links, r=jyn514

Enable --generate-link-to-definition for rustc's docs

cc `@jyn514`

2 years agoAuto merge of #88979 - tmiasko:no-remove-zsts-in-generators, r=oli-obk
bors [Thu, 16 Sep 2021 16:46:02 +0000 (16:46 +0000)]
Auto merge of #88979 - tmiasko:no-remove-zsts-in-generators, r=oli-obk

Disable RemoveZsts in generators to avoid query cycles

Querying layout of a generator requires its optimized MIR. Thus
computing layout during MIR optimization of a generator might create a
query cycle. Disable RemoveZsts in generators to avoid the issue
(similar approach is used in ConstProp transform already).

Fixes #88972.

2 years agofix rebase
Esteban Kuber [Thu, 16 Sep 2021 14:01:37 +0000 (14:01 +0000)]
fix rebase

2 years agoAuto merge of #88219 - jyn514:parallel-io, r=GuillaumeGomez
bors [Thu, 16 Sep 2021 13:47:55 +0000 (13:47 +0000)]
Auto merge of #88219 - jyn514:parallel-io, r=GuillaumeGomez

rustdoc: reduce number of copies when using parallel IO

This is Windows-only for now; I was getting really bad slowdowns from this on linux for some reason.

Helps with https://github.com/rust-lang/rust/issues/82741. Follow-up to https://github.com/rust-lang/rust/pull/60971.

2 years agoPoint at argument when evaluating `Path`'s bounds
Esteban Kuber [Tue, 14 Sep 2021 10:52:36 +0000 (10:52 +0000)]
Point at argument when evaluating `Path`'s bounds

When evaluating an `ExprKind::Call`, we first have to `check_expr` on it's
callee. When this one is a `ExprKind::Path`, we had to evaluate the bounds
introduced for its arguments, but by the time we evaluated them we no
longer had access to the argument spans. Now we special case this so
that we can point at the right place on unsatisfied bounds. This also
allows the E0277 deduplication to kick in correctly, so we now emit
fewer errors.

2 years agoFix rebase
Esteban Kuber [Sun, 12 Sep 2021 20:36:58 +0000 (20:36 +0000)]
Fix rebase

2 years agoRemove unnecessary label
Esteban Kuber [Tue, 7 Sep 2021 14:25:40 +0000 (14:25 +0000)]
Remove unnecessary label

2 years agofix rebase
Esteban Kuber [Tue, 7 Sep 2021 14:05:08 +0000 (14:05 +0000)]
fix rebase

2 years agofix `clone` call
Esteban Kuber [Tue, 7 Sep 2021 13:23:39 +0000 (13:23 +0000)]
fix `clone` call

2 years agoAccount for blocks in arguments
Esteban Kuber [Tue, 7 Sep 2021 11:57:01 +0000 (11:57 +0000)]
Account for blocks in arguments

When giving an error about an obligation introduced by a function call
that an argument doesn't fulfill, and that argument is a block, add a
span_label pointing at the innermost tail expression.

2 years agoPoint at call span that introduced obligation for the arg
Esteban Kuber [Tue, 7 Sep 2021 11:30:53 +0000 (11:30 +0000)]
Point at call span that introduced obligation for the arg

2 years agoRefactor `FulfillmentError` to track less data
Esteban Kuber [Tue, 7 Sep 2021 11:19:57 +0000 (11:19 +0000)]
Refactor `FulfillmentError` to track less data

Move the information about pointing at the call argument expression in
an unmet obligation span from the `FulfillmentError` to a new
`ObligationCauseCode`.

2 years agoPoint at argument instead of call for their obligations
Esteban Kuber [Tue, 7 Sep 2021 07:42:44 +0000 (07:42 +0000)]
Point at argument instead of call for their obligations

When an obligation is introduced by a specific `fn` argument, point at
the argument instead of the `fn` call if the obligation fails to be
fulfilled.

2 years agoFix typo in `break` docs
tatami4 [Thu, 16 Sep 2021 11:51:14 +0000 (14:51 +0300)]
Fix typo in `break` docs

2 years agoEnable rustdoc's --generate-link-to-definition for rustc docs
Giacomo Stevanato [Tue, 24 Aug 2021 15:23:20 +0000 (17:23 +0200)]
Enable rustdoc's --generate-link-to-definition for rustc docs

2 years agoAuto merge of #86809 - DevinR528:reachable-pat, r=Nadrieril
bors [Thu, 16 Sep 2021 05:29:22 +0000 (05:29 +0000)]
Auto merge of #86809 - DevinR528:reachable-pat, r=Nadrieril

Add non_exhaustive_omitted_patterns lint related to rfc-2008-non_exhaustive

Fixes: #84332
This PR adds `non_exhaustive_omitted_patterns`, an allow by default lint that is triggered when a `non_exhaustive` type is missing explicit patterns. The warning or deny attribute can be put above the wildcard `_` pattern on enums or on the expression for enums or structs. The lint is capable of warning about multiple types within the same pattern. This lint will not be triggered for `if let ..` patterns.

```rust
// crate A
#[non_exhaustive]
pub struct Foo {
    a: u8,
    b: usize,
}
#[non_exhaustive]
pub enum Bar {
    A(Foo),
    B,
}

// crate B
#[deny(non_exhaustive_omitted_patterns)] // here
match Bar::B {
    Bar::B => {}
    #[deny(non_exhaustive_omitted_patterns)] // or here
    _ => {}
}

#[warn(non_exhaustive_omitted_patterns)] // only here
let Foo { a, .. } = Foo::default();

#[deny(non_exhaustive_omitted_patterns)]
match Bar::B {
    // triggers for Bar::B, and Foo.b
    Bar::A(Foo { a, .. }) => {}
    // if the attribute was here only Bar::B would cause a warning
    _ => {}
}
```

2 years agoAuto merge of #88992 - Manishearth:rollup-k9hijii, r=Manishearth
bors [Thu, 16 Sep 2021 02:00:08 +0000 (02:00 +0000)]
Auto merge of #88992 - Manishearth:rollup-k9hijii, r=Manishearth

Rollup of 8 pull requests

Successful merges:

 - #87320 (Introduce -Z remap-cwd-prefix switch)
 - #88690 (Accept `m!{ .. }.method()` and `m!{ .. }?` statements. )
 - #88775 (Revert anon union parsing)
 - #88841 (feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`)
 - #88907 (Highlight the `const fn` if error happened because of a bound on the impl block)
 - #88915 (`Wrapping<T>` has the same layout and ABI as `T`)
 - #88933 (Remove implementation of `min_align_of` intrinsic)
 - #88951 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoAuto merge of #88977 - ehuss:disable-validate-maintainers, r=Mark-Simulacrum
bors [Wed, 15 Sep 2021 23:02:02 +0000 (23:02 +0000)]
Auto merge of #88977 - ehuss:disable-validate-maintainers, r=Mark-Simulacrum

Disable validate_maintainers.

The validate_maintainers check has started to fail with the error:

```
HTTPError: HTTP Error 403: Forbidden
b'{"message":"Must have admin access to view repository collaborators.","documentation_url":"https://docs.github.com/rest/reference/repos#list-repository-collaborators"}'
```

Apparently GitHub has restricted the collaborators API to admins.  For now, this just disables the check to get CI working again.  Eventually, I think we'll just need to remove the check since we will unlikely use an admin token, and I don't see a workaround.  The `MAINTAINERS` list doesn't change often, so we may just need to put a sternly worded comment near the list.

2 years agoDisable debuginfo test on Windows that fails in new cdb version.
Eric Huss [Wed, 15 Sep 2021 22:59:48 +0000 (15:59 -0700)]
Disable debuginfo test on Windows that fails in new cdb version.

2 years agoRollup merge of #88951 - ehuss:update-books, r=ehuss
Manish Goregaokar [Wed, 15 Sep 2021 21:57:04 +0000 (14:57 -0700)]
Rollup merge of #88951 - ehuss:update-books, r=ehuss

Update books

## rust-by-example

1 commits in 04f489c889235fe3b6dfe678ae5410d07deda958..9d4132b56c4999cd3ce1aeca5f1b2f2cb0d11c24
2021-08-17 08:01:20 -0300 to 2021-09-14 06:56:00 -0300
- Fix link to "integration testing" page (rust-lang/rust-by-example#1458)

## rustc-dev-guide

17 commits in 95f1acf9a39d6f402f654e917e2c1dfdb779c5fc..9198465b6ca8bed669df0cbb67c0e6d0b140803c
2021-08-31 12:38:30 -0500 to 2021-09-12 11:50:44 -0500
- Clarify difference of a help vs note diagnostic.
- remove ctag section
- Update suggested.md
- Update SUMMARY.md
- Move ctag section to "Suggested Workflow"
- Delete ctags.md
- Clarify paragraph in "Keeping things up to date"
- Docs: added section on rustdoc
- Docs: made suggested fix
- Docs: deleted copy
- Docs: added section discussing core ideas
- Docs: delete redundant use of correctness
- Docs: consolidated parallelism information
- Add links to overview.md (rust-lang/rustc-dev-guide#1202)
- Spelling change intermidiate to intermediate
- Fix a typo (rust-lang/rustc-dev-guide#1200)
- Documenting diagnostic items with their usage and naming conventions (rust-lang/rustc-dev-guide#1192)

## embedded-book

1 commits in c3a51e23859554369e6bbb5128dcef0e4f159fb5..4c76da9ddb4650203c129fceffdea95a3466c205
2021-08-26 07:04:58 +0000 to 2021-09-12 12:43:03 +0000
- 2.1(QEMU): update app name for git project init  (rust-embedded/book#301)

2 years agoRollup merge of #88933 - tmiasko:remove-min-align-of, r=oli-obk
Manish Goregaokar [Wed, 15 Sep 2021 21:57:03 +0000 (14:57 -0700)]
Rollup merge of #88933 - tmiasko:remove-min-align-of, r=oli-obk

Remove implementation of `min_align_of` intrinsic

Since #88839 `min_align_of` is lowered to AlignOf operator.

2 years agoRollup merge of #88915 - joshlf:patch-4, r=kennytm
Manish Goregaokar [Wed, 15 Sep 2021 21:57:02 +0000 (14:57 -0700)]
Rollup merge of #88915 - joshlf:patch-4, r=kennytm

`Wrapping<T>` has the same layout and ABI as `T`

2 years agoRollup merge of #88907 - WaffleLapkin:targeted_const_fn_with_a_bound_in_impl_block_er...
Manish Goregaokar [Wed, 15 Sep 2021 21:57:01 +0000 (14:57 -0700)]
Rollup merge of #88907 - WaffleLapkin:targeted_const_fn_with_a_bound_in_impl_block_error, r=estebank

Highlight the `const fn` if error happened because of a bound on the impl block

Currently, for the following code, the compiler produces the errors like the
following:
```rust
struct Type<T>(T);

impl<T: Clone> Type<T> {
    const fn f() {}
}
```
```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

This can be confusing (especially to newcomers) since the error mentions "const fn parameters", but highlights only the impl.

This PR adds function highlighting, changing the error to the following:

```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
4 |     pub const fn f() {}
  |     ---------------- function declared as const here
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

---

I've originally wanted to point directly to `const` token, but couldn't find a way to get it's span. It seems like this span is lost during the AST -> HIR lowering.

Also, since the errors for object casts in `const fn`s (`&T` -> `&dyn Trait`) seem to trigger the same error, this PR accidentally changes these errors too. Not sure if it's desired or how to fix this.

P.S. it's my first time contributing to diagnostics, so feedback is very appreciated!

---

r? ```@estebank```

```@rustbot``` label: +A-diagnostics

2 years agoRollup merge of #88841 - notriddle:notriddle/method-parens, r=estebank
Manish Goregaokar [Wed, 15 Sep 2021 21:56:59 +0000 (14:56 -0700)]
Rollup merge of #88841 - notriddle:notriddle/method-parens, r=estebank

feat(rustc_typeck): suggest removing bad parens in `(recv.method)()`

Fixes #88803

2 years agoRollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco
Manish Goregaokar [Wed, 15 Sep 2021 21:56:58 +0000 (14:56 -0700)]
Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco

Revert anon union parsing

Revert PR #84571 and #85515, which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code.

Fix #88583.

2 years agoRollup merge of #88690 - m-ou-se:macro-braces-dot-question-expr-parse, r=nagisa
Manish Goregaokar [Wed, 15 Sep 2021 21:56:57 +0000 (14:56 -0700)]
Rollup merge of #88690 - m-ou-se:macro-braces-dot-question-expr-parse, r=nagisa

Accept `m!{ .. }.method()` and `m!{ .. }?` statements.

This PR fixes something that I keep running into when using `quote!{}.into()` in a proc macro to convert the `proc_macro2::TokenStream` to a `proc_macro::TokenStream`:

Before:

```
error: expected expression, found `.`
 --> src/lib.rs:6:6
  |
4 |     quote! {
5 |         ...
6 |     }.into()
  |      ^ expected expression
```

After:
```
```
(No output, compiles fine.)

---

Context:

For expressions like `{ 1 }` and `if true { 1 } else { 2 }`, we accept them as full statements without a trailing `;`, which means the following is not accepted:

```rust
{ 1 } - 1 // error
```

since that is parsed as two statements: `{ 1 }` and `-1`. Syntactically correct, but the type of `{ 1 }` should be `()` as there is no `;`.

However, for specifically `.` and `?` after the `}`, we do [continue parsing it as an expression](https://github.com/rust-lang/rust/blob/13db8440bbbe42870bc828d4ec3e965b38670277/compiler/rustc_parse/src/parser/expr.rs#L864-L876):

```rust
{ "abc" }.len(); // ok
```

For braced macro invocations, we do not do this:

```rust
vec![1, 2, 3].len(); // ok
vec!{1, 2, 3}.len(); // error
```

(It parses `vec!{1, 2, 3}` as a full statement, and then complains about `.len()` not being a valid expression.)

This PR changes this to also look for a `.` and `?` after a braced macro invocation. We can be sure the macro is an expression and not a full statement in those cases, since no statement can start with a `.` or `?`.

2 years agoRollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister
Manish Goregaokar [Wed, 15 Sep 2021 21:56:56 +0000 (14:56 -0700)]
Rollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister

Introduce -Z remap-cwd-prefix switch

This switch remaps any absolute paths rooted under the current
working directory to a new value. This includes remapping the
debug info in `DW_AT_comp_dir` and `DW_AT_decl_file`.

Importantly, this flag does not require passing the current working
directory to the compiler, such that the command line can be
run on any machine (with the same input files) and produce the
same results. This is critical property for debugging compiler
issues that crop up on remote machines.

This is based on adetaylor's https://github.com/rust-lang/rust/commit/dbc4ae7cba0ba8d650b91ddd459b86a02a2d05c5

Major Change Proposal: https://github.com/rust-lang/compiler-team/issues/450
Discussed on #38322. Would resolve issue #87325.

2 years agoAllow call to get_body_with_borrowck_facts without -Z polonius
Will Crichton [Wed, 15 Sep 2021 18:45:31 +0000 (11:45 -0700)]
Allow call to get_body_with_borrowck_facts without -Z polonius

2 years agoMake rustc_mir_dataflow::framework::graphviz and rustc_mir_transform::MirPass public
Will Crichton [Wed, 15 Sep 2021 18:41:37 +0000 (11:41 -0700)]
Make rustc_mir_dataflow::framework::graphviz and rustc_mir_transform::MirPass public

2 years agoUpdate the backtrace crate
Henrik Böving [Wed, 15 Sep 2021 18:32:35 +0000 (20:32 +0200)]
Update the backtrace crate

https://github.com/rust-lang/backtrace-rs/pull/437 fixed backtraces in
OpenBSD -> update it here as well so OpenBSD Rust code can produce
proper backtraces.

2 years agoUpdate clobber_abi list to include k[1-7] regs
Commeownist [Wed, 15 Sep 2021 18:31:59 +0000 (21:31 +0300)]
Update clobber_abi list to include k[1-7] regs

2 years agoDisable both reproducible-build tests for crate-type=bin
danakj [Wed, 15 Sep 2021 17:37:22 +0000 (13:37 -0400)]
Disable both reproducible-build tests for crate-type=bin

These tests fail on Windows, as the build is not deterministic there for
bin targets.

Issue https://github.com/rust-lang/rust/issues/88982 is filed for this
problem.

2 years agoDisable RemoveZsts in generators to avoid query cycles
Tomasz Miąsko [Wed, 15 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Disable RemoveZsts in generators to avoid query cycles

Querying layout of a generator requires its optimized MIR. Thus
computing layout during MIR optimization of a generator might create a
query cycle. Disable RemoveZsts in generators to avoid the issue
(similar approach is used in ConstProp transform already).

2 years agoDisable validate_maintainers.
Eric Huss [Wed, 15 Sep 2021 16:25:06 +0000 (09:25 -0700)]
Disable validate_maintainers.

2 years agodocs(std): add docs for cof_from_cstr impls
Michael Howell [Wed, 15 Sep 2021 16:14:20 +0000 (09:14 -0700)]
docs(std): add docs for cof_from_cstr impls

CC #51430

2 years agochore(rustc_expand): fix typo in comment
Michael Howell [Wed, 15 Sep 2021 16:13:18 +0000 (09:13 -0700)]
chore(rustc_expand): fix typo in comment

2 years agoVerify bin crates are not deterministic on Windows
danakj [Wed, 15 Sep 2021 15:49:12 +0000 (11:49 -0400)]
Verify bin crates are not deterministic on Windows

This disables the remap_cwd_bin test which is failing on windows,
and adds a test for --remap-path-prefix making a bin crate
instead, to see if it will fail the same way.

2 years agoMove object safety suggestions to the end of the error
Esteban Kuber [Sun, 12 Sep 2021 18:49:56 +0000 (18:49 +0000)]
Move object safety suggestions to the end of the error

2 years agoAuto merge of #87867 - bjorn3:unique_type_id_interner, r=wesleywiser
bors [Wed, 15 Sep 2021 12:34:31 +0000 (12:34 +0000)]
Auto merge of #87867 - bjorn3:unique_type_id_interner, r=wesleywiser

Use a separate interner type for UniqueTypeId

Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols
with the global interner. In fact the Debug implementation of
UniqueTypeId did exactly this.

Using a separate interner type also avoids prefilling the interner with
unused symbols and allow for optimizing the symbol interner for parallel
access without negatively affecting the single threaded module codegen.

2 years agoAuto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu
bors [Wed, 15 Sep 2021 09:30:00 +0000 (09:30 +0000)]
Auto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu

Remove `cfg(doc)` from std::os module reexports to fix rustdoc linking issues

Fixes https://github.com/rust-lang/rust/issues/88304.

I tested it based on https://github.com/rust-lang/rust/pull/88292.

Not sure if it's the best approach, but at least it makes thing a bit simpler.

cc `@jyn514`

2 years agoAuto merge of #88558 - fee1-dead:const-drop, r=oli-obk
bors [Wed, 15 Sep 2021 03:51:03 +0000 (03:51 +0000)]
Auto merge of #88558 - fee1-dead:const-drop, r=oli-obk

Const drop

The changes are pretty primitive at this point. But at least it works. ^-^

Problems with the current change that I can think of now:
 - [x] `~const Drop` shouldn't change anything in the non-const world.
 - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`.
 - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue.

Fixes #88424.

Significant Changes:

- `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue)
- `T: ~const Drop` will not be linted like `T: Drop`.
- Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others.

Changes not related to `const Drop`ping and/or changes that are insignificant:

 - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed.
 - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir.
 - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor.

r? `@oli-obk`

2 years agoUpdate books
Eric Huss [Wed, 15 Sep 2021 00:57:07 +0000 (17:57 -0700)]
Update books

2 years agoAdd reachable_patterns lint to rfc-2008-non_exhaustive
Devin Ragotzy [Fri, 10 Sep 2021 20:45:04 +0000 (16:45 -0400)]
Add reachable_patterns lint to rfc-2008-non_exhaustive

Add linting on non_exhaustive structs and enum variants

Add ui tests for non_exhaustive reachable lint

Rename to non_exhaustive_omitted_patterns and avoid triggering on if let

2 years agoreview comment: move recovery code to its own function
Esteban Kuber [Tue, 14 Sep 2021 18:16:33 +0000 (18:16 +0000)]
review comment: move recovery code to its own function

2 years agoAuto merge of #73314 - GuillaumeGomez:display-warnings, r=jyn514
bors [Tue, 14 Sep 2021 16:05:44 +0000 (16:05 +0000)]
Auto merge of #73314 - GuillaumeGomez:display-warnings, r=jyn514

Rename "--display-warnings" to "--display-doctest-warnings"

Fixes #41574.

cc `@ollie27`
r? `@kinnison`

2 years agoRemove implementation of `min_align_of` intrinsic
Tomasz Miąsko [Tue, 14 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Remove implementation of `min_align_of` intrinsic

Since 88839 `min_align_of` is lowered to AlignOf operator.

2 years agoAdd test for --display-doctest-warnings option
Guillaume Gomez [Thu, 9 Sep 2021 14:52:48 +0000 (16:52 +0200)]
Add test for --display-doctest-warnings option

2 years agoRename --display-warnings to --display-doctest-warnings
Guillaume Gomez [Thu, 9 Sep 2021 14:52:19 +0000 (16:52 +0200)]
Rename --display-warnings to --display-doctest-warnings

2 years agoAuto merge of #88914 - GuillaumeGomez:rollup-h5svc6w, r=GuillaumeGomez
bors [Tue, 14 Sep 2021 08:46:22 +0000 (08:46 +0000)]
Auto merge of #88914 - GuillaumeGomez:rollup-h5svc6w, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #88033 (Add links for primitives in "jump to definition" feature)
 - #88722 (Make `UnsafeCell::get_mut` const)
 - #88851 (Fix duplicate bounds for const_trait_impl)
 - #88859 (interpreter PointerArithmetic: use new Size helper methods)
 - #88885 (Fix jump def background)
 - #88894 (Improve error message for missing trait in trait impl)
 - #88896 (Reduce possibility of flaky tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoDocument the closure arguments for `reduce`.
Dan Zwell [Tue, 14 Sep 2021 06:22:49 +0000 (14:22 +0800)]
Document the closure arguments for `reduce`.

Fixes issue #88927.

2 years agoAuto merge of #87794 - bonega:enum_niche_prefer_zero, r=nagisa
bors [Mon, 13 Sep 2021 22:14:57 +0000 (22:14 +0000)]
Auto merge of #87794 - bonega:enum_niche_prefer_zero, r=nagisa

Enum should prefer discriminant zero for niche

Given an enum with unassigned zero-discriminant, rust should prefer it for niche selection.
Zero as discriminant for `Option<Enum>` makes it possible for LLVM to optimize resulting asm.

- Eliminate branch when expected value coincides.
- Use smaller instruction `test eax, eax` instead of `cmp eax, ?`
- Possible interaction with zeroed memory?

Example:
```rust

pub enum Size {
    One = 1,
    Two = 2,
    Three = 3,
}

pub fn handle(x: Option<Size>) -> u8 {
    match x {
        None => {0}
        Some(size) => {size as u8}
    }
}
```
In this case discriminant zero is available as a niche.

Above example on nightly:
```asm
 mov     eax, edi
 cmp     al, 4
 jne     .LBB0_2
 xor     eax, eax
.LBB0_2:
 ret
```

PR:
```asm
 mov     eax, edi
 ret
```

I created this PR because I had a performance regression when I tried to use an enum to represent legal grapheme byte-length for utf8.

Using an enum instead of `NonZeroU8` [here](https://github.com/bonega/yore/blob/d683304f5dfe2e99f769e6ab8adf8d60a0d1d9b3/src/internal/decoder_incomplete.rs#L90)
resulted in a performance regression of about 5%.
I consider this to be a somewhat realistic benchmark.

Thanks to `@ogoffart` for pointing me in the right direction!

Edit: Updated description

2 years agoenum niche allocation grows toward zero if possible
Andreas Liljeqvist [Sun, 8 Aug 2021 11:34:46 +0000 (13:34 +0200)]
enum niche allocation grows toward zero if possible

2 years ago`Wrapping<T>` has the same layout and ABI as `T`
Joshua Liebow-Feeser [Mon, 13 Sep 2021 19:39:45 +0000 (12:39 -0700)]
`Wrapping<T>` has the same layout and ABI as `T`

2 years agoUpdate permissions path for clippy lint
Guillaume Gomez [Mon, 13 Sep 2021 19:27:53 +0000 (21:27 +0200)]
Update permissions path for clippy lint

2 years agoRollup merge of #88896 - GuillaumeGomez:flakyness, r=camelid
Guillaume Gomez [Mon, 13 Sep 2021 19:20:43 +0000 (21:20 +0200)]
Rollup merge of #88896 - GuillaumeGomez:flakyness, r=camelid

Reduce possibility of flaky tests

As asked in https://github.com/rust-lang/rust/pull/88885.

r? ``@camelid``

2 years agoRollup merge of #88894 - FabianWolff:issue-88818, r=estebank
Guillaume Gomez [Mon, 13 Sep 2021 19:20:42 +0000 (21:20 +0200)]
Rollup merge of #88894 - FabianWolff:issue-88818, r=estebank

Improve error message for missing trait in trait impl

Fixes #88818. For the following example:
```rust
struct S { }
impl for S { }
```
the current output is:
```
error: missing trait in a trait impl
 --> t1.rs:2:5
  |
2 | impl for S { }
  |     ^
```
With my changes, I get:
```
error: missing trait in a trait impl
 --> t1.rs:2:5
  |
2 | impl for S { }
  |     ^
  |
help: add a trait here
  |
2 | impl Trait for S { }
  |      +++++
help: for an inherent impl, drop this `for`
  |
2 - impl for S { }
2 + impl S { }
  |
```

2 years agoRollup merge of #88885 - GuillaumeGomez:fix-jump-def-background, r=camelid
Guillaume Gomez [Mon, 13 Sep 2021 19:20:41 +0000 (21:20 +0200)]
Rollup merge of #88885 - GuillaumeGomez:fix-jump-def-background, r=camelid

Fix jump def background

Fixes #88870.

I somehow badly wrote the color in #88111.

r? ``@camelid``

2 years agoRollup merge of #88859 - RalfJung:size-helpers, r=oli-obk
Guillaume Gomez [Mon, 13 Sep 2021 19:20:40 +0000 (21:20 +0200)]
Rollup merge of #88859 - RalfJung:size-helpers, r=oli-obk

interpreter PointerArithmetic: use new Size helper methods

2 years agoRollup merge of #88851 - fee1-dead:dup-bound, r=oli-obk
Guillaume Gomez [Mon, 13 Sep 2021 19:20:39 +0000 (21:20 +0200)]
Rollup merge of #88851 - fee1-dead:dup-bound, r=oli-obk

Fix duplicate bounds for const_trait_impl

Fixes #88383.

Compare the constness of the candidates before winnowing and removing a `~const` `BoundCandidate`.

2 years agoRollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay
Guillaume Gomez [Mon, 13 Sep 2021 19:20:39 +0000 (21:20 +0200)]
Rollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay

Make `UnsafeCell::get_mut` const

2 years agoRollup merge of #88033 - GuillaumeGomez:jump-to-def-primitive, r=jyn514
Guillaume Gomez [Mon, 13 Sep 2021 19:20:38 +0000 (21:20 +0200)]
Rollup merge of #88033 - GuillaumeGomez:jump-to-def-primitive, r=jyn514

Add links for primitives in "jump to definition" feature

Follow-up of #84176.

I created a function `primitive_from_str` which is code that was originally in `collect_intra_doc_links::resolve_primitive` to prevent code duplication.

I also created the `primitive_link_url` function which is somewhat similar to `primitive_link` but too much different to merge both of them.

r? ``@jyn514``

2 years agoMove fortanix module position in std::os reexports for alpha sort
Guillaume Gomez [Tue, 7 Sep 2021 13:44:08 +0000 (15:44 +0200)]
Move fortanix module position in std::os reexports for alpha sort

2 years agoRemove usage of cfg_if in std/src/os/mod.rs
Guillaume Gomez [Fri, 3 Sep 2021 19:13:52 +0000 (21:13 +0200)]
Remove usage of cfg_if in std/src/os/mod.rs

2 years agoSimplify std::os module reexports to fix rustdoc linking issues
Guillaume Gomez [Fri, 3 Sep 2021 15:21:52 +0000 (17:21 +0200)]
Simplify std::os module reexports to fix rustdoc linking issues

2 years ago * Enable generate-link-to-def feature on a rustdoc GUI test
Guillaume Gomez [Sun, 12 Sep 2021 13:43:30 +0000 (15:43 +0200)]
 * Enable generate-link-to-def feature on a rustdoc GUI test
 * Add test for jump-to-def links background color

2 years agoAuto merge of #87915 - estebank:fancy-spans, r=oli-obk
bors [Mon, 13 Sep 2021 16:31:12 +0000 (16:31 +0000)]
Auto merge of #87915 - estebank:fancy-spans, r=oli-obk

Use smaller spans for some structured suggestions

Use more accurate suggestion spans for

* argument parse error
* fully qualified path
* missing code block type
* numeric casts

2 years agoAdd negative test in macro-braces-dot-question.rs.
Mara Bos [Mon, 13 Sep 2021 15:50:59 +0000 (17:50 +0200)]
Add negative test in macro-braces-dot-question.rs.

2 years agoAdd test for primitive in "jump to definition" feature
Guillaume Gomez [Sat, 14 Aug 2021 18:17:43 +0000 (20:17 +0200)]
Add test for primitive in "jump to definition" feature

2 years agoAdd support for primitives in "jump to definition" feature
Guillaume Gomez [Sat, 14 Aug 2021 18:17:28 +0000 (20:17 +0200)]
Add support for primitives in "jump to definition" feature

2 years agoHighlight the const function if error happened because of a bound on the impl block
Waffle [Mon, 13 Sep 2021 13:36:14 +0000 (16:36 +0300)]
Highlight the const function if error happened because of a bound on the impl block

Currently, for the following code, the compiler produces the errors like the
following error:
```rust
struct Type<T>

impl<T: Clone> Type<T> {
fn const f() {}
}
```
```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

This can be confusing (especially to newcomers) since the error mentions
"const fn parameters", but highlights only the impl.

This commits adds function highlighting, changing the error to the following:

```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
4 |     pub const fn f() {}
  |     ---------------- function declared as const here
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

2 years agoAuto merge of #88766 - ehuss:update-cargo, r=ehuss
bors [Mon, 13 Sep 2021 13:12:34 +0000 (13:12 +0000)]
Auto merge of #88766 - ehuss:update-cargo, r=ehuss

Update cargo

6 commits in 18751dd3f238d94d384a7fe967abfac06cbfe0b9..e515c3277bf0681bfc79a9e763861bfe26bb05db
2021-09-01 14:26:00 +0000 to 2021-09-08 14:32:15 +0000
- Remove log output that may leak tokens (rust-lang/cargo#9873)
- rev = "refs/pull/𑑛/head" (rust-lang/cargo#9859)
- Update suggestion message on bad project name error (rust-lang/cargo#9877)
- clarify what goes into "*-sys" crates (rust-lang/cargo#9871)
- Improve error message when unable to initialize git index repo (rust-lang/cargo#9869)
- Use serde_json to generate cargo_vcs_info.json (rust-lang/cargo#9865)

2 years agoUse a separate interner type for UniqueTypeId
bjorn3 [Sun, 8 Aug 2021 15:24:30 +0000 (17:24 +0200)]
Use a separate interner type for UniqueTypeId

Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols
with the global interner. In fact the Debug implementation of
UniqueTypeId did exactly this.

Using a separate interner type also avoids prefilling the interner with
unused symbols and allow for optimizing the symbol interner for parallel
access without negatively affecting the single threaded module codegen.

2 years agoAuto merge of #88745 - hnj2:allow-trait-impl-missing-code, r=GuillaumeGomez
bors [Mon, 13 Sep 2021 09:41:22 +0000 (09:41 +0000)]
Auto merge of #88745 - hnj2:allow-trait-impl-missing-code, r=GuillaumeGomez

Allow missing code examples in trait impls.

Excludes Trait implementations from the items that need to have doc code examples when using the `rustdoc::missing_doc_code_examples` lint.

For details see #88741

fixes #88741

r? `@jyn514`

2 years agoAuto merge of #88529 - Meziu:master, r=nagisa
bors [Mon, 13 Sep 2021 05:48:03 +0000 (05:48 +0000)]
Auto merge of #88529 - Meziu:master, r=nagisa

ARMv6K Nintendo 3DS Tier 3 target added

Addition of the target specifications to build .elf files for Nintendo 3DS (ARMv6K, Horizon). Requires devkitARM 3DS toolkit for system libraries and arm-none-eabi-gcc linker.

2 years agochore: convert to a multi-part suggestion
Michael Howell [Mon, 13 Sep 2021 02:51:09 +0000 (19:51 -0700)]
chore: convert to a multi-part suggestion

2 years agoAuto merge of #88517 - smoelius:without-patch-versions, r=flip1995
bors [Mon, 13 Sep 2021 02:45:18 +0000 (02:45 +0000)]
Auto merge of #88517 - smoelius:without-patch-versions, r=flip1995

Update Clippy dependencies without patch versions

Trial run for https://github.com/rust-lang/rust-clippy/pull/7606

2 years agoAuto merge of #88839 - nbdd0121:alignof, r=nagisa
bors [Sun, 12 Sep 2021 23:49:24 +0000 (23:49 +0000)]
Auto merge of #88839 - nbdd0121:alignof, r=nagisa

Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.

2 years agoAdd mir opt test for min_align_of -> AlignOf lowering
Gary Guo [Fri, 10 Sep 2021 23:54:10 +0000 (00:54 +0100)]
Add mir opt test for min_align_of -> AlignOf lowering

2 years agoIntroduce NullOp::AlignOf
Gary Guo [Tue, 7 Sep 2021 15:06:07 +0000 (16:06 +0100)]
Introduce NullOp::AlignOf

2 years agoAuto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb
bors [Sun, 12 Sep 2021 20:48:09 +0000 (20:48 +0000)]
Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb

Add -Z panic-in-drop={unwind,abort} command-line option

This PR changes `Drop` to abort if an unwinding panic attempts to escape it, making the process abort instead. This has several benefits:
- The current behavior when unwinding out of `Drop` is very unintuitive and easy to miss: unwinding continues, but the remaining drops in scope are simply leaked.
- A lot of unsafe code doesn't expect drops to unwind, which can lead to unsoundness:
  - https://github.com/servo/rust-smallvec/issues/14
  - https://github.com/bluss/arrayvec/issues/3
- There is a code size and compilation time cost to this: LLVM needs to generate extra landing pads out of all calls in a drop implementation. This can compound when functions are inlined since unwinding will then continue on to process drops in the callee, which can itself unwind, etc.
  - Initial measurements show a 3% size reduction and up to 10% compilation time reduction on some crates (`syn`).

One thing to note about `-Z panic-in-drop=abort` is that *all* crates must be built with this option for it to be sound since it makes the compiler assume that dropping `Box<dyn Any>` will never unwind.

cc https://github.com/rust-lang/lang-team/issues/97

2 years agoReduce possibility of flaky tests
Guillaume Gomez [Sun, 12 Sep 2021 14:34:18 +0000 (16:34 +0200)]
Reduce possibility of flaky tests

2 years agoImprove error message for missing trait in trait impl
Fabian Wolff [Sun, 12 Sep 2021 20:05:52 +0000 (22:05 +0200)]
Improve error message for missing trait in trait impl

2 years agoAuto merge of #88811 - jackh726:issue-88446, r=nikomatsakis
bors [Sun, 12 Sep 2021 17:04:10 +0000 (17:04 +0000)]
Auto merge of #88811 - jackh726:issue-88446, r=nikomatsakis

Use a HashMap for UniverseInfo in mir borrowck

Fixes #88446

r? `@nikomatsakis`

2 years agoFix invalid background for jump-to-def links in source code pages
Guillaume Gomez [Sun, 12 Sep 2021 14:33:57 +0000 (16:33 +0200)]
Fix invalid background for jump-to-def links in source code pages