Open
Description
I have a function call that's something like:
test(&[&"nani?" as &_, &"=_=".to_owned() as &_]);
The first &_
is interpreted as a no-op cast, and the second is interpreted as a &String -> &&str
. I did this to try and get a list of boxed traits, but the error message is pretty misleading unless you notice what the compiler's actually inferring, and almost makes it sound like as
can't be used in this situation at all:
error[E0605]: non-primitive cast: `&std::string::String` as `&&str`
...
= note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
I don't know how, but it would be nice if it could automagically recommend boxed traits in similar situations.
Metadata
Metadata
Assignees
Labels
Area: implicit and explicit `expr as Type` coercionsArea: Messages for errors, warnings, and lintsDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.