-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Warning about non-local impl-definition in derive-macro output #131643
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.L-non_local_definitionsLint: non_local_definitionsLint: non_local_definitionsT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
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.L-non_local_definitionsLint: non_local_definitionsLint: non_local_definitionsT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
I tried this code:
I expected to see this happen: The code should compile without errors or warnings.
Instead, this happened: There is a warning: "warning: non-local
impldefinition,implblocks should be written at the same level as their item".This might seem very convoluted. It is a minimization of code generated by the savefile-derive crate when it is generating implementations of AbiExportable for traits returning boxed Fn-trait objects. It generates helper-types for these, and then effectively recurses, generating impls for these helpers types. That's why we get two levels of the
const _: () = {...}-trick. This trick is used by crates like savefile and serde, but I suppose serde doesn't end up recursing and is probably not affected by this issue.Version it worked on
It works in stable rust 1.81, and also in
rustc 1.83.0-nightly (52fd99839 2024-10-10).Version with regression
It does not work in
rustc 1.83.0-nightly (1bc403daa 2024-10-11).@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged