Skip to content
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

Raw identifiers do not work inside generic types #431

Open
dtolnay opened this issue Dec 27, 2024 · 0 comments
Open

Raw identifiers do not work inside generic types #431

dtolnay opened this issue Dec 27, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@dtolnay
Copy link

dtolnay commented Dec 27, 2024

Both of the following generate a working impl:

#[derive(Display)]
#[display("{thing}")]
struct Struct<T> {
    thing: T,  // generic
}
#[derive(Display)]
#[display("{thing}")]
struct Struct {
    r#thing: i32,  // raw
}

but this generates an impl that does not compile.

#[derive(Display)]
#[display("{thing}")]
struct Struct<T> {
    r#thing: T,  // raw, generic
}
error[E0277]: `T` doesn't implement `derive_more::Display`
 --> src/main.rs:3:10
  |
3 | #[derive(Display)]
  |          ^^^^^^^ `T` cannot be formatted with the default formatter
  |
  = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
  = note: required for `&T` to implement `derive_more::Display`
  = note: this error originates in the derive macro `Display` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `T` with trait `Display`
  |
5 | struct Struct<T: derive_more::Display> {
  |                ++++++++++++++++++++++
@tyranron tyranron self-assigned this Dec 30, 2024
@tyranron tyranron added the bug label Dec 30, 2024
@tyranron tyranron added this to the 2.0.0 milestone Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants