1917 Commits

Author SHA1 Message Date
Camille Gillot 4433512e90 Lighten and document partial_res_overrides. 2026-04-24 23:58:52 +00:00
Camille Gillot 9044aba8e1 Use imported NodeId. 2026-04-24 23:58:52 +00:00
Camille Gillot 0705bbac94 Do not modify resolver outputs during lowering
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2026-04-24 23:58:52 +00:00
aerooneqq 7f2a98d1fc Rename Self generic param to This in recursive delegations 2026-04-24 09:59:20 +03:00
Guillaume Gomez abce9f98d7 Rollup merge of #155442 - CoCo-Japan-pan:impl-restriction-reorder, r=Urgau,fmease,jhpratt
Change keyword order for `impl` restrictions

Based on rust-lang/rust#155222, this PR reorders keywords in trait definitions to group restrictions with visibility. It changes the order from `pub(...) const unsafe auto impl(...) trait Foo {...}`  to `pub(...) impl(...) const unsafe auto trait Foo {...}`.

Tracking issue for restrictions: rust-lang/rust#105077

r? @Urgau
cc @jhpratt
2026-04-23 14:42:47 +02:00
Guillaume Gomez aebbe6bb5f Rollup merge of #155644 - aerooneqq:delegation-self-ty-propagation-2, r=petrochenkov
delegation: support self ty propagation for functions in free to trait reuse

This PR adds support for self types specified in free to trait reuse. Up to this point we always generated `Self` despite the fact whether self type was specified or not. Now we use it in signature inheritance. Moreover we no more generate `Self` for static methods. Part of rust-lang/rust#118212.

```rust
trait Trait<T> {
  fn foo<const B: bool>(&self) {}
  fn bar() {}
}

impl<T> Trait<T> for usize {}

reuse <usize as Trait>::foo;

// Desugaring (no `Self` as usize is specified)
fn foo<T, const B: bool>(self: &usize) {
  <usize as Trait::<T>>::foo::<B>(self)
}

reuse Trait::bar;

// Desugaring (no `Self` as static method)
fn bar<T>() {
  Trait::<T>::bar(); //~ERROR: type annotations needed
}
```

r? @petrochenkov
2026-04-23 14:42:46 +02:00
aerooneqq abd8c38a28 Support self ty propagation for functions in free to trait reuse 2026-04-22 15:24:30 +03:00
aerooneqq 2e6a082513 Use per-parent disambiguators 2026-04-21 18:23:40 +03:00
CoCo-Japan-pan 614994fb8b Update HIR pretty printing 2026-04-19 15:58:02 +09:00
CoCo-Japan-pan a0b8e89456 Update AST pretty printing 2026-04-19 15:58:02 +09:00
bors 6f109d8a2d Auto merge of #155223 - teor2345:fndef-refactor, r=mati865
Refactor FnDecl and FnSig non-type fields into a new wrapper type





#### Why this Refactor?

This PR is part of an initial cleanup for the [arg splat experiment](https://github.com/rust-lang/rust/issues/153629), but it's a useful refactor by itself.

It refactors the non-type fields of `FnDecl`, `FnSig`, and `FnHeader` into a new packed wrapper types, based on this comment in the `splat` experiment PR:
https://github.com/rust-lang/rust/pull/153697#discussion_r3004637413

It also refactors some common `FnSig` creation settings into their own methods. I did this instead of creating a struct with defaults.

#### Relationship to `splat` Experiment

I don't think we can use functional struct updates (`..default()`) to create `FnDecl` and `FnSig`, because we need the bit-packing for the `splat` experiment.

Bit-packing will avoid breaking "type is small" assertions for commonly used types when `splat` is added.
This PR packs these types:
- ExternAbi: enum + `unwind` variants (38) -> 6 bits
- ImplicitSelfKind: enum variants (5) -> 3 bits
- lifetime_elision_allowed, safety, c_variadic: bool -> 1 bit

#### Minor Changes

Fixes some typos, and applies rustfmt to clippy files that got skipped somehow.
2026-04-18 23:46:37 +00:00
Guillaume Gomez c5b9918540 Set up API to make it possible to pass closures instead of AttributeLint.
The end goal being to completely remove `AttributeLint`.
2026-04-17 23:43:06 +02:00
bors f29256dd14 Auto merge of #155248 - JonathanBrouwer:no_hash_delayed_lints, r=GuillaumeGomez
Don't hash `DelayedLints`

This PR unblocks https://github.com/rust-lang/rust/pull/154432, and was also a minor perf win locally
2026-04-17 16:05:32 +00:00
Jonathan Brouwer d14311c4a1 Don't hash DelayedLints 2026-04-17 16:08:45 +02:00
aerooneqq 699eb29443 Fix delegation def path hash collision, add per-parent disambiguators 2026-04-17 09:46:54 +03:00
teor dafb6bb801 Refactor FnDecl and FnSig flags into packed structs 2026-04-16 07:08:08 +10:00
mu001999 77419b45dc Add FIXME for the fatal errors 2026-04-15 21:52:11 +08:00
mu001999 1fca34d15d Emit fatal on defaults for generic params in binders if with nested defs 2026-04-15 21:41:19 +08:00
mu001999 58af51e243 Emit fatal on invalid const args with nested defs 2026-04-14 09:43:02 +08:00
bors 17584a1819 Auto merge of #155253 - JonathanBrouwer:rollup-lERdTAB, r=JonathanBrouwer
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155162 (relnotes for 1.95)
 - rust-lang/rust#140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - rust-lang/rust#153604 (Fix thread::available_parallelism on WASI targets with threads)
 - rust-lang/rust#154193 (Implement EII for statics)
 - rust-lang/rust#154389 (Add more robust handling of nested query cycles)
 - rust-lang/rust#154435 (resolve: Some import resolution cleanups)
 - rust-lang/rust#155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - rust-lang/rust#155243 (cg_ssa: transmute between scalable vectors)
 - rust-lang/rust#153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - rust-lang/rust#154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - rust-lang/rust#154624 (Make `DerefPure` dyn-incompatible)
 - rust-lang/rust#154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - rust-lang/rust#154944 (Small refactor of `arena_cache` query values)
 - rust-lang/rust#155055 (UI automation)
 - rust-lang/rust#155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - rust-lang/rust#155131 (Stabilize feature `uint_bit_width`)
 - rust-lang/rust#155147 (Stabilize feature `int_lowest_highest_one`)
 - rust-lang/rust#155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - rust-lang/rust#155194 (Fix manpage version replacement and use verbose version)
2026-04-13 18:32:47 +00:00
Jonathan Brouwer d2fa85cd4d Rollup merge of #154193 - JonathanBrouwer:external-static, r=jdonszelmann
Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
2026-04-13 20:19:56 +02:00
Jonathan Brouwer f8a8c9e244 Rollup merge of #155003 - malezjaa:update-thinvec, r=davidtwco
update thin-vec

With thin-vec v0.2.15 released, copy-pasted implementation of ExtractIf can be removed.
2026-04-13 14:02:35 +02:00
Jonathan Brouwer 14b5df4749 Rollup merge of #155226 - aerooneqq:delegation-hir-crate-items-revert, r=petrochenkov
delegation: revert execution of hir_crate_items before delayed lowering

This PR reverts rust-lang/rust#154368, as after weekend consideration I don't think that it is a correct way of fixing cycles during delayed lowering:

- The number of ICEs were reported, fixing them would require to develop solution from rust-lang/rust#154368 but I am afraid that it would lead to cancer code growing,
- The [memory regression](https://github.com/rust-lang/rust/pull/154368#issuecomment-4229353764) for rustdoc was reported, it can be fixed with moving `tcx.force_delayed_owners_lowering` call earlier, but it is already bad that this is call is now required everywhere, before rust-lang/rust#154368 AST was dropped before `hir_crate_items` automatically and users of `rustc` API did not have to think about it.

I will try to come up with a more robust solution leaving rust-lang/rust#154368 as a last resort if nothing else will work.

Re-opens rust-lang/rust#154169.
Fixes rust-lang/rust#155125. Fixes rust-lang/rust#155127. Fixes rust-lang/rust#155128. Fixes rust-lang/rust#155164. Fixes rust-lang/rust#155202.
Part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-13 14:02:34 +02:00
Jonathan Brouwer ab551b1550 Rollup merge of #155096 - aerooneqq:delegation-user-specified-args-impl-traits, r=petrochenkov
delegation: support proper interaction of user-specified args and impl Traits

This PR supports usages of user-specified args with impl Traits. When there are user-specified args in child we still need to generate synthetic generic params and use them during signature inheritance:
```rust
fn foo<T, const N: usize>(f: impl FnOnce()) {}

reuse foo::<String, 123> as bar;

//desugaring
fn bar<TSynth: impl FnOnce()>(f: _) {
    foo::<String, 123>(f)
}
```
When inheriting predicates we process impl Trait ones, so we need generic params to instantiate them. Other approach may involve not generating synthetic generic params and try to filter out those predicates, but fairly generating synthetic params seems more consistent?.

Fixes rust-lang/rust#154780, part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-13 14:02:31 +02:00
aerooneqq 51888a15fb Support proper interaction of user-specified args and impl Traits 2026-04-13 10:55:03 +03:00
aerooneqq 791a3dcef0 Revert "Fix cycles during delayed lowering" 2026-04-13 10:19:33 +03:00
Jonathan Brouwer e756d1607d Add eii_impls argument to StaticItem 2026-04-11 10:17:07 +02:00
Jacob Pratt 44bad026ce Rollup merge of #154661 - CoCo-Japan-pan:impl-restriction-check, r=jhpratt,Urgau
Semantic checks of `impl` restrictions

This PR implements semantic checks for `impl` restrictions proposed in the [Restrictions RFC](https://rust-lang.github.io/rfcs/3323-restrictions.html) (Tracking Issue rust-lang/rust#105077), and linked to a [GSOC idea/proposal](https://github.com/rust-lang/google-summer-of-code/tree/142433eb3b104b2f32bae0b9dfafb78a0a2ac579?tab=readme-ov-file#implementing-impl-and-mut-restrictions).

It lowers the resolved paths of `impl` restrictions from the AST to HIR and into `TraitDef`, and integrates the checks into the coherence phase by extending `check_impl`. As parsing (rust-lang/rust#152943) and path resolution (rust-lang/rust#153556) have already been implemented, this PR provides a working implementation of `impl` restrictions.

r? @Urgau
cc @jhpratt
2026-04-11 01:49:12 -04:00
Jonathan Brouwer ad68deab08 Rollup merge of #154369 - ver-nyan:fix-bit_or-pat_macro-msg, r=JohnTitor
Fix `pattern_from_macro_note` for bit-or expr

This is a continuation of issue https://github.com/rust-lang/rust/issues/99380 (and pr https://github.com/rust-lang/rust/pull/124488) but covers bit-or pattern.

Essentially a `pat1 | pat2`, or any bit-or pattern used in a `$e:expr` was not firing the `.pattern_from_macro_note` diagnostic bc `ast::Expr::is_approximately_pattern()` did not cover bit-or.

The cover for bit-or is only added in `lower_expr_within_pat()`, otherwise doing it in `is_approximately_pattern()` would result in the suggestion `if (i + 2) = 2 => if let (i + 2) = 2` from `suggest_pattern_match_with_let()` (which is the only other place `ast::Expr::is_approximately_pattern()` is used from what i see).

resolves https://github.com/rust-lang/rust/issues/99380
refs https://github.com/rust-lang/rust/pull/124488
2026-04-10 15:33:13 +02:00
bors dd82fd2034 Auto merge of #155056 - JonathanBrouwer:revert-lint-port, r=lqd,mati865
Revert "Port lint attributes to attribute parser"

This PR reverts the following two PRs:
- https://github.com/rust-lang/rust/pull/154808
- https://github.com/rust-lang/rust/pull/152369

This was not a clean revert, I manually solved several merge conflicts.

Closes https://github.com/rust-lang/rust/issues/154878
Closes https://github.com/rust-lang/rust/issues/154800
Closes https://github.com/rust-lang/rust/issues/155008
Re-opens https://github.com/rust-lang/rust/issues/132218 (this was never closed, oops)

r? @ghost
2026-04-09 23:54:22 +00:00
Jonathan Brouwer 65745a1b95 Revert #152369 because of multiple regressions
The regressions are documented in the PR comments.
This reverts commit 2972b5e, reversing changes made to f908263.
2026-04-09 18:53:59 +02:00
bors a87c9b9603 Auto merge of #154368 - aerooneqq:delegation-force-lowering-later, r=petrochenkov
delegation: fix cycles during delayed lowering



This PR forces lowering of delayed owners after `hir_crate_items`, as some diagnostics use `hir_crate_items` which results in query cycle which is then hangs calling `def_path_str` again and again. Fixes rust-lang/rust#154169. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-09 13:26:48 +00:00
aerooneqq dac2e3eedf Fix cycles during delayed lowering 2026-04-09 15:13:50 +03:00
bors 9004856428 Auto merge of #153838 - oli-obk:use-tree-span, r=davidtwco
Use fine grained component-wise span tracking in use trees

This often produces nicer spans and even doesn't need a Span field anymore (not that I expect the unused field to affect any perf, but still neat).
2026-04-08 20:09:27 +00:00
malezjaa 39f7cdb8e6 update thin-vec 2026-04-08 21:09:07 +02:00
Oli Scherer 9017621ace Use fine grained component-wise span tracking in use trees 2026-04-08 12:37:25 +02:00
Jonathan Brouwer 3e14c2a135 Rollup merge of #154931 - aerooneqq:delegation-small-cleanup, r=petrochenkov
delegation(small cleanup): remove not needed PhantomData

r? @petrochenkov
2026-04-07 17:26:37 +02:00
aerooneqq eacf5b8556 Generate more verbose error delegation 2026-04-07 13:04:59 +03:00
aerooneqq 7f06f55bc2 Remove not needed PhantomData 2026-04-07 10:37:23 +03:00
CoCo-Japan-pan 4f1260910a Remove the type alias for Path<'hir, DefId> 2026-04-04 17:16:14 +09:00
CoCo-Japan-pan 5863660b0d Remove shorthand from HIR 2026-04-04 16:53:30 +09:00
Edvin Bryntesson 4ab05bc659 make tools on AttributeParser hold reference to RegisteredTools 2026-04-03 11:08:10 +02:00
Redddy 7dc9a0856f Lower spans for literal const args 2026-04-02 09:20:45 +00:00
CoCo-Japan-pan d5c756acf3 Lower impl restriction to HIR 2026-04-01 12:01:40 +09:00
Jonathan Brouwer c13e9ec32b Rollup merge of #154364 - aerooneqq:delegation-generics-small-fixes, r=petrochenkov
delegation: don't propagate synthetic params, remove lifetime hacks

Some small fixes after new delegation lowering was merged: remove lifetime hacks as now we get only early-bound lifetimes from generics, don't propagate synthetic generic params as now we know that they are synthetic. Fixes rust-lang/rust#143498. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-03-25 19:52:56 +01:00
Jonathan Brouwer 145917253d Rollup merge of #154363 - aerooneqq:nested-delegations, r=petrochenkov
delegation: fix zero-args nested delegation ICE

This PR fixes an ICE when during lowering of nested delegation we need to access information about its parent, who is also inside body of another delegation. As a fix we lower delegation body even if there are no arguments in signature function, in this case we will see an error `this function takes 0 arguments but 1 argument was supplied`. Fixes rust-lang/rust#154332. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-03-25 19:52:55 +01:00
Jonathan Brouwer 6e3c17424d Rollup merge of #153702 - SpriteOvO:guard-matcher, r=davidtwco
Add macro matcher for `guard` fragment specifier

Tracking issue #153104

This PR implements a new `guard` macro matcher to match `if-let` guards (specifically [`MatchArmGuard`](https://github.com/rust-lang/reference/blob/50a1075e879be75aeec436252c84eef0fad489f4/src/expressions/match-expr.md#match-guards)). In the upcoming PR, we can use this new matcher in the `matches!` and `assert_matches!` macros to support their use with `if-let` guards. (see #152313)

The original `Expr` used to represent a guard has been wrapped in a new `Guard` type, allowing us to carry the span information of the leading `if` keyword. However, it might be even better to include the `if` keyword in the `Guard` type as well? I've left a FIXME comment in the code.
2026-03-25 19:52:50 +01:00
Tyrone Wu 2f46855070 Fix pattern macro note detection for bit-or expr
Add bit-or detection in lower expr within pattern.

Previously `pat1 | pat2` in `$e:expr` failed to trigger
`.pattern_from_macro_note` diagnostic bc
`ast::Expr::is_approximately_pattern()` did not cover bit-or.
2026-03-25 09:20:51 -04:00
aerooneqq c2383b53a2 Don't propagate synthetic params, remove lifetime hacks 2026-03-25 13:04:03 +03:00
aerooneqq 11a338deb6 Fix nested zero-args delegation ICE 2026-03-25 12:08:31 +03:00