Fix type resolution of associated const equality bounds (take 2)#119385
Conversation
This comment has been minimized.
This comment has been minimized.
299d62f to
8ce12cd
Compare
8ce12cd to
cca22f2
Compare
cca22f2 to
8bf6e86
Compare
This comment has been minimized.
This comment has been minimized.
8bf6e86 to
809f68c
Compare
| let term: ty::Term<'_> = match term { | ||
| hir::Term::Ty(ty) => self.ast_ty_to_ty(ty).into(), | ||
| hir::Term::Const(ct) => { | ||
| ty::Const::from_anon_const(tcx, ct.def_id).into() |
There was a problem hiding this comment.
This might leak {type error} since we haven't actually resolved & feed the type to type_of(AnonConst) if we reach this case. The pretty-printer doesn't seem to care though (not sure if it can actually crash on certain inputs involving ty::TyKind::Error though).
Alternatively, I could pretty-print the HIR of the const but I'd need to create a public helper, const_to_string, since rustc_hir_pretty doesn't seem to expose anything like that yet?
7938112 to
ecf2aba
Compare
|
Best reviewed commit by commit. |
This comment was marked as outdated.
This comment was marked as outdated.
cfc3f0f to
ca6ac84
Compare
Oh, that makes perfect sense, thanks! Apart from eliminating indirection, does your change affect incremental query evaluation? Just out of curiosity I'd like to ask if the previous approach was unsound? As for next steps, is this change ready to be merged? Who should review it lol? |
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
It fed a hir id query, which we haven't considered yet at all. We could have marked whichever query did that as depending on the forever red node, meaning it would get rerun always. That would have been sound, but horrible for perf. Then again, it's not really worse than what I did with the other query, just fewer moving parts. Also DefIds are a bit more stable than hir ids, due to their tree style relative nature. I did not think about hir id query feeding soundness too much, so it may have been fine |
It fed a hir id query, which we haven't considered yet at all. We could have marked whichever query did that as depending on the forever red node, meaning it would get rerun always. That would have been sound, but horrible for perf. Then again, it's not really worse than what I did with the other query, just fewer moving parts. Also DefIds are a bit more stable than hir ids, due to their tree style relative nature. I did not think about hir id query feeding soundness too much, so it may have been fine
We can cross review each other's changes 😅 or get cjgillot to chime in |
2b166bd to
858d336
Compare
|
Hey, @cjgillot. If you have time and energy, could you skim this PR and double-check if the query feeding performed here roughly makes sense from a soundness perspective wrt. incr comp? Thanks a lot in advance!
Otherwise the changes look good to me! |
|
LGTM. Sorry for the delay. |
Instead of trying to re-resolve the type of assoc const bindings inside the
type_ofquery impl in an incomplete manner, transfer the already (correctly) resolved type fromadd_predicates_for_ast_type_bindingtotype_of/anon_type_ofthrough query feeding.Together with #118668 (merged) and #121258, this supersedes #118360.
Fixes #118040.
r? @ghost