Skip to content

Commit

Permalink
Ignore non_local_definitions warning in macro-generated impls
Browse files Browse the repository at this point in the history
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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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 <rust-lang/rust#120363>
       = 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)
  • Loading branch information
dtolnay committed Feb 26, 2024
1 parent 26275ea commit e7c48db
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e7c48db

Please sign in to comment.