Description
I'm sorry, but I don't have enough knowledge to identify and solve this problem. I have searched existing issues, but I couldn't find any relevant reports (it's possible that there are too many issues to locate). Therefore, I am submitting this issue here according to the instructions in the error message.
Clippy: clippy 0.1.70 (90c5418 2023-05-31)
Rustc: rustc 1.70.0 (90c5418 2023-05-31)
Code
struct Type(i64);
impl Into<i64> for Type {
fn into(self: Self) -> i64 {
self.0
}
}
fn main() {
println!("Hello, world!");
}
Message
warning: failed to automatically apply fixes suggested by rustc to crate `test_clippy`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: expected parameter name, found `:`
--> src/main.rs:4:22
|
4 | fn from(val: Type: Self) -> Self {
| ^ expected parameter name
error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `:`
--> src/main.rs:4:22
|
4 | fn from(val: Type: Self) -> Self {
| ^
| |
| expected one of 7 possible tokens
| help: missing `,`
warning: consider choosing a more descriptive name
--> src/main.rs:4:18
|
4 | fn from(val: Type: Self) -> Self {
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
= note: `#[warn(clippy::just_underscores_and_digits)]` on by default
error[E0050]: method `from` has 2 parameters but the declaration in trait `std::convert::From::from` has 1
--> src/main.rs:4:18
|
4 | fn from(val: Type: Self) -> Self {
| ^^^^^^^^^^ expected 1 parameter, found 2
|
= note: `from` from trait: `fn(T) -> Self`
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0050`.
Original diagnostics will follow.
warning: the type of the `self` parameter does not need to be arbitrary
--> src/main.rs:4:13
|
4 | fn into(self: Self) -> i64 {
| ^^^^^^^^^^ help: consider to change this parameter to: `self`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_arbitrary_self_type
= note: `#[warn(clippy::needless_arbitrary_self_type)]` on by default
warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> src/main.rs:3:1
|
3 | impl Into<i64> for Type {
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= 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: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into
= note: `#[warn(clippy::from_over_into)]` on by default
help: replace the `Into` implentation with `From<Type>`
|
3 ~ impl From<Type> for i64 {
4 ~ fn from(val: Type: Self) -> Self {
5 ~ val.0
|
warning: `test_clippy` (bin "test_clippy") generated 2 warnings (1 duplicate) (run `cargo clippy --fix --bin "test_clippy"` to apply 1 suggestion)
warning: `test_clippy` (bin "test_clippy" test) generated 2 warnings (1 duplicate) (run `cargo clippy --fix --bin "test_clippy" --tests` to apply 1 suggestion)
Finished dev [unoptimized + debuginfo] target(s) in 0.11s