You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// src/main.rs// this appears in the errormod name;use name::Name;fnmain(){let name_1 = Name::from("John Cena");let name_2 = Name::from("Not John Cena");println!("{}", name_1 == name_2);}
// src/name.rspubstructName{pubfirst:String,pubmiddle:String,publast:String,}implFrom<&str>forName{fnfrom(name:&str) -> Self{letmut parts = name.split_whitespace();let first = parts.next().unwrap_or_default();let last = parts.clone().last().unwrap_or_default();let middle = parts.collect::<Vec<_>>().join(" ");Self{first: first.to_owned(),
middle,last: last.to_owned(),}}}
This code, as expected, produces E0369, shown below. However, the help message at the bottom of the error appears to be referencing line 2 in src/main.rs, while displaying the filename src/name.rs, thus suggesting we add the derive annotation to a comment in src/main.rs. It should instead point to the struct in src/name.rs.
error[E0369]: binary operation `==` cannot be applied to type `Name`
--> src/main.rs:11:27
|
11 | println!("{}", name_1 == name_2);
| ------ ^^ ------ Name
| |
| Name
|
note: an implementation of `PartialEq` might be missing for `Name`
--> src/name.rs:2:1
|
2 | pub struct Name{
| ^^^^^^^^^^^^^^^ must implement `PartialEq`
help: consider annotating `Name` with `#[derive(PartialEq)]`
--> src/name.rs:2:1
|
2 + #[derive(PartialEq)]3 | // this appears in the error
|
I have the following code, split into two files:
This code, as expected, produces
E0369
, shown below. However, the help message at the bottom of the error appears to be referencing line 2 insrc/main.rs
, while displaying the filenamesrc/name.rs
, thus suggesting we add thederive
annotation to a comment insrc/main.rs
. It should instead point to thestruct
insrc/name.rs
.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: