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

Incorrect unused_braces when a proc macro is applied to a GAT type conversion #109473

Open
teor2345 opened this issue Mar 22, 2023 · 0 comments
Open
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@teor2345
Copy link
Contributor

teor2345 commented Mar 22, 2023

I tried this code:

use serde_derive::{Deserialize};

const BAR: u32 = 1;

#[derive(Deserialize)]
struct Generic<const ASSOCIATED: u8> {}

#[derive(Deserialize)]
struct FooDeserializable {
    item: Generic<{ BAR as u8 }>,
}

Full example - reproduces locally with serde 1.0.158 and 1.0.156, but not on the playground with serde 1.0.156:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=98ec53a2a8de5c14af46d88f45feda1c

I expected to see this happen:

No warnings, or a warning with a working fix.

Instead, this happened:

An incorrect warning that the braces were not needed around BAR as u8.
An incorrect suggestion/fix to remove those brances.

Meta

rustc --version --verbose:

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-unknown-linux-gnu
release: 1.68.0
LLVM version: 15.0.6

The bug also exists in beta and nightly.

The warning itself might be a serde_derive bug, but the incorrect fix is a Rust bug:
serde-rs/serde#2414

This seems similar to these non-proc macro bugs:
#73068
#88104

@teor2345 teor2345 added the C-bug Category: This is a bug. label Mar 22, 2023
@Nilstrieb Nilstrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants