Unexpected type inference around unsized coercion #104859
Labels
A-coercions
Area: implicit and explicit `expr as Type` coercions
A-trait-system
Area: Trait system
C-bug
Category: This is a bug.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen:
Line 6 to infer
and compile successfully.
Instead, this happened:
Changing line 6 to
works as expected, leading me to believe that the current behavior is inferring
(which gives the same error).
Also of note is that moving
x
rather that borrowing works as expected, e.g.Presumably, the difference is that
works fine by coercing
x
before the call toid
, whereas&Rc<i32>
can't be coerced to&Rc<dyn Any>
, so the coercion must happen after the call toRc::clone
, which doesn't play well with type inference.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: