derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Non-local `impl` definition warning

Open TylerBloom opened this issue 1 year ago • 3 comments
trafficstars

While using the Rust beta release, I got a some warning around derived Display impls. The exact warning message is below:

warning: non-local `impl` definition, they should be avoided as they go against expectation
   --> spirit/src/lookup.rs:609:68
    |
609 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, From, IsVariant, derive_more::Display)]
    |                                                                    ^^^^^^^^^^^^^^^^^^^^
    |
    = help: move this `impl` block outside the of the current constant `_derive_more_DisplayAs_impl` and up 2 bodies
    = 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 `derive_more::Display` may come from an old version of the `derive_more` crate, try updating your dependency with `cargo update -p derive_more`
    = note: this warning originates in the derive macro `derive_more::Display` (in Nightly builds, run with -Z macro-backtrace for more info)

In the message, they link to an tracking issue.

Because this is on the beta channel, this warning will soon be on by default for anyone that updates their stable Rust version. I thought I would rise the issue now, and maybe it can be addressed before you get a much of duplicate issues.

TylerBloom avatar Jun 03 '24 19:06 TylerBloom

@TylerBloom is this reproducible on 1.0.0-beta.6?

tyranron avatar Jun 12 '24 09:06 tyranron

Using that, I get a compile-time panic:

proc-macro derive panicked
message: not yet implemented: https://github.com/JelteF/derive_more/issues/142

TylerBloom avatar Jun 12 '24 18:06 TylerBloom

Can you share codesnipped that causes this warning?

Also could you try with this PR: https://github.com/JelteF/derive_more/pull/377 That should solve the "not yet implemented" error.

JelteF avatar Jul 02 '24 11:07 JelteF