]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #89187 - ehuss:update-cargo, r=ehuss
bors [Wed, 22 Sep 2021 22:38:03 +0000 (22:38 +0000)]
Auto merge of #89187 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in 9a28ac83c9eb73e42ffafac552c0a55f00dbf40c..0121d66aa2ef5ffa9735f86c2b56f5fdc5a837a6
2021-09-18 15:42:28 -0500 to 2021-09-22 16:08:27 +0000
- Implement example completion for zsh (rust-lang/cargo#9939)
- Bump curl-sys dependency (rust-lang/cargo#9937)
- Add fetch smoke test. (rust-lang/cargo#9921)
- Differentiate tests in progress bar. (rust-lang/cargo#9934)
- Remove TOML incompatibility hacks (rust-lang/cargo#9932)
- Change diesel compatibility messages (rust-lang/cargo#9927)
- Remove broken link in contrib docs. (rust-lang/cargo#9928)

2 years agoUpdate cargo
Eric Huss [Wed, 22 Sep 2021 22:06:52 +0000 (15:06 -0700)]
Update cargo

2 years agoAuto merge of #89179 - the8472:rollup-moxrtaj, r=the8472
bors [Wed, 22 Sep 2021 19:40:13 +0000 (19:40 +0000)]
Auto merge of #89179 - the8472:rollup-moxrtaj, r=the8472

Rollup of 8 pull requests

Successful merges:

 - #89036 (Fix missing `no_global_oom_handling` cfg-gating)
 - #89041 (Work around invalid DWARF bugs for fat LTO)
 - #89046 ("Fix" an overflow in byte position math)
 - #89127 (Re-enable the `src/test/debuginfo/mutex.rs` test on Windows)
 - #89133 (Fix ICE with `--cap-lints=allow` and `-Zfuel=...=0`)
 - #89162 (rustc_index: Add some map-like APIs to `IndexVec`)
 - #89164 (Document `--show-type-layout` in the rustdoc book)
 - #89170 (Disable the leak sanitizer on Macos aarch64 for now)

Failed merges:

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

2 years agoRollup merge of #89170 - rusticstuff:aarch64_macos_disable_leak_sanitizer, r=petrochenkov
the8472 [Wed, 22 Sep 2021 17:03:27 +0000 (19:03 +0200)]
Rollup merge of #89170 - rusticstuff:aarch64_macos_disable_leak_sanitizer, r=petrochenkov

Disable the leak sanitizer on Macos aarch64 for now

It is currently broken, see #88132.

2 years agoRollup merge of #89164 - camelid:show-type-layout-docs, r=jyn514
the8472 [Wed, 22 Sep 2021 17:03:26 +0000 (19:03 +0200)]
Rollup merge of #89164 - camelid:show-type-layout-docs, r=jyn514

Document `--show-type-layout` in the rustdoc book

I also made a few small, related changes as separate commits.

r? `@jyn514`

2 years agoRollup merge of #89162 - petrochenkov:ivmap, r=davidtwco
the8472 [Wed, 22 Sep 2021 17:03:25 +0000 (19:03 +0200)]
Rollup merge of #89162 - petrochenkov:ivmap, r=davidtwco

rustc_index: Add some map-like APIs to `IndexVec`

`IndexVec` is often used as a map, but its map APIs are lacking.
This PR adds a couple of useful methods.

2 years agoRollup merge of #89133 - FabianWolff:issue-79546, r=michaelwoerister
the8472 [Wed, 22 Sep 2021 17:03:24 +0000 (19:03 +0200)]
Rollup merge of #89133 - FabianWolff:issue-79546, r=michaelwoerister

Fix ICE with `--cap-lints=allow` and `-Zfuel=...=0`

Fixes #79546.

2 years agoRollup merge of #89127 - wesleywiser:reenable_mutex_debuginfo_test, r=ehuss
the8472 [Wed, 22 Sep 2021 17:03:23 +0000 (19:03 +0200)]
Rollup merge of #89127 - wesleywiser:reenable_mutex_debuginfo_test, r=ehuss

Re-enable the `src/test/debuginfo/mutex.rs` test on Windows

This test required a newer version of cdb than was previously enabled in
CI thus leading to some bitrot in the test since the time it was
originally created. With the update to the `windows-latest` image last
week, we're now running this test in CI and thus uncovered the
regression.

I've updated the test and it now passes.

r? `@ehuss`

2 years agoRollup merge of #89046 - oli-obk:fix_oflo, r=estebank
the8472 [Wed, 22 Sep 2021 17:03:22 +0000 (19:03 +0200)]
Rollup merge of #89046 - oli-obk:fix_oflo, r=estebank

"Fix" an overflow in byte position math

r? `@estebank`

help! I fixed the ICE only to brick the diagnostic.

I mean, it was wrong previously (using an already expanded macro span), but it is really bad now XD

2 years agoRollup merge of #89041 - sticnarf:sticnarf/fat-lto-dwarf, r=nagisa
the8472 [Wed, 22 Sep 2021 17:03:21 +0000 (19:03 +0200)]
Rollup merge of #89041 - sticnarf:sticnarf/fat-lto-dwarf, r=nagisa

Work around invalid DWARF bugs for fat LTO

This PR applies the same workaround in #46772 to fat LTO.

It seems to fix the bug reported in https://github.com/rust-lang/rust/issues/66118#issuecomment-917434036.

2 years agoRollup merge of #89036 - nbdd0121:alloc, r=yaahc
the8472 [Wed, 22 Sep 2021 17:03:20 +0000 (19:03 +0200)]
Rollup merge of #89036 - nbdd0121:alloc, r=yaahc

Fix missing `no_global_oom_handling` cfg-gating

Cfg-gate these trait impls that are neglected.

These functions compile now because they use `box` syntax which depends on `exchange_malloc` during codegen only; as a result they compiles with cfg `no_global_oom_handling` but shouldn't.

Discovered in #89030 because that PR makes `box` syntax depend on `exchange_malloc` lang item during MIR construction.

2 years agoAuto merge of #89134 - est31:revert_rustdoc_box_syntax, r=GuillaumeGomez
bors [Wed, 22 Sep 2021 09:55:13 +0000 (09:55 +0000)]
Auto merge of #89134 - est31:revert_rustdoc_box_syntax, r=GuillaumeGomez

Revert the rustdoc box syntax removal

Reverts the rustdoc box syntax removal from #87781.

It turned out to cause (minor) perf regressions.

Requested in https://github.com/rust-lang/rust/pull/87781#issuecomment-922589168

2 years agoAuto merge of #88865 - guswynn:must_not_suspend, r=oli-obk
bors [Wed, 22 Sep 2021 06:43:33 +0000 (06:43 +0000)]
Auto merge of #88865 - guswynn:must_not_suspend, r=oli-obk

Implement `#[must_not_suspend]`

implements #83310

Some notes on the impl:

1. The code that searches for the attribute on the ADT is basically copied from the `must_use` lint. It's not shared, as the logic did diverge
2. The RFC does specify that the attribute can be placed on fn's (and fn-like objects), like `must_use`. I think this is a direct copy from the `must_use` reference definition. This implementation does NOT support this, as I felt that ADT's (+ `impl Trait` + `dyn Trait`) cover the usecase's people actually want on the RFC, and adding an imp for the fn call case would be significantly harder. The `must_use` impl can do a single check at fn call stmt time, but `must_not_suspend` would need to answer the question: "for some value X with type T, find any fn call that COULD have produced this value". That would require significant changes to `generator_interior.rs`, and I would need mentorship on that. `@eholk` and I are discussing it.
3. `@estebank` do you know a way I can make the user-provided `reason` note pop out? right now it seems quite hidden

Also, I am not sure if we should run perf on this

r? `@nikomatsakis`

2 years agoDisable the leak sanitizer on Macos aarch64 for now.
Hans Kratz [Wed, 22 Sep 2021 04:42:28 +0000 (06:42 +0200)]
Disable the leak sanitizer on Macos aarch64 for now.

It is currently broken, see #88132.

2 years agoAuto merge of #88846 - jackh726:issue-88360, r=nikomatsakis
bors [Wed, 22 Sep 2021 04:02:01 +0000 (04:02 +0000)]
Auto merge of #88846 - jackh726:issue-88360, r=nikomatsakis

In suggest_missing_return_type, erase late bound regions after normalizing

Fixes #88360

There might be some hardening that could be done to not error or avoid erroring with LUBing `ReErased` with `ReEmpty`, but this was the most simple fix for this particular case.

r? `@nikomatsakis`

2 years agorustdoc: Emphasize "completely unstable"
Noah Lev [Wed, 22 Sep 2021 02:15:29 +0000 (19:15 -0700)]
rustdoc: Emphasize "completely unstable"

2 years agorustdoc: Note that type layout may differ between compilations
Noah Lev [Wed, 22 Sep 2021 02:13:15 +0000 (19:13 -0700)]
rustdoc: Note that type layout may differ between compilations

2 years agoFix inconsistent heading level in the rustdoc book
Noah Lev [Wed, 22 Sep 2021 02:17:09 +0000 (19:17 -0700)]
Fix inconsistent heading level in the rustdoc book

2 years agoDocument `--show-type-layout` in the rustdoc book
Noah Lev [Wed, 22 Sep 2021 02:12:10 +0000 (19:12 -0700)]
Document `--show-type-layout` in the rustdoc book

2 years agoAuto merge of #88629 - wesleywiser:fix_debuginfo_for_scalarpair_params, r=oli-obk
bors [Wed, 22 Sep 2021 01:13:49 +0000 (01:13 +0000)]
Auto merge of #88629 - wesleywiser:fix_debuginfo_for_scalarpair_params, r=oli-obk

Fix debuginfo for parameters passed via the ScalarPair abi on Windows

Mark all of these as locals so the debugger does not try to interpret
them as being a pointer to the value. This extends the approach used
in #81898.

Fixes #88625

2 years agorustc_index: Add some map-like APIs to `IndexVec`
Vadim Petrochenkov [Tue, 21 Sep 2021 22:59:46 +0000 (01:59 +0300)]
rustc_index: Add some map-like APIs to `IndexVec`

2 years agoAuto merge of #89158 - the8472:rollup-3e4ijth, r=the8472
bors [Tue, 21 Sep 2021 22:07:32 +0000 (22:07 +0000)]
Auto merge of #89158 - the8472:rollup-3e4ijth, r=the8472

Rollup of 12 pull requests

Successful merges:

 - #88795 (Print a note if a character literal contains a variation selector)
 - #89015 (core::ascii::escape_default: reduce struct size)
 - #89078 (Cleanup: Remove needless reference in ParentHirIterator)
 - #89086 (Stabilize `Iterator::map_while`)
 - #89096 ([bootstrap] Improve the error message when `ninja` is not found to link to installation instructions)
 - #89113 (dont `.ensure()` the `thir_abstract_const` query call in `mir_build`)
 - #89114 (Fixes a technicality regarding the size of C's `char` type)
 - #89115 (:arrow_up: rust-analyzer)
 - #89126 (Fix ICE when `indirect_structural_match` is allowed)
 - #89141 (Impl `Error` for `FromSecsError` without foreign type)
 - #89142 (Fix match for placeholder region)
 - #89147 (add case for checking const refs in check_const_value_eq)

Failed merges:

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

2 years agoRollup merge of #89147 - b-naber:refs_in_check_const_value_eq, r=oli-obk
the8472 [Tue, 21 Sep 2021 20:54:08 +0000 (22:54 +0200)]
Rollup merge of #89147 - b-naber:refs_in_check_const_value_eq, r=oli-obk

add case for checking const refs in check_const_value_eq

Previously in `check_const_value_eq` we destructured `ConstValue::ByRef` instances, this didn't account for `ty::Ref`s however, which led to an ICE.

Fixes https://github.com/rust-lang/rust/issues/88876
Fixes https://github.com/rust-lang/rust/issues/88384

r? `@oli-obk`

2 years agoRollup merge of #89142 - nerandell:master, r=jackh726
the8472 [Tue, 21 Sep 2021 20:54:07 +0000 (22:54 +0200)]
Rollup merge of #89142 - nerandell:master, r=jackh726

Fix match for placeholder region

cc #89118

2 years agoRollup merge of #89141 - mbartlett21:patch-2, r=kennytm
the8472 [Tue, 21 Sep 2021 20:54:07 +0000 (22:54 +0200)]
Rollup merge of #89141 - mbartlett21:patch-2, r=kennytm

Impl `Error` for `FromSecsError` without foreign type

Using it through the crate-local path in `std` means that it shouldn't make an "Implementations on Foreign Types" section in the `std::error::Error` docs.

2 years agoRollup merge of #89126 - FabianWolff:issue-89088, r=petrochenkov
the8472 [Tue, 21 Sep 2021 20:54:06 +0000 (22:54 +0200)]
Rollup merge of #89126 - FabianWolff:issue-89088, r=petrochenkov

Fix ICE when `indirect_structural_match` is allowed

Fixes #89088. The ICE is caused by `delay_good_path_bug()`, which is called (indirectly) from a `format!()` macro invocation. I have moved the macro invocation into the `decorate` closure of `struct_span_lint_hir()`, so that the macro is only invoked if the lint is not allowed (i.e., causes at least a warning, and thus prevents `delay_good_path_bug()` from firing).

2 years agoRollup merge of #89115 - lnicola:rust-analyzer-2021-09-20, r=Mark-Simulacrum
the8472 [Tue, 21 Sep 2021 20:54:05 +0000 (22:54 +0200)]
Rollup merge of #89115 - lnicola:rust-analyzer-2021-09-20, r=Mark-Simulacrum

:arrow_up: rust-analyzer

`@bors` r+ rollup

2 years agoRollup merge of #89114 - dequbed:c-char, r=yaahc
the8472 [Tue, 21 Sep 2021 20:54:04 +0000 (22:54 +0200)]
Rollup merge of #89114 - dequbed:c-char, r=yaahc

Fixes a technicality regarding the size of C's `char` type

Specifically, ISO/IEC 9899:2018 — better known as "C18" — (and at least
C11, C99 and C89) do not specify the size of `byte` in bits.
Section 3.6 defines "byte" as "addressable unit of data storage" while
section 6.2.5 ("Types") only defines "char" as "large enough to store
any member of the basic execution set" giving it a lower bound of 7 bit
(since there are 96 characters in the basic execution set).
With section 6.5.3.4 paragraph 4 "When sizeof is applied to an operant
that has type char […] the result is 1" you could read this as the size
of `char` in bits being defined as exactly the same as the number of
bits in a byte but it's also valid to read that as an exception.

In general implementations take `char` as the smallest unit of
addressable memory, which for modern byte-addressed architectures is
overwhelmingly 8 bits to the point of this convention being completely
cemented into just about all of our software.

So is any of this actually relevant at all? I hope not. I sincerely hope
that this never, ever comes up.
But if for some reason a poor rustacean is having to interface with C
code running on a Cray X1 that in 2003 is still doing word-addressed
memory with 64-bit chars and they trust the docs here blindly it will
blow up in her face. And I'll be truly sorry for her to have to deal
with … all of that.

2 years agoRollup merge of #89113 - BoxyUwU:incr-comp-thir-act, r=lcnr
the8472 [Tue, 21 Sep 2021 20:54:03 +0000 (22:54 +0200)]
Rollup merge of #89113 - BoxyUwU:incr-comp-thir-act, r=lcnr

dont `.ensure()` the `thir_abstract_const` query call in `mir_build`

might fix an ICE seen in #89022 (note: this PR does not close that issue) about attempting to read stolen thir. I couldn't repro the ICE but this `.ensure` seems sus anyway.

r? `@lcnr`

2 years agoRollup merge of #89096 - daira:improve-ninja-error-message, r=jyn514
the8472 [Tue, 21 Sep 2021 20:54:02 +0000 (22:54 +0200)]
Rollup merge of #89096 - daira:improve-ninja-error-message, r=jyn514

[bootstrap] Improve the error message when `ninja` is not found to link to installation instructions

fixes #89091

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2 years agoRollup merge of #89086 - WaffleLapkin:stabilize_iter_map_while, r=kennytm
the8472 [Tue, 21 Sep 2021 20:54:01 +0000 (22:54 +0200)]
Rollup merge of #89086 - WaffleLapkin:stabilize_iter_map_while, r=kennytm

Stabilize `Iterator::map_while`

Per the FCP: https://github.com/rust-lang/rust/issues/68537#issuecomment-922385035

This PR stabilizes `Iterator::map_while` and `iter::MapWhile` in Rust 1.57.

2 years agoRollup merge of #89078 - camsteffen:map-ref, r=cjgillot
the8472 [Tue, 21 Sep 2021 20:54:00 +0000 (22:54 +0200)]
Rollup merge of #89078 - camsteffen:map-ref, r=cjgillot

Cleanup: Remove needless reference in ParentHirIterator

It forces an intermediate binding of `Map` which is a Copy type.

2 years agoRollup merge of #89015 - klensy:escape-def, r=Mark-Simulacrum
the8472 [Tue, 21 Sep 2021 20:53:59 +0000 (22:53 +0200)]
Rollup merge of #89015 - klensy:escape-def, r=Mark-Simulacrum

core::ascii::escape_default: reduce struct size

2 years agoRollup merge of #88795 - FabianWolff:issue-88684, r=wesleywiser
the8472 [Tue, 21 Sep 2021 20:53:58 +0000 (22:53 +0200)]
Rollup merge of #88795 - FabianWolff:issue-88684, r=wesleywiser

Print a note if a character literal contains a variation selector

Fixes #88684.

2 years agoAuto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank
bors [Tue, 21 Sep 2021 19:25:49 +0000 (19:25 +0000)]
Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank

Migrate in-tree crates to 2021

This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074.

It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there.

I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first.

Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately.

It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c877110748296760aefddc21a0ea1d316 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.

2 years agoAuto merge of #88981 - durin42:llvm-14-crc32, r=nagisa
bors [Tue, 21 Sep 2021 16:13:24 +0000 (16:13 +0000)]
Auto merge of #88981 - durin42:llvm-14-crc32, r=nagisa

rustc_codegen_llvm: make sse4.2 imply crc32 for LLVM 14

This fixes compiling things like the `snap` crate after
https://reviews.llvm.org/D105462. I added a test that verifies the
additional attribute gets specified, and confirmed that I can build
cargo with both LLVM 13 and 14 with this change applied.

r? `@nagisa` cc `@nikic`

2 years agoadd case for checking const refs in check_const_value_eq
b-naber [Tue, 21 Sep 2021 13:07:28 +0000 (15:07 +0200)]
add case for checking const refs in check_const_value_eq

2 years agoAuto merge of #89125 - Aaron1011:remove-intercrate-cache, r=jackh726
bors [Tue, 21 Sep 2021 13:25:14 +0000 (13:25 +0000)]
Auto merge of #89125 - Aaron1011:remove-intercrate-cache, r=jackh726

Don't use projection cache or candidate cache in intercrate mode

Fixes #88969

It appears that *just* disabling the evaluation cache (in #88994)
leads to other issues involving intercrate mode caching. I suspect
that since we now always end up performing the full evaluation
in intercrate mode, we end up 'polluting' the candidate and projection
caches with results that depend on being in intercrate mode in some way.
Previously, we might have hit a cached evaluation (stored during
non-intercrate mode), and skipped doing this extra work in
intercrate mode.

The whole situation with intercrate mode caching is turning into
a mess. Ideally, we would remove intercrate mode entirely - however,
this might require waiting on Chalk.

2 years agoRe-export FromSecsError from `std`
mbartlett21 [Tue, 21 Sep 2021 11:18:57 +0000 (21:18 +1000)]
Re-export FromSecsError from `std`

2 years agoAuto merge of #89045 - oli-obk:lazy_normalization_in_opaque_types, r=nikomatsakis
bors [Tue, 21 Sep 2021 10:33:15 +0000 (10:33 +0000)]
Auto merge of #89045 - oli-obk:lazy_normalization_in_opaque_types, r=nikomatsakis

Register normalization obligations instead of immediately normalizing in opaque type instantiation

For lazy TAIT we will need to instantiate opaque types from within `rustc_infer`, which cannot invoke normalization methods (they are in `rustc_trait_resolution`). So before we move the logic over to `rustc_infer`, we need make sure no normalization happens anymore. This PR resolves that by just registering normalization obligations and continuing.

This PR is best reviewed commit by commit

I also included f7ad36e which is just an independent cleanup that touches the same code and reduces diagnostics noise a bit

r? `@nikomatsakis` cc `@spastorino`

2 years agoFix match for placeholder region
Ankit Chandawala [Tue, 21 Sep 2021 08:31:59 +0000 (09:31 +0100)]
Fix match for placeholder region

2 years agoImpl `Error` for `FromSecsError` without foreign type
mbartlett21 [Tue, 21 Sep 2021 08:02:18 +0000 (18:02 +1000)]
Impl `Error` for `FromSecsError` without foreign type

Using it through the crate-local path in `std` means that it shouldn't make an "Implementations on Foreign Types" section in the `std::error::Error` docs.

2 years agoAuto merge of #87234 - cjgillot:lower-mono, r=petrochenkov
bors [Tue, 21 Sep 2021 07:52:15 +0000 (07:52 +0000)]
Auto merge of #87234 - cjgillot:lower-mono, r=petrochenkov

Lower only one HIR owner at a time

Based on https://github.com/rust-lang/rust/pull/83723
Additional diff is here: https://github.com/cjgillot/rust/compare/ownernode...lower-mono

Lowering is very tangled and has a tendency to intertwine the transformation of different items. This PR aims at simplifying the logic by:
- moving global analyses to the resolver (item_generics_num_lifetimes, proc_macros, trait_impls);
- removing a few special cases (non-exported macros and use statements);
- restricting the amount of available information at any one time;
- avoiding back-and-forth between different owners: an item must now be lowered all at once, and its parent cannot refer to its nodes.

I also removed the sorting of bodies by span.  The diagnostic ordering changes marginally, since definitions are pretty much sorted already according to the AST. This uncovered a subtlety in thir-unsafeck.

(While these items could logically be in different PRs, the dependency between commits and the amount of conflicts force a monolithic PR.)

2 years agoAdjust documentation for compatibility with 2021
Mark Rousskov [Mon, 20 Sep 2021 12:46:26 +0000 (08:46 -0400)]
Adjust documentation for compatibility with 2021

This also adjusts the lint docs generation to accept (and ignore) an allow
attribute, rather than expecting the documentation to be immediately followed by
the lint name.

2 years agoRemove Drop-caused migration-added captures
Mark Rousskov [Sun, 19 Sep 2021 17:46:05 +0000 (13:46 -0400)]
Remove Drop-caused migration-added captures

All of these were added due to insignificant Drop types being present.

2 years agoDrop migration lint for Send/Sync bound in LTO backend
Mark Rousskov [Sun, 19 Sep 2021 17:13:16 +0000 (13:13 -0400)]
Drop migration lint for Send/Sync bound in LTO backend

The closure in question does not require Send/Sync impls, so it's OK to lose
them when we just capture data.0.

2 years agoAdjust tidy edition lint to force 2021
Noah Lev [Sun, 19 Sep 2021 00:31:54 +0000 (17:31 -0700)]
Adjust tidy edition lint to force 2021

This has a few exceptions today (library crates, a few submodules), but is
mostly accurate.

2 years agoMigrate to 2021
Mark Rousskov [Sun, 19 Sep 2021 16:49:55 +0000 (12:49 -0400)]
Migrate to 2021

2 years agoAuto merge of #87830 - hkmatsumoto:suggest-brackets-for-array-esque-block-expr, r...
bors [Tue, 21 Sep 2021 00:34:10 +0000 (00:34 +0000)]
Auto merge of #87830 - hkmatsumoto:suggest-brackets-for-array-esque-block-expr, r=estebank

Suggest replacing braces for brackets on array-esque invalid block expr

Newcomers may write `{1, 2, 3}` for making arrays, and the current error message is not informative enough to quickly convince them what is needed to fix the error.

This PR implements a diagnostic for this case, and its output looks like this:
```text
error: this code is interpreted as a block expression, not an array
 --> src/lib.rs:1:22
  |
1 |   const FOO: [u8; 3] = {
  |  ______________________^
2 | |     1, 2, 3
3 | | };
  | |_^
  |
  = note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
  |
1 | const FOO: [u8; 3] = [
2 |     1, 2, 3
3 | ];
  |
```

Fix #87672

2 years agoRevert the rustdoc box syntax removal
est31 [Mon, 20 Sep 2021 23:49:47 +0000 (01:49 +0200)]
Revert the rustdoc box syntax removal

It turned out to cause (minor) perf regressions.

2 years agoFix ICE with `--cap-lints=allow` and `-Zfuel=...=0`
Fabian Wolff [Mon, 20 Sep 2021 23:53:04 +0000 (01:53 +0200)]
Fix ICE with `--cap-lints=allow` and `-Zfuel=...=0`

2 years agoDon't use projection cache or candidate cache in intercrate mode
Aaron Hill [Mon, 20 Sep 2021 19:23:21 +0000 (14:23 -0500)]
Don't use projection cache or candidate cache in intercrate mode

Fixes #88969

It appears that *just* disabling the evaluation cache (in #88994)
leads to other issues involving intercrate mode caching. I suspect
that since we now always end up performing the full evaluation
in intercrate mode, we end up 'polluting' the candidate and projection
caches with results that depend on being in intercrate mode in some way.
Previously, we might have hit a cached evaluation (stored during
non-intercrate mode), and skipped doing this extra work in
intercrate mode.

The whole situation with intercrate mode caching is turning into
a mess. Ideally, we would remove intercrate mode entirely - however,
this might require waiting on Chalk.

2 years agoRe-enable the `src/test/debuginfo/mutex.rs` test on Windows
Wesley Wiser [Mon, 20 Sep 2021 19:26:56 +0000 (15:26 -0400)]
Re-enable the `src/test/debuginfo/mutex.rs` test on Windows

This test required a newer version of cdb than was previously enabled in
CI thus leading to some bitrot in the test since the time it was
originally created. With the update to the `windows-latest` image last
week, we're now running this test in CI and thus uncovered the
regression.

I've updated the test and it now passes.

2 years agoFix ICE when `indirect_structural_match` is allowed
Fabian Wolff [Mon, 20 Sep 2021 19:06:09 +0000 (21:06 +0200)]
Fix ICE when `indirect_structural_match` is allowed

2 years agoAuto merge of #89117 - michaelwoerister:update-to-odht-0.3, r=wesleywiser
bors [Mon, 20 Sep 2021 17:38:07 +0000 (17:38 +0000)]
Auto merge of #89117 - michaelwoerister:update-to-odht-0.3, r=wesleywiser

Update odht crate to 0.3.0

This version of odht contains a potential fix for #89085.

r? `@wesleywiser`

2 years agoAvoid the overflow with rustc+debugassertions in issue-44406
Oli Scherer [Mon, 20 Sep 2021 15:39:16 +0000 (15:39 +0000)]
Avoid the overflow with rustc+debugassertions in issue-44406

2 years agorustc_codegen_llvm: make sse4.2 imply crc32 for LLVM 14
Augie Fackler [Wed, 15 Sep 2021 14:18:10 +0000 (10:18 -0400)]
rustc_codegen_llvm: make sse4.2 imply crc32 for LLVM 14

This fixes compiling things like the `snap` crate after
https://reviews.llvm.org/D105462. I added a test that verifies the
additional attribute gets specified, and confirmed that I can build
cargo with both LLVM 13 and 14 with this change applied.

2 years agoAdd some more tracing
Oli Scherer [Mon, 20 Sep 2021 15:24:47 +0000 (15:24 +0000)]
Add some more tracing

2 years agoAuto merge of #89069 - bjorn3:optimize_sharded_new, r=Mark-Simulacrum
bors [Mon, 20 Sep 2021 14:33:00 +0000 (14:33 +0000)]
Auto merge of #89069 - bjorn3:optimize_sharded_new, r=Mark-Simulacrum

Use <[T; N]>::map in Sharded instead of SmallVec and unsafe code

This results in a lot less assembly

2 years agoAdd a doc comment to infer_projection
Oli Scherer [Sat, 18 Sep 2021 07:34:06 +0000 (09:34 +0200)]
Add a doc comment to infer_projection

2 years agoUse `ty::Error` for opaque types with errors in its bounds.
Oli Scherer [Tue, 10 Aug 2021 15:24:48 +0000 (15:24 +0000)]
Use `ty::Error` for opaque types with errors in its bounds.

This reduces unhelpful diagnostics down the road.

2 years agoGenerate inference vars and obligations for projections in opaque types instead of...
Oli Scherer [Tue, 10 Aug 2021 11:45:32 +0000 (11:45 +0000)]
Generate inference vars and obligations for projections in opaque types instead of trying to normalize them.

2 years agoInline a function that is only called once
Oli Scherer [Tue, 10 Aug 2021 11:31:05 +0000 (11:31 +0000)]
Inline a function that is only called once

2 years agoUse tracing debugging in `fold_opaque_ty`
Oli Scherer [Tue, 10 Aug 2021 11:28:54 +0000 (11:28 +0000)]
Use tracing debugging in `fold_opaque_ty`

2 years agoAdd helper function to `InferCtxt` that generates inference vars for unresolved assoc...
Oli Scherer [Tue, 10 Aug 2021 11:12:11 +0000 (11:12 +0000)]
Add helper function to `InferCtxt` that generates inference vars for unresolved associated types

2 years agoUpdate odht crate to 0.3.0
Michael Woerister [Mon, 20 Sep 2021 13:57:45 +0000 (15:57 +0200)]
Update odht crate to 0.3.0

This version of odht contains a potential fix for #89085.

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 20 Sep 2021 12:45:46 +0000 (15:45 +0300)]
:arrow_up: rust-analyzer

2 years agoEnable 2021 compatibility lints for all in-tree code
Mark Rousskov [Sat, 18 Sep 2021 21:37:24 +0000 (17:37 -0400)]
Enable 2021 compatibility lints for all in-tree code

This just applies the suggested fixes from the compatibility warnings,
leaving any that are in practice spurious in. This is primarily intended to
provide a starting point to identify possible fixes to the migrations (e.g., by
avoiding spurious warnings).

A secondary commit cleans these up where they are false positives (as is true in
many of the cases).

2 years agoAdjust to SourceType::InTree in several places
Mark Rousskov [Sun, 19 Sep 2021 14:36:17 +0000 (10:36 -0400)]
Adjust to SourceType::InTree in several places

These were left over in migrations to subtrees, which should generally be treated
as-if it was local.

Also fixes a warning caused by this change.

2 years agoWorkaround ICE with if-let and RFC 2229
Mark Rousskov [Sat, 18 Sep 2021 22:04:40 +0000 (18:04 -0400)]
Workaround ICE with if-let and RFC 2229

2 years agono ensure
Ellen [Mon, 20 Sep 2021 08:30:23 +0000 (09:30 +0100)]
no ensure

2 years agoAuto merge of #88321 - glaubitz:m68k-linux, r=wesleywiser
bors [Mon, 20 Sep 2021 07:21:05 +0000 (07:21 +0000)]
Auto merge of #88321 - glaubitz:m68k-linux, r=wesleywiser

Add initial support for m68k

This patch series adds initial support for m68k making use of the new M68k
backend introduced with LLVM-13. Additional changes will be needed to be
able to actually use the backend for this target.

2 years agoBless incremental tests.
Camille GILLOT [Sun, 29 Aug 2021 13:33:03 +0000 (15:33 +0200)]
Bless incremental tests.

2 years agoMake with_hir_id_owner responsible for registering the item.
Camille GILLOT [Fri, 16 Jul 2021 08:16:23 +0000 (10:16 +0200)]
Make with_hir_id_owner responsible for registering the item.

2 years agoFix a technicality regarding the size of C's `char` type
Nadja Reitzenstein [Mon, 20 Sep 2021 06:19:13 +0000 (08:19 +0200)]
Fix a technicality regarding the size of C's `char` type

Specifically, ISO/IEC 9899:2018 — better known as "C18" — (and at least
C11, C99 and C89) do not specify the size of `byte` in bits.
Section 3.6 defines "byte" as "addressable unit of data storage" while
section 6.2.5 ("Types") only defines "char" as "large enough to store
any member of the basic execution set" giving it a lower bound of 7 bit
(since there are 96 characters in the basic execution set).
With section 6.5.3.4 paragraph 4 "When sizeof is applied to an operant
that has type char […] the result is 1" you could read this as the size
of `char` in bits being defined as exactly the same as the number of
bits in a byte but it's also valid to read that as an exception.

In general implementations take `char` as the smallest unit of
addressable memory, which for modern byte-addressed architectures is
overwhelmingly 8 bits to the point of this convention being completely
cemented into just about all of our software.

So is any of this actually relevant at all? I hope not. I sincerely hope
that this never, ever comes up.
But if for some reason a poor rustacean is having to interface with C
code running on a Cray X1 that in 2003 is still doing word-addressed
memory with 64-bit words and they trust the docs here blindly it will
blow up in her face. And I'll be truly sorry for her to have to deal
with … all of that.

2 years agoAuto merge of #88842 - wesleywiser:fix_dbg_tests_windows_sdk, r=michaelwoerister
bors [Mon, 20 Sep 2021 03:53:10 +0000 (03:53 +0000)]
Auto merge of #88842 - wesleywiser:fix_dbg_tests_windows_sdk, r=michaelwoerister

Fix debuginfo tests for the latest version of the Windows SDK.

Re-enable the tests that were disabled to fix CI.

Changes:
- Cdb now correctly visualizes enums.
- Cdb doesn't render emoji characters in `OSStr` anymore.
- Cdb doesn't always render `str` correctly (#88840)

2 years agoAuto merge of #88708 - Aaron1011:aggregate-usage, r=oli-obk
bors [Mon, 20 Sep 2021 00:53:13 +0000 (00:53 +0000)]
Auto merge of #88708 - Aaron1011:aggregate-usage, r=oli-obk

Add `ConstraintCategory::Usage` for handling aggregate construction

In some cases, we emit borrowcheck diagnostics pointing
at a particular field expression in a struct expression
(e.g. `MyStruct { field: my_expr }`). However, this
behavior currently relies on us choosing the
`ConstraintCategory::Boring` with the 'correct' span.
When adding additional variants to `ConstraintCategory`,
(or changing existing usages away from `ConstraintCategory::Boring`),
the current behavior can easily get broken, since a non-boring
constraint will get chosen over a boring one.

To make the diagnostic output less fragile, this commit
adds a `ConstraintCategory::Usage` variant. We use this variant
for the temporary assignments created for each field of
an aggregate we are constructing.

Using this new variant, we can emit a message mentioning
"this usage", emphasizing the fact that the error message
is related to the specific use site (in the struct expression).

This is preparation for additional work on improving NLL error messages
(see #57374)

2 years agoRemove lower_node_id_with_owner.
Camille GILLOT [Wed, 14 Jul 2021 21:50:53 +0000 (23:50 +0200)]
Remove lower_node_id_with_owner.

2 years agoDo not store visibility in *ItemRef.
Camille GILLOT [Thu, 15 Jul 2021 20:19:39 +0000 (22:19 +0200)]
Do not store visibility in *ItemRef.

2 years agoAuto merge of #88575 - eddyb:fn-abi-queries, r=nagisa
bors [Sun, 19 Sep 2021 21:39:47 +0000 (21:39 +0000)]
Auto merge of #88575 - eddyb:fn-abi-queries, r=nagisa

Querify `FnAbi::of_{fn_ptr,instance}` as `fn_abi_of_{fn_ptr,instance}`.

*Note: opening this PR as draft because it's based on #88499*

This more or less replicates the `LayoutOf::layout_of` setup from #88499, to replace `FnAbi::of_{fn_ptr,instance}` with `FnAbiOf::fn_abi_of_{fn_ptr,instance}`, and also route them through queries (which `layout_of` has used for a while).

The two changes at the use sites (other than the names) are:
* return type is now wrapped in `&'tcx`
  * the value *is* interned, which may affect performance
* the `extra_args` list is now an interned `&'tcx ty::List<Ty<'tcx>>`
  * should be cheap (it's empty for anything other than C variadics)

Theoretically, a `FnAbiOfHelpers` implementer could choose to keep the `Result<...>` instead of eagerly erroring, but the only existing users of these APIs are codegen backends, so they don't (want to) take advantage of this.
At least miri could make use of this, since it prefers propagating errors (it "just" doesn't use `FnAbi` yet - cc `@RalfJung).`

The way this is done is probably less efficient than what is possible, because the queries handle the correctness-oriented API (i.e. the split into `fn` pointers vs instances), whereas a lower-level query could end up with more reuse between different instances with identical signatures.

r? `@nagisa` cc `@oli-obk` `@bjorn3`

2 years agoAuto merge of #89049 - Aaron1011:caching-sourcemap-assert, r=Mark-Simulacrum
bors [Sun, 19 Sep 2021 18:54:31 +0000 (18:54 +0000)]
Auto merge of #89049 - Aaron1011:caching-sourcemap-assert, r=Mark-Simulacrum

Convert `debug_assert` to `assert` in `CachingSourceMapView`

I suspect that there's a bug somewhere in this code, which is
leading to the `predicates_of` ICE being seen in #89035

2 years agoRestore the suggestion to set `ninja = false`.
Daira Hopwood [Sun, 19 Sep 2021 18:50:08 +0000 (19:50 +0100)]
Restore the suggestion to set `ninja = false`.

2 years agoAuto merge of #88703 - cjgillot:lazymod, r=petrochenkov
bors [Sun, 19 Sep 2021 16:13:42 +0000 (16:13 +0000)]
Auto merge of #88703 - cjgillot:lazymod, r=petrochenkov

Gather module items after lowering.

This avoids having a non-local analysis inside lowering.

By implementing `hir_module_items` using a visitor, we make sure that iterations and visitors are consistent.

2 years ago[bootstrap] Improve the error message when `ninja` is not found to link to installati...
Daira Hopwood [Sun, 19 Sep 2021 13:27:49 +0000 (14:27 +0100)]
[bootstrap] Improve the error message when `ninja` is not found to link to installation instructions.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2 years agoAuto merge of #88627 - cjgillot:noallocuse, r=petrochenkov
bors [Sun, 19 Sep 2021 13:44:18 +0000 (13:44 +0000)]
Auto merge of #88627 - cjgillot:noallocuse, r=petrochenkov

Do not preallocate HirIds

Part of https://github.com/rust-lang/rust/pull/87234

r? `@petrochenkov`

2 years agoAuto merge of #89089 - JohnTitor:rollup-6s6mccx, r=JohnTitor
bors [Sun, 19 Sep 2021 11:03:09 +0000 (11:03 +0000)]
Auto merge of #89089 - JohnTitor:rollup-6s6mccx, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #87960 (Suggest replacing an inexisting field for an unmentioned field)
 - #88855 (Allow simd_shuffle to accept vectors of any length)
 - #88966 (Check for shadowing issues involving block labels)
 - #88996 (Fix linting when trailing macro expands to a trailing semi)
 - #89017 (fix potential race in AtomicU64 time monotonizer)
 - #89021 (Add a separate error for `dyn Trait` in `const fn`)
 - #89051 (Add intra-doc links and small changes to `std::os` to be more consistent)
 - #89053 (refactor: VecDeques IntoIter fields to private)
 - #89055 (Suggest better place to add call parentheses for method expressions wrapped in parentheses)
 - #89081 (Fix a typo)

Failed merges:

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

2 years agoSuggest replacing braces for brackets on array-esque invalid block expr
Hirochika Matsumoto [Fri, 6 Aug 2021 19:34:29 +0000 (04:34 +0900)]
Suggest replacing braces for brackets on array-esque invalid block expr

Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
 --> src/lib.rs:1:22
  |
1 |   const FOO: [u8; 3] = {
  |  ______________________^
2 | |     1, 2, 3
3 | | };
  | |_^
  |
  = note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
  |
1 | const FOO: [u8; 3] = [
2 |     1, 2, 3
3 | ];
  |
```

Fix #87672

2 years agoRollup merge of #89081 - ondra05:patch-1, r=dtolnay
Yuki Okushi [Sun, 19 Sep 2021 08:31:35 +0000 (17:31 +0900)]
Rollup merge of #89081 - ondra05:patch-1, r=dtolnay

Fix a typo

Removed extra spaces in front of commas

2 years agoRollup merge of #89055 - Kobzol:wrapped-method-expr-call-parens, r=wesleywiser
Yuki Okushi [Sun, 19 Sep 2021 08:31:35 +0000 (17:31 +0900)]
Rollup merge of #89055 - Kobzol:wrapped-method-expr-call-parens, r=wesleywiser

Suggest better place to add call parentheses for method expressions wrapped in parentheses

I wanted to improve the suggestion a bit to both remove the wrapping parentheses **and** add call parentheses by both calling `suggest_method_call` and using `multipart_suggestion`. But I very quickly ran into a problem where multiple overlapping machine applicable suggestions cannot be properly applied together. So I applied the suggestion from the issue and only added the call parentheses directly after the expression.

Fixes: https://github.com/rust-lang/rust/issues/89044
2 years agoRollup merge of #89053 - DeveloperC286:into_iter_fields_to_private, r=Mark-Simulacrum
Yuki Okushi [Sun, 19 Sep 2021 08:31:34 +0000 (17:31 +0900)]
Rollup merge of #89053 - DeveloperC286:into_iter_fields_to_private, r=Mark-Simulacrum

refactor: VecDeques IntoIter fields to private

Made the fields of VecDeque's IntoIter private by creating a IntoIter::from(...) function to create a new instance of IntoIter and migrating usage to use IntoIter::from(...).

2 years agoRollup merge of #89051 - schctl:master, r=jyn514
Yuki Okushi [Sun, 19 Sep 2021 08:31:33 +0000 (17:31 +0900)]
Rollup merge of #89051 - schctl:master, r=jyn514

Add intra-doc links and small changes to `std::os` to be more consistent

I believe that a few items in `std::os` should be linked. I've also added a basic example in `std::os::windows`.

2 years agoRollup merge of #89021 - WaffleLapkin:separate_error_for_dyn_trait_in_const_fn, r...
Yuki Okushi [Sun, 19 Sep 2021 08:31:33 +0000 (17:31 +0900)]
Rollup merge of #89021 - WaffleLapkin:separate_error_for_dyn_trait_in_const_fn, r=estebank

Add a separate error for `dyn Trait` in `const fn`

Previously "trait bounds other than `Sized` on const fn parameters are unstable" error was used for both trait bounds (`<T: Trait>`) and trait objects (`dyn Trait`). This was pretty confusing.

This PR adds a separate error for trait objects: "trait objects in const fn are unstable". The error for trait bounds is otherwise intact.

This is follow up to #88907

r? ``@estebank``

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

2 years agoRollup merge of #89017 - the8472:fix-u64-time-monotonizer, r=kennytm
Yuki Okushi [Sun, 19 Sep 2021 08:31:32 +0000 (17:31 +0900)]
Rollup merge of #89017 - the8472:fix-u64-time-monotonizer, r=kennytm

fix potential race in AtomicU64 time monotonizer

The AtomicU64-based monotonizer introduced in #83093 is incorrect because several threads could try to update the value concurrently and a thread which doesn't have the newest value among all the updates could win.

That bug probably has little real world impact since it doesn't make observed time worse than hardware clocks. The worst case would probably be a thread which has a clock that is behind by several cycles observing several inconsistent fixups, which should be similar to observing the unfiltered backslide in the first place.

New benchmarks, they don't look as good as the original PR but still an improvement compared to the mutex.
I don't know why the contended mutex case is faster now than in the previous benchmarks.

```
actually_monotonic() == true:
test time::tests::instant_contention_01_threads                   ... bench:          44 ns/iter (+/- 0)
test time::tests::instant_contention_02_threads                   ... bench:          45 ns/iter (+/- 0)
test time::tests::instant_contention_04_threads                   ... bench:          45 ns/iter (+/- 0)
test time::tests::instant_contention_08_threads                   ... bench:          45 ns/iter (+/- 0)
test time::tests::instant_contention_16_threads                   ... bench:          46 ns/iter (+/- 0)

atomic u64:
test time::tests::instant_contention_01_threads                   ... bench:          66 ns/iter (+/- 0)
test time::tests::instant_contention_02_threads                   ... bench:         287 ns/iter (+/- 14)
test time::tests::instant_contention_04_threads                   ... bench:         296 ns/iter (+/- 43)
test time::tests::instant_contention_08_threads                   ... bench:         604 ns/iter (+/- 163)
test time::tests::instant_contention_16_threads                   ... bench:       1,147 ns/iter (+/- 29)

mutex:
test time::tests::instant_contention_01_threads                   ... bench:          78 ns/iter (+/- 0)
test time::tests::instant_contention_02_threads                   ... bench:         652 ns/iter (+/- 275)
test time::tests::instant_contention_04_threads                   ... bench:         900 ns/iter (+/- 32)
test time::tests::instant_contention_08_threads                   ... bench:       1,927 ns/iter (+/- 62)
test time::tests::instant_contention_16_threads                   ... bench:       3,748 ns/iter (+/- 146)
```

2 years agoRollup merge of #88996 - Aaron1011:trailing-macro-semi, r=petrochenkov
Yuki Okushi [Sun, 19 Sep 2021 08:31:31 +0000 (17:31 +0900)]
Rollup merge of #88996 - Aaron1011:trailing-macro-semi, r=petrochenkov

Fix linting when trailing macro expands to a trailing semi

When a macro is used in the trailing expression position of a block
(e.g. `fn foo() { my_macro!() }`), we currently parse it as an
expression, rather than a statement. As a result, we ended up
using the `NodeId` of the containing statement as our `lint_node_id`,
even though we don't normally do this for macro calls.

If such a macro expands to an expression with a `#[cfg]` attribute,
then the trailing statement can get removed entirely. This lead to
an ICE, since we were usng the `NodeId` of the expression to emit
a lint.

Ths commit makes us skip updating `lint_node_id` when handling
a macro in trailing expression position. This will cause us to
lint at the closest parent of the macro call.

2 years agoRollup merge of #88966 - tmiasko:block-label-shadowing, r=petrochenkov
Yuki Okushi [Sun, 19 Sep 2021 08:31:30 +0000 (17:31 +0900)]
Rollup merge of #88966 - tmiasko:block-label-shadowing, r=petrochenkov

Check for shadowing issues involving block labels

2 years agoRollup merge of #88855 - calebzulawski:feature/simd_shuffle, r=nagisa
Yuki Okushi [Sun, 19 Sep 2021 08:31:29 +0000 (17:31 +0900)]
Rollup merge of #88855 - calebzulawski:feature/simd_shuffle, r=nagisa

Allow simd_shuffle to accept vectors of any length

cc ``@rust-lang/project-portable-simd`` ``@workingjubilee``

2 years agoRollup merge of #87960 - hkmatsumoto:suggest-inexisting-field-for-unmentioned-field...
Yuki Okushi [Sun, 19 Sep 2021 08:31:29 +0000 (17:31 +0900)]
Rollup merge of #87960 - hkmatsumoto:suggest-inexisting-field-for-unmentioned-field, r=estebank

Suggest replacing an inexisting field for an unmentioned field

Fix #87938

This PR adds a suggestion to replace an inexisting field for an
unmentioned field. Given the following code:
```rust
enum Foo {
    Bar { alpha: u8, bravo: u8, charlie: u8 },
}

fn foo(foo: Foo) {
    match foo {
        Foo::Bar {
            alpha,
            beta, // `bravo` miswritten as `beta` here.
            charlie,
        } => todo!(),
    }
}
```
the compiler now emits the error messages below.
```text
error[E0026]: variant `Foo::Bar` does not have a field named `beta`
 --> src/lib.rs:9:13
  |
9 |             beta, // `bravo` miswritten as `beta` here.
  |             ^^^^
  |             |
  |             variant `Foo::Bar` does not have this field
  |             help: `Foo::Bar` has a field named `bravo`: `bravo`
```

Note that this suggestion is available iff the number of inexisting
fields and unmentioned fields are both 1.

2 years agoAuto merge of #89031 - the8472:outline-once-cell-init-closure, r=Mark-Simulacrum
bors [Sun, 19 Sep 2021 08:05:45 +0000 (08:05 +0000)]
Auto merge of #89031 - the8472:outline-once-cell-init-closure, r=Mark-Simulacrum

Don't inline OnceCell initialization closures

The more general variant of #89026, originally suggested in https://github.com/rust-lang/rust/pull/86898#issuecomment-920138051

2 years agoAuto merge of #89028 - Aaron1011:coercion-cause, r=nagisa
bors [Sun, 19 Sep 2021 04:34:16 +0000 (04:34 +0000)]
Auto merge of #89028 - Aaron1011:coercion-cause, r=nagisa

Propagate coercion cause into `try_coerce`

Currently, `coerce_inner` discards its `ObligationCause`
when calling `try_coerce`. This interfers with other
diagnostc improvements I'm working on, since we will lose
the original span by the time the actual coercion occurs.

Additionally, we now use the span of the trailing expression
(rather than the span of the entire function) when performing
a coercion in `check_return_expr`. This currently has no visible
effect on any of the unit tests, but will unblock future
diagnostic improvements.

2 years agoAuto merge of #88968 - tmiasko:start-block-no-predecessors, r=davidtwco
bors [Sun, 19 Sep 2021 01:38:17 +0000 (01:38 +0000)]
Auto merge of #88968 - tmiasko:start-block-no-predecessors, r=davidtwco

Start block is not allowed to have basic block predecessors

* The MIR validator is extended to detect potential violations.
* The start block has no predecessors after building MIR, so no changes are required there.
* The SimplifyCfg could previously violate this requirement when collapsing goto chains, so transformation is disabled for the start block, which also substantially simplifies the implementation.
* The LLVM function entry block also must not have basic block predecessors. Previously, to ensure that code generation had to perform necessary adjustments. This now became unnecessary.

The motivation behind the change is to align with analogous requirement in LLVM, and to avoid potential latent bugs like the one reported in #88043.