Commit Graph

9242 Commits

Author SHA1 Message Date
Eric Huss
67a5b193c1 Check for duplicate attributes. 2021-11-18 16:10:26 -08:00
bors
cc946fcd32 Auto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #90386 (Add `-Zassert-incr-state` to assert state of incremental cache)
 - #90438 (Clean up mess for --show-coverage documentation)
 - #90480 (Mention `Vec::remove` in `Vec::swap_remove`'s docs)
 - #90607 (Make slice->str conversion and related functions `const`)
 - #90750 (rustdoc: Replace where-bounded Clean impl with simple function)
 - #90895 (require full validity when determining the discriminant of a value)
 - #90989 (Avoid suggesting literal formatting that turns into member access)
 - #91002 (rustc: Remove `#[rustc_synthetic]`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-18 20:23:26 +00:00
Yuki Okushi
08c1639fd9
Rollup merge of #91002 - petrochenkov:nosynth, r=davidtwco
rustc: Remove `#[rustc_synthetic]`

This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.

Noticed while reviewing https://github.com/rust-lang/rust/pull/90947.
2021-11-19 02:22:59 +09:00
Yuki Okushi
dfbbb3b900
Rollup merge of #90989 - notriddle:notriddle/rustc-suggest-float-ending-in-dot, r=sanxiyn
Avoid suggesting literal formatting that turns into member access

Fixes #90974
2021-11-19 02:22:59 +09:00
Yuki Okushi
0a2b7d71d9
Rollup merge of #90895 - RalfJung:read-discriminant-valid, r=oli-obk
require full validity when determining the discriminant of a value

This resolves (for now) the semantic question that came up in https://github.com/rust-lang/rust/pull/89764: arguably, reading the discriminant of a value is 'using' that value, so we are in our right to demand full validity. Reading a discriminant is somewhat special in that it works for values of *arbitrary* type; all the other primitive MIR operations work on specific types (e.g. `bool` or an integer) and basically implicitly require validity as part of just "doing their job".

The alternative would be to just require that the discriminant itself is valid, if any -- but then what do we do for types that do not have a discriminant, which kind of validity do we check? [This code](81117ff930/compiler/rustc_codegen_ssa/src/mir/place.rs (L206-L215)) means we have to at least reject uninhabited types, but I would rather not special case that.

I don't think this can be tested in CTFE (since validity is not enforced there), I will add a compile-fail test to Miri:
```rust
#[allow(enum_intrinsics_non_enums)]
fn main() {
    let i = 2u8;
    std::mem::discriminant(unsafe { &*(&i as *const _ as *const bool) }); // UB
}
```

(I tried running the check even on the CTFE machines, but then it runs during ConstProp and that causes all sorts of problems. We could run it for ConstEval but not ConstProp, but that simply does not seem worth the effort currently.)

r? ``@oli-obk``
2021-11-19 02:22:58 +09:00
Yuki Okushi
728b3f2356
Rollup merge of #90386 - pierwill:assert-incr-state-85864, r=Aaron1011
Add `-Zassert-incr-state` to assert state of incremental cache

Closes #85864.
2021-11-19 02:22:54 +09:00
bors
b6f580acc0 Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett
std: Get the standard library compiling for wasm64

This commit goes through and updates various `#[cfg]` as appropriate to
get the wasm64-unknown-unknown target behaving similarly to the
wasm32-unknown-unknown target. Most of this is just updating various
conditions for `target_arch = "wasm32"` to also account for `target_arch
= "wasm64"` where appropriate. This commit also lists `wasm64` as an
allow-listed architecture to not have the `restricted_std` feature
enabled, enabling experimentation with `-Z build-std` externally.

The main goal of this commit is to enable playing around with
`wasm64-unknown-unknown` externally via `-Z build-std` in a way that's
similar to the `wasm32-unknown-unknown` target. These targets are
effectively the same and only differ in their pointer size, but wasm64
is much newer and has much less ecosystem/library support so it'll still
take time to get wasm64 fully-fledged.
2021-11-18 17:19:27 +00:00
Vadim Petrochenkov
91e02177a1 rustc: Remove #[rustc_synthetic]
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-18 14:32:29 +08:00
Michael Howell
a7261c32f4 Avoid suggesting literal formatting that turns into member access
Fixes #90974
2021-11-17 17:23:15 -07:00
Matthias Krüger
469faa2b66
Rollup merge of #90901 - rukai:improve_manuallydrop_help, r=estebank
Improve ManuallyDrop suggestion

closes https://github.com/rust-lang/rust/issues/90585
* Fixes the recommended change to use ManuallyDrop as per the issue
* Changes the note to a help
* improves the span so it only points at the type.
2021-11-17 15:58:06 +01:00
Matthias Krüger
fb660de28e
Rollup merge of #90900 - andjo403:removeLlvm12Check, r=nikic
Remove workaround for the forward progress handling in LLVM

this workaround was only needed for LLVM < 12 and the minimum LLVM version was updated to 12 in #90175
2021-11-17 15:58:05 +01:00
Matthias Krüger
23ad7a7697
Rollup merge of #90884 - Nilstrieb:fix-span-trivial-trait-bound, r=estebank
Fix span for non-satisfied trivial trait bounds

The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before.
Now they only reference the obligation itself (`String: Copy`)

Address #90869
2021-11-17 15:58:04 +01:00
Matthias Krüger
ab958a7ab0
Rollup merge of #90861 - 5225225:nonprinting-char, r=davidtwco
Print escaped string if char literal has multiple characters, but only one printable character

Fixes #90857

I'm not sure about the error message here, it could get rather long and *maybe* using the names of characters would be better? That wouldn't help the length any, though.
2021-11-17 15:58:02 +01:00
Matthias Krüger
d7b86880d2
Rollup merge of #90667 - rukai:improve_static_lifetime_diagnostics, r=estebank
Improve diagnostics when a static lifetime is expected

Makes progress towards https://github.com/rust-lang/rust/issues/90600

The diagnostics here were previously entirely removed due to giving a misleading suggestion but if we instead provide an informative label in that same location it should better help the user understand the situation.

I included the example from the issue as it demonstrates an area where the diagnostics are still lacking.
Happy to remove that if its just adding noise atm.
2021-11-17 15:57:57 +01:00
Matthias Krüger
07342828c5
Rollup merge of #89610 - guswynn:must_use_future, r=wesleywiser
warn on must_use use on async fn's

As referenced in #78149

This only works on `async` fn's for now, I can also look into if I can get `Box<dyn Future>` and `impl Future` working at this level (hir)
2021-11-17 15:57:56 +01:00
Matthias Krüger
3f550078c9
Rollup merge of #90935 - jhpratt:alphabetize-features, r=joshtriplett
Alphabetize language features

This should significantly reduce the frequency of merge conflicts.

r? ````@joshtriplett````

````@rustbot```` label: +A-contributor-roadblock +S-waiting-on-review
2021-11-16 23:58:25 +01:00
Matthias Krüger
eb9859f00d
Rollup merge of #90933 - compiler-errors:master, r=estebank
Fix await suggestion on non-future type

Remove a match block that would suggest to add `.await` in the case where the expected type's `Future::Output` equals the found type. We only want to suggest `.await`ing in the opposite case (the found type's `Future::Output` equals the expected type).

The code sample is here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6ba6b83d4dddda263553b79dca9f6bcb

Before:
```
➜  ~ rustc --edition=2021 --crate-type=lib test.rs
error[E0308]: `match` arms have incompatible types
 --> test.rs:4:14
  |
2 |       let x = match 1 {
  |  _____________-
3 | |         1 => other(),
  | |              ------- this is found to be of type `impl Future`
4 | |         2 => other().await,
  | |              ^^^^^^^^^^^^^ expected opaque type, found enum `Result`
5 | |     };
  | |_____- `match` arms have incompatible types
  |
  = note: expected type `impl Future`
             found enum `Result<(), ()>`
help: consider `await`ing on the `Future`
  |
4 |         2 => other().await.await,
  |                           ++++++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
```

After:
```
➜  ~ rustc +stage1 --edition=2021 --crate-type=lib test.rs
error[E0308]: `match` arms have incompatible types
 --> test.rs:4:14
  |
2 |       let x = match 1 {
  |  _____________-
3 | |         1 => other(),
  | |              ------- this is found to be of type `impl Future`
4 | |         2 => other().await,
  | |              ^^^^^^^^^^^^^ expected opaque type, found enum `Result`
5 | |     };
  | |_____- `match` arms have incompatible types
  |
  = note: expected type `impl Future`
             found enum `Result<(), ()>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
```

Fixes #90931
2021-11-16 23:58:24 +01:00
Matthias Krüger
c63cf076b5
Rollup merge of #90787 - JohnTitor:inline-sorted-index-map, r=oli-obk
Add `#[inline]`s to `SortedIndexMultiMap`

They're small enough and good candidates to add `#[inline]` generally.
2021-11-16 23:58:22 +01:00
Michael Goulet
fc816c37b7 Fix await suggestion better 2021-11-16 13:30:01 -08:00
Alex Crichton
97cd27ab1d Add emscripten to the "wasm" family of targets 2021-11-16 13:10:35 -08:00
Wesley Wiser
83ce771c0f Update compiler/rustc_passes/src/check_attr.rs
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2021-11-16 11:43:13 -05:00
bors
d914f17ca7 Auto merge of #90919 - nnethercote:rm-DropArena, r=Mark-Simulacrum
Remove `DropArena`.

Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a
few infrequently used ones share a `DropArena`. This sharing adds complexity
but doesn't help performance or memory usage. Perhaps it was more effective in
the past prior to some other improvements to arenas.

This commit removes `DropArena` and the sharing of arenas via the `few`
attribute of the `arena_types` macro. This change removes over 100 lines of
code and nine uses of `unsafe` (one of which affects the parallel compiler) and
makes the remaining code easier to read.
2021-11-16 11:48:37 +00:00
bors
934624fe5f Auto merge of #90945 - JohnTitor:rollup-wc35xss, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #86455 (check where-clause for explicit `Sized` before suggesting `?Sized`)
 - #90801 (Normalize both arguments of `equate_normalized_input_or_output`)
 - #90803 (Suggest `&str.chars()` on attempt to `&str.iter()`)
 - #90819 (Fixes incorrect handling of TraitRefs when emitting suggestions.)
 - #90910 (fix getting the discriminant of a zero-variant enum)
 - #90925 (rustc_mir_build: reorder bindings)
 - #90928 (Use a different server for checking clock drift)
 - #90936 (Add a regression test for #80772)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-16 08:22:55 +00:00
5225225
09e59c2875 Inline printable function 2021-11-16 08:06:31 +00:00
5225225
52199c93bb Suggest removing the non-printing characters 2021-11-16 08:06:30 +00:00
5225225
de05d3ec31 Print full char literal on error if any are non-printing 2021-11-16 08:06:30 +00:00
Yuki Okushi
cdc12ba5a3
Rollup merge of #90925 - krasimirgg:rustc_mir_build_fix, r=petrochenkov
rustc_mir_build: reorder bindings

No functional changes intended.

I'm playing around with building compiler components using nightly rust
(2021-11-02) in a non-standard way. I encountered the following error while
trying to build rustc_mir_build:

```
error[E0597]: `wildcard` does not live long enough
    --> rust/src/nightly/compiler/rustc_mir_build/src/build/matches/mod.rs:1767:82
     |
1767 |         let mut otherwise_candidate = Candidate::new(expr_place_builder.clone(), &wildcard, false);
     |                                                                                  ^^^^^^^^^ borrowed value does not live long enough
...
1799 |     }
     |     -
     |     |
     |     `wildcard` dropped here while still borrowed
     |     borrow might be used here, when `guard_candidate` is dropped and runs the destructor for type `Candidate<'_, '_>`
     |
     = note: values in a scope are dropped in the opposite order they are defined
```

I believe this flags an issue that may become an error in the future.
Swapping the order of `wildcard` and `guard_candidate` resolves it.
2021-11-16 15:59:42 +09:00
Yuki Okushi
6d9c3a1b97
Rollup merge of #90910 - RalfJung:const-discriminant-empty-enum, r=petrochenkov
fix getting the discriminant of a zero-variant enum

Fixes https://github.com/rust-lang/rust/issues/89765
2021-11-16 15:59:41 +09:00
Yuki Okushi
d44cec3453
Rollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkov
Fixes incorrect handling of TraitRefs when emitting suggestions.

Closes #90804 , although there were more issues here that were hidden by the thing that caused this ICE.

Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations.

This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
2021-11-16 15:59:40 +09:00
Yuki Okushi
b17de50a41
Rollup merge of #90803 - TaKO8Ki:suggest-chars-on-attempt-to-iter, r=estebank
Suggest `&str.chars()` on attempt to `&str.iter()`

closes #90786
2021-11-16 15:59:39 +09:00
Yuki Okushi
21bff4a4c1
Rollup merge of #90801 - b-naber:missing_normalization_equate_inputs_output, r=jackh726
Normalize both arguments of `equate_normalized_input_or_output`

Fixes https://github.com/rust-lang/rust/issues/90638
Fixes https://github.com/rust-lang/rust/issues/90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ````@jackh726````
2021-11-16 15:59:39 +09:00
Yuki Okushi
ebef3ce25b
Rollup merge of #86455 - tlyu:check-where-before-suggesting-unsized, r=estebank
check where-clause for explicit `Sized` before suggesting `?Sized`

Fixes #85945.

Based on #86454.

``@rustbot`` label +A-diagnostics +A-traits +A-typesystem +D-papercut +T-compiler
2021-11-16 15:59:38 +09:00
bors
a2a7683e8f Auto merge of #90845 - JakobDegen:adt-drop-perf, r=Mark-Simulacrum
Address performance regression introduced by #90218

As part of the changes in #90218 , the `adt_drop_tys` and friends code stopped recursing through the query system, meaning that intermediate computations did not get cached. This change adds the recursions back in without re-introducing any of the old issues.

On local benchmarks this fixes the 5% regressions in #90504 ; the wg-grammar regressions didn't seem to move too much. I may take some time later to look into those.

Not sure who to request for review here, so will leave it up to whoever gets it.
2021-11-16 05:18:57 +00:00
Taylor Yu
1a50725a4d refactor is_param_bound 2021-11-15 22:31:56 -06:00
Taylor Yu
c9fcbda389 check where clause before suggesting unsized 2021-11-15 22:31:55 -06:00
Jacob Pratt
77b0613f1a
Alphabetize language features
This should significantly reduce the frequency of merge conflicts.
2021-11-15 21:33:39 -05:00
bors
02063124f9 Auto merge of #90934 - JohnTitor:rollup-5soqo0j, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #85766 (Stabilize File::options())
 - #88601 (Implement `Termination` for `Result<Infallible, E>`)
 - #90058 (Stabilize -Z strip as -C strip)
 - #90790 (Fix standard library test with read_link)
 - #90834 (Android is not GNU)
 - #90835 (Rename WASI's `is_character_device` to `is_char_device`.)
 - #90837 (Move some tests to more reasonable directories - 9)
 - #90848 (Remove bigint_helper_methods for *signed* types)
 - #90892 (fix ICE on Miri/CTFE copy of half a pointer)
 - #90909 (disable portable SIMD tests in Miri)

Failed merges:

 - #90128 (Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0)

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-16 02:23:42 +00:00
Yuki Okushi
fff9055afb
Rollup merge of #90892 - RalfJung:miri-partial-ptr-copy, r=oli-obk
fix ICE on Miri/CTFE copy of half a pointer

Fixes https://github.com/rust-lang/miri/issues/1910
r? `````@oli-obk`````
2021-11-16 09:14:22 +09:00
Yuki Okushi
ed7ed5fc90
Rollup merge of #90834 - cuviper:android-gnu, r=petrochenkov
Android is not GNU

For a long time, the Android targets had `target_env=""`, but this changed to `"gnu"` in Rust 1.49.0. I tracked this down to #77729 which started setting `"gnu"` in the `linux_base` target options, and this was inherited by `android_base`. Then #78929 split the env into `linux_gnu_base`, but `android_base` was also changed to follow that. Android was not specifically mentioned in either pull request, so I believe this was an accident. Moving it back to `linux_base` will use an empty `env` again.

r? ````@Mark-Simulacrum````
cc ````@petrochenkov````
2021-11-16 09:14:18 +09:00
Yuki Okushi
a0dc4abe98
Rollup merge of #90058 - joshtriplett:stabilize-strip, r=wesleywiser
Stabilize -Z strip as -C strip

Leave -Z strip available temporarily as an alias, to avoid breaking
cargo until cargo transitions to using -C strip.
2021-11-16 09:14:16 +09:00
bors
b053550847 Auto merge of #90827 - matthewjasper:assoc-item-cleanup-2, r=cjgillot
Assoc item cleanup Part 2

- Remove `AssocItem` from `RegionVariableOrigin::AutoRef`
- Use the `associated_item_def_ids` query instead of the `associated_items` query when possible

The change to `ObligationCauseCode` from #90639 is omitted because it caused a perf regression.

r? `@cjgillot`
2021-11-15 23:27:59 +00:00
bors
c26746af5a Auto merge of #90473 - joshtriplett:stabilize-format-args-capture, r=Mark-Simulacrum
stabilize format args capture

Works as expected, and there are widespread reports of success with it, as well as interest in it.

RFC: rust-lang/rfcs#2795
Tracking issue: https://github.com/rust-lang/rust/issues/67984

Addressing items from the tracking issue:

- We don't support capturing arguments from a non-literal format string like `format_args!(concat!(...))`. We could add that in a future enhancement, or we can decide that it isn't supported (as suggested in https://github.com/rust-lang/rust/issues/67984#issuecomment-801394736 ).
- I've updated the documentation.
- `panic!` now supports capture as well.
- There are potentially opportunities to further improve diagnostics for invalid usage, such as if it looks like the user tried to use an expression rather than a variable. However, such cases are all already caught and provide reasonable syntax errors now, and we can always provided even friendlier diagnostics in the future.
2021-11-15 16:10:19 +00:00
Krasimir Georgiev
c1c20138a9 rustc_mir_build: reorder bindings
No functional changes intended.

I'm playing around with building compiler components using nightly rust
(2021-11-02) in a non-standard way. I encountered the following error while
trying to build rustc_mir_build:

```
error[E0597]: `wildcard` does not live long enough
    --> rust/src/nightly/compiler/rustc_mir_build/src/build/matches/mod.rs:1767:82
     |
1767 |         let mut otherwise_candidate = Candidate::new(expr_place_builder.clone(), &wildcard, false);
     |                                                                                  ^^^^^^^^^ borrowed value does not live long enough
...
1799 |     }
     |     -
     |     |
     |     `wildcard` dropped here while still borrowed
     |     borrow might be used here, when `guard_candidate` is dropped and runs the destructor for type `Candidate<'_, '_>`
     |
     = note: values in a scope are dropped in the opposite order they are defined
```

I believe this flags an issue that may become an error in the future.
Swapping the order of `wildcard` and `guard_candidate` resolves it.
2021-11-15 16:23:02 +01:00
bors
eab2d7519a Auto merge of #90717 - kit-981:fix-ld64-flags, r=petrochenkov
Fix ld64 flags

- The `-exported_symbols_list` argument appears to be malformed for `ld64` (if you are not going through `clang`).
- The `-dynamiclib` argument isn't support for `ld64`. It should be guarded behind a compiler flag.

These problems are fixed by these changes. I have also refactored the way linker arguments are generated to be ld/compiler agnostic and therefore less error prone.

These changes are necessary to support cross-compilation to darwin targets.
2021-11-15 11:18:44 +00:00
Josh Triplett
e35b7bbdf8 Stabilize -Z strip as -C strip
Leave -Z strip available temporarily as an alias, to avoid breaking
cargo until cargo transitions to using -C strip. (If the user passes
both, the -C version wins.)
2021-11-15 10:21:02 +01:00
Josh Triplett
c4884bbec7 Support having -Z and -C options with the same name
Tweak the `options!` macro to allow for -Z and -C options with the same
name without generating conflicting internal parsing functions.

Split out of the commit stabilizing -Z strip as -C strip.
2021-11-15 10:18:30 +01:00
Josh Triplett
8c9bfaa5f3 Stabilize format_args_capture
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
2021-11-15 10:14:29 +01:00
Nicholas Nethercote
fb80c73fb3 Remove DropArena.
Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a
few infrequently used ones share a `DropArena`. This sharing adds complexity
but doesn't help performance or memory usage. Perhaps it was more effective in
the past prior to some other improvements to arenas.

This commit removes `DropArena` and the sharing of arenas via the `few`
attribute of the `arena_types` macro. This change removes over 100 lines of
code and nine uses of `unsafe` (one of which affects the parallel compiler) and
makes the remaining code easier to read.
2021-11-15 18:33:43 +11:00
bors
d5a0c7cb03 Auto merge of #90645 - terrarier2111:master, r=estebank
Implement diagnostic for String conversion

This is my first real contribution to rustc, any feedback is highly appreciated.
This should fix https://github.com/rust-lang/rust/issues/89856

Thanks to `@estebank` for guiding me.
2021-11-15 06:55:01 +00:00
Lucas Kent
62acf7f96d feedback 2021-11-15 14:51:56 +11:00