-
-
Notifications
You must be signed in to change notification settings - Fork 17.2k
False positive dead_code for const used as const generic argument during impl marker trait #128617
Copy link
Copy link
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.L-dead_codeLint: dead_codeLint: dead_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.L-dead_codeLint: dead_codeLint: dead_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
In the following snippet,
CONSTgets adead_codewarning. However,CONSTis most definitely used and the trait is also pub, so this warning seems incorrect.Removing
CONSTcauses the crate to no longer compile, and removing the impl would be a breaking change.Adding any function (i.e.
fn method();) to the trait and implementing it removes the warning as well. However, for marker traits this is not an option. It also clearly demonstrates thatCONSTis considered to be used despite being unaffected byfn method().Rust version: rustc 1.80.0 (0514789 2024-07-21)
This code compiles without warnings on 1.79.0 (rustc 1.79.0 (129f3b9 2024-06-10))
Warning:
Adding
method()removes the warning: