Rollup of 6 pull requests#159262
Closed
jhpratt wants to merge 20 commits into
Closed
Conversation
…hat the ty vars are equal
Since PR 154149, when one item is glob-imported into a module twice with different visibilities, the first-arrived declaration stays in the resolution slot and the most visible declaration of the ambiguous glob set is only recorded in `ambiguity_vis_max`. `DeclData::vis()` returns the max, so name resolution, metadata reexports and `cross_crate_inlinable` export the item at the maximum visibility, but `set_bindings_effective_visibilities` walked only the slot-resident declaration's reexport chain. When the restricted route arrives first, the definition's effective visibility caps at the restricted visibility while the item is still exported: spurious dead_code, the item missing from reachable_set, should_encode_mir returning false, and downstream crates failing with "missing optimized MIR" (a 1.96.1 -> 1.97.0 stable-to-stable regression). Generalize the one-level `ambiguity_vis_max` update that PR 154149 added in `update_import` (to keep the most visible import from being reported as unused) into a walk of that declaration's whole reexport chain: extract the chain walk into `update_decl_chain` and recurse into `ambiguity_vis_max` at every hop, so the most visible declaration drives the effective visibility of everything on its route, including the final definition. Updates are monotone, so the dual walk is order-independent. The `ambiguous_import_visibilities` lint and the PR 156284 diagnostic suppression are untouched.
Point the suggestion at the const argument's span instead of the whole obligation, and parenthesize the snippet when the const expression needs it (e.g. `(N + 1) as usize`) so the suggested bound parses and compiles. Also add regression tests for legacy const generic where-bound suggestions.
…biguity, r=petrochenkov resolve: fix effective visibilities for items in ambiguous glob sets Fixes rust-lang#159038 (1.96.1 → 1.97.0 regression; details there). When an item is glob-imported twice at different visibilities, effective visibility was computed from whichever declaration arrived first, not the most visible one. An exported item could then get no MIR encoded, and downstream crates fail with ``missing optimized MIR``. Fix: also walk the most visible declaration's re-export chain (`update_decl_chain`, recursing into `ambiguity_vis_max`). Lint behavior unchanged. Two regression tests added; `tests/ui/{imports,privacy,resolve}` pass with every rust-lang#154149 / rust-lang#156284 test unmodified. @rustbot label +A-resolve +A-visibility +T-compiler +regression-from-stable-to-stable
…=lcnr,wafflelapkin Fix trait method resolution on an adjusted never type Fixes rust-lang#143349 r? @WaffleLapkin cc @lcnr
…-bound-suggestion, r=mu001999
Fix where-bound suggestion with legacy const generics
## Summary
During lowering of legacy const generics in `lower_legacy_const_generics`, the function's span was passed when creating the associated `LocalDefId` instead of the const argument span. This later caused diagnostics to pull the function's name instead of the const argument for suggestions when emitting an `unconstrained generic constant` error.
Also adds regression tests for all basic integer types. The full set isn't redundant: non-`usize` types exercise the `as usize` cast in the suggestion, while `usize` exercises the no-cast path. The tests use a cross-crate aux crate rather than a target-specific intrinsic (the rewrite only fires cross-crate), so they run on all platforms.
### Sample
```rust
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use std::arch::x86_64::*;
fn uwu<const N: i32>() {
unsafe {
let a = _mm_setzero_ps();
let b = _mm_setzero_ps();
_mm_shuffle_ps(a, b, N + 1);
}
}
```
### Previous Output
```rust
error: unconstrained generic constant
--> src/lib.rs:9:30
|
9 | _mm_shuffle_ps(a, b, N + 1);
| ^^^^^
|
help: try adding a `where` bound
|
5 | fn uwu<const N: i32>() where [(); _mm_shuffle_ps as usize]: {
| ++++++++++++++++++++++++++++++++++++
```
### Current Output
```rust
error: unconstrained generic constant
--> src/lib.rs:9:30
|
9 | _mm_shuffle_ps(a, b, N + 1);
| ^^^^^
|
help: try adding a `where` bound
|
5 | fn uwu<const N: i32>() where [(); N + 1 as usize]: {
| +++++++++++++++++++++++++++
```
## AI Assistance Disclosure
This is my first time contributing to the compiler, and I used Claude Opus 4.8 to assist with finding the root cause and implementing the fix, and to navigate the contributing docs, build system, and debugging tooling. The regression tests were designed and written entirely by me. I used Grok to proofread the written materials (commit bodies and this PR) for spelling and grammar. I reviewed and verified all changes myself.
## Related Issues
Closes rust-lang#108382
…al-casts-dyn-any, r=folkertdev Skip trivial cast lint for trait object upcasts Fixes rust-lang#148219 In the case like `(other as &dyn Any).downcast_ref::<T>()`, removing the cast can change method lookup, so the cast is not always trivial, so skip lint on it.
…ias, r=Urgau compiler: Remove `-Zmutable-noalias` Let us mark the end of an era. The `noalias` optimization has been working relatively well for some time now. There may still be issues to sort out with `noalias`. If so, those are mostly on LLVM's side, where it may need to have a better model of what `noalias` means as that is necessary for soundly inferring it. We also may need to not add `noalias` somewhere we currently do, if our semantics do not actually match that. Either way, it doesn't seem useful to configure on a compilation-wide basis.
…thanBrouwer Rename `errors.rs` file to `diagnostics.rs` (13/N) Follow-up of rust-lang#157485. r? @JonathanBrouwer
Member
Author
|
@bors r+ rollup=never p=5 |
Contributor
Contributor
|
⌛ Testing commit e2b231c with merge 731a628... Workflow: https://github.com/rust-lang/rust/actions/runs/29304962581 |
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 14, 2026
Rollup of 6 pull requests Successful merges: - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets) - #156047 (Fix trait method resolution on an adjusted never type) - #158981 (Fix where-bound suggestion with legacy const generics) - #159061 (Skip trivial cast lint for trait object upcasts) - #159248 (compiler: Remove `-Zmutable-noalias`) - #159250 (Rename `errors.rs` file to `diagnostics.rs` (13/N))
Contributor
|
PR #156047, 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:
-Zmutable-noalias#159248 (compiler: Remove-Zmutable-noalias)errors.rsfile todiagnostics.rs(13/N) #159250 (Renameerrors.rsfile todiagnostics.rs(13/N))r? @ghost
Create a similar rollup