Skip to content

Add supertrait item shadowing for type-level path resolution#152225

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
Amanieu:type-supertrait-shadowing
Jun 28, 2026
Merged

Add supertrait item shadowing for type-level path resolution#152225
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
Amanieu:type-supertrait-shadowing

Conversation

@Amanieu

@Amanieu Amanieu commented Feb 6, 2026

Copy link
Copy Markdown
Member

View all comments

This makes type-level name resolution (used primarily for associated types) also prefer subtrait items to supertrait items in case of ambiguity.

This addresses the concern from #148605 about the inconsistency with name resolution in expressions and method calls.

@rustbot

rustbot commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 6, 2026
@rustbot

rustbot commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

r? @madsmtm

rustbot has assigned @madsmtm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • People who recently interacted with files modified in this PR: compiler
  • compiler expanded to 20 candidates
  • Random selection from 12 candidates

println!("{}", size_of::<T::T>());
}

fn generic2<T: C<T = i16>>() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about T: B<T = i16> and T: A<T = i8> - do those resolve to B::T and A::T respectively?

Also, please use a different name for the generic and the associated type, it's a bit confusing as-is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've cleaned up the example and added tests showing how B<T = i16> and A<T = i8> are resolved.

@jackh726

jackh726 commented Feb 9, 2026

Copy link
Copy Markdown
Member

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Feb 9, 2026
@traviscross traviscross added the I-lang-radar Items that are on lang's radar and will need eventual work or consideration. label Feb 10, 2026
@madsmtm

madsmtm commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

r? types

Wait, I'm not sure if that should've unassigned me or not? In any case, if you also need a compiler reviewer, I'm the wrong one for the job, so I'm gonna unassign myself.

@madsmtm madsmtm removed their assignment Feb 26, 2026
@Amanieu Amanieu force-pushed the type-supertrait-shadowing branch from 1cde4c7 to 5a9ef14 Compare March 28, 2026 12:33
@rustbot

This comment has been minimized.

@jackh726 jackh726 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I think this needs some more tests. I've already commented about adding the testing attr, but ideally we should go through the existing tests/ui/methods/supertrait-shadowing tests (which in general are pretty thorough) and write the equivalent test for associated types and consts. These cover cases like multiple ancestors, unsatisfied trait bounds, scoping, and (in a PR I'm about to make) stability.

I also would like to see test that show that <U as A>::T works just fine, even if you have U: B.

View changes since this review

use std::mem::size_of;

trait A {
type T;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a different name for the associated type to name lexically clash with the param.

println!("{}", size_of::<U::T>());
}

fn generic3<U: B<T = i16>>() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is missing here is a test of U: B<T = i8> and U: B, just to show the former is not callable (because of the blanket impl), and the latter still uses <U as B>::T. (Similar for C below)

trait C: B {}
impl<T> C for T {}

fn main() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have rustc_dump_predicates, which we could use to verify the predicates are getting lowered as we expect. It would be good to use that in this (or another) test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this test probably doesn't make sense here, right? This is not about method resolution.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally getting back around to this! Some questions about your preferences for the test organization.

Would you prefer moving all supertrait-shadowing tests into their own directory (tests/ui/supertrait-shadowing) or would you prefer adding a separate directory which just contains tests for type-level shadowing?

In the former case, would you like type-level shadowing tests to be in separate files or in the same file as the corresponding method-level test?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong preference. I think a separate directory is good. Putting them in the same file also seems reasonable.

/// supertrait of another candidate trait.
///
/// This implements RFC #3624.
fn collapse_candidates_to_subtrait_pick(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think docs here and for collapse_candidates_to_subtrait_pick in method::probe should link to each other to help ensure they are kept up to date.

It's kind of unfortunate we can't have some shared code here.

continue;
}

// This pick is not a supertrait of the `child_pick`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a commit with some cleanup that I'm about to push - but child_pick doesn't exist. Should be child_trait. Here and below.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2026
@joshtriplett

Copy link
Copy Markdown
Member

What's the current state of this PR? AIUI, this is the remaining blocker for stabilizing supertrait item shadowing.

@jackh726

Copy link
Copy Markdown
Member

I think this is waiting on @Amanieu to address the review.

@rust-bors

This comment has been minimized.

@Amanieu

Amanieu commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

I've addressed the review feedback. I couldn't adapt the following tests because the corresponding functionality doesn't exist in type-level name resolution, and always results in an ambiguity error:

  • trivially-false-subtrait.rs
  • unstable.rs
  • false-subtrait-after-inference.rs

@Amanieu Amanieu force-pushed the type-supertrait-shadowing branch from 5a9ef14 to 9407a97 Compare June 4, 2026 22:32
@rustbot

This comment has been minimized.

@jackh726

jackh726 commented Jun 8, 2026

Copy link
Copy Markdown
Member

I've addressed the review feedback. I couldn't adapt the following tests because the corresponding functionality doesn't exist in type-level name resolution, and always results in an ambiguity error:

* `trivially-false-subtrait.rs`
* `unstable.rs`
* `false-subtrait-after-inference.rs`

@Amanieu hmm for trivially-false-subtrait and false-subtrait-after-inference, these seem important, right? This basically means that associated type resolution doesn't take into account trait bounds but method resolution does...which seems like an important property to match

Generally, it's also interesting to me (and I must have missed this when I was going through) that false-subtrait-after-inference is ambiguous because of an inference variable...certainly for me it's obvious, but for the average user it feels weird. Especially because the error says i32: Foo doesn't hold, which a natural reaction should be "so don't pick it!" (which we don't if it's not an inference var)

Given the above, I'm wondering if may we want to limit that resolution even for the method case right now. Thoughts?

@Amanieu

Amanieu commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

For trivially-false-subtrait there's no way to directly express the thing we're testing:

//@ run-pass

// Make sure we don't prefer a subtrait that we would've otherwise eliminated
// in `consider_probe` during method probing.

use core::mem::size_of;

#![allow(dead_code)]

struct W<T>(T);

trait Upstream {
    fn hello(&self) -> &'static str {
        "upstream"
    }
    type Assoc = i8;
}
impl<T> Upstream for T {}

trait Downstream: Upstream {
    fn hello(&self) -> &'static str {
        "downstream"
    }
    type Assoc = i16;
}
impl<T> Downstream for W<T> where T: Foo {}

trait Foo {}

fn main() {
    let x = W(1i32);
    assert_eq!(x.hello(), "upstream");

    // This doesn't work: accessing type-level associated items requires 
    // specifying the trait name explicitly with <W<i32> as Upstream> or
    // <W<i32> as Downstream>. But then that overrides supertrait shadowing
    // anyways...
    assert_eq!(size_of::<W<i32>::Assoc>(), 1);
    
    // This works but always resolves to the supertrait because that's what's
    // in the bounds of check1.
    check1::<W<i32>>();
    // This fails because W<i32> doesn't implement Downstream
    check2::<W<i32>>();
}

fn check1<T: Upstream>() {
    assert_eq!(size_of::<T::Assoc>(), 1);
}

fn check2<T: Downstream>() {
    assert_eq!(size_of::<T::Assoc>(), 2);
}

Similar issue with false-subtrait-after-inference.

@Amanieu

Amanieu commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Generally, it's also interesting to me (and I must have missed this when I was going through) that false-subtrait-after-inference is ambiguous because of an inference variable...certainly for me it's obvious, but for the average user it feels weird. Especially because the error says i32: Foo doesn't hold, which a natural reaction should be "so don't pick it!" (which we don't if it's not an inference var)

Given the above, I'm wondering if may we want to limit that resolution even for the method case right now. Thoughts?

That seems difficult to do in the current code structure, which I'm not super familiar with. Additionally, this is really an edge case: you would need to be intentionally shadowing a supertrait item while also having different trait bounds on the subtrait.

@jackh726 jackh726 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine - but we need test that shows that the feature needs to be enabled for this to work. (Though I can trivially see that this is true.)

After that, r=me

View changes since this review

@Amanieu

Amanieu commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

This is fine - but we need test that shows that the feature needs to be enabled for this to work. (Though I can trivially see that this is true.)

Which feature are you talking about specifically? I'm not sure which of my comments you're replying to.

@jackh726

Copy link
Copy Markdown
Member

@bors r+

@rust-log-analyzer

This comment has been minimized.

@Amanieu Amanieu force-pushed the type-supertrait-shadowing branch from 1ab6862 to af3eaee Compare June 26, 2026 17:32
@rustbot

rustbot commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  PR_CI_JOB: 1
  IMAGE: pr-check-2
##[endgroup]
    Updating crates.io index
error: failed to get `cc` as a dependency of package `ring v0.17.11`
    ... which satisfies dependency `ring = "^0.17"` of package `rustls v0.23.23`
    ... which satisfies dependency `rustls = "^0.23.22"` of package `ureq v3.0.8`
    ... which satisfies dependency `ureq = "^3"` of package `citool v0.1.0 (/home/runner/work/rust/rust/src/ci/citool)`

Caused by:
  failed to load source for dependency `cc`

Caused by:

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

Got the same error on #158493, so it could be spurious
@bors try jobs=x86_64-gnu-llvm-22-3

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
Add supertrait item shadowing for type-level path resolution


try-job: x86_64-gnu-llvm-22-3
@rust-bors

rust-bors Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

💔 Test for a559af7 failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-llvm-22-3 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [codegen] tests/codegen-llvm/issues/issue-107681-unwrap_unchecked.rs stdout ----
------FileCheck stdout------------------------------

------FileCheck stderr------------------------------
/checkout/tests/codegen-llvm/issues/issue-107681-unwrap_unchecked.rs:17:12: error: CHECK: expected string not found in input
 // CHECK: [[RET:%.*]] = load i32, ptr [[INNER]]
           ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll:11:24: note: scanning from here
 %_7 = load ptr, ptr %x, align 8, !nonnull !4, !noundef !4
                       ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll:11:24: note: with "INNER" equal to "%_7"
 %_7 = load ptr, ptr %x, align 8, !nonnull !4, !noundef !4
                       ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll:15:2: note: possible intended match here
 %_4 = load i32, ptr %_6, align 4, !noundef !4
 ^

Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll
Check file: /checkout/tests/codegen-llvm/issues/issue-107681-unwrap_unchecked.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = 'issue_107681_unwrap_unchecked.67fd71670d665894-cgu.0' 
            2: source_filename = "issue_107681_unwrap_unchecked.67fd71670d665894-cgu.0" 
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 
            4: target triple = "x86_64-unknown-linux-gnu" 
            5:  
            6: ; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(read, argmem: readwrite, inaccessiblemem: write, target_mem0: none, target_mem1: none) uwtable 
            7: define noundef i32 @foo(ptr noalias nofree noundef align 8 captures(none) dereferenceable(16) %x) unnamed_addr #0 { 
            8: start: 
            9:  %0 = getelementptr inbounds nuw i8, ptr %x, i64 8 
           10:  %_6 = load ptr, ptr %0, align 8, !nonnull !4, !noundef !4 
           11:  %_7 = load ptr, ptr %x, align 8, !nonnull !4, !noundef !4 
check:17'0                            X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:17'1                                                                 with "INNER" equal to "%_7"
           12:  %_8 = icmp ne ptr %_6, %_7 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           13:  %_14 = getelementptr inbounds nuw i8, ptr %_6, i64 4 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           14:  store ptr %_14, ptr %0, align 8 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           15:  %_4 = load i32, ptr %_6, align 4, !noundef !4 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:17'2      ?                                              possible intended match
           16:  tail call void @llvm.assume(i1 %_8) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           17:  ret i32 %_4 
check:17'0     ~~~~~~~~~~~~~
           18: } 
check:17'0     ~~
           19:  
check:17'0     ~
           20: ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           21: declare void @llvm.assume(i1 noundef) #1 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           22:  
check:17'0     ~
           23: attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(read, argmem: readwrite, inaccessiblemem: write, target_mem0: none, target_mem1: none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" } 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           24: attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           25:  
check:17'0     ~
           26: !llvm.module.flags = !{!0, !1, !2} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           27: !llvm.ident = !{!3} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~
           28:  
check:17'0     ~
           29: !0 = !{i32 8, !"PIC Level", i32 2} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           30: !1 = !{i32 2, !"RtLibUseGOT", i32 1} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           31: !2 = !{i32 7, !"uwtable", i32 2} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           32: !3 = !{!"rustc version 1.98.0-nightly (a559af70e 2026-06-27)"} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           33: !4 = !{} 
check:17'0     ~~~~~~~~~
>>>>>>

------------------------------------------

error: verification with 'FileCheck' failed
status: exit status: 1
command: "/usr/lib/llvm-22/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll" "/checkout/tests/codegen-llvm/issues/issue-107681-unwrap_unchecked.rs" "--check-prefix=CHECK" "--allow-unused-prefixes" "--dump-input-context" "100" "--implicit-check-not" "br {{.*}}" "--implicit-check-not" "select"
stdout: none
--- stderr -------------------------------
/checkout/tests/codegen-llvm/issues/issue-107681-unwrap_unchecked.rs:17:12: error: CHECK: expected string not found in input
 // CHECK: [[RET:%.*]] = load i32, ptr [[INNER]]
           ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll:11:24: note: scanning from here
 %_7 = load ptr, ptr %x, align 8, !nonnull !4, !noundef !4
                       ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll:11:24: note: with "INNER" equal to "%_7"
 %_7 = load ptr, ptr %x, align 8, !nonnull !4, !noundef !4
                       ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll:15:2: note: possible intended match here
 %_4 = load i32, ptr %_6, align 4, !noundef !4
 ^

Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-llvm/issues/issue-107681-unwrap_unchecked/issue-107681-unwrap_unchecked.ll
Check file: /checkout/tests/codegen-llvm/issues/issue-107681-unwrap_unchecked.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = 'issue_107681_unwrap_unchecked.67fd71670d665894-cgu.0' 
            2: source_filename = "issue_107681_unwrap_unchecked.67fd71670d665894-cgu.0" 
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 
            4: target triple = "x86_64-unknown-linux-gnu" 
            5:  
            6: ; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(read, argmem: readwrite, inaccessiblemem: write, target_mem0: none, target_mem1: none) uwtable 
            7: define noundef i32 @foo(ptr noalias nofree noundef align 8 captures(none) dereferenceable(16) %x) unnamed_addr #0 { 
            8: start: 
            9:  %0 = getelementptr inbounds nuw i8, ptr %x, i64 8 
           10:  %_6 = load ptr, ptr %0, align 8, !nonnull !4, !noundef !4 
           11:  %_7 = load ptr, ptr %x, align 8, !nonnull !4, !noundef !4 
check:17'0                            X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:17'1                                                                 with "INNER" equal to "%_7"
           12:  %_8 = icmp ne ptr %_6, %_7 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           13:  %_14 = getelementptr inbounds nuw i8, ptr %_6, i64 4 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           14:  store ptr %_14, ptr %0, align 8 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           15:  %_4 = load i32, ptr %_6, align 4, !noundef !4 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:17'2      ?                                              possible intended match
           16:  tail call void @llvm.assume(i1 %_8) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           17:  ret i32 %_4 
check:17'0     ~~~~~~~~~~~~~
           18: } 
check:17'0     ~~
           19:  
check:17'0     ~
           20: ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           21: declare void @llvm.assume(i1 noundef) #1 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           22:  
check:17'0     ~
           23: attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(read, argmem: readwrite, inaccessiblemem: write, target_mem0: none, target_mem1: none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" } 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           24: attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           25:  
check:17'0     ~
           26: !llvm.module.flags = !{!0, !1, !2} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           27: !llvm.ident = !{!3} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~
           28:  
check:17'0     ~
           29: !0 = !{i32 8, !"PIC Level", i32 2} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           30: !1 = !{i32 2, !"RtLibUseGOT", i32 1} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           31: !2 = !{i32 7, !"uwtable", i32 2} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           32: !3 = !{!"rustc version 1.98.0-nightly (a559af70e 2026-06-27)"} 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           33: !4 = !{} 
check:17'0     ~~~~~~~~~
>>>>>>
------------------------------------------

---- [codegen] tests/codegen-llvm/issues/issue-107681-unwrap_unchecked.rs stdout end ----

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

This is a spurious issue, not the fault of this PR, see #158500

@JonathanBrouwer

JonathanBrouwer commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Spurious issue fixed by github.com//pull/158502
@bors r=jackh726

@rust-bors

rust-bors Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit af3eaee has been approved by jackh726

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 27, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 27, 2026
… r=jackh726

Add supertrait item shadowing for type-level path resolution

This makes type-level name resolution (used primarily for associated types) also prefer subtrait items to supertrait items in case of ambiguity.

This addresses the concern from rust-lang#148605 about the inconsistency with name resolution in expressions and method calls.
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #158502 (Revert "LLVM 23: Adapt codegen test to moved assume")
 - #152225 (Add supertrait item shadowing for type-level path resolution)
 - #158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…)
 - #158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs)
 - #158501 (miri subtree update)
 - #153097 (Expand `OptionFlatten`'s iterator methods)
 - #158163 (Fix too-short variance slice in `variances_of` cycle recovery)
 - #158233 (Allow the unstable attribute on foreign type)
 - #158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.)
 - #158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #158502 (Revert "LLVM 23: Adapt codegen test to moved assume")
 - #152225 (Add supertrait item shadowing for type-level path resolution)
 - #158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…)
 - #158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs)
 - #158501 (miri subtree update)
 - #153097 (Expand `OptionFlatten`'s iterator methods)
 - #158163 (Fix too-short variance slice in `variances_of` cycle recovery)
 - #158233 (Allow the unstable attribute on foreign type)
 - #158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.)
 - #158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #158502 (Revert "LLVM 23: Adapt codegen test to moved assume")
 - #152225 (Add supertrait item shadowing for type-level path resolution)
 - #158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…)
 - #158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs)
 - #158501 (miri subtree update)
 - #153097 (Expand `OptionFlatten`'s iterator methods)
 - #158163 (Fix too-short variance slice in `variances_of` cycle recovery)
 - #158233 (Allow the unstable attribute on foreign type)
 - #158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.)
 - #158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #158502 (Revert "LLVM 23: Adapt codegen test to moved assume")
 - #152225 (Add supertrait item shadowing for type-level path resolution)
 - #158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…)
 - #158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs)
 - #158501 (miri subtree update)
 - #153097 (Expand `OptionFlatten`'s iterator methods)
 - #158163 (Fix too-short variance slice in `variances_of` cycle recovery)
 - #158233 (Allow the unstable attribute on foreign type)
 - #158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.)
 - #158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 28, 2026
… r=jackh726

Add supertrait item shadowing for type-level path resolution

This makes type-level name resolution (used primarily for associated types) also prefer subtrait items to supertrait items in case of ambiguity.

This addresses the concern from rust-lang#148605 about the inconsistency with name resolution in expressions and method calls.
rust-bors Bot pushed a commit that referenced this pull request Jun 28, 2026
Rollup of 15 pull requests

Successful merges:

 - #158497 (stdarch subtree update)
 - #152225 (Add supertrait item shadowing for type-level path resolution)
 - #158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…)
 - #158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs)
 - #158501 (miri subtree update)
 - #153097 (Expand `OptionFlatten`'s iterator methods)
 - #157614 (Move tests drop)
 - #157996 (perf: drop the full-crate AST walk in check_unused)
 - #158163 (Fix too-short variance slice in `variances_of` cycle recovery)
 - #158233 (Allow the unstable attribute on foreign type)
 - #158433 (Fix inconsistent safety requirement in VecDeque::nonoverlapping_ranges)
 - #158464 (Reorganize `tests/ui/issues` [15/N])
 - #158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.)
 - #158485 (Reorganize `tests/ui/issues` [16/N])
 - #158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
@rust-bors rust-bors Bot merged commit f477b56 into rust-lang:main Jun 28, 2026
26 of 53 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 28, 2026
rust-timer added a commit that referenced this pull request Jun 28, 2026
Rollup merge of #152225 - Amanieu:type-supertrait-shadowing, r=jackh726

Add supertrait item shadowing for type-level path resolution

This makes type-level name resolution (used primarily for associated types) also prefer subtrait items to supertrait items in case of ambiguity.

This addresses the concern from #148605 about the inconsistency with name resolution in expressions and method calls.
faukah pushed a commit to faukah/miri that referenced this pull request Jun 28, 2026
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#158497 (stdarch subtree update)
 - rust-lang/rust#152225 (Add supertrait item shadowing for type-level path resolution)
 - rust-lang/rust#158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…)
 - rust-lang/rust#158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs)
 - rust-lang/rust#158501 (miri subtree update)
 - rust-lang/rust#153097 (Expand `OptionFlatten`'s iterator methods)
 - rust-lang/rust#157614 (Move tests drop)
 - rust-lang/rust#157996 (perf: drop the full-crate AST walk in check_unused)
 - rust-lang/rust#158163 (Fix too-short variance slice in `variances_of` cycle recovery)
 - rust-lang/rust#158233 (Allow the unstable attribute on foreign type)
 - rust-lang/rust#158433 (Fix inconsistent safety requirement in VecDeque::nonoverlapping_ranges)
 - rust-lang/rust#158464 (Reorganize `tests/ui/issues` [15/N])
 - rust-lang/rust#158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.)
 - rust-lang/rust#158485 (Reorganize `tests/ui/issues` [16/N])
 - rust-lang/rust#158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants