Closed
Description
Code
struct Foo;
struct Bar;
impl From<&Foo> for Bar {
fn from(foo: &Foo) -> Bar {
Bar
}
}
fn main() {
let foo = Foo;
let b: Bar = foo.into();
}
Current output
error[E0277]: the trait bound `Foo: Into<_>` is not satisfied
--> src/main.rs:13:22
|
13 | let b: Bar = foo.into();
| ^^^^ the trait `~const Into<_>` is not implemented for `Foo`
|
= note: required for `Foo` to implement `Into<Bar>`
help: consider borrowing here
|
13 | let b: Bar = &foo.into();
| +
For more information about this error, try `rustc --explain E0277`.
error: could not compile `reference-loop` due to previous error
Desired output
error[E0277]: the trait bound `Foo: Into<_>` is not satisfied
--> src/main.rs:13:22
|
13 | let b: Bar = foo.into();
| ^^^^ the trait `~const Into<_>` is not implemented for `Foo`
|
= note: required for `Foo` to implement `Into<Bar>`
help: consider borrowing here
|
13 | let b: Bar = (&foo).into();
| +
For more information about this error, try `rustc --explain E0277`.
error: could not compile `reference-loop` due to previous error
Rationale and extra context
No response
Other cases
No response
Anything else?
The help message suggests borrowing foo.into()
, which obviously doesn't fix the issue (it leads to a series of other misleading errors). This happens using rustc 1.68.0 (2c8cc3432 2023-03-06)
.