From e7c48db298cb75b539760d99e999a585e52eafb2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 25 Feb 2024 22:18:20 -0800 Subject: [PATCH] Ignore non_local_definitions warning in macro-generated impls This macro needs to be redesigned if this ever becomes a hard error. warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_generics.rs:7:1 | 7 | / library! { 8 | | use simple { 9 | | trait Simple { 10 | | fn simple(); ... | 14 | | } 15 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `simple` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the macro `library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_parse_trait_objects.rs:6:1 | 6 | / library! { 7 | | use Mod { 8 | | type Struct; 9 | | trait Trait {} ... | 16 | | } 17 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `single_dyn` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the macro `library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_parse_trait_objects.rs:6:1 | 6 | / library! { 7 | | use Mod { 8 | | type Struct; 9 | | trait Trait {} ... | 16 | | } 17 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `double_dyn` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: this warning originates in the macro `library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_zero_args.rs:7:1 | 7 | / library! { 8 | | use zero { 9 | | trait Zero { 10 | | fn zero(); 11 | | } 12 | | } 13 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `zero` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the macro `library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_field_access.rs:36:1 | 36 | / library! { 37 | | use base { 38 | | type FieldAccessor; 39 | | impl FieldAccessor { ... | 46 | | } 47 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `access_field` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the macro `library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_field_access.rs:36:1 | 36 | / library! { 37 | | use base { 38 | | type FieldAccessor; 39 | | impl FieldAccessor { ... | 46 | | } 47 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `trivial` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: this warning originates in the macro `library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_tuple.rs:7:1 | 7 | / library! { 8 | | use tuple { 9 | | type One; 10 | | type Two; ... | 15 | | } 16 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `swap` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the macro `library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_displaydoc.rs:16:1 | 16 | / reflect::library! { 17 | | extern crate std { 18 | | mod fmt { 19 | | type Formatter; ... | 28 | | } 29 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `fmt` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `reflect::library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the macro `reflect::library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/debug/mod.rs:10:1 | 10 | / reflect::library! { 11 | | extern crate std { 12 | | mod fmt { 13 | | type Formatter; ... | 30 | | } 31 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `fmt` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `reflect::library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the macro `reflect::library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/debug/mod.rs:10:1 | 10 | / reflect::library! { 11 | | extern crate std { 12 | | mod fmt { 13 | | type Formatter; ... | 30 | | } 31 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `debug_struct` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `reflect::library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: this warning originates in the macro `reflect::library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/debug/mod.rs:10:1 | 10 | / reflect::library! { 11 | | extern crate std { 12 | | mod fmt { 13 | | type Formatter; ... | 30 | | } 31 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `field` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `reflect::library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: this warning originates in the macro `reflect::library` (in Nightly builds, run with -Z macro-backtrace for more info) warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/debug/mod.rs:10:1 | 10 | / reflect::library! { 11 | | extern crate std { 12 | | mod fmt { 13 | | type Formatter; ... | 30 | | } 31 | | } | |_^ | = help: move this `impl` block outside the of the current associated function `finish` = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block = 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 = note: the macro `reflect::library` may come from an old version of the `reflect_internal` crate, try updating your dependency with `cargo update -p reflect_internal` = note: this warning originates in the macro `reflect::library` (in Nightly builds, run with -Z macro-backtrace for more info) --- macros/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 4750344..aae0c46 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -451,6 +451,7 @@ fn declare_function(parent: &Ident, function: &Function) -> TokenStream2 { } } + #[allow(unknown_lints, non_local_definitions)] impl #parent { #[allow(non_upper_case_globals)] pub const #name: #name = #name;