`non_local_definitions` triggers on macro-generated code

I tried this code:

> cargo new foo && cd foo
    Creating binary (application) `foo` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

> cargo add displaydoc
    Updating crates.io index
      Adding displaydoc v0.2.4 to dependencies
             Features:
             + std
    Updating crates.io index
     Locking 6 packages to latest compatible versions

> echo '#[derive(displaydoc::Display)] pub enum Foo { #[doc = "test"] Test }' >> src/main.rs

I expected to see this happen: no warnings

Instead, this happened:

> cargo check
    Checking foo v0.1.0 (/tmp/scratch.rust.2024-05-28T21-14.UGSjii/foo)
warning: non-local `impl` definition, they should be avoided as they go against expectation
 --> src/main.rs:4:10
  |
4 | #[derive(displaydoc::Display)] pub enum Foo { #[doc = "test"] Test }
  |          ^^^^^^^^^^^^^^^^^^^
  |
  = help: move this `impl` block outside the of the current constant `_DERIVE_Display_FOR_Foo`
  = note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl`
  = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
  = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
  = note: the derive macro `displaydoc::Display` may come from an old version of the `displaydoc` crate, try updating your dependency with `cargo update -p displaydoc`
  = note: `#[warn(non_local_definitions)]` on by default
  = note: this warning originates in the derive macro `displaydoc::Display` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `foo` (bin "foo") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s

Meta

rustc --version --verbose:

rustc 1.80.0 (84b40fc90 2024-05-27)
binary: rustc
commit-hash: 84b40fc908c3adc7e0e470b3fbaa264df0e122b8
commit-date: 2024-05-27
host: x86_64-unknown-linux-gnu
release: 1.80.0
LLVM version: 18.1.6

cc #120363