rust/src/test/ui/nonscalar-cast.fixed
Esteban Küber e857696cf8 Tweak "non-primitive cast" error
- Suggest borrowing expression if it would allow cast to work.
- Suggest using `<Type>::from(<expr>)` when appropriate.
- Minor tweak to `;` typo suggestion.

Partily address #47136.
2020-06-15 08:57:20 -07:00

17 lines
255 B
Rust

// run-rustfix
#[derive(Debug)]
struct Foo {
x: isize
}
impl From<Foo> for isize {
fn from(val: Foo) -> isize {
val.x
}
}
fn main() {
println!("{}", isize::from(Foo { x: 1 })); //~ non-primitive cast: `Foo` as `isize` [E0605]
}