]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agounitalicize O(1) complexities
Takashi Idobe [Fri, 24 Sep 2021 13:33:49 +0000 (08:33 -0500)]
unitalicize O(1) complexities

2 years agoMerge branch 'rust-lang:master' into master
Takashi Idobe [Fri, 24 Sep 2021 13:31:03 +0000 (08:31 -0500)]
Merge branch 'rust-lang:master' into master

2 years agoAuto merge of #89130 - nikic:update-llvm-2, r=cuviper
bors [Fri, 24 Sep 2021 08:12:15 +0000 (08:12 +0000)]
Auto merge of #89130 - nikic:update-llvm-2, r=cuviper

Update LLVM submodule

This merges the upstream `release/13.x` branch to pull in the second fix for #88769.

2 years agoAuto merge of #89120 - In-line:remove_unneded_visible_parents_map, r=estebank
bors [Fri, 24 Sep 2021 05:29:49 +0000 (05:29 +0000)]
Auto merge of #89120 - In-line:remove_unneded_visible_parents_map, r=estebank

Disable visible path calculation for PrettyPrinter in Ok path of compiler

2 years agoAuto merge of #89211 - workingjubilee:rollup-fj4eduk, r=workingjubilee
bors [Fri, 24 Sep 2021 01:48:02 +0000 (01:48 +0000)]
Auto merge of #89211 - workingjubilee:rollup-fj4eduk, r=workingjubilee

Rollup of 7 pull requests

Successful merges:

 - #88612 (Add a better error message for #39364)
 - #89023 (Resolve issue : Somewhat confusing error with extended_key_value_attributes)
 - #89148 (Suggest `_` in turbofish if param will be inferred from fn argument)
 - #89171 (Run `no_core` rustdoc tests only on Linux)
 - #89176 (Change singular to plural)
 - #89184 (Temporarily rename int_roundings functions to avoid conflicts)
 - #89200 (Fix typo)

Failed merges:

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

2 years agoRollup merge of #89200 - hkmatsumoto:patch, r=workingjubilee
Jubilee [Fri, 24 Sep 2021 00:31:47 +0000 (17:31 -0700)]
Rollup merge of #89200 - hkmatsumoto:patch, r=workingjubilee

Fix typo

2 years agoRollup merge of #89184 - joshtriplett:master, r=estebank
Jubilee [Fri, 24 Sep 2021 00:31:46 +0000 (17:31 -0700)]
Rollup merge of #89184 - joshtriplett:master, r=estebank

Temporarily rename int_roundings functions to avoid conflicts

These functions are unstable, but because they're inherent they still
introduce conflicts with stable trait functions in crates. Temporarily
rename them to fix these conflicts, until we can resolve those conflicts
in a better way.

2 years agoRollup merge of #89176 - TaKO8Ki:change-singular-to-plural, r=lcnr
Jubilee [Fri, 24 Sep 2021 00:31:45 +0000 (17:31 -0700)]
Rollup merge of #89176 - TaKO8Ki:change-singular-to-plural, r=lcnr

Change singular to plural

2 years agoRollup merge of #89171 - rusticstuff:aarch64_macos_rustdoc_ci_fixes, r=jyn514
Jubilee [Fri, 24 Sep 2021 00:31:44 +0000 (17:31 -0700)]
Rollup merge of #89171 - rusticstuff:aarch64_macos_rustdoc_ci_fixes, r=jyn514

Run `no_core` rustdoc tests only on Linux

I don't think this is really worth investigating further so I just disabled them.

They currently fail like this:
```
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-Wl,-exported_symbols_list,/var/folders/pg/gjhzdz7n361f0pv665d0723w0000gn/T/rustcPUsMpx/list" "-arch" "arm64" "/Users/hans/dev/rust/build/aarch64-apple-darwin/test/rustdoc/intra-doc/prim-methods-external-core/auxiliary/my-core.my_core.9f3c60de-cgu.0.rcgu.o" "/Users/hans/dev/rust/build/aarch64-apple-darwin/test/rustdoc/intra-doc/prim-methods-external-core/auxiliary/my-core.50fu2g9urkmisdsg.rcgu.o" "-L" "/Users/hans/dev/rust/build/aarch64-apple-darwin/native/rust-test-helpers" "-L" "/Users/hans/dev/rust/build/aarch64-apple-darwin/test/rustdoc/intra-doc/prim-methods-external-core/auxiliary" "-L" "/Users/hans/dev/rust/build/aarch64-apple-darwin/stage1/lib/rustlib/aarch64-apple-darwin/lib" "-L" "/Users/hans/dev/rust/build/aarch64-apple-darwin/stage1/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/hans/dev/rust/build/aarch64-apple-darwin/test/rustdoc/intra-doc/prim-methods-external-core/auxiliary/libmy_core.dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-Wl,-install_name" "-Wl,``@rpath/libmy_core.dylib"`` "-nodefaultlibs"
  = note: ld: dynamic main executables must link with libSystem.dylib for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

r? ``@jyn514``

2 years agoRollup merge of #89148 - estebank:used-type-param, r=oli-obk
Jubilee [Fri, 24 Sep 2021 00:31:43 +0000 (17:31 -0700)]
Rollup merge of #89148 - estebank:used-type-param, r=oli-obk

Suggest `_` in turbofish if param will be inferred from fn argument

2 years agoRollup merge of #89023 - Wardenfar:issue-85066, r=nagisa
Jubilee [Fri, 24 Sep 2021 00:31:42 +0000 (17:31 -0700)]
Rollup merge of #89023 - Wardenfar:issue-85066, r=nagisa

Resolve issue : Somewhat confusing error with extended_key_value_attributes

Fixes #85066

2 years agoRollup merge of #88612 - lovasoa:patch-1, r=m-ou-se
Jubilee [Fri, 24 Sep 2021 00:31:41 +0000 (17:31 -0700)]
Rollup merge of #88612 - lovasoa:patch-1, r=m-ou-se

Add a better error message for #39364

There is a known bug in the implementation of mpsc channels in rust.
This adds a clearer error message when the bug occurs, so that developers don't lose too much time looking for the origin of the bug.
See https://github.com/rust-lang/rust/issues/39364

2 years agoremove trailing whitespace
Takashi Idobe [Thu, 23 Sep 2021 23:20:46 +0000 (18:20 -0500)]
remove trailing whitespace

2 years agoAdd time complexities to linked_list.rs
Takashi Idobe [Thu, 23 Sep 2021 22:58:02 +0000 (17:58 -0500)]
Add time complexities to linked_list.rs

2 years agoAuto merge of #88804 - Mark-Simulacrum:never-algo-v2, r=nikomatsakis,jackh726
bors [Thu, 23 Sep 2021 22:45:22 +0000 (22:45 +0000)]
Auto merge of #88804 - Mark-Simulacrum:never-algo-v2, r=nikomatsakis,jackh726

Revise never type fallback algorithm

This is a rebase of https://github.com/rust-lang/rust/pull/84573, but dropping the stabilization of never type (and the accompanying large test diff).

Each commit builds & has tests updated alongside it, and could be reviewed in a more or less standalone fashion. But it may make more sense to review the PR as a whole, I'm not sure. It should be noted that tests being updated isn't really a good indicator of final behavior -- never_type_fallback is not enabled by default in this PR, so we can't really see the full effects of the commits here.

This combines the work by Niko, which is [documented in this gist](https://gist.github.com/nikomatsakis/7a07b265dc12f5c3b3bd0422018fa660), with some additional rules largely derived to target specific known patterns that regress with the algorithm solely derived by Niko. We build these from an intuition that:

* In general, fallback to `()` is *sound* in all cases
* But, in general, we *prefer* fallback to `!` as it accepts more code, particularly that written to intentionally use `!` (e.g., Result's with a Infallible/! variant).

When evaluating Niko's proposed algorithm, we find that there are certain cases where fallback to `!` leads to compilation failures in real-world code, and fallback to `()` fixes those errors. In order to allow for stabilization, we need to fix a good portion of these patterns.

The final rule set this PR proposes is that, by default, we fallback from `?T` to `!`, with the following exceptions:

1. `?T: Foo` and `Bar::Baz = ?T` and `(): Foo`, then fallback to `()`
2. Per [Niko's algorithm](https://gist.github.com/nikomatsakis/7a07b265dc12f5c3b3bd0422018fa660#proposal-fallback-chooses-between--and--based-on-the-coercion-graph), the "live" `?T` also fallback to `()`.

The first rule is necessary to address a fairly common pattern which boils down to something like the snippet below. Without rule 1, we do not see the closure's return type as needing a () fallback, which leads to compilation failure.

```rust
#![feature(never_type_fallback)]

trait Bar { }
impl Bar for () {  }
impl Bar for u32 {  }

fn foo<R: Bar>(_: impl Fn() -> R) {}

fn main() {
    foo(|| panic!());
}
```

r? `@jackh726`

2 years agoAuto merge of #89024 - oli-obk:lazy_tait_is_not_limited_to_being_used_in_return_posit...
bors [Thu, 23 Sep 2021 19:38:30 +0000 (19:38 +0000)]
Auto merge of #89024 - oli-obk:lazy_tait_is_not_limited_to_being_used_in_return_position, r=nikomatsakis

Lazy TAIT preparation cleanups

Check that TAIT generics are fully generic in mir typeck instead of wf-check, as wf-check can by definition only check TAIT in return position and not account for TAITs defined in the body of the function

r? `@spastorino` `@nikomatsakis`

2 years agoAuto merge of #89016 - lcnr:non_blanket_impls, r=nikomatsakis,michaelwoerister
bors [Thu, 23 Sep 2021 15:44:53 +0000 (15:44 +0000)]
Auto merge of #89016 - lcnr:non_blanket_impls, r=nikomatsakis,michaelwoerister

fix non_blanket_impls iteration order

We sometimes iterate over all `non_blanket_impls`, not sure if this is observable outside
of error messages (i.e. as incremental bugs). This should fix the underlying issue of #86986.

second attempt of #88718

r? `@nikomatsakis`

2 years agoSuggest `_` in turbofish if param will be inferred from fn argument
Esteban Kuber [Tue, 21 Sep 2021 13:18:26 +0000 (13:18 +0000)]
Suggest `_` in turbofish if param will be inferred from fn argument

2 years agoCheck that TAIT generics are fully generic in mir typeck instead of wf-check, as...
Oli Scherer [Thu, 16 Sep 2021 19:08:25 +0000 (19:08 +0000)]
Check that TAIT generics are fully generic in mir typeck instead of wf-check, as wf-check can by definition only check TAIT in return position and not account for TAITs defined in the body of the function

2 years agoAuto merge of #87064 - Aaron1011:new-closure-track-caller, r=estebank
bors [Thu, 23 Sep 2021 12:26:51 +0000 (12:26 +0000)]
Auto merge of #87064 - Aaron1011:new-closure-track-caller, r=estebank

Support `#[track_caller]` on closures and generators

## Lang team summary

This PR adds support for placing the `#[track_caller]` attribute on closure and generator expressions. This attribute's addition behaves identically (from a users perspective) to the attribute being placed on the method in impl Fn/FnOnce/FnMut for ... generated by compiler.

The attribute is currently "double" feature gated -- both `stmt_expr_attributes` (preexisting) and `closure_track_caller` (newly added) must be enabled in order to place these attributes on closures.

As the Fn* traits lack a `#[track_caller]` attribute in their definition, caller information does not propagate when invoking closures through dyn Fn*. There is no limitation that this PR adds in supporting this; it can be added in the future.

# Implementation details

This is implemented in the same way as for functions - an extra
location argument is appended to the end of the ABI. For closures,
this argument is *not* part of the 'tupled' argument storing the
parameters - the final closure argument for `#[track_caller]` closures
is no longer a tuple.

For direct (monomorphized) calls, the necessary support was already
implemented - we just needeed to adjust some assertions around checking
the ABI and argument count to take closures into account.

For calls through a trait object, more work was needed.
When creating a `ReifyShim`, we need to create a shim
for the trait method (e.g. `FnOnce::call_mut`) - unlike normal
functions, closures are never invoked directly, and always go through a
trait method.

Additional handling was needed for `InstanceDef::ClosureOnceShim`. In
order to pass location information throgh a direct (monomorphized) call
to `FnOnce::call_once` on an `FnMut` closure, we need to make
`ClosureOnceShim` aware of `#[tracked_caller]`. A new field
`track_caller` is added to `ClosureOnceShim` - this is used by
`InstanceDef::requires_caller` location, allowing codegen to
pass through the extra location argument.

Since `ClosureOnceShim.track_caller` is only used by codegen,
we end up generating two identical MIR shims - one for
`track_caller == true`, and one for `track_caller == false`. However,
these two shims are used by the entire crate (i.e. it's two shims total,
not two shims per unique closure), so this shouldn't a big deal.

2 years agoUpdate compiler/rustc_infer/src/infer/error_reporting/mod.rs
Takayuki Maeda [Thu, 23 Sep 2021 11:27:20 +0000 (20:27 +0900)]
Update compiler/rustc_infer/src/infer/error_reporting/mod.rs

Co-authored-by: mbartlett21 <29034492+mbartlett21@users.noreply.github.com>
2 years agoFix typo
Hirochika Matsumoto [Thu, 23 Sep 2021 09:57:23 +0000 (18:57 +0900)]
Fix typo

2 years agoAuto merge of #88587 - bdbai:fix/uwpio, r=joshtriplett
bors [Thu, 23 Sep 2021 06:18:07 +0000 (06:18 +0000)]
Auto merge of #88587 - bdbai:fix/uwpio, r=joshtriplett

Fix WinUWP std compilation errors due to I/O safety

I/O safety for Windows has landed in #87329. However, it does not cover UWP specific parts and prevents all UWP targets from building. See https://github.com/YtFlow/Maple/issues/18. This PR fixes these compile errors when building std for UWP targets.

2 years agoAuto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum
bors [Thu, 23 Sep 2021 02:10:26 +0000 (02:10 +0000)]
Auto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum

Use ZST for fmt unsafety

as suggested here - https://github.com/rust-lang/rust/pull/83302#issuecomment-923529151.

2 years agoReason safety for unsafe blocks for uwp stdin
bdbai [Wed, 22 Sep 2021 23:29:52 +0000 (07:29 +0800)]
Reason safety for unsafe blocks for uwp stdin

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 agoTemporarily rename int_roundings functions to avoid conflicts
Josh Triplett [Wed, 22 Sep 2021 20:56:01 +0000 (13:56 -0700)]
Temporarily rename int_roundings functions to avoid conflicts

These functions are unstable, but because they're inherent they still
introduce conflicts with stable trait functions in crates. Temporarily
rename them to fix these conflicts, until we can resolve those conflicts
in a better way.

2 years agoSupport `#[track_caller]` on closures and generators
Aaron Hill [Sun, 27 Jun 2021 19:01:11 +0000 (14:01 -0500)]
Support `#[track_caller]` on closures and generators

This PR allows applying a `#[track_caller]` attribute to a
closure/generator expression. The attribute as interpreted as applying
to the compiler-generated implementation of the corresponding trait
method (`FnOnce::call_once`, `FnMut::call_mut`, `Fn::call`, or
`Generator::resume`).

This feature does not have its own feature gate - however, it requires
`#![feature(stmt_expr_attributes)]` in order to actually apply
an attribute to a closure or generator.

This is implemented in the same way as for functions - an extra
location argument is appended to the end of the ABI. For closures,
this argument is *not* part of the 'tupled' argument storing the
parameters - the final closure argument for `#[track_caller]` closures
is no longer a tuple.

For direct (monomorphized) calls, the necessary support was already
implemented - we just needeed to adjust some assertions around checking
the ABI and argument count to take closures into account.

For calls through a trait object, more work was needed.
When creating a `ReifyShim`, we need to create a shim
for the trait method (e.g. `FnOnce::call_mut`) - unlike normal
functions, closures are never invoked directly, and always go through a
trait method.

Additional handling was needed for `InstanceDef::ClosureOnceShim`. In
order to pass location information throgh a direct (monomorphized) call
to `FnOnce::call_once` on an `FnMut` closure, we need to make
`ClosureOnceShim` aware of `#[tracked_caller]`. A new field
`track_caller` is added to `ClosureOnceShim` - this is used by
`InstanceDef::requires_caller` location, allowing codegen to
pass through the extra location argument.

Since `ClosureOnceShim.track_caller` is only used by codegen,
we end up generating two identical MIR shims - one for
`track_caller == true`, and one for `track_caller == false`. However,
these two shims are used by the entire crate (i.e. it's two shims total,
not two shims per unique closure), so this shouldn't a big deal.

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 agoUpdate library/std/src/sync/mpsc/shared.rs
Mara Bos [Wed, 22 Sep 2021 18:20:33 +0000 (20:20 +0200)]
Update library/std/src/sync/mpsc/shared.rs

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 agoFix test
Cameron Steffen [Wed, 22 Sep 2021 16:48:01 +0000 (11:48 -0500)]
Fix test

2 years agochange singular to plural
Takayuki Maeda [Wed, 22 Sep 2021 15:43:51 +0000 (00:43 +0900)]
change singular to plural

2 years agoRun no_core rustdoc tests on Linux only.
Hans Kratz [Wed, 22 Sep 2021 07:05:39 +0000 (09:05 +0200)]
Run no_core rustdoc tests on Linux only.

Windows on Macos ARM64 produce linker errors.

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 agoUse ZST for fmt unsafety
Cameron Steffen [Tue, 21 Sep 2021 05:56:45 +0000 (00:56 -0500)]
Use ZST for fmt unsafety

This allows the format_args! macro to keep the pre-expansion code out of
the unsafe block without doing gymnastics with nested `match`
expressions. This reduces codegen.

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 ago`crates` is already deterministic
lcnr [Fri, 17 Sep 2021 07:13:16 +0000 (09:13 +0200)]
`crates` is already deterministic

2 years agouse indexmap instead of hashmap
lcnr [Thu, 16 Sep 2021 15:53:50 +0000 (17:53 +0200)]
use indexmap instead of hashmap

2 years agorename
lcnr [Thu, 16 Sep 2021 15:32:57 +0000 (17:32 +0200)]
rename

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 agoUpdate LLVM submodule
Nikita Popov [Mon, 20 Sep 2021 21:07:04 +0000 (23:07 +0200)]
Update LLVM submodule

2 years agoDisable visible path calculation for PrettyPrinter in Ok path of compiler
Alik Aslanyan [Mon, 20 Sep 2021 16:22:55 +0000 (20:22 +0400)]
Disable visible path calculation for PrettyPrinter in Ok path of compiler

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