-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Don't probe InferConst
in fold_const
if self.infcx
is None
, deeply_normalize
tys in check_tys_might_be_eq
#124526
Conversation
changes to the core type system |
r? lcnr |
This comment has been minimized.
This comment has been minimized.
Some changes occurred in src/tools/compiletest cc @jieyouxu |
@rustbot label -A-testsuite -T-bootstrap |
Im not sure this fix is correct. Whether the paramenv has already been canonicalized or not has nothing to do with whether we can encounter consts with aliases as their type. I would expect the correct fix to be to normalize both types in Sooo we probably want that fn to call |
ty::Const
if its ParamEnv
isn't canonicalized yetInferConst
in fold_const
if self.infcx
is None
, deeply_normalize
tys in check_tys_might_be_eq
Ty for the pointers, though non-wf aliases ICEs even without struct Sized<T>(T);
type NonWf = Sized<dyn ToString>;
struct Walk<const W: NonWf> {}
impl Walk<{ Sized("") }> {} https://play.rust-lang.org/?gist=66eb4c5f0a126c73ba8734ef399b639d @rustbot label -A-testsuite -T-bootstrap |
Why the first commit? You didn't update the function that handles tys and also it shouldn't be required for this as in super_combine_tys we have an infcx available for canonicalization |
It's for #119381, whose backtrack is as follow:
Though it may be preferable to (re-)canonicalize |
☔ The latest upstream changes (presumably #125541) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -487,7 +502,19 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> { | |||
} | |||
} | |||
ty::ConstKind::Infer(InferConst::EffectVar(vid)) => { | |||
match self.infcx.unwrap().probe_effect_var(vid) { | |||
let Some(infcx) = self.infcx else { |
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.
I've avoided to review this PR for a while as this feels very suspicious to me but I wasn't able to explain why without a significant time investment. sorry 😅
The ICE occurs in equate_impl_headers
which is used to compute the constraints we can assume. We cannot eagerly replace infer vars with placeholders at this point
equate_impl_headers(infcx, param_env, &impl1_header, &impl2_header) |
We should use an infcx
when encountering inference varialbes to make sure these infer vars do not resolve to any other types. I would personally prefer to only do the deeply_normalize
change in this PR and fix the negative_coherence
issue by cleaning up our const handling in general.
While your approach does work and may at worst slightly worsen type inference here, this change does cause the code to be "conceptionally broken"1, so I would prefer to not land it, esp given that it's an ICE which only occurs with a nightly feature enabled.
Footnotes
-
this is mostly just vibe based 🤔 using it here as the way to rationalize this change is "yes, this may cause unexpected and wrong results in rare cases, but it's not unsound, so it's fine". It's somewhat difficult to explain exactly what I mean here ↩
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.
For context, I tried to add a subdiagnostic “if there's a conflicting implementation and if using negative coherence solves it, suggests adding #![feature(with_negative_coherence)]
” but it ICEd some tests, and I may have been too hasty in my attempt to fix it. I’ll try to come up with a nicer approach when I have time.
@rustbot author |
@ShE3py any updates on this? thanks |
Fixes #119381, fixes #114456.