Commit Graph

6063 Commits

Author SHA1 Message Date
Matthias Krüger
702261dce6
Rollup merge of #122886 - matthiaskrgr:issue90192, r=fee1-dead
add test for #90192

Fixes #90192
2024-03-24 17:08:16 +01:00
Matthias Krüger
04eedb24c9
Rollup merge of #122757 - h1467792822:priv-dep, r=davidtwco
Fixed the `private-dependency` bug

Fixed the private-dependency bug: If the directly dependent crate is loaded last and is not configured with `--extern`, it may be incorrectly set to `private-dependency`

Fixes #122756
2024-03-24 17:08:15 +01:00
bors
6e6c721742 Auto merge of #122895 - matthiaskrgr:ice-tests-5xxxx-to-9xxxx, r=fmease
add some ice tests 5xxxx to 9xxxx

  Fixes rust-lang/rust#98842
  Fixes rust-lang/rust#90691
  Fixes rust-lang/rust#88421
  Fixes rust-lang/rust#88212
  Fixes rust-lang/rust#83056
  Fixes rust-lang/rust#80125
  Fixes rust-lang/rust#64784
  Fixes rust-lang/rust#52334
2024-03-24 13:38:12 +00:00
bors
6a92312a1e Auto merge of #122891 - compiler-errors:encode-implied-predicates-always, r=oli-obk
Encode implied predicates for traits

In #112629, we decided to make associated type bounds in the "supertrait" AST position *implied* even though they're not supertraits themselves.

This means that the `super_predicates` and `implied_predicates` queries now differ for regular traits. The assumption that they didn't differ was hard-coded in #107614, so in cross-crate positions this means that we forget the implied predicates from associated type bounds.

This isn't unsound, just kind of annoying. This should be backported since associated type bounds are slated to stabilize for 1.78 -- either that, or associated type bounds can be reverted on beta and re-shipped in 1.79 with this patch.

Fixes #122859
2024-03-24 11:17:21 +00:00
Matthias Krüger
114d012a0e add issue numbers via // issue: rust-lang/rust#ISSUE_NUM directive 2024-03-24 09:34:11 +01:00
Matthias Krüger
57f500512b add test for stack overflow with recursive type #98842
Fixes #98842
2024-03-24 09:23:13 +01:00
Matthias Krüger
5ae90256da add test for ice #90691 ICE: resolution failed during building vtable representation
Fixes #90691
2024-03-24 09:23:13 +01:00
Matthias Krüger
f44ee8f87d add test for 88421 ICE: could not fully normalize `&<MyType as std::ops::Index<MyType>>::Output
Fixes #88421
2024-03-24 09:23:13 +01:00
Matthias Krüger
74ca9813ed add test for #88212 ICE when lambda captures unsized local
Fixes #88212
2024-03-24 09:23:13 +01:00
Matthias Krüger
445507a19d add test for ice 83056 "bad input type for cast"
Fixes #83056
2024-03-24 09:23:12 +01:00
Matthias Krüger
19310ce2cc add test for str as extern "C" arg causes compiler panic #80125
Fixes #80125
2024-03-24 09:23:12 +01:00
Matthias Krüger
a5ad0be52f add test for #64784 Declarative macros can create infinite glob import cycles
Fixes #64784
2024-03-24 09:23:12 +01:00
Matthias Krüger
14d05c4c4b add test for #52334
Fixes #52334
2024-03-24 09:23:12 +01:00
Matthias Krüger
fc5085d570 add test for #90192
Fixes #90192
2024-03-24 09:19:29 +01:00
Jubilee
992aa1edb6
Rollup merge of #122879 - maurer:callsite-instances, r=workingjubilee
CFI: Strip auto traits off Virtual calls

We already use `Instance` at declaration sites when available to glean additional information about possible abstractions of the type in use. This does the same when possible at callsites as well.

The primary purpose of this change is to allow CFI to alter how it generates type information for indirect calls through `Virtual` instances.

This is needed for the "separate machinery" version of my approach to the vtable issues (#122573), because we need to respond differently to a `Virtual` call to the same type as a non-virtual call, specifically [stripping auto traits off the receiver's `Self`](54b15b0c36) because there isn't a separate vtable for `Foo` vs `Foo + Send`.

This would also make a more general underlying mechanism that could be used by rcvalle's [proposed drop detection / encoding](edcd1e20a1) if we end up using his approach, as we could condition out on the `def_id` in the CFI code rather than requiring the generating code to explicitly note whether it was calling drop.
2024-03-23 22:59:42 -07:00
Jubilee
b9b65f816d
Rollup merge of #122875 - maurer:cfi-transparent-termination, r=workingjubilee
CFI: Support self_cell-like recursion

Current `transform_ty` attempts to avoid cycles when normalizing `#[repr(transparent)]` types to their interior, but runs afoul of this pattern used in `self_cell`:

```
struct X<T> {
  x: u8,
  p: PhantomData<T>,
}

 #[repr(transparent)]
struct Y(X<Y>);
```

When attempting to normalize Y, it will still cycle indefinitely. By using a types-visited list, this will instead get expanded exactly one layer deep to X<Y>, and then stop, not attempting to normalize `Y` any further.

This PR was split off from #121962 as part of fixing the larger vtable compatibility issues.

r? ``````@workingjubilee``````
2024-03-23 22:59:42 -07:00
Jubilee
97fcfaa103
Rollup merge of #121940 - veera-sivarajan:bugfix-121593, r=fmease
Mention Register Size in `#[warn(asm_sub_register)]`

Fixes #121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
2024-03-23 22:59:40 -07:00
Matthias Krüger
2463ad0f5f
Rollup merge of #122943 - matthiaskrgr:ice-tests-9xxxx-to-12xxxx, r=fmease
add a couple more ice tests

Fixes rust-lang/rust#104779
Fixes rust-lang/rust#106423
Fixes rust-lang/rust#106444
Fixes rust-lang/rust#101852
Fixes rust-lang/rust#106874
Fixes rust-lang/rust#105047
Fixes rust-lang/rust#107228
Fixes rust-lang/rust#99945
2024-03-24 01:05:54 +01:00
Matthias Krüger
d8c224267d
Rollup merge of #122942 - Luv-Ray:master, r=lcnr
Add test in higher ranked subtype

I'm a beginner in this repository, and there are some things I'm not sure about:

- Is it okay that there is a warning:
```
rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit) }
```
- Is it okay that there are two duplicate errors in the same line?
- Did I put the test in the right place?

Any suggestions would be appreciated.

Fixes #121649
2024-03-24 01:05:54 +01:00
Matthias Krüger
cb03714e6f
Rollup merge of #122907 - compiler-errors:uniquify-reerror, r=lcnr
Uniquify `ReError` on input mode in canonicalizer

See test descr

Fixes #122861

r? lcnr
2024-03-24 01:05:53 +01:00
Matthias Krüger
1164c2725e
Rollup merge of #122217 - estebank:issue-119685, r=fmease
Handle str literals written with `'` lexed as lifetime

Given `'hello world'` and `'1 str', provide a structured suggestion for a valid string literal:

```
error[E0762]: unterminated character literal
  --> $DIR/lex-bad-str-literal-as-char-3.rs:2:26
   |
LL |     println!('hello world');
   |                          ^^^^
   |
help: if you meant to write a `str` literal, use double quotes
   |
LL |     println!("hello world");
   |              ~           ~
```
```
error[E0762]: unterminated character literal
  --> $DIR/lex-bad-str-literal-as-char-1.rs:2:20
   |
LL |     println!('1 + 1');
   |                    ^^^^
   |
help: if you meant to write a `str` literal, use double quotes
   |
LL |     println!("1 + 1");
   |              ~     ~
```

Fix #119685.
2024-03-24 01:05:51 +01:00
Matthias Krüger
516758136e
Rollup merge of #121281 - kadiwa4:test_103626, r=estebank,lcnr
regression test for #103626

I don't know what a descriptive filename for this would be.

Fixes #103626
2024-03-24 01:05:50 +01:00
Matthew Maurer
f434c27067 CFI: Strip auto traits off Self for virtual calls
Additional trait bounds beyond the principal trait and its implications
are not possible in the vtable. This means that if a receiver is
`&dyn Foo + Send`, the function will only be expecting `&dyn Foo`.

This strips those auto traits off before CFI encoding.
2024-03-23 18:30:45 +00:00
Kalle Wachsmuth
188c46a65e
regression test for #103626 2024-03-23 17:48:57 +01:00
bors
020bbe46bd Auto merge of #122947 - matthiaskrgr:rollup-10j7orh, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #120577 (Stabilize slice_split_at_unchecked)
 - #122698 (Cancel `cargo update` job if there's no updates)
 - #122780 (Rename `hir::Local` into `hir::LetStmt`)
 - #122915 (Delay a bug if no RPITITs were found)
 - #122916 (docs(sync): normalize dot in fn summaries)
 - #122921 (Enable more mir-opt tests in debug builds)
 - #122922 (-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.)
 - #122927 (Change an ICE regression test to use the original reproducer)
 - #122930 (add panic location to 'panicked while processing panic')
 - #122931 (Fix some typos in the pin.rs)
 - #122933 (tag_for_variant follow-ups)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-23 15:58:17 +00:00
Luv-Ray
246f7465b3 Add test in higher-ranked 2024-03-23 23:33:43 +08:00
Matthias Krüger
9aea37d3c1 address review feedback 2024-03-23 16:14:42 +01:00
Matthias Krüger
691d5f533d
Rollup merge of #122930 - RalfJung:panic-in-panic-fmt, r=Amanieu
add panic location to 'panicked while processing panic'

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

r? `@Amanieu`
2024-03-23 15:00:20 +01:00
Matthias Krüger
aaf5f3b53e
Rollup merge of #122927 - gurry:122199-ice-unexpected-node-2, r=workingjubilee
Change an ICE regression test to use the original reproducer

The ICE was fixed in PR https://github.com/rust-lang/rust/pull/122370, but the test used a different reproducer than the one originally reported. This PR changes it to the original one, giving us more confidence that the fix works.

Fixes #122199
2024-03-23 15:00:20 +01:00
Matthias Krüger
9418f69446
Rollup merge of #122922 - kpreid:print-async, r=compiler-errors
-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.

This should assist comprehending the size of coroutines. In particular, whenever a future is suspended while awaiting another future, the latter is given the special name `__awaitee`, and now the type of the awaited future will be printed, allowing identifying caller/callee — er, I mean, poller/pollee — relationships.

It would be possible to include the type name in more cases, but I thought that that might be overly verbose (`print-type-sizes` is already a lot of text) and ordinary named fields or variables are easier for readers to discover the types of.

This change will also synergize with my other PR #122923 which changes type printing to print the path of the `async fn` instead of the span.

Implementation note: I'm not sure if `Symbol::intern` is appropriate for this application, but it was the obvious way to not have to remove the `Copy` implementation from `FieldInfo`, or add a `'tcx` lifetime, while avoiding keeping a lot of possibly redundant strings in memory. I don't know what the proper tradeoff to make here is (though presumably it is not too important for a `-Z` debugging option).
2024-03-23 15:00:20 +01:00
Matthias Krüger
f03326c579
Rollup merge of #122915 - fmease:lt-opaq-mismatch-delay-bug, r=compiler-errors
Delay a bug if no RPITITs were found

Fixes #122655. See the issue for context.

r? compiler-errors or compiler
2024-03-23 15:00:18 +01:00
bors
d6eb0f5a09 Auto merge of #122582 - scottmcm:swap-intrinsic-v2, r=oli-obk
Let codegen decide when to `mem::swap` with immediates

Making `libcore` decide this is silly; the backend has so much better information about when it's a good idea.

Thus this PR introduces a new `typed_swap` intrinsic with a fallback body, and replaces that fallback implementation when swapping immediates or scalar pairs.

r? oli-obk

Replaces #111744, and means we'll never need more libs PRs like #111803 or #107140
2024-03-23 13:57:55 +00:00
Matthias Krüger
368bfb2c10 add test for #107228
Fixes #107228
2024-03-23 13:05:22 +01:00
Matthias Krüger
f2bc9c5997 add test for #106874 ICE BoundUniversalRegionError
Fixes #106874
2024-03-23 12:50:21 +01:00
Matthias Krüger
cc422cee97 add test for ICE #106444
Fixes #106444
2024-03-23 12:38:50 +01:00
Matthias Krüger
f8aeac8a36 add test for #106423
Fixes #106423
2024-03-23 12:32:32 +01:00
Matthias Krüger
f1f287fadb add test for ICE "raw ptr comparison should already be caught in the trait system" #105047
Fixes #105047
2024-03-23 12:24:40 +01:00
Matthias Krüger
e54bff7109 add test for #104779 opaque types, patterns and subtyping ICE: IndexMap: key not found
Fixes #104779
2024-03-23 12:19:05 +01:00
Matthias Krüger
2f9a240b91 add test for opaque type with non-universal region substs #101852
Fixes #101852
2024-03-23 12:01:39 +01:00
Matthias Krüger
12e362989b add test for #99945
Fixes #99945
2024-03-23 11:57:26 +01:00
Ralf Jung
fc257fae3c add panic location to 'panicked while processing panic' 2024-03-23 09:44:04 +01:00
Gurinder Singh
4afce46231 Change an ICE regression test to use the original reproducer
This gives us more confidence that the ICE was indeed fixed.
2024-03-23 11:22:17 +05:30
Kevin Reid
44d185b0d0 -Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.
This should assist comprehending the size of coroutines.
In particular, whenever a future is suspended while awaiting another
future, the latter is given the special name `__awaitee`, and now the
type of the awaited future will be printed, allowing identifying
caller/callee — er, I mean, poller/pollee — relationships.

It would be possible to include the type name in more cases, but I
thought that that might be overly verbose (`print-type-sizes` is already
a lot of text) and ordinary named fields or variables are easier for
readers to discover the types of.
2024-03-22 18:07:15 -07:00
bors
c308726599 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin
Replace visibility test with reachability test in dead code detection

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

Also included is a fix for an error now flagged by the lint
2024-03-23 00:37:05 +00:00
Matthew Maurer
dec36c3d6e CFI: Support self_cell-like recursion
Current `transform_ty` attempts to avoid cycles when normalizing
`#[repr(transparent)]` types to their interior, but runs afoul of this
pattern used in `self_cell`:

```
struct X<T> {
  x: u8,
  p: PhantomData<T>,
}

 #[repr(transparent)]
struct Y(X<Y>);
```

When attempting to normalize Y, it will still cycle indefinitely. By
using a types-visited list, this will instead get expanded exactly
one layer deep to X<Y>, and then stop, not attempting to normalize `Y`
any further.
2024-03-22 23:02:05 +00:00
León Orell Valerian Liehr
807bd98971
Delay a bug if no RPITITs were found 2024-03-22 22:56:28 +01:00
Michael Goulet
1fcf2eaa9f Uniquify ReError on input mode in canonicalizer 2024-03-22 16:35:50 -04:00
Matthias Krüger
487933889b
Rollup merge of #122888 - matthiaskrgr:evenmoretests, r=compiler-errors
add a couple more tests
2024-03-22 20:31:31 +01:00
Matthias Krüger
4e594572b4
Rollup merge of #122651 - kornelski:flat-turbofish, r=spastorino,compiler-errors
Suggest `_` for missing generic arguments in turbofish

The compiler may suggest unusable generic type names for missing generic arguments in an expression context:

```rust
fn main() {
    (0..1).collect::<Vec>()
}
```

> help: add missing generic argument
>
>      (0..1).collect::<Vec<T>>()

but `T` is not a valid name in this context, and this suggestion won't compile.

I've changed it to use `_` inside method calls (turbofish), so it will suggest `(0..1).collect::<Vec<_>>()` which _may_ compile.

It's possible that the suggested `_` will be ambiguous, but there is very extensive E0283 that will help resolve that, which is more helpful than a basic "cannot find type `T` in this scope" users would get otherwise.

Out of caution to limit scope of the change I've limited it to just turbofish, but I suspect `_` could be the better choice in more cases. Perhaps in all expressions?
2024-03-22 20:31:29 +01:00
Matthias Krüger
aa184c558f
Rollup merge of #122195 - jieyouxu:impl-return-note, r=fmease
Note that the caller chooses a type for type param

```
error[E0308]: mismatched types
  --> $DIR/return-impl-trait.rs:23:5
   |
LL | fn other_bounds<T>() -> T
   |                 -       -
   |                 |       |
   |                 |       expected `T` because of return type
   |                 |       help: consider using an impl return type: `impl Trait`
   |                 expected this type parameter
...
LL |     ()
   |     ^^ expected type parameter `T`, found `()`
   |
   = note: expected type parameter `T`
                   found unit type `()`
   = note: the caller chooses the type of T which can be different from ()
```

Tried to see if "expected this type parameter" can be replaced, but that goes all the way to `rustc_infer` so seems not worth the effort and can affect other diagnostics.

Revives #112088 and #104755.
2024-03-22 20:31:28 +01:00