-
Notifications
You must be signed in to change notification settings - Fork 14k
IAT: Reinstate early bailout #148771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
IAT: Reinstate early bailout #148771
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Ensure that IAT selection doesn't hard error on associated type paths that could refer to | ||
| // an inherent associated type if we can't find an applicable inherent candidate since there | ||
| // might still be valid trait associated type candidates. | ||
| // | ||
| // FIXME(#142006): This only covers the bare minimum, we also need to disqualify inherent | ||
| // candidates if they're inaccessible or if the impl headers don't match / apply. | ||
| // | ||
| // issue: <https://github.com/rust-lang/rust/issues/142006#issuecomment-2938846613> | ||
| //@ check-pass | ||
|
|
||
| #![feature(inherent_associated_types)] | ||
| #![expect(incomplete_features)] | ||
|
|
||
| struct Type; | ||
| trait Trait { type AssocTy; fn scope(); } | ||
|
|
||
| impl Trait for Type { | ||
| type AssocTy = (); | ||
|
|
||
| fn scope() { | ||
| let (): Self::AssocTy; | ||
| } | ||
| } | ||
|
|
||
| fn main() { <Type as Trait>::scope(); } |
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote this test and it's rooted in a deep misconception, namely that there can't ever be a case where we would pick a trait candidate over an inherent one. Back then I didn't know about #142006. In essence, I don't like this test, hence its removal. Once we fix #142006, we'll have plenty of tests regarding "candidate preference/elimination". |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #![feature(inherent_associated_types)] | ||
| #![expect(incomplete_features)] | ||
|
|
||
| // Ensure that prefer inherent associated types over trait associated types | ||
| // (assuming the impl headers match and they're accessible). | ||
| //@ check-pass | ||
|
|
||
| struct Adt; | ||
|
|
||
| impl Adt { | ||
| type Ty = (); | ||
| } | ||
|
|
||
| trait Trait { | ||
| type Ty; | ||
| fn scope(); | ||
| } | ||
|
|
||
| impl Trait for Adt { | ||
| type Ty = i32; | ||
| fn scope() { | ||
| // We prefer the inherent assoc ty `Adt::Ty` (`()`) over the | ||
| // trait assoc ty `<Adt as Trait>::Ty` (`i32`). | ||
| let (): Self::Ty; | ||
| } | ||
| } | ||
|
|
||
| fn main() {} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously this is but a hotfix for a minute part of #142006. I was briefly toying with the idea of properly addressing #142006 now but for that I would need to rewrite type-relative path resolution in HIR ty lowering to properly assemble inherent & trait candidates (instead of eagerly trying to resolve them in sequence) but I realized I would only be stepping on your toes / doing throwaway work (#145825).