Auto merge of #12141 - samueltardieu:issue-12138, r=Jarcho

from_over_into: suggest a correct conversion to ()

changelog: [`from_over_into`]: suggest a correct conversion to `()`

Fix #12138
This commit is contained in:
bors 2024-01-15 04:32:22 +00:00
commit d6ff2d2c2d
4 changed files with 37 additions and 4 deletions

View file

@ -89,4 +89,12 @@ fn msrv_1_41() {
}
}
fn issue_12138() {
struct Hello;
impl From<Hello> for () {
fn from(val: Hello) {}
}
}
fn main() {}

View file

@ -89,4 +89,12 @@ fn msrv_1_41() {
}
}
fn issue_12138() {
struct Hello;
impl Into<()> for Hello {
fn into(self) {}
}
}
fn main() {}

View file

@ -86,5 +86,19 @@ LL ~ fn from(val: Vec<T>) -> Self {
LL ~ FromOverInto(val)
|
error: aborting due to 6 previous errors
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:95:5
|
LL | impl Into<()> for Hello {
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: `impl From<Local> for Foreign` is allowed by the orphan rules, for more information see
https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence
help: replace the `Into` implementation with `From<issue_12138::Hello>`
|
LL ~ impl From<Hello> for () {
LL ~ fn from(val: Hello) {}
|
error: aborting due to 7 previous errors