-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Restore diagnostics when no inherent const candidates found #149814
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: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -1522,7 +1522,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |
| // as potential fallback candidates (#142006). To temporarily mask that issue, let's not | ||
| // select at all if there are no early inherent candidates. | ||
| if candidates.is_empty() { | ||
| return Ok(None); | ||
| return match assoc_tag { | ||
| ty::AssocTag::Type => Ok(None), | ||
| ty::AssocTag::Const => Err(self.report_unresolved_inherent_assoc_item( | ||
|
Member
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. Just so we're clear, this is not the correct fix long term because we need to probe trait candidates, too, if there are no inherent candidates. Moreover, adding this error back in just means we're likely just papering over some deeper mGCA issue that ultimately needs to be fixed some other way, possible. Well, I haven't really looked into the cause of the ICEs but Boxy knew of their existence all the way back when she worked on #140247. |
||
| name, | ||
| self_ty, | ||
| candidates, | ||
| vec![], | ||
| span, | ||
| assoc_tag, | ||
| )), | ||
| ty::AssocTag::Fn => unreachable!(), | ||
| }; | ||
| } | ||
|
|
||
| let (applicable_candidates, fulfillment_errors) = | ||
|
|
||
|
Member
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. This should reside in |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //! regression test for #148949, #149809 | ||
| #![expect(incomplete_features)] | ||
| #![feature(min_generic_const_args)] | ||
| #![feature(inherent_associated_types)] | ||
| struct Foo<'a> { | ||
| x: &'a (), | ||
| } | ||
|
|
||
| impl<'a> Foo<'a> { | ||
| fn bar(_: [u8; Foo::X]) {} | ||
| //~^ ERROR: associated constant `X` not found for `Foo<'_>` in the current scope | ||
| // #[type_const] | ||
| // const Y: usize = 10; | ||
| // fn foo(_: [u8; Foo::Y]) {} | ||
| // associated constant `Y` not found for `Foo<'_>` in the current scope | ||
| } | ||
|
|
||
| fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| error[E0220]: associated constant `X` not found for `Foo<'_>` in the current scope | ||
| --> $DIR/iat-const-resolution.rs:10:25 | ||
| | | ||
| LL | struct Foo<'a> { | ||
| | -------------- associated constant `X` not found for this struct | ||
| ... | ||
| LL | fn bar(_: [u8; Foo::X]) {} | ||
| | ^ associated item not found in `Foo<'_>` | ||
| | | ||
| = note: the associated constant was found for | ||
|
|
||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0220`. |
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.
This comment needs to be moved above the
Typebranch then, otherwise it no longer makes sense