Commit graph

4991 commits

Author SHA1 Message Date
bors
2da29dbe8f Auto merge of #139577 - davidtwco:sizedness-go-vroom, r=oli-obk
re-use `Sized` fast-path

There's an existing fast path for the `type_op_prove_predicate` predicate, checking for trivially `Sized` types, which can be re-used when evaluating obligations within queries. This should improve performance and was found to be beneficial in #137944.

r? types
2025-04-14 19:54:27 +00:00
lcnr
5d0048303c NonGenericOpaqueTypeParam::ty to arg 2025-04-11 15:18:30 +02:00
Stuart Cook
d213934874
Rollup merge of #139564 - compiler-errors:deeply-norm, r=lcnr
Deeply normalize obligations in `BestObligation` folder

Built on #139513.

This establishes a somewhat rough invariant that the `Obligation`'s predicate is always deeply normalized in the folder; when we construct a new obligation we normalize it.

Putting this up for discussion since it does affect some goals.

r? lcnr
2025-04-11 13:31:48 +10:00
Stuart Cook
573ebf011e
Rollup merge of #138998 - rperier:donot_suggest_to_use_impl_trait_in_closure_params, r=Noratrieb
Don't suggest the use of  `impl Trait` in closure parameter

Fixes #138932
2025-04-11 13:31:46 +10:00
Michael Goulet
decd7ecd1e Deeply normalize obligations in BestObligation 2025-04-10 18:58:04 +00:00
Michael Goulet
62d5fb85ac Simplify 2025-04-10 17:52:46 +00:00
Matthias Krüger
79f357e63d
Rollup merge of #139510 - nnethercote:name-to-ident, r=fee1-dead
Rename some `name` variables as `ident`.

It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`.

This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.

r? `@fee1-dead`
2025-04-10 17:27:14 +02:00
bors
9d28fe3976 Auto merge of #139000 - compiler-errors:rigid-missing-item, r=lcnr
Rigidly project missing item due to guaranteed impossible sized predicate

This is a somewhat involved change, but it amounts to treating missing impl items due to guaranteed impossible where clauses (dyn/str/slice sized, cc #135480) as *rigid projections* rather than projecting to an error term, since that was preventing either reporting a proper error (in an empty param env) *or* successfully type checking the code (in the presence of trivially false where clauses).

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

r? `@lcnr` `@oli-obk`
2025-04-10 04:03:59 +00:00
Nicholas Nethercote
1b3fc585cb Rename some name variables as ident.
It bugs me when variables of type `Ident` are called `name`. It leads to
silly things like `name.name`. `Ident` variables should be called
`ident`, and `name` should be used for variables of type `Symbol`.

This commit improves things by by doing `s/name/ident/` on a bunch of
`Ident` variables. Not all of them, but a decent chunk.
2025-04-10 09:30:55 +10:00
Michael Goulet
830aeb6102 Use a query rather than recomputing the tail repeatedly 2025-04-09 20:26:58 +00:00
Michael Goulet
27836e1e57 Rigidly project missing item due to guaranteed impossible sized predicate 2025-04-09 20:26:57 +00:00
Michael Goulet
f6faaee372 Report higher-ranked trait error when higher-ranked projection goal fails in new solver 2025-04-09 17:53:32 +00:00
David Wood
72d17bfebb
re-use sized fast path
There's an existing fast path for the `type_op_prove_predicate`
predicate, checking for trivially `Sized` types, which can be re-used
when evaluating obligations within queries. This should improve
performance, particularly in anticipation of new sizedness traits being
added which can take advantage of this.
2025-04-09 10:42:26 +00:00
Romain Perier
8b6ff4a378 Suggest the use of impl Trait in function parameter only
Currently in case of a Trait object in closure parameter, the compiler
suggests either to use a reference, which is correct or to use an
`impl Trait` which is not. Do not emit this suggestion when the parameter
is part of a closure.
2025-04-09 08:56:04 +02:00
bors
97c966bb40 Auto merge of #139552 - matthiaskrgr:rollup-b194mk8, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #139494 (Restrict some queries by def-kind more)
 - #139496 (Revert r-a changes of rust-lang/rust#139455)
 - #139506 (add missing word in doc comment (part 2))
 - #139515 (Improve presentation of closure signature mismatch from `Fn` trait goal)
 - #139520 (compiletest maintenance: sort deps and drop dep on `anyhow`)
 - #139523 (Rustc dev guide subtree update)
 - #139526 (Fix deprecation note for std::intrinsics)
 - #139528 (compiletest: Remove the `--logfile` flag)
 - #139541 (Instantiate higher-ranked transmute goal w/ placeholders before emitting sub-obligations)
 - #139547 (Update library tracking issue template to set S-tracking-unimplemented)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-09 05:39:18 +00:00
Matthias Krüger
8a64ba5c3f
Rollup merge of #139541 - compiler-errors:transmute, r=lcnr
Instantiate higher-ranked transmute goal w/ placeholders before emitting sub-obligations

This avoids an ICE where we weren't keeping track of bound variables correctly in the `Freeze` obligations we emit for transmute goals. We could use `rebind` instead on that goal, but I think it's better just to instantiate the binder.

Fixes #139538

r? `@lcnr` or reassign
2025-04-08 21:26:02 +02:00
Matthias Krüger
b41e2bd807
Rollup merge of #139515 - compiler-errors:sig-mismatch, r=lcnr
Improve presentation of closure signature mismatch from `Fn` trait goal

Flip the order of "expected" and "found" since that wasn't correct.

Don't present the arguments as a tuple, since it leaves a trailing comma. Instead, just use `fn(arg, arg)`.

Finally, be better with binders since we were just skipping binders.

r? oli-obk or reassign
2025-04-08 21:25:59 +02:00
Michael Goulet
68692b7fbb Instantiate higher-ranked transmute goal 2025-04-08 17:00:29 +00:00
Matthias Krüger
1cbf8b56af
Rollup merge of #139509 - xizheyin:issue-139359, r=lcnr
clean: remove Deref<Target=RegionKind> impl for Region and use `.kind()`

Closes #139359

r? `@lcnr`
2025-04-08 18:05:34 +02:00
Michael Goulet
d940038636 Remove unnecessary dyn Display in favor of str 2025-04-08 06:09:04 +00:00
Michael Goulet
c5320454ed Improve presentation of closure signature mismatch from Fn trait goal 2025-04-08 05:54:57 +00:00
xizheyin
c7272a6cbc
clean code: remove Deref<Target=RegionKind> impl for Region and use .kind()
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-08 10:51:41 +08:00
Michael Goulet
45afefa7c0 Fix trait upcasting to dyn type with no principal when there are projections 2025-04-05 19:34:04 +00:00
bors
17ffbc81a3 Auto merge of #138785 - lcnr:typing-mode-borrowck, r=compiler-errors,oli-obk
add `TypingMode::Borrowck`

Shares the first commit with #138499, doesn't really matter which PR to land first 😊 😁

Introduces `TypingMode::Borrowck` which unlike `TypingMode::Analysis`, uses the hidden type computed by HIR typeck as the initial value of opaques instead of an unconstrained infer var. This is a part of https://github.com/rust-lang/types-team/issues/129.

Using this new `TypingMode` is unfortunately a breaking change for now, see tests/ui/impl-trait/non-defining-uses/as-projection-term.rs. Using an inference variable as the initial value results in non-defining uses in the defining scope. We therefore only enable it if with `-Znext-solver=globally` or `-Ztyping-mode-borrowck`

To do that the PR contains the following changes:
- `TypeckResults::concrete_opaque_type` are already mapped to the definition of the opaque type
  - writeback now checks that the non-lifetime parameters of the opaque are universal
  - for this, `fn check_opaque_type_parameter_valid` is moved from `rustc_borrowck` to `rustc_trait_selection`
- we add a new `query type_of_opaque_hir_typeck` which, using the same visitors as MIR typeck, attempts to merge the hidden types from HIR typeck from all defining scopes
  - done by adding a `DefiningScopeKind` flag to toggle between using borrowck and HIR typeck
  - the visitors stop checking that the MIR type matches the HIR type. This is trivial as the HIR type are now used as the initial hidden types of the opaque. This check is useful as a safeguard when not using `TypingMode::Borrowck`, but adding it to the new structure is annoying and it's not soundness critical, so I intend to not add it back.
- add a `TypingMode::Borrowck`  which behaves just like `TypingMode::Analysis` except when normalizing opaque types
   - it uses `type_of_opaque_hir_typeck(opaque)` as the initial value after replacing its regions with new inference vars
   - it uses structural lookup in the new solver

fixes #112201, fixes #132335, fixes #137751

r? `@compiler-errors` `@oli-obk`
2025-04-04 19:54:42 +00:00
Matthias Krüger
c264f3e4d8
Rollup merge of #139335 - compiler-errors:error-implies, r=oli-obk
Pass correct param-env to `error_implies`

Duplicated comment from the test:

In the error reporting code, when reporting fulfillment errors for goals A and B, we try to see if elaborating A will result in another goal that can equate with B. That would signal that B is "implied by" A, allowing us to skip reporting it, which is beneficial for cutting down on the number of diagnostics we report.

In the new trait solver especially, but even in the old trait solver through things like defining opaque type usages, this `can_equate` call was not properly taking the param-env of the goals, resulting in nested obligations that had empty param-envs. If one of these nested obligations was a `ConstParamHasTy` goal, then we would ICE, since those goals are particularly strict about the param-env they're evaluated in.

This is morally a fix for <https://github.com/rust-lang/rust/issues/139314>, but that repro uses details about how defining usages in the `check_opaque_well_formed` code can spring out of type equality, and will likely stop failing soon coincidentally once we start using `PostBorrowck` mode in that check. Instead, we use lazy normalization to end up generating an alias-eq goal whose nested goals woul trigger the ICE instead, since this is a lot more stable.

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

r? ``@oli-obk`` or reassign
2025-04-04 08:02:08 +02:00
bors
9e14530c7c Auto merge of #120706 - Bryanskiy:leak, r=lcnr
Initial support for auto traits with default bounds

This PR is part of ["MCP: Low level components for async drop"](https://github.com/rust-lang/compiler-team/issues/727)
Tracking issue: #138781
Summary: https://github.com/rust-lang/rust/pull/120706#issuecomment-1934006762

### Intro

Sometimes we want to use type system to express specific behavior and provide safety guarantees. This behavior can be specified by various "marker" traits. For example, we use `Send` and `Sync` to keep track of which types are thread safe. As the language develops, there are more problems that could be solved by adding new marker traits:

- to forbid types with an async destructor to be dropped in a synchronous context a trait like `SyncDrop` could be used [Async destructors, async genericity and completion futures](https://sabrinajewson.org/blog/async-drop).
- to support [scoped tasks](https://without.boats/blog/the-scoped-task-trilemma/) or in a more general sense to provide a [destruction guarantee](https://zetanumbers.github.io/book/myosotis.html) there is a desire among some users to see a `Leak` (or `Forget`) trait.
- Withoutboats in his [post](https://without.boats/blog/changing-the-rules-of-rust/) reflected on the use of `Move` trait instead of a `Pin`.

All the traits proposed above are supposed to be auto traits implemented for most types, and usually implemented automatically by compiler.

For backward compatibility these traits have to be added implicitly to all bound lists in old code (see below). Adding new default bounds involves many difficulties: many standard library interfaces may need to opt out of those default bounds, and therefore be infected with confusing `?Trait` syntax, migration to a new edition may contain backward compatibility holes, supporting new traits in the compiler can be quite difficult and so forth. Anyway, it's hard to evaluate the complexity until we try the system on a practice.

In this PR we introduce new optional lang items for traits that are added to all bound lists by default, similarly to existing `Sized`. The examples of such traits could be `Leak`, `Move`, `SyncDrop` or something else, it doesn't matter much right now (further I will call them `DefaultAutoTrait`'s). We want to land this change into rustc under an option, so it becomes available in bootstrap compiler. Then we'll be able to do standard library experiments with the aforementioned traits without adding hundreds of `#[cfg(not(bootstrap))]`s. Based on the experiments, we can come up with some scheme for the next edition, in which such bounds are added in a more targeted way, and not just everywhere.

Most of the implementation is basically a refactoring that replaces hardcoded uses of `Sized` with iterating over a list of traits including both `Sized` and the new traits when `-Zexperimental-default-bounds` is enabled (or just `Sized` as before, if the option is not enabled).

### Default bounds for old editions

All existing types, including generic parameters, are considered `Leak`/`Move`/`SyncDrop` and can be forgotten, moved or destroyed in generic contexts without specifying any bounds. New types that cannot be, for example, forgotten and do not implement `Leak` can be added at some point, and they should not be usable in such generic contexts in existing code.

To both maintain this property and keep backward compatibility with existing code, the new traits should be added as default bounds _everywhere_ in previous editions. Besides the implicit `Sized` bound contexts that includes supertrait lists and trait lists in trait objects (`dyn Trait1 + ... + TraitN`). Compiler should also generate implicit `DefaultAutoTrait` implementations for foreign types (`extern { type Foo; }`) because they are also currently usable in generic contexts without any bounds.

#### Supertraits

Adding the new traits as supertraits to all existing traits is potentially necessary, because, for example, using a `Self` param in a trait's associated item may be a breaking change otherwise:

```rust
trait Foo: Sized {
    fn new() -> Option<Self>; // ERROR: `Option` requires `DefaultAutoTrait`, but `Self` is not `DefaultAutoTrait`
}

// desugared `Option`
enum Option<T: DefaultAutoTrait + Sized> {
    Some(T),
    None,
}
```

However, default supertraits can significantly affect compiler performance. For example, if we know that `T: Trait`, the compiler would deduce that `T: DefaultAutoTrait`. It also implies proving `F: DefaultAutoTrait` for each field `F` of type `T` until an explicit impl is be provided.

If the standard library is not modified, then even traits like `Copy` or `Send` would get these supertraits.

In this PR for optimization purposes instead of adding default supertraits, bounds are added to the associated items:

```rust
// Default bounds are generated in the following way:
trait Trait {
   fn foo(&self) where Self: DefaultAutoTrait {}
}

// instead of this:
trait Trait: DefaultAutoTrait {
   fn foo(&self) {}
}
```

It is not always possible to do this optimization because of backward compatibility:

```rust
pub trait Trait<Rhs = Self> {}
pub trait Trait1 : Trait {} // ERROR: `Rhs` requires `DefaultAutoTrait`, but `Self` is not `DefaultAutoTrait`
```

or

```rust
trait Trait {
   type Type where Self: Sized;
}
trait Trait2<T> : Trait<Type = T> {} // ERROR: `???` requires `DefaultAutoTrait`, but `Self` is not `DefaultAutoTrait`
```

Therefore, `DefaultAutoTrait`'s are still being added to supertraits if the `Self` params or type bindings were found in the trait header.

#### Trait objects

Trait objects requires explicit `+ Trait` bound to implement corresponding trait which is not backward compatible:

```rust
fn use_trait_object(x: Box<dyn Trait>) {
   foo(x) // ERROR: `foo` requires `DefaultAutoTrait`, but `dyn Trait` is not `DefaultAutoTrait`
}

// implicit T: DefaultAutoTrait here
fn foo<T>(_: T) {}
```

So, for a trait object `dyn Trait` we should add an implicit bound `dyn Trait + DefaultAutoTrait` to make it usable, and allow relaxing it with a question mark syntax `dyn Trait + ?DefaultAutoTrait` when it's not necessary.

#### Foreign types

If compiler doesn't generate auto trait implementations for a foreign type, then it's a breaking change if the default bounds are added everywhere else:

```rust
// implicit T: DefaultAutoTrait here
fn foo<T: ?Sized>(_: &T) {}

extern "C" {
    type ExternTy;
}

fn forward_extern_ty(x: &ExternTy) {
    foo(x); // ERROR: `foo` requires `DefaultAutoTrait`, but `ExternTy` is not `DefaultAutoTrait`
}
```

We'll have to enable implicit `DefaultAutoTrait` implementations for foreign types at least for previous editions:

```rust
// implicit T: DefaultAutoTrait here
fn foo<T: ?Sized>(_: &T) {}

extern "C" {
    type ExternTy;
}

impl DefaultAutoTrait for ExternTy {} // implicit impl

fn forward_extern_ty(x: &ExternTy) {
    foo(x); // OK
}
```

### Unresolved questions

New default bounds affect all existing Rust code complicating an already complex type system.

- Proving an auto trait predicate requires recursively traversing the type and proving the predicate for it's fields. This leads to a significant performance regression. Measurements for the stage 2 compiler build show up to 3x regression.
    - We hope that fast path optimizations for well known traits could mitigate such regressions at least partially.
- New default bounds trigger some compiler bugs in both old and new trait solver.
- With new default bounds we encounter some trait solver cycle errors that break existing code.
    - We hope that these cases are bugs that can be addressed in the new trait solver.

Also migration to a new edition could be quite ugly and enormous, but that's actually what we want to solve. For other issues there's a chance that they could be solved by a new solver.
2025-04-04 01:35:52 +00:00
Michael Goulet
64b58dd13b Pass correct param-env to error_implies 2025-04-03 18:55:53 +00:00
Bryanskiy
581c5fbc40 Initial support for auto traits with default bounds 2025-04-03 14:59:39 +03:00
lcnr
509a144eed add TypingMode::Borrowck 2025-04-03 11:13:10 +02:00
lcnr
990201cb78 move check_opaque_type_parameter_valid 2025-04-03 11:13:10 +02:00
Takayuki Maeda
bda2ea4d01
Rollup merge of #139232 - nnethercote:remove-Map-5, r=Zalathar
Move methods from `Map` to `TyCtxt`, part 5.

This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.

A follow-up to #137504.

r? `@Zalathar`
2025-04-02 22:52:46 +09:00
bors
ae9173d7dd Auto merge of #139018 - oli-obk:incremental-trait-impls, r=compiler-errors
Various local trait item iteration cleanups

Adding a trait impl for `Foo` unconditionally affected all queries that are interested in a completely independent trait `Bar`. Perf has no effect on this. We probably don't have a good perf test for this tho.

r? `@compiler-errors`

I am unsure about 9d05efb66f as it doesn't improve anything wrt incremental, because we still do all the checks for valid `Drop` impls, which subsequently will still invoke many queries and basically keep the depgraph the same.

I want to do

9549077a47/compiler/rustc_middle/src/ty/trait_def.rs (L141)

but would leave that to a follow-up PR, this one changes enough things as it is
2025-04-02 10:10:50 +00:00
Oli Scherer
062ef5365d Remove a hir_* helper that was just forwarding to a query 2025-04-02 07:30:11 +00:00
Oli Scherer
6697f02761 Fetch the destructor constness lazily 2025-04-02 07:30:11 +00:00
Stuart Cook
2311b342bc
Rollup merge of #139191 - lcnr:interner-opaques, r=compiler-errors
small opaque type/borrowck cleanup

pulled out of #138785
2025-04-02 13:10:40 +11:00
Stuart Cook
781240939f
Rollup merge of #138941 - compiler-errors:receiver-is-dispatchable-bounds, r=BoxyUwU
Do not mix normalized and unnormalized caller bounds when constructing param-env for `receiver_is_dispatchable`

See comments in code and in test I added.

r? `@BoxyUwU` since you reviewed the last PR, or reassign

Fixes #138937
2025-04-02 13:10:38 +11:00
Nicholas Nethercote
6713f34ee4 Move methods from Map to TyCtxt, part 5.
This eliminates all methods on `Map`. Actually removing `Map` will occur
in a follow-up PR.
2025-04-02 10:00:46 +11:00
lcnr
cb275d4f26 simplify Interner opaque types API 2025-04-01 23:24:28 +02:00
lcnr
654b7b5413 increment depth of nested obligations 2025-03-31 23:58:17 +02:00
Matthias Krüger
e15161d528
Rollup merge of #138176 - compiler-errors:rigid-sized-obl, r=lcnr
Prefer built-in sized impls (and only sized impls) for rigid types always

This PR changes the confirmation of `Sized` obligations to unconditionally prefer the built-in impl, even if it has nested obligations. This also changes all other built-in impls (namely, `Copy`/`Clone`/`DiscriminantKind`/`Pointee`) to *not* prefer built-in impls over param-env impls. This aligns the old solver with the behavior of the new solver.

---

In the old solver, we register many builtin candidates with the `BuiltinCandidate { has_nested: bool }` candidate kind. The precedence this candidate takes over other candidates is based on the `has_nested` field. We only prefer builtin impls over param-env candidates if `has_nested` is `false`

2b4694a698/compiler/rustc_trait_selection/src/traits/select/mod.rs (L1804-L1866)

Preferring param-env candidates when the builtin candidate has nested obligations *still* ends up leading to detrimental inference guidance, like:

```rust
fn hello<T>() where (T,): Sized {
    let x: (_,) = Default::default();
    // ^^ The `Sized` obligation on the variable infers `_ = T`.
    let x: (i32,) = x;
    // We error here, both a type mismatch and also b/c `T: Default` doesn't hold.
}
```

Therefore this PR adjusts the candidate precedence of `Sized` obligations by making them a distinct candidate kind and unconditionally preferring them over all other candidate kinds.

Special-casing `Sized` this way is necessary as there are a lot of traits with a `Sized` super-trait bound, so a `&'a str: From<T>` where-bound results in an elaborated `&'a str: Sized` bound. People tend to not add explicit where-clauses which overlap with builtin impls, so this tends to not be an issue for other traits.

We don't know of any tests/crates which need preference for other builtin traits. As this causes builtin impls to diverge from user-written impls we would like to minimize the affected traits. Otherwise e.g. moving impls for tuples to std by using variadic generics would be a breaking change. For other builtin impls it's also easier for the preference of builtin impls over where-bounds to result in issues.

---

There are two ways preferring builtin impls over where-bounds can be incorrect and undesirable:
- applying the builtin impl results in undesirable region constraints. E.g. if only `MyType<'static>` implements `Copy` then a goal like `(MyType<'a>,): Copy` would require `'a == 'static` so we must not prefer it over a `(MyType<'a>,): Copy` where-bound
   - this is mostly not an issue for `Sized` as all `Sized` impls are builtin and don't add any region constraints not already required for the type to be well-formed
   - however, even with `Sized` this is still an issue if a nested goal also gets proven via a where-bound: [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=30377da5b8a88f654884ab4ebc72f52b)
- if the builtin impl has associated types, we should not prefer it over where-bounds when normalizing that associated type. This can result in normalization adding more region constraints than just proving trait bounds. https://github.com/rust-lang/rust/issues/133044
  - not an issue for `Sized` as it doesn't have associated types.

r? lcnr
2025-03-31 14:36:20 +02:00
Michael Goulet
4f2baaa9c6 Do not mix normalized and unnormalized caller bounds when constructing param-env for receiver_is_dispatchable 2025-03-30 02:39:19 +00:00
Nicholas Nethercote
8d2c63f514 Don't use kw::Empty in hir::Lifetime::ident.
`hir::Lifetime::ident` currently sometimes uses `kw::Empty` for elided
lifetimes and sometimes uses `kw::UnderscoreLifetime`, and the
distinction is used when creating some error suggestions, e.g. in
`Lifetime::suggestion` and `ImplicitLifetimeFinder::visit_ty`. I found
this *really* confusing, and it took me a while to understand what was
going on.

This commit replaces all uses of `kw::Empty` in `hir::Lifetime::ident`
with `kw::UnderscoreLifetime`. It adds a new field
`hir::Lifetime::is_path_anon` that mostly replaces the old
empty/underscore distinction and makes things much clearer.

Some other notable changes:

- Adds a big comment to `Lifetime` talking about permissable field
  values.

- Adds some assertions in `new_named_lifetime` about what ident values
  are permissible for the different `LifetimeRes` values.

- Adds a `Lifetime::new` constructor that does some checking to make
  sure the `is_elided` and `is_anonymous` states are valid.

- `add_static_impl_trait_suggestion` now looks at `Lifetime::res`
  instead of the ident when creating the suggestion. This is the one
  case where `is_path_anon` doesn't replace the old empty/underscore
  distinction.

- A couple of minor pretty-printing improvements.
2025-03-28 10:15:23 +11:00
bors
ecb170afc8 Auto merge of #139012 - Zalathar:rollup-qgt5yfo, r=Zalathar
Rollup of 10 pull requests

Successful merges:

 - #130883 (Add environment variable query)
 - #138624 (Add mipsel maintainer)
 - #138672 (Avoiding calling queries when collecting active queries)
 - #138935 (Update wg-prio triagebot config)
 - #138946 (Un-bury chapters from the chapter list in rustc book)
 - #138964 (Implement lint against using Interner and InferCtxtLike in random compiler crates)
 - #138977 (Don't deaggregate InvocationParent just to reaggregate it again)
 - #138980 (Collect items referenced from var_debug_info)
 - #138985 (Use the correct binder scope for elided lifetimes in assoc consts)
 - #138987 (Always emit `native-static-libs` note, even if it is empty)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-27 07:47:39 +00:00
Michael Goulet
5f1e36f8ad Stop using Interner in the compiler randomly 2025-03-26 04:39:38 +00:00
Michael Goulet
93b3be3300 Instantiate binder before registering nested obligations for auto/built-in traits 2025-03-24 23:52:08 +00:00
Michael Goulet
575f129faa Obligation::as_goal 2025-03-23 18:18:47 +00:00
Matthias Krüger
915576935a
Rollup merge of #138685 - nnethercote:use-Option-Ident-for-lowered-param-names, r=compiler-errors
Use `Option<Ident>` for lowered param names.

Parameter patterns are lowered to an `Ident` by `lower_fn_params_to_names`, which is used when lowering bare function types, trait methods, and foreign functions. Currently, there are two exceptional cases where the lowered param can become an empty `Ident`.

- If the incoming pattern is an empty `Ident`. This occurs if the parameter is anonymous, e.g. in a bare function type.

- If the incoming pattern is neither an ident nor an underscore. Any such parameter will have triggered a compile error (hence the `span_delayed_bug`), but lowering still occurs.

This commit replaces these empty `Ident` results with `None`, which eliminates a number of `kw::Empty` uses, and makes it impossible to fail to check for these exceptional cases.

Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It actually should have been removed in #138482, the precursor to this PR. That PR changed the lowering of wild patterns to `_` symbols instead of empty symbols, which made the mentioned underscore check load-bearing.

r? ``@compiler-errors``
2025-03-20 15:36:17 +01:00
Matthias Krüger
9ab2a0e353
Rollup merge of #138594 - oli-obk:no-select, r=lcnr
Fix next solver handling of shallow trait impl check

I'm trying to remove unnecessary direct calls to `select`, and this one seemed like a good place to start 😆

r? `@compiler-errors` or `@lcnr`
2025-03-19 16:52:57 +01:00
Oli Scherer
14cd467001 Fix next solver handling of shallow trait impl check 2025-03-19 14:40:14 +00:00
Nicholas Nethercote
f27cab806e Use Option<Ident> for lowered param names.
Parameter patterns are lowered to an `Ident` by
`lower_fn_params_to_names`, which is used when lowering bare function
types, trait methods, and foreign functions. Currently, there are two
exceptional cases where the lowered param can become an empty `Ident`.

- If the incoming pattern is an empty `Ident`. This occurs if the
  parameter is anonymous, e.g. in a bare function type.

- If the incoming pattern is neither an ident nor an underscore. Any
  such parameter will have triggered a compile error (hence the
  `span_delayed_bug`), but lowering still occurs.

This commit replaces these empty `Ident` results with `None`, which
eliminates a number of `kw::Empty` uses, and makes it impossible to fail
to check for these exceptional cases.

Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It
actually should have been removed in #138482, the precursor to this PR.
That PR changed the lowering of wild patterns to `_` symbols instead of
empty symbols, which made the mentioned underscore check load-bearing.
2025-03-19 20:54:10 +11:00