Closed
Description
Missing a single bracket, can lead to 8 errors in this case, and 16 in the actual project this sample code comes from.
Example mistake:
use serde::{Deserialize, Serialize//};
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=015ef4d8827e4c3915e385428acf29fb
use serde::{Deserialize, Serialize//};
use std::net::SocketAddr;
fn main() {
let addr = "0.0.0.0:8000".parse().unwrap();
let noderef = NodeRef::new(addr);
noderef.get("hi");
noderef.upsert("hi".to_owned(), "hey".to_owned());
noderef.upsert_prefix_ref("hi", addr);
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
pub struct NodeRef {
pub address: SocketAddr,
}
impl NodeRef {
pub fn new(address: SocketAddr) -> NodeRef {
NodeRef { address }
}
pub fn get(&self, key: &str) -> Option<String> {
dbg!(key);
None
}
pub fn upsert(&self, key: String, value: String) {
dbg!(key, value);
}
pub fn upsert_prefix_ref(&self, prefix: &str, addr: SocketAddr) {
dbg!(prefix, addr);
}
}
The current output is:
Checking errortest v0.1.0 (/home/frederik/Programmeren/rust/errortest)
error: this file contains an unclosed delimiter
--> src/main.rs:35:2
|
1 | use serde::{Deserialize, Serialize//};
| - unclosed delimiter
...
35 |
| ^
error: expected identifier, found keyword `use`
--> src/main.rs:2:1
|
2 | use std::net::SocketAddr;
| ^^^ expected identifier, found keyword
error: expected one of `,`, `::`, `as`, or `}`, found keyword `use`
--> src/main.rs:2:1
|
1 | use serde::{Deserialize, Serialize//};
| - unclosed delimiter - expected one of `,`, `::`, `as`, or `}`
2 | use std::net::SocketAddr;
| ^^^ unexpected token
|
help: `}` may belong here
|
1 | use serde::{Deserialize, Serialize}//};
| ^
help: missing `,`
|
1 | use serde::{Deserialize, Serialize,//};
| ^
error: expected one of `,`, `::`, `as`, or `}`, found `std`
--> src/main.rs:2:5
|
2 | use std::net::SocketAddr;
| -^^^ expected one of `,`, `::`, `as`, or `}`
| |
| help: missing `,`
error: expected identifier, found keyword `fn`
--> src/main.rs:4:1
|
4 | fn main() {
| ^^ expected identifier, found keyword
error: expected one of `,`, `::`, `as`, or `}`, found `;`
--> src/main.rs:2:25
|
2 | use std::net::SocketAddr;
| ^
| |
| expected one of `,`, `::`, `as`, or `}`
| help: missing `,`
error: expected one of `,`, `::`, `as`, or `}`, found `main`
--> src/main.rs:4:4
|
4 | fn main() {
| -^^^^ expected one of `,`, `::`, `as`, or `}`
| |
| help: missing `,`
error: expected one of `,`, `::`, `as`, or `}`, found `(`
--> src/main.rs:4:8
|
4 | fn main() {
| ^ expected one of `,`, `::`, `as`, or `}`
error: aborting due to 8 previous errors
error: could not compile `errortest`
To learn more, run the command again with --verbose.
Ideally the output should look like:
Checking errortest v0.1.0 (/home/frederik/Programmeren/rust/errortest)
error: this file contains an unclosed delimiter
--> src/main.rs:35:2
|
1 | use serde::{Deserialize, Serialize//};
| - unclosed delimiter
...
35 |
| ^
error: aborting due to 1 previous error
error: could not compile `errortest`
To learn more, run the command again with --verbose.
Also the placing of the unclosed delimiter warning arrow seems weird? I think it should point to where I put the // ? Usually rustc error output is pretty good at pointing to where I actually need to make a change.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Too much output caused by a single piece of incorrect code.Relevant to the compiler team, which will review and decide on the PR/issue.