Commit graph

1527 commits

Author SHA1 Message Date
Matthias Krüger bde3cbd8c3
Rollup merge of #111023 - tmiasko:multi-variant-capture, r=compiler-errors
Test precise capture with a multi-variant enum and exhaustive patterns

Add test checking that it is possible to capture fields of a multi-variant enum, when remaining variants are visibly uninhabited (under the `exhaustive_patterns` feature gate).
2023-05-01 01:09:48 +02:00
Matthias Krüger 07726e3bf2
Rollup merge of #111015 - cjgillot:chained-let-and, r=compiler-errors
Remove wrong assertion in match checking.

This assertions is completely misguided, introduced by https://github.com/rust-lang/rust/pull/108504. The responsible PR is on beta, nominating for backport.

Instead of checking that this is not a `&&`, it would make sense to check that neither arms of that `&&` is a `let`. This seems like a lot of code for unclear benefit.

r? `@saethlin`
2023-05-01 01:09:48 +02:00
Matthias Krüger 1b262b8b56
Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber
Tweak await span to not contain dot

Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue.

Fixes #110761

This mostly touches a bunch of tests to tighten their `await` span.
2023-05-01 01:09:47 +02:00
Tomasz Miąsko b855308521 Test precise capture with a multi-variant enum and exhaustive patterns
Add test checking that it is possible to capture fields of a
multi-variant enum, when remaining variants are visibly uninhabited
(under the `exhaustive_patterns` feature gate).
2023-04-30 20:24:10 +02:00
Camille GILLOT 84cb7ecbc1 Remove wrong assertion. 2023-04-30 14:08:26 +00:00
Matthias Krüger a656a2019a
Rollup merge of #110984 - cjgillot:const-infer-lifetime, r=compiler-errors
Do not resolve anonymous lifetimes in consts to be static.

Fixes https://github.com/rust-lang/rust/issues/110931
2023-04-30 01:14:59 +02:00
Matthias Krüger 791d33c5eb
Rollup merge of #110973 - bindsdev:packed-struct-ref-diagnostic-note, r=compiler-errors
improve error notes for packed struct reference diagnostic

Addresses #110199
2023-04-30 01:14:58 +02:00
Matthias Krüger 734e866e63
Rollup merge of #110586 - ChrisDenton:msvc-oem-output, r=workingjubilee
Fix Unreadable non-UTF-8 output on localized MSVC

Fixes #35785 by converting non UTF-8 linker output to Unicode using the OEM code page.

Before:

```text
  = note: Non-UTF-8 output: LINK : fatal error LNK1181: cannot open input file \'m\x84rchenhaft.obj\'\r\n
```

After:

```text
   = note: LINK : fatal error LNK1181: cannot open input file 'märchenhaft.obj'
```

The difference is more dramatic if using a non-ascii language pack for Windows.
2023-04-30 01:14:55 +02:00
Matthias Krüger 957a6ad4d9
Rollup merge of #110644 - pietroalbini:pa-json-formatting-tests, r=Mark-Simulacrum
Update tests for libtest `--format json`

This PR makes the test work on beta and stable, and adds a test ensuring the option is not available on beta and stable. Backported these commits from https://github.com/rust-lang/rust/pull/110414.
2023-04-29 15:51:15 +02:00
Camille GILLOT 63028ac3a1 Do not force anonymous lifetimes in consts to be static. 2023-04-29 10:32:31 +00:00
bors f2299490c1 Auto merge of #108106 - the8472:layout-opt, r=wesleywiser
Improve niche placement by trying two strategies and picking the better result

Fixes #104807
Fixes #105371

Determining which sort order is better requires calculating the struct size (so we can calculate the niche offset). But that in turn depends on the field order, so happens after sorting. So the simple way to solve that is to run the whole thing twice and pick the better result.

1st commit is just code motion, the meat is in the later ones.
2023-04-29 08:55:04 +00:00
Dylan DPC 81910a1b21
Rollup merge of #110965 - compiler-errors:anon-lt-dupe-oops, r=cjgillot
Don't duplicate anonymous lifetimes for async fn in traits

`record_lifetime_params_for_async` needs to be called outside of the scope of the function, or else it'll end up collecting anonymous lifetimes twice (those on the function and those within the `AnonymousCreateParameter` rib). This matches how `record_lifetime_params_for_async` is being used for functions with bodies below.

This fixes (partially) #110963 when the lifetimes are late-bound, but does not do so when the lifetimes are early-bound (as seen from the known-bug that I added).
2023-04-29 11:27:56 +05:30
Dylan DPC 6da62a40f2
Rollup merge of #110614 - compiler-errors:new-solver-overflow-response, r=lcnr
Clear response values for overflow in new solver

When we have an overflow, return a trivial query response. This fixes an ICE with the code described in #110544:

```rust
trait Trait {}

struct W<T>(T);

impl<T, U> Trait for W<(W<T>, W<U>)>
where
    W<T>: Trait,
    W<U>: Trait,
{}

fn impls<T: Trait>() {}

fn main() {
    impls::<W<_>>()
}
```

Where, while proving `W<?0>: Trait`, we overflow but still apply the query response of `?0 = (W<?1>, W<?2>)`. Then while re-processing the query to validate that our evaluation result was stable, we get a different query response that looks like `?1 = (W<?3>, W<?4>), ?2 = (W<?5>, W<?6>)`, and so we trigger the ICE.

Also, by returning a trivial query response we also avoid the infinite-loop/OOM behavior of the old solver.

r? ``@lcnr``
2023-04-29 11:27:54 +05:30
bindsdev 107d480892 improve error notes for packed struct reference diagnostic 2023-04-28 20:28:56 -05:00
The 8472 61fb5a91b7 layout-alignment-promotion logic should depend on the niche-bias
For start-biased layout we want to avoid overpromoting so that
the niche doesn't get pushed back.
For end-biased layout we want to avoid promoting fields that
may contain one of the niches of interest.
2023-04-28 23:08:54 +02:00
Matthias Krüger 34ef13b15b
Rollup merge of #110960 - lukas-code:unused-mut, r=compiler-errors
fix false negative for `unused_mut`

fixes https://github.com/rust-lang/rust/issues/110849

We want to avoid double diagnostics for code like this, but only if an error actually occurs:
```rust
fn main() {
    let mut x: (i32, i32);
    x.0 = 1;
}
```

The first commit fixes the lint and the second one removes all the unused `mut`s it found.
2023-04-28 22:56:47 +02:00
Matthias Krüger 235d088412
Rollup merge of #110957 - WaffleLapkin:reach_generator_conflict_error, r=cjgillot
Fix an ICE in conflict error diagnostics

Fixes  #110929
r? ``@cjgillot``
2023-04-28 22:56:47 +02:00
Matthias Krüger aba9fb4696
Rollup merge of #110877 - compiler-errors:binop-err, r=cjgillot
Provide better type hints when a type doesn't support a binary operator

For example, when checking whether `vec![A] == vec![A]` holds, we first evaluate the LHS's ty, then probe for any `PartialEq` implementations for that. If none is found, we report an error by evaluating `Vec<A>: PartialEq<?0>` for fulfillment errors, but the RHS is not yet evaluated and remains an inference variable `?0`!

To fix this, we evaluate the RHS and equate it to that RHS infer var `?0`, so that we are able to provide more detailed fulfillment errors for why `Vec<A>: PartialEq<Vec<A>>` doesn't hold (namely, the nested obligation `A: PartialEq<A>` doesn't hold).

Fixes #95285
Fixes #110867
2023-04-28 22:56:44 +02:00
Michael Goulet 4e05cfb5ff Don't duplicate anonymous lifetimes for async fn in traits 2023-04-28 20:21:03 +00:00
Lukas Markeffsky fc63926e18 remove unused muts 2023-04-28 20:19:48 +02:00
Maybe Waffle 754a62c306 Fix an ICE in conflict errors diagnostics 2023-04-28 17:37:56 +00:00
Lukas Markeffsky 69c71dacda fix false negative for unused_mut 2023-04-28 19:35:40 +02:00
Maybe Waffle b29b56f520 Add regression test for issue 110929 2023-04-28 16:50:28 +00:00
Josh Stone dc94522072 bless line changes in tests-listing-format-json.run.stdout 2023-04-28 09:22:29 -07:00
bors 43a78029b4 Auto merge of #110837 - scottmcm:offset-for-add, r=compiler-errors
Use MIR's `Offset` for pointer `add` too

~~Status: draft while waiting for #110822 to land, since this is built atop that.~~
~~r? `@ghost~~`

Canonical Rust code has mostly moved to `add`/`sub` on pointers, which take `usize`, instead of `offset` which takes `isize`.  (And, relatedly, when `sub_ptr` was added it turned out it replaced every single in-tree use of `offset_from`, because `usize` is just so much more useful than `isize` in Rust.)

Unfortunately, `intrinsics::offset` could only accept `*const` and `isize`, so there's a *huge* amount of type conversions back and forth being done.  They're identity conversions in the backend, but still end up producing quite a lot of unhelpful MIR.

This PR changes `intrinsics::offset` to accept `*const` *and* `*mut` along with `isize` *and* `usize`.  Conveniently, the backends and CTFE already handle this, since MIR's `BinOp::Offset` [already supports all four combinations](adaac6b166/compiler/rustc_const_eval/src/transform/validate.rs (L523-L528)).

To demonstrate the difference, I added some `mir-opt/pre-codegen/` tests around slice indexing.  Here's the difference to `[T]::get_mut`, since it uses `<*mut _>::add` internally:
```diff
`@@` -79,30 +70,21 `@@` fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
         StorageLive(_12);                // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         StorageLive(_9);                 // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         _9 = _8 as *mut u32 (PtrToPtr);  // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageLive(_13);                // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _13 = _2 as isize (IntToInt);    // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageLive(_14);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageLive(_15);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _15 = _9 as *const u32 (Pointer(MutToConstPointer)); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _14 = Offset(move _15, _13);     // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageDead(_15);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _7 = move _14 as *mut u32 (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageDead(_14);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageDead(_13);                // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
+        _7 = Offset(_9, _2);             // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
         StorageDead(_9);                 // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         StorageDead(_12);                // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         StorageDead(_11);                // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
```
1c1c8e442a (diff-a841b6a4538657add3f39bc895744331453d0625e7aace128b1f604f0b63c8fdR80)
2023-04-28 09:26:59 +00:00
bors 2fce229086 Auto merge of #110924 - matthiaskrgr:rollup-jvznpq2, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110766 (More core::fmt::rt cleanup.)
 - #110873 (Migrate trivially translatable `rustc_parse` diagnostics)
 - #110904 (rustdoc: rebind bound vars to type-outlives predicates)
 - #110913 (Add some missing built-in lints)
 - #110918 (`remove_dir_all`: try deleting the directory even if `FILE_LIST_DIRECTORY` access is denied)
 - #110920 (Fix unavailable url)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-28 06:32:01 +00:00
Scott McMurray e1da77c76d Also use mir::Offset for pointer add 2023-04-27 22:44:42 -07:00
Matthias Krüger 901bab70d3
Rollup merge of #110913 - compiler-errors:missing-lints, r=Nilstrieb
Add some missing built-in lints

(and also sort them, so this is best reviewed one commit at a time)

Fixes #110911

I wonder if there's a good way to detect when a lint is built-in (i.e. not associated to a lint pass). If so, it needs to be added to this list, or else we're unable to `allow` or `deny` it. Leaving that for future work, I guess...
2023-04-28 07:34:03 +02:00
Matthias Krüger 29f5ec3640
Rollup merge of #110873 - clubby789:migrate-rustc-parse-trivial, r=compiler-errors
Migrate trivially translatable `rustc_parse` diagnostics

cc #100717

Migrate diagnostics in `rustc_parse` which are emitted in a single statement. I worked on this by expanding the lint introduced in #108760, although that isn't included here as there is much more work to be done to satisfy it
2023-04-28 07:34:02 +02:00
Matthias Krüger cf911ac757
Rollup merge of #110766 - m-ou-se:fmt-rt, r=jyn514
More core::fmt::rt cleanup.

- Removes the `V1` suffix from the `Argument` and `Flag` types.

- Moves more of the format_args lang items into the `core::fmt::rt` module. (The only remaining lang item in `core::fmt` is `Arguments` itself, which is a public type.)

Part of https://github.com/rust-lang/rust/issues/99012

Follow-up to https://github.com/rust-lang/rust/pull/110616
2023-04-28 07:34:02 +02:00
bors 033aa092ab Auto merge of #110919 - JohnTitor:rollup-9phs2vx, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #109702 (configure --set support list as arguments)
 - #110620 (Document `const {}` syntax for `std::thread_local`.)
 - #110721 (format panic message only once)
 - #110881 (refactor(docs): remove macro resolution fallback)
 - #110893 (remove inline const deadcode in typeck)
 - #110898 (Remove unused std::sys_common::thread_local_key::Key)
 - #110909 (Skip `rustc` version detection on macOS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-28 03:27:33 +00:00
Yuki Okushi eea5f8a9c4
Rollup merge of #110721 - lukas-code:panic-fmt, r=Amanieu
format panic message only once

Formatting the panic message multiple times can cause problems for some real-world crates, so here's a test to ensure that we don't do that.

This was regressed in https://github.com/rust-lang/rust/pull/109507 and reverted in https://github.com/rust-lang/rust/pull/110782.

fixes https://github.com/rust-lang/rust/issues/110717
fixes https://github.com/rust-itertools/itertools/issues/694
2023-04-28 10:51:59 +09:00
bors 9a3258fa52 Auto merge of #110801 - WaffleLapkin:io-tests, r=jyn514
Fix `ui/io-checks/inaccessbile-temp-dir.rs` test

Fixes #110794

r? `@jyn514`
2023-04-28 00:17:47 +00:00
The 8472 1a51ec6864 bless tests 2023-04-27 22:29:04 +02:00
The 8472 4907dac54c don't promote large fields to higher alignments if that would affect niche placement 2023-04-27 22:29:03 +02:00
The 8472 faf2da3e2f try two different niche-placement strategies when layouting univariant structs 2023-04-27 22:29:03 +02:00
Matthias Krüger 1091a7a884
Rollup merge of #110878 - whtahy:105107/known-bug-tests-for-unsound-issues, r=jackh726
Add `known-bug` tests for 4 unsound issues

This PR adds `known-bug` tests for 4 unsound issues as part of #105107
- #40582
- #49682
- #74629
- #105782
2023-04-27 21:34:16 +02:00
Michael Goulet 183c7904e9 Add invalid_macro_export_arguments to built-in macro list 2023-04-27 18:33:39 +00:00
Michael Goulet 6d6c904431 Make async removal span more resilient to macro expansions 2023-04-27 18:25:07 +00:00
Michael Goulet 6c9249f689 Don't call await a method 2023-04-27 17:18:12 +00:00
Michael Goulet e6077fc1b8 tweak removal span 2023-04-27 17:18:12 +00:00
Michael Goulet f0fc4f9acf Tweak await span 2023-04-27 17:18:11 +00:00
Michael Goulet 12a2f24b15 Remove a bunch of orphaned test files 2023-04-27 17:17:38 +00:00
Matthias Krüger 1ca3f33ef7
Rollup merge of #110866 - compiler-errors:test, r=jyn514
Make `method-not-found-generic-arg-elision.rs` error message not path dependent

Every time I bless `tests/ui/methods/method-not-found-generic-arg-elision.rs`, I get some nonsense "type is too long" + "written to disk" that shows up and have to manually revert because the combination of my rustc repo path + the UI test directory hits the length limit for printing types spilling to disk (since this happens before UI test path sanitization).

The fact that we use a closure in this test doesn't have to do with the UI test, so just box the closure to make the type name smaller and not path dependent.
2023-04-27 15:10:55 +02:00
Matthias Krüger 63fbb05839
Rollup merge of #110816 - clubby789:rustc-passes-diagnostics, r=compiler-errors
Migrate `rustc_passes` to translatable diagnostics

cc #100717
2023-04-27 15:10:54 +02:00
Matthias Krüger 5215782421
Rollup merge of #110804 - cuishuang:master, r=jyn514
Remove repeated definite articles
2023-04-27 15:10:53 +02:00
Chris Denton 73b65746e8
Fix Unreadable non-UTF-8 output on localized MSVC
Fixes #35785 by converting non UTF-8 linker output to Unicode using the OEM code page.

Before:

```text
  = note: Non-UTF-8 output: LINK : fatal error LNK1181: cannot open input file \'m\x84rchenhaft.obj\'\r\n
```

After:

```text
   = note: LINK : fatal error LNK1181: cannot open input file 'märchenhaft.obj'

```

The difference is more dramatic if using a non-ascii language pack for Visual Studio.
2023-04-27 09:58:18 +01:00
whtahy fcf8468efc add known-bug test for unsound issue 105782 2023-04-26 22:34:39 -04:00
whtahy 21b9f5c3bb add known-bug test for unsound issue 74629 2023-04-26 22:34:39 -04:00
whtahy a87359d7c9 add known-bug test for unsound issue 49682 2023-04-26 22:34:30 -04:00