Skip to content

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

Closed
@hkmatsumoto

Description

@hkmatsumoto

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions