-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustc: Improve unexpected close delimiter hint #68987
Comments
It turns out a match { } block missing a line |
I wasted a minute or two trying to understand the first error message from code like: fn f(i: u32, j: u32) {
let res = String::new();
let mut cnt = i;
while cnt < j {
write!&mut res, " ");
}
} The error report is:
The first error is not helpful because the curly braces match perfectly. It is somewhat common to ignore all but the first error when you have mismatched delimiters, so even though the second error points to the error exactly, some won't notice it immediately. |
I ran into another instance of this confusing error here: async fn obstest() -> Result<impl Responder, MyError> {
let obs_connect = || -> Result<(obws::Version, Vec<obws::responses::scenes::Scene>)>, MyError) {
async {
let client = Client::connect("localhost", 4455, Some("1234567890")).await?;
let version = client.general().version().await?.obs_version;
let scene_list = client.scenes().list().await?.scenes;
Ok((version, scene_list))
}
}
if let Ok(version, scene_list) = obs_connect() {
Ok(HttpResponse::Ok().body(format!("Hello from OBS {:?}\nScenes are: {:?}", version, scene_list)))
} else {
Err(MyError { name: "test" })
}
} The error messages I get are:
Again the first error is misleading because it matches just fine, and as someone who just came back to messing around with Rust after a couple of years it took me a few minutes before I noticed the what the second error is saying. It also does not help that the first thing the second error highlights is again in fact correct. |
@rustbot claim |
…indentation, r=petrochenkov Improve unexpected close and mismatch delimiter hint in TokenTreesReader Fixes rust-lang#103882 Fixes rust-lang#68987 Fixes rust-lang#69259 The inner indentation mismatching will be covered by outer block, the new added function `report_error_prone_delim_block` will find out the error prone candidates for reporting.
…indentation, r=petrochenkov Improve unexpected close and mismatch delimiter hint in TokenTreesReader Fixes rust-lang#103882 Fixes rust-lang#68987 Fixes rust-lang#69259 The inner indentation mismatching will be covered by outer block, the new added function `report_error_prone_delim_block` will find out the error prone candidates for reporting.
I found writing rust often confused by missing closing "}" or ")" error message. when editting large file. the line number in error message is completely wrong, looking through my code the changes are no where near the line. It takes a long time for me to spot the syntax problem.
The text was updated successfully, but these errors were encountered: