JelteF / derive_more

Some more derive(Trait) options
MIT License
1.73k stars 123 forks source link

Non-local `impl` definition warning #366

Open TylerBloom opened 5 months ago

TylerBloom commented 5 months ago

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.

tyranron commented 4 months ago

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

TylerBloom commented 4 months ago

Using that, I get a compile-time panic:

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

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.