Skip to content

Incorrect error for type already defined in scope using raw identifiers #69054

Closed

Description

This code

trait T<r#fn> {
    fn f<r#fn>() {}
}

fn main() {}

(Playground)

Gives incorrect error for type declared using raw identifiers:

error[E0403]: the name `fn` is already used for a generic parameter in this item's generic parameters
 --> src/main.rs:2:10
  |
1 | trait T<r#fn> {
  |         ---- first use of `fn`
2 |     fn f<r#fn>() {}
  |          ^^^^ already used

warning: type parameter `fn` should have an upper camel case name
 --> src/main.rs:1:9
  |
1 | trait T<r#fn> {
  |         ^^^^ help: convert the identifier to upper camel case: `Fn`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

warning: type parameter `fn` should have an upper camel case name
 --> src/main.rs:2:10
  |
2 |     fn f<r#fn>() {}
  |          ^^^^ help: convert the identifier to upper camel case: `Fn`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0403`.
error: could not compile `playground`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.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