Skip to content

Incorrect help message for type declared on struct using raw identifier #69053

Open
@olegnn

Description

@olegnn

This code

struct r#struct<r#fn>;

fn main() {}

(Playground)

Produces incorrect help message:

   Compiling playground v0.0.1 (/playground)
warning: type `struct` should have an upper camel case name
 --> src/main.rs:1:8
  |
1 | struct r#struct<r#fn>;
  |        ^^^^^^^^ help: convert the identifier to upper camel case: `Struct`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

warning: type parameter `fn` should have an upper camel case name
 --> src/main.rs:1:17
  |
1 | struct r#struct<r#fn>;
  |                 ^^^^ help: convert the identifier to upper camel case: `Fn`

error[E0392]: parameter `fn` is never used
 --> src/main.rs:1:17
  |
1 | struct r#struct<r#fn>;
  |                 ^^^^ unused parameter
  |
  = help: consider removing `fn`, referring to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0392`.
error: could not compile `playground`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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