You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nll: respect user type annotations with constants in expressions #54571
That PR adds the ability for user type annotations to be more complex than they presently are. I think we need to extend the UserTypeAnnotation type to account for constants. In the branch, it is:
match user_ty {UserTypeAnnotation::Ty(canonical_ty) => ...,UserTypeAnnotation::FnDef(def_id, canonical_substs) => ...,
...
}
I think we need to extend this with a case for ConstantDef -- or maybe we can actually adapt the FnDef code so it works for both cases (maybe even merge the two variants).
It would work like so:
Instantiate the canonical_substs with fresh variables (like FnDef)
Fetch the type_of for def_id and substitute the canonical_substs (different from FnDef, but that same code would probably work for fns too)
Relate the types and apply the user_self_ty exactly as with FnDef
If we do that, then the only thing we have left to do is to find the FIXME(#47184) spots that pertain to constants and propagate the user-substs onto those spots.
Activity
nikomatsakis commentedon Sep 25, 2018
Assigning to myself to investigate, write up some instructions, etc
nikomatsakis commentedon Oct 2, 2018
Test case #1 (should not compile, does):
nikomatsakis commentedon Oct 2, 2018
Test case #2 (same story):
nikomatsakis commentedon Oct 2, 2018
Test case #3:
nikomatsakis commentedon Oct 15, 2018
The fix for this will have to build on #55093
nikomatsakis commentedon Oct 15, 2018
That PR adds the ability for user type annotations to be more complex than they presently are. I think we need to extend the
UserTypeAnnotationtype to account for constants. In the branch, it is:So something like this:
Next, there is code that instantiates these "user type annotations" in various ways in:
It looks sort of like this:
I think we need to extend this with a case for
ConstantDef-- or maybe we can actually adapt theFnDefcode so it works for both cases (maybe even merge the two variants).It would work like so:
canonical_substswith fresh variables (likeFnDef)type_offordef_idand substitute thecanonical_substs(different fromFnDef, but that same code would probably work for fns too)user_self_tyexactly as withFnDefIf we do that, then the only thing we have left to do is to find the
FIXME(#47184)spots that pertain to constants and propagate the user-substs onto those spots.nikomatsakis commentedon Oct 17, 2018
Fix in #55152