Fully-qualifying a From::from
call adds an implicit reborrow that is not inferred otherwise
#89966
Labels
A-borrow-checker
Area: The borrow checker
A-inference
Area: Type inference
A-type-system
Area: Type system
C-discussion
Category: Discussion or questions that doesn't represent real issues.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
This code fails with a borrow-check error:
However, explicitly specifying
<() as From<&mut Foo>>
in the first call causes compilation to succeed:Comparing the MIR output for the two versions, it appears that the fully-qualified version reborrows from
foo_mut
, whereas the unqualified version does not:I'm guessing this reborrow is due to, or at least related to, the following change in "User Type Annotations":
In the unqualified
<()>::from(...)
version,From::from
's type seems to be generic over a type parameter, while in the qualified<() as From<&mut Foo>>::from(...)
version,From::from
's type is generic over a lifetime.See also this Zulip thread.
The text was updated successfully, but these errors were encountered: