Commit Graph

5164 Commits

Author SHA1 Message Date
bors
6c8138de8f Auto merge of #142127 - compiler-errors:nested-goals-certainty, r=lcnr
Apply nested goals certainty to `InspectGoals` for normalizes-to

...so that normalizes-to goals don't have `Certainty::Yes` even if they have nested goals which don't hold.

r? lcnr
2025-06-12 11:29:20 +00:00
Matthias Krüger
bdf7b74517
Rollup merge of #142040 - jswrenn:transmute-ty-region-generic, r=compiler-errors
transmutability: shift abstraction boundary

Previously, `rustc_transmute`'s layout representations were genericized over `R`, a reference. Now, it's instead genericized over representations of type and region. This allows us to move reference transmutability logic from `rustc_trait_selection` to `rustc_transmutability` (and thus unit test it independently of the compiler), and — in a follow-up PR — will make it possible to support analyzing function pointer transmutability with minimal surgery.

r? `@compiler-errors`
2025-06-12 03:14:49 +02:00
bors
e703dff8fe Auto merge of #142358 - matthiaskrgr:rollup-fxe6m7k, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#141967 (Configure bootstrap backport nominations through triagebot)
 - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose)
 - rust-lang/rust#142272 (tests: Change ABIs in tests to more future-resilient ones)
 - rust-lang/rust#142282 (Only run `citool` tests on the `auto` branch)
 - rust-lang/rust#142297 (Implement `//@ needs-target-std` compiletest directive)
 - rust-lang/rust#142298 (Make loongarch-none target maintainers more easily pingable)
 - rust-lang/rust#142306 (Dont unwrap and re-wrap typing envs)
 - rust-lang/rust#142324 (Remove unneeded `FunctionCx` from some codegen methods)
 - rust-lang/rust#142328 (feat: Add `bit_width` for unsigned integer types)

Failed merges:

 - rust-lang/rust#141639 (Expose discriminant values in stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-11 17:51:57 +00:00
bors
bdb04d6c4f Auto merge of #141763 - lcnr:fixme-gamer, r=BoxyUwU
`FIXME(-Znext-solver)` triage

r? `@BoxyUwU`
2025-06-11 11:47:05 +00:00
Esteban Küber
3fce086d79 Make E0621 missing lifetime suggestion verbose
```
error[E0621]: explicit lifetime required in the type of `x`
  --> $DIR/42701_one_named_and_one_anonymous.rs:10:9
   |
LL |         &*x
   |         ^^^ lifetime `'a` required
   |
help: add explicit lifetime `'a` to the type of `x`
   |
LL | fn foo2<'a>(a: &'a Foo, x: &'a i32) -> &'a i32 {
   |                             ++
```
2025-06-09 19:55:00 +00:00
Michael Goulet
cd1d84e304 Apply nested goals certainty to InspectGoals for normalizes-to 2025-06-09 17:02:09 +00:00
Jack Wrenn
e9eae28eee transmutability: shift abstraction boundary
Previously, `rustc_transmute`'s layout representations were genericized
over `R`, a reference. Now, it's instead genericized over
representations of type and region. This allows us to move reference
transmutability logic from `rustc_trait_selection` to
`rustc_transmutability` (and thus unit test it independently of the
compiler), and — in a follow-up PR — will make it possible to support
analyzing function pointer transmutability with minimal surgery.
2025-06-09 14:08:12 +00:00
Jubilee
940a43677a
Rollup merge of #142194 - bjorn3:less_unstable_features, r=jieyouxu
Remove all unused feature gates from the compiler
2025-06-08 17:17:58 -07:00
bjorn3
9223704f4b Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
bors
244bbfc60e Auto merge of #142088 - compiler-errors:perf-universal-stall, r=lcnr
Filter out universals and lifetimes from `stalled_vars`

lol

r? lcnr
2025-06-08 11:25:24 +00:00
Guillaume Gomez
7c3cb5688d
Rollup merge of #142126 - compiler-errors:normalize-uv-via-relate, r=BoxyUwU
Treat normalizing consts like normalizing types in deeply normalize

...so that we don't end up putting a top-level normalizes-to goal in the fulfillment context, which ICEs. This basically just models the normalize-const code off of the normalize-ty code above it, which uses an alias-relate goal instead.

Fixes rust-lang/rust#140571

r? lcnr
2025-06-07 22:22:58 +02:00
bors
2f2c8c3512 Auto merge of #141927 - compiler-errors:perf-select, r=lcnr
Clear nested candidates in select if certainty is yes

Proving these goals is redundant.
2025-06-07 15:26:34 +00:00
Jacob Pratt
cf7ffa1aec
Rollup merge of #142045 - estebank:obligation-cause-code-suggestion, r=compiler-errors
Make obligation cause code suggestions verbose

```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:28:10
   |
LL |     e!().await;
   |          ^^^^^ `()` is not a future
   |
   = help: the trait `Future` is not implemented for `()`
   = note: () must be a future or must implement `IntoFuture` to be awaited
   = note: required for `()` to implement `IntoFuture`
help: remove the `.await`
   |
LL -     e!().await;
LL +     e!();
   |
```
```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:1:47
   |
LL | static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5];
   |                                               ^^^^ the trait `Copy` is not implemented for `String`
   |
   = note: required for `Option<String>` to implement `Copy`
   = note: the `Copy` trait is required because this value will be copied for each element of the array
help: create an inline `const` block
   |
LL | static _MAYBE_STRINGS: [Option<String>; 5] = [const { None }; 5];
   |                                               +++++++      +
```

Part of rust-lang/rust#141973
2025-06-07 07:05:47 +02:00
Michael Goulet
aa1b296dd6 Unify normalization of terms in deeply normalize 2025-06-07 02:35:28 +00:00
Esteban Küber
ac980cace8 Make obligation cause code suggestions verbose
```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:28:10
   |
LL |     e!().await;
   |          ^^^^^ `()` is not a future
   |
   = help: the trait `Future` is not implemented for `()`
   = note: () must be a future or must implement `IntoFuture` to be awaited
   = note: required for `()` to implement `IntoFuture`
help: remove the `.await`
   |
LL -     e!().await;
LL +     e!();
   |
```
```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:1:47
   |
LL | static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5];
   |                                               ^^^^ the trait `Copy` is not implemented for `String`
   |
   = note: required for `Option<String>` to implement `Copy`
   = note: the `Copy` trait is required because this value will be copied for each element of the array
help: create an inline `const` block
   |
LL | static _MAYBE_STRINGS: [Option<String>; 5] = [const { None }; 5];
   |                                               +++++++      +
```
2025-06-06 20:12:11 +00:00
Michael Goulet
7efd90a1a5 Treat normalizing consts like normalizing types in deeply normalize 2025-06-06 17:13:53 +00:00
Michael Goulet
8addb6f3be Filter out universals and lifetimes from stalled_vars 2025-06-06 15:34:14 +00:00
bors
9f0e5d963d Auto merge of #141681 - compiler-errors:fast-path-stalled, r=lcnr
Fast path for stalled obligations on self ty

If we see that the `self` type of a goal is an infer var, then don't try to compute the goal at all, since we know that it'll be forced ambiguous.

This is currently only implemented when there are no opaques in the environment. We could extend it to check that the self type is not related to any already defined opaques via subtyping, but I'll leave that as a follow-up.

---

Also stall coerce and subtype predicates if both of their vars are not resolved to concrete types.

---

~~Also, we don't care if the goal is higher-ranked for the sized and copy/clone fast path.~~ pulling this out into another PR.

r? lcnr
2025-06-06 15:20:21 +00:00
Matthias Krüger
c1d1f7a16f
Rollup merge of #142012 - oli-obk:no-optional-spans, r=fee1-dead
Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None

Turns out many locations actually have a span available that we could use, so I used it
2025-06-06 00:58:44 +02:00
Michael Goulet
1e5cd122f0 Only instantiate impl args 2025-06-05 21:18:58 +00:00
Michael Goulet
dcf22aa7cb Clear nested candidates in select if certainty is yes 2025-06-05 21:18:58 +00:00
bors
ccf3198de3 Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, r=traviscross,jieyouxu
Add a new `mismatched-lifetime-syntaxes` lint

The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is:

- Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples:

    ```rust
    // Lint will warn about these
    fn(v: ContainsLifetime) -> ContainsLifetime<'_>;
    fn(&'static u8) -> &u8;
    ```

- Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule:

    ```rust
    // Lint will not warn about these
    fn(&u8) -> &'_ u8;
    fn(&'_ u8) -> &u8;
    fn(&u8) -> ContainsLifetime<'_>;
    ```

- Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler.

---

This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-05 19:49:30 +00:00
Oli Scherer
fd3da4bebd Replace some Option<Span> with Span and use DUMMY_SP instead of None 2025-06-05 14:14:59 +00:00
Mara Bos
da2e33b406 Don't refer to 'this tail expression' in expansion.
The user has no clue what tail expression the compiler is talking
about: it is an implementation detail of the macro that it uses a block
with tail expression.
2025-06-04 15:42:58 +02:00
Oli Scherer
5fbdfc3e10
Add iter macro
This adds an `iter!` macro that can be used to create movable
generators.

This also adds a yield_expr feature so the `yield` keyword can be used
within iter! macro bodies. This was needed because several unstable
features each need `yield` expressions, so this allows us to stabilize
them separately from any individual feature.

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
Co-authored-by: Travis Cross <tc@traviscross.com>
2025-06-03 10:52:32 -07:00
Jake Goulding
d2bf16ad6d Rename LifetimeSyntax variants to lang-team-approved names 2025-06-03 09:06:08 -04:00
lcnr
7dac755be8 FIXME(-Znext-solver) triage
Co-authored-by: Michael Goulet <michael@errs.io>
2025-06-03 14:23:56 +02:00
Michael Goulet
9899464906 Fast path for subtype and coercion goals 2025-06-02 19:23:20 +00:00
Michael Goulet
3418d5db3a Fast path for stalled obligations on self ty 2025-06-02 19:23:20 +00:00
bors
9b0268a43b Auto merge of #141731 - compiler-errors:tweak-fast-path-trait, r=lcnr
Tweak fast path trait handling

(1.) Make it more sound by considering polarity (lol)

(2.) Make it more general, by considering higher-ranked size/copy/clone

(2.) Make it less observable, by only doing copy/clone fast path if there are no regions involved

r? lcnr
2025-06-01 10:59:38 +00:00
Nicholas Nethercote
f8887aa5af Reorder fields in hir::ItemKind variants.
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match
the textual order in the source code.

The interesting part of the change is in
`compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical
refactoring.
2025-05-30 02:23:20 +10:00
Michael Goulet
f1da288557 Tweak fast path trait handling 2025-05-29 11:14:36 +00:00
bors
5f025f363d Auto merge of #141581 - lcnr:fold-clauses, r=compiler-errors
add additional `TypeFlags` fast paths

Some crates, e.g. `diesel`, have items with a lot of where-clauses (more than 150). In these cases checking the `TypeFlags` of the whole `param_env` can be very beneficial.

This adds `fn fold_clauses` to mirror the existing `fn visit_clauses` and then uses this in folders which fold `ParamEnv`s.

Split out from rust-lang/rust#141451, depends on rust-lang/rust#141442.

r? `@compiler-errors`
2025-05-29 02:29:01 +00:00
Michael Goulet
29c3babd7c Rename unpack to kind 2025-05-27 11:14:45 +00:00
bors
2805e1dc4c Auto merge of #141605 - jieyouxu:rollup-3gjqh5l, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#140898 (minor improvements on running miri)
 - rust-lang/rust#141392 (Avoid obligation construction dance with query region constraints)
 - rust-lang/rust#141431 (Emit dummy open drop for unsafe binder)
 - rust-lang/rust#141433 (Properly analyze captures from unsafe binders)
 - rust-lang/rust#141439 (Deduplicate dyn compatibility violations due to coercion)
 - rust-lang/rust#141449 (further deduplicate ast visitor code)
 - rust-lang/rust#141513 (interpret: add allocation parameters to `AllocBytes`)
 - rust-lang/rust#141516 (speed up charsearcher for ascii chars)
 - rust-lang/rust#141526 (add a dedicated section for compiler environment variables in the unstable book)
 - rust-lang/rust#141550 (Fix `unused_braces` lint suggestion when encountering attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-26 20:30:06 +00:00
lcnr
c56efaedfa add additional TypeFlags fast paths 2025-05-26 19:57:48 +00:00
Michael Goulet
e2215a8ad9 Don't rerun goals if none of its vars have changed 2025-05-26 10:10:03 +00:00
Michael Goulet
9d742eea25 Rename 2025-05-26 08:48:19 +00:00
Michael Goulet
4d783c3c19 Don't retry in pred_known_to_hold_modulo_regions in new solver, since new solver is more complete
Just a totally unrelated nitpick I'm folding into the PR, since it's
code I'd like for us to prune when the new solver lands.
2025-05-26 08:37:28 +00:00
Michael Goulet
3efd885927 Avoid obligation construction dance with query region constraints 2025-05-26 08:28:45 +00:00
Michael Goulet
9a8cf3dd0c Comment for not using select_in_new_trait_solver 2025-05-25 10:37:58 +00:00
lcnr
326b7e9a6b yeet CanonicalVarInfo 2025-05-23 12:10:53 +00:00
bors
52bf0cf795 Auto merge of #140553 - BoxyUwU:defer_type_system_ctfe, r=compiler-errors
Defer evaluating type system constants when they use infers or params

Split out of #137972, the parts necessary for associated const equality and min generic const args to make progress and have correct semantics around when CTFE is invoked. According to a [previous perf run](https://perf.rust-lang.org/compare.html?start=93257e2d20809d82d1bc0fcc1942480d1a66d7cd&end=01b4cbf0f47c3f782330db88fa5ba199bba1f8a2&stat=instructions:u) of adding the new `const_arg_kind` query we should expect minor regressions here.

I think this is acceptable as we should be able to remove this query relatively soon once mgca is more complete as we'll then be able to implement GCE in terms of mgca and rip out `GCEConst` at which point it's trivial to determine what kind of anon const we're dealing with (either it has generics and is a repeat expr hack, or it doesnt and is a normal anon const).

This should only affect unstable code as we handle repeat exprs specially and those are the only kinds of type system consts that are allowed to make use of generic parameters.

Fixes #133066
Fixes #133199
Fixes #136894
Fixes #137813

r? compiler-errors
2025-05-23 05:30:45 +00:00
bors
912981a9ea Auto merge of #141396 - matthiaskrgr:rollup-feg050g, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #135562 (Add ignore value suggestion in closure body)
 - #139635 (Finalize repeat expr inference behaviour with inferred repeat counts)
 - #139668 (Handle regions equivalent to 'static in non_local_bounds)
 - #140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths)
 - #140435 (use uX::from instead of _ as uX in non - const contexts)
 - #141130 (rustc_on_unimplemented cleanups)
 - #141286 (Querify `coroutine_hidden_types`)

Failed merges:

 - #140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-22 21:02:18 +00:00
bors
e3892a40a9 Auto merge of #141397 - matthiaskrgr:rollup-l9uu6g6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #141355 (ci: improve citool job db errors)
 - #141359 (Fix `FnOnce` impl for `AsyncFn`/`AsyncFnMut` self-borrowing closures in new solver)
 - #141362 (Normalize aliases to correct kind of error term)
 - #141377 (Remove unnecessary `is_empty` checks)
 - #141381 (try_cast_aligned: avoid bare int-to-ptr casts)
 - #141382 (ci: convert distcheck to free runner)
 - #141389 (ci: prepare aws access keys for migration)
 - #141390 (Don't allow `poly_select` in new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-22 14:55:52 +00:00
Matthias Krüger
580bd6e16f
Rollup merge of #141390 - compiler-errors:poly-select-new-solver, r=lcnr
Don't allow `poly_select` in new solver

I added a `poly_select` call in #140519, but this causes an ICE since the new solver doesn't properly handle the "instantiate binder -> recanonicalize" step in the proof tree visitor.

While we could fix the select visitor to look at the next step in proof tree, it's not really necessary. Instead, let's enforce that all callees call the non-higher-ranked `select` function in the new solver.

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

r? lcnr
2025-05-22 16:04:16 +02:00
Matthias Krüger
5cab70ed7f
Rollup merge of #141362 - BoxyUwU:correct_error_term_kind, r=lcnr
Normalize aliases to correct kind of error term

Fixes #140642

When normalizing an alias to an error in the old solver, normalize to the same term kind as the alias being normalized instead of always to a type error.

r? lcnr
2025-05-22 16:04:12 +02:00
Matthias Krüger
654b2f39f1
Rollup merge of #141359 - compiler-errors:async-fn-once, r=lcnr
Fix `FnOnce` impl for `AsyncFn`/`AsyncFnMut` self-borrowing closures in new solver

This only affects closures that are "`AsyncFn`/`AsyncFnMut`" in their calling capability that are being called with the `FnOnce` trait.

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/217

r? lcnr
2025-05-22 16:04:12 +02:00
Matthias Krüger
8c2508292b
Rollup merge of #141286 - compiler-errors:querify-coroutine, r=oli-obk
Querify `coroutine_hidden_types`

This is necessary if we ever want to add implied bounds that would be used for higher-ranked coroutine auto trait goals (e.g. future implements `Send`).

Modest perf regression in `hyper` full build which (afaict?) is the only async stress test, so definitely worth it IMO.

r? oli-obk
2025-05-22 16:02:31 +02:00
Matthias Krüger
c385715806
Rollup merge of #141130 - mejrs:use_self, r=compiler-errors
rustc_on_unimplemented cleanups

Addresses some of the fixmes from https://github.com/rust-lang/rust/pull/139091 and https://github.com/rust-lang/rust/pull/140307.

- switch from `_Self` to `Self` in library
- properly validate that arguments in the `on` filter and the format strings are actually valid

See https://github.com/rust-lang/rustc-dev-guide/pull/2357 for the relevant documentation.
2025-05-22 16:02:30 +02:00