Skip to content

Bad diagnostics span for unmatched angle brackets of generic args #94058

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

Closed
hkmatsumoto opened this issue Feb 16, 2022 · 0 comments · Fixed by #94495
Closed

Bad diagnostics span for unmatched angle brackets of generic args #94058

hkmatsumoto opened this issue Feb 16, 2022 · 0 comments · Fixed by #94495
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hkmatsumoto
Copy link
Member

Given the following code: Playground link

use std::sync::{Arc, Mutex};

pub struct Foo {
    a: Mutex<usize>,
    b: Arc<Mutex<usize>, // an not-ok line
    c: Arc<Mutex<usize>>, // an ok line
}

The current output is:

error: expected one of `>`, a const expression, lifetime, or type, found `}`
 --> src/lib.rs:7:1
  |
6 |     c: Arc<Mutex<usize>>, // an ok line
  |                          - expected one of `>`, a const expression, lifetime, or type
7 | }
  | ^ unexpected token

Ideally the output should look like:

error: expected one of `>`, a const expression, lifetime, or type, found `}`
 --> src/lib.rs:6:1
  |
5 |     b: Arc<Mutex<usize>, // an not-ok line
  |                         - expected one of `>`, a const expression, lifetime, or type
6 | }
  | ^ unexpected token
@hkmatsumoto hkmatsumoto added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 16, 2022
@estebank estebank added A-parser Area: The lexing & parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. labels Mar 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 27, 2022
Provide suggestion for missing `>` in a type parameter list

When encountering an inproperly terminated type parameter list, provide
a suggestion to close it after the last non-constraint type parameter
that was successfully parsed.

Fix rust-lang#94058.
@bors bors closed this as completed in 6874bd2 Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants