Rollup of 10 pull requests - #162472
Closed
JonathanBrouwer wants to merge 56 commits into
Closed
Conversation
so that we can specify more than one i32 of padding.
Remove LD_STATIC_TLS_EXTRA workaround from FreeBSD CI
make `pad_i32` of `PassMode::cast` an integer
so that we can specify more than one i32 of padding. This PR only adds the functionality but does not yet use it: there should be no functional changes.
This is needed for the ABI of `Complex<{ float }>` on 32-bit powerpc. Other mechanisms, e.g. using `PassMode::prefixed` don't appear to work.
More discussion is in [#t-compiler/help > power complex abi](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/power.20complex.20abi/with/613294420).
Co-Authored-By: Mads Marquart <mads@marquart.dk>
* Implement Reborrow as a recursive operation If Reborrow finds '&'a mut T' fields then it inserts a Deref and borrow of the T, and likewise if it finds a 'T: Reborrow' field then the field type is recursed into. This makes Reborrow always produce the correct borrow checking logic at the cost of most probably being inconsiderately expensive. The thinking is that performance will be a followup consideration. * PhantomDeref * Simpler deref test * Add more PhantomDeref unreachability assertions * Write out lifetime omission * Document ProjectionElem::PhantomDeref * Comment half of reborrow tests * fix PhantomDeref conflicting with AccessDepth::Shallow * Recheck CoerceShared in borrowck TypeChecker to ensure its lifetimes make sense * Fix rebase * Changes... but where to? * Typo fix * Improve comment * Use fully_perform_op to evaluate CoerceShared trait in borrowck * More CoerceShared comment * Comment rest of Reborrow tests Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
…ce, r=oli-obk fix(reborrow): recursive implementation If Reborrow finds '&'a mut T' fields where 'a is the Reborrowed type's first lifetime parameter (currently the only lifetime that is allowed to reborrow) then it inserts a Deref and borrow of the T, and likewise if it finds a 'T: Reborrow' field then the field type is recursed into. This makes Reborrow always produce the correct borrow checking logic at the cost of most probably being inconsiderately expensive. The thinking is that performance will be a followup consideration. r? @oli-obk
I added this flag back in 2017 to enable benchmarking of the saturating semantics when it was newly implemented and still experimental. But saturation has been the official semantics for float<->int `as` casts for years now. A flag for turning it off no longer serves any purpose, it's just `-Zplease-miscompile-casts` now.
…eature, r=Amanieu support `#[target_feature(enable = ...)]` on `#[naked]` functions fixes rust-lang#136280 Instructions that are part of a target feature require a special directive on some targets. This PR adds those for the most common targets. This is very WIP, but I'm hoping to collect some feedback on what is (not) supported and how to report that to users. r? @ghost cc @taiki-e @Amanieu
…ncs, r=folkertdev Make sin, cos, exp, exp2, log, log2, log10 generic Rebased and smaller version of rust-lang#153934 Following `fabs`, make the `sin`, `cos`, `exp`, `exp2`, `log`, `log2` and `log10` intrinsics generic over the float type, rather than having four variants per float type. The first two commits are purely stylistic: - reorganised Cranelift code to make following changes simpler - moved a misplaced comment in `compiler/rustc_codegen_llvm/src/intrinsic.rs` that caused `x fmt` to give up The last commit actually makes them generic! Most code is a bit simpler, ~~and this will also hopefully simplify adding support for these intrinsics for the future [`bf16` type](rust-lang#160859 :) Unfortunately both GCC and Cranelift backend changes are a bit churny. Their code is a bit, opaque, to put it kindly, and I didn't want to refactor those here. r? @folkertdev cc @RalfJung
…RalfJung Remove -Zsaturating-float-casts flag I added this flag back in 2017 (rust-lang#45205) to enable benchmarking of the saturating semantics when it was newly implemented and still experimental. But saturation has been the official semantics for float<->int `as` casts for years now. A flag for turning it off no longer serves any purpose, it's just `-Zplease-miscompile-casts` now.
Facilitates scalable vector support in inline assembly.
…O is enabled The parallel frontend makes the cookies nondeterministic in their current form, resulting in nondeterministic outputs when bitcode is emitted or LTO is used. Causes minor diagnostic regression for inline asm in release builds.
…ods, r=petrochenkov
delegation: supporting inherent impls
This PR adds support for delegation to inherent impl functions on the delegation side.
Support for inherent impls in delegation consists of two problems: we need to resolve inherent function through `ProbeContext` routine and then we need to generate delegation function knowing the `DefId` of the signature function. The first problem is a fundamental problem given current compiler architecture, and it is not solved in this PR. To imitate working resolution for tests we adopt simple resolution by name only in inherent impls (not trait impls, which would work if we implement fair resolution through `ProbeContext`). A `resolve_type_relative_delegations` query was created which tries to resolve unresolved delegations after resolve stage. In future, when we will be able to fairly resolve delegations through `ProbeContext` contents of this query can be changed and all other logic implemented in this pull request will work.
## Free to inherent impl
Unlike free to trait delegation where we generated explicit `Self` param, here we just use default parameter.
```rust
struct X<'a, T, const B: bool>(...);
impl<'a, T, const B: bool> X<'a, T, B> {
fn foo<'b, U, const X: usize>(&self) { ... }
}
reuse X::<'static, (), false>::foo as foo1;
reuse X::<'static, (), false,>::foo::<'static, (), 123> as foo3;
//Desugaring:
#[attr = Inline(Hint)]
fn foo1<'b, U, const X: _>(self: _) -> _ where
'b:'b { X<'static, (), false>::foo::<'b, U, X>(self) }
#[attr = Inline(Hint)]
fn foo3(self: _) -> _ { X<'static, (), false>::foo::<'static, (), 123>(self) }
```
## Trait to inherent impl
In trait to inherent impl delegation we replace the type of self parameter from impl's type to `Self` generic param (if the signature function is a method).
```rust
trait Trait {
reuse X::<'static, (), false>::foo as foo1;
reuse X::<'static, (), false,>::foo::<'static, (), true> as foo3;
}
// Desugaring:
trait Trait {
#[attr = Inline(Hint)]
fn foo1<'b, U, const X: _>(self: _) -> _ where
'b:'b { X<'static, (), false>::foo::<'b, U, X>(self) }
#[attr = Inline(Hint)]
fn foo3(self: _)
-> _ { X<'static, (), false>::foo::<'static, (), 123>(self) }
}
```
Note that we didn't specified target expression, so we would get errors like:
```rust
error[E0308]: mismatched types
--> $DIR/xd.rs:10:14
|
LL | trait Trait {
| ----------- found this type parameter
LL | reuse X::foo;
| ^^^
| |
| expected `&X<'_, T, B>`, found `&Self`
| arguments to this function are incorrect
|
= note: expected reference `&X<'_, T, B>`
found reference `&Self`
```
## Trait impl to inherent impl
Here the resolution should look signature in trait as in other cases where we delegate from trait impl. We generate function whose signature matches the resolved function in trait. We propagate only child generics if they are not specified.
```rust
trait Trait {
fn foo<A, B, C>(&self) { }
fn foo1<T, U, V>(&self) { }
fn foo2<'a, T, U, V>(&self) where 'a:'a { }
fn foo3(&self) { }
}
impl Trait for X {
reuse X::<'static, (), false>::foo as foo1;
reuse X::<'static, (), false,>::foo::<'static, (), 123> as foo3;
}
// Desugaring:
impl Trait for X<'_> {
#[attr = Inline(Hint)]
fn foo1<T, U, V>(self: _)
-> _ { X<'static, (), false>::foo::<T, U, V>(self) }
#[attr = Inline(Hint)]
fn foo3(self: _)
-> _ { X<'static, (), false>::foo::<'static, (), 123>(self) }
}
```
## Inherent impl to inherent impl
In inherent impl to inherent impl delegation we replace signature self type with delegation parent self type in case of methods.
```rust
trait Trait {
fn foo<A, B, C>(&self) { }
fn foo1<T, U, V>(&self) { }
fn foo2<'a, T, U, V>(&self) where 'a:'a { }
fn foo3(&self) { }
}
struct Y;
impl Trait for Y {
reuse X::<'static, (), false>::foo as foo1;
reuse X::<'static, (), false,>::foo::<'static, (), 123> as foo3;
}
impl Trait for Y {
#[attr = Inline(Hint)]
fn foo1<T, U, V>(self: _)
-> _ { X<'static, (), false>::foo::<T, U, V>(self) }
#[attr = Inline(Hint)]
fn foo3(self: _)
-> _ { X<'static, (), false>::foo::<'static, (), 123>(self) }
}
```
We did not specify target expression so we would get errors like:
```rust
error[E0308]: mismatched types
--> $DIR/xd.rs:12:14
|
LL | reuse X::foo;
| ^^^
| |
| expected `&X<'_, T, B>`, found `Y`
| arguments to this function are incorrect
|
= note: expected reference `&X<'_, T, B>`
found struct `Y`
```
## Generics
After some experiments I think that we should force user to always specify generics for parent segment of delegation to inherent impls. Consider the following example and imagine that we can use fair resolution through `ProbeContext`:
```rust
trait M1 {}
trait M2 {}
struct S1;
struct S2;
impl M1 for S1 {}
impl M2 for S2 {}
struct X<T, U>(T, U);
impl<T: M1> X<T, ()> {
fn foo() {}
}
impl<T: M2> X<T, usize> {
fn foo() {}
}
reuse X::foo;
```
How to resolve `X::foo`? If we generate parent generics (`fn foo<T, U>() { X::<T, U>::foo() }`) which clauses should we inherit? It is impossible to determine which function to reuse, and despite the fact that there may be some cases where it is possible, I don't think that we should write heuristics for that. So always specifying parent generics seems to be a good option. Also I think we should ban infers in parent segment too.
One implementation aspect of how we map generic args for signature and predicates inheritance, as we inherit predicates not from the ADT declaration but from the impl block we need to take generic args from this impl, not from the declaration. So indices of generic args are taken from the impl block and then they are used in mapping and future instantiation:
```rust
struct S<'a, A, const C: usize> {
xd: &'a [A; C],
}
// index of A = 3
// index of C = 4
impl<'a, 'b, 'c, A, const C: usize> S<A, C> {
fn foo_self<'d: 'd, 'e, T, const B: bool>(self) {}
}
trait Trait<'a, AA, BB> where Self: Sized {
reuse S::<(), ()>::foo_self;
// Args: [Self/#0, 'a/rust-lang#1, AA/rust-lang#2, BB/rust-lang#3, '{region error}, 'd/rust-lang#4, (), {const error}, T/rust-lang#5, B/rust-lang#6]
// Mapping: {0: 0, 7: 9, 5: 5, 3: 6, 6: 8, 4: 7}, A (index 3) is mapped into index 6 (`()`), C (index 4) mapped into index 7 (const error)
}
```
## Other concerns
### Glob and list delegations
List delegations are supported, glob delegations are not supported:
```rust
struct X;
impl X {
fn foo(&self) {}
fn foo2(&self) {}
}
struct Y;
impl Y {
reuse X::{foo, foo2} { X }
}
impl Y {
reuse X::*;
//~^ ERROR: expected trait, found struct `X`
}
```
### Self type adjustments and target expression deletion
Adjustments for receiver are applied, adjustments for other parameters whose types contain `Self` are not applied as `Self` acts as a type alias to the struct, not a generic param which will can get replaced. The deletion of target expression should work as before.
```rust
enum X {
...
}
impl X {
fn static_f() {}
fn by_value(self) {}
fn by_ref(&self) {}
fn by_mut_ref(&mut self) {}
}
struct Y;
impl Y {
fn get_x(&self) -> X { X }
reuse X::{static_f, by_value, by_ref, by_mut_ref} { self.get_x() }
}
impl Y {
fn get_x(&self) -> X { X }
#[attr = Inline(Hint)]
fn static_f() -> _ { X::static_f() }
#[attr = Inline(Hint)]
fn by_value(self: _) -> _ { X::by_value(self.get_x()) }
#[attr = Inline(Hint)]
fn by_ref(self: _) -> _ { X::by_ref(self.get_x()) }
#[attr = Inline(Hint)]
fn by_mut_ref(self: _) -> _ { X::by_mut_ref(self.get_x()) }
}
fn main() {
let y = Y;
y.by_ref();
y.by_mut_ref();
//~^ ERROR: cannot borrow `y` as mutable, as it is not declared as mutable
y.by_value();
let y = &Y;
y.by_value();
//~^ ERROR: cannot move out of `*y` which is behind a shared reference
y.by_ref();
y.by_mut_ref();
//~^ ERROR: cannot borrow `*y` as mutable, as it is behind a `&` reference
let y = &mut Y;
y.by_value();
//~^ ERROR: cannot move out of `*y` which is behind a mutable reference
y.by_ref();
y.by_mut_ref();
}
```
### Recursive delegations
Works as before, we just check the resolution chain and we do not care whether it came from resolution at resolve stage or from resolution of type relative delegations.
r? @petrochenkov
…call-args, r=WaffleLapkin mir: validate `Move` call arguments are locals or box derefs Fixes rust-lang#103362. This PR adds a MIR validation check for `Move` arguments passed to `Call` and `TailCall` terminators. A moved argument should be either a local or the contents of the `Box`. Other places can deinitialize memory that codegen does not track correctly. The check is only enabled with `-Zvalidate-mir`, using the same phase restriction as the existing `Copy` check. Added a regression test covering the invalid case.
…nBrouwer Add tests and docs for `#[derive(GenericTypeVisitable)]` ..given the added complexity from the newly-added `bounds` attribute Follow-up to rust-lang#160914 More details in individual commits. cc @JonathanBrouwer (you might want to take over the review of this since you have some context already.. but as you wish) cc @ChayimFriedman2
…r=WaffleLapkin run `extern "tail"` with `byval` argument test With LLVM 23 we can run `extern "tail"` tests with `byval` arguments on x86 and x86_64. AArch64 does not (yet) support this, see llvm/llvm-project#206718.
…nnethercote windows-gnu: document libgcc requirement Fixes rust-lang#158933
Update books ## rust-lang/book 1 commits in 917544888a55e4da7109bdba8c88c893c0da70f4..1500248d8f230566e4ec9f27fcbb8fe9e2898ab1 2026-09-02 16:04:34 UTC to 2026-09-02 16:04:34 UTC - Update to Rust 1.98 (rust-lang/book#4823) ## rust-lang/edition-guide 1 commits in f5abcf137698e5ad6ebed359d69654ff705346af..ab8544aeed7b792984366aa122ac19bd47ad9a2f 2026-08-25 19:50:54 UTC to 2026-08-25 19:50:54 UTC - Update never-type-fallback for never type stabilization (rust-lang/edition-guide#384) ## rust-lang/reference 12 commits in 3b38834b39f732c64686f7c64aa29dcf3cd83ba5..e24eecf97b0c9a6dbac67191098204dc8a190aaa 2026-09-02 04:25:27 UTC to 2026-08-25 07:52:18 UTC - Fix nested block comment grammar (rust-lang/reference#2348) - dangling pointers: turn some consequences of the definition into notes (rust-lang/reference#2336) - Fix the nightly grammar validation job (rust-lang/reference#2347) - Order grammar summary deterministically (rust-lang/reference#2346) - Remove leftover `types/textual.md` file (rust-lang/reference#2345) - Fix non-leaf rules with bodies (rust-lang/reference#2344) - Fix rule IDs not following the header hierarchy (rust-lang/reference#2343) - Fix heading level of the `verbatim` modifier section (rust-lang/reference#2342) - Fix `...diagnostics.deprecated...` rule ID (rust-lang/reference#2341) - Update for stabilization of the never type (rust-lang/reference#2283) - Add missing punctuation (rust-lang/reference#2339) - Fix field-less `repr(C)` enum docs (rust-lang/reference#2018)
…-diagnostic-attribute-lint, r=mejrs Add regression test for item-local diagnostic attribute lint levels Closes rust-lang#135772 This issue was fixed by rust-lang#160499 indirectly. r? @mejrs
…, r=Darksonn docs(time): replace "method" with "function" I used the word "method" in rust-lang#162195 and rust-lang#162199, but these are associated functions, not methods, so I think it's correct to use the word "function". @rustbot label +A-docs
…athanBrouwer Fix my duplicate thanks entry r? @ghost I accidentally committed with the wrong email :3
Member
Author
|
@bors r+ p=5 |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 8, 2026
…uwer Rollup of 10 pull requests Successful merges: - #162470 (Subtree sync for rustc_codegen_cranelift) - #160505 (delegation: supporting inherent impls) - #160651 (mir: validate `Move` call arguments are locals or box derefs) - #161806 (Add tests and docs for `#[derive(GenericTypeVisitable)]`) - #161912 (run `extern "tail"` with `byval` argument test) - #162435 (windows-gnu: document libgcc requirement) - #162439 (Update books) - #162451 (Add regression test for item-local diagnostic attribute lint levels) - #162459 (docs(time): replace "method" with "function") - #162465 (Fix my duplicate thanks entry)
Contributor
|
⌛ Testing commit c7a95b9 with merge f517d84... Workflow: https://github.com/rust-lang/rust/actions/runs/34223539817 |
Contributor
|
PR #162470, which is a member of this rollup, was unapproved. This rollup was thus unapproved. Auto build was cancelled due to unapproval. Cancelled workflows: |
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
Movecall arguments are locals or box derefs #160651 (mir: validateMovecall arguments are locals or box derefs)#[derive(GenericTypeVisitable)]#161806 (Add tests and docs for#[derive(GenericTypeVisitable)])extern "tail"withbyvalargument test #161912 (runextern "tail"withbyvalargument test)r? @ghost
Create a similar rollup