mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
Split non_local_definitions
lint tests in separate test files
This commit is contained in:
parent
0e3235f85b
commit
ddc16e98e6
20
tests/ui/lint/non-local-defs/cargo-update.rs
Normal file
20
tests/ui/lint/non-local-defs/cargo-update.rs
Normal file
@ -0,0 +1,20 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
//@ aux-build:non_local_macro.rs
|
||||
//
|
||||
// To suggest any Cargo specific help/note rustc wants
|
||||
// the `CARGO_CRATE_NAME` env to be set, so we set it
|
||||
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
|
||||
//
|
||||
// and since we specifically want to check the presence
|
||||
// of the `cargo update` suggestion we assert it here.
|
||||
//@ error-pattern: `cargo update -p non_local_macro`
|
||||
|
||||
extern crate non_local_macro;
|
||||
|
||||
struct LocalStruct;
|
||||
|
||||
non_local_macro::non_local_impl!(LocalStruct);
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
fn main() {}
|
16
tests/ui/lint/non-local-defs/cargo-update.stderr
Normal file
16
tests/ui/lint/non-local-defs/cargo-update.stderr
Normal file
@ -0,0 +1,16 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/cargo-update.rs:17:1
|
||||
|
|
||||
LL | non_local_macro::non_local_impl!(LocalStruct);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `_IMPL_DEBUG`
|
||||
= 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 macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
|
||||
= note: `#[warn(non_local_definitions)]` on by default
|
||||
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
88
tests/ui/lint/non-local-defs/consts.rs
Normal file
88
tests/ui/lint/non-local-defs/consts.rs
Normal file
@ -0,0 +1,88 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
|
||||
|
||||
#![feature(inline_const)]
|
||||
|
||||
struct Test;
|
||||
|
||||
trait Uto {}
|
||||
const Z: () = {
|
||||
trait Uto1 {}
|
||||
|
||||
impl Uto1 for Test {} // the trait is local, don't lint
|
||||
|
||||
impl Uto for &Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
};
|
||||
|
||||
trait Ano {}
|
||||
const _: () = {
|
||||
impl Ano for &Test {} // ignored since the parent is an anon-const
|
||||
};
|
||||
|
||||
trait Uto2 {}
|
||||
static A: u32 = {
|
||||
impl Uto2 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
trait Uto3 {}
|
||||
const B: u32 = {
|
||||
impl Uto3 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
trait Uto4 {}
|
||||
impl Uto4 for Test {}
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
trait Uto5 {}
|
||||
fn main() {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
|
||||
const {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn hoo() {}
|
||||
}
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
const _: u32 = {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn foo2() {}
|
||||
}
|
||||
|
||||
1
|
||||
};
|
||||
}
|
||||
|
||||
trait Uto9 {}
|
||||
trait Uto10 {}
|
||||
const _: u32 = {
|
||||
let _a = || {
|
||||
impl Uto9 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
type A = [u32; {
|
||||
impl Uto10 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
1
|
||||
};
|
103
tests/ui/lint/non-local-defs/consts.stderr
Normal file
103
tests/ui/lint/non-local-defs/consts.stderr
Normal file
@ -0,0 +1,103 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:15:5
|
||||
|
|
||||
LL | const Z: () = {
|
||||
| - help: use a const-anon item to suppress this lint: `_`
|
||||
...
|
||||
LL | impl Uto for &Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `Z`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:26:5
|
||||
|
|
||||
LL | impl Uto2 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current static `A`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:34:5
|
||||
|
|
||||
LL | impl Uto3 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `B`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:45:5
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn foo() {}
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:52:9
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn hoo() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current inline constant `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:61:9
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn foo2() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `_` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:74:9
|
||||
|
|
||||
LL | impl Uto9 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current closure `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/consts.rs:81:9
|
||||
|
|
||||
LL | impl Uto10 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: 8 warnings emitted
|
||||
|
48
tests/ui/lint/non-local-defs/exhaustive-trait.rs
Normal file
48
tests/ui/lint/non-local-defs/exhaustive-trait.rs
Normal file
@ -0,0 +1,48 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
|
||||
struct Dog;
|
||||
|
||||
fn main() {
|
||||
impl PartialEq<()> for Dog {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &()) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<()> for &Dog {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &()) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<Dog> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &Dog) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<&Dog> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &&Dog) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<Dog> for &Dog {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &Dog) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<&Dog> for &Dog {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &&Dog) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
99
tests/ui/lint/non-local-defs/exhaustive-trait.stderr
Normal file
99
tests/ui/lint/non-local-defs/exhaustive-trait.stderr
Normal file
@ -0,0 +1,99 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive-trait.rs:7:5
|
||||
|
|
||||
LL | / impl PartialEq<()> for Dog {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &()) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive-trait.rs:14:5
|
||||
|
|
||||
LL | / impl PartialEq<()> for &Dog {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &()) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive-trait.rs:21:5
|
||||
|
|
||||
LL | / impl PartialEq<Dog> for () {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &Dog) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive-trait.rs:28:5
|
||||
|
|
||||
LL | / impl PartialEq<&Dog> for () {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &&Dog) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive-trait.rs:35:5
|
||||
|
|
||||
LL | / impl PartialEq<Dog> for &Dog {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &Dog) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive-trait.rs:42:5
|
||||
|
|
||||
LL | / impl PartialEq<&Dog> for &Dog {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &&Dog) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: 6 warnings emitted
|
||||
|
84
tests/ui/lint/non-local-defs/exhaustive.rs
Normal file
84
tests/ui/lint/non-local-defs/exhaustive.rs
Normal file
@ -0,0 +1,84 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
trait Trait {}
|
||||
struct Test;
|
||||
|
||||
fn main() {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
impl Display for Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl dyn Trait {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl<T: Trait> Trait for Vec<T> { }
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Trait for &dyn Trait {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Trait for *mut Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Trait for *mut [Test] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Trait for [Test; 8] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Trait for (Test,) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Trait for fn(Test) -> () {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Trait for fn() -> Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
let _a = || {
|
||||
impl Trait for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
struct InsideMain;
|
||||
|
||||
impl Trait for *mut InsideMain {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Trait for *mut [InsideMain] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Trait for [InsideMain; 8] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Trait for (InsideMain,) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Trait for fn(InsideMain) -> () {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Trait for fn() -> InsideMain {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
fn inside_inside() {
|
||||
impl Display for InsideMain {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl InsideMain {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn bar() {}
|
||||
}
|
||||
}
|
||||
}
|
239
tests/ui/lint/non-local-defs/exhaustive.stderr
Normal file
239
tests/ui/lint/non-local-defs/exhaustive.stderr
Normal file
@ -0,0 +1,239 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:10:5
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn foo() {}
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:15:5
|
||||
|
|
||||
LL | / impl Display for Test {
|
||||
LL | |
|
||||
LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:22:5
|
||||
|
|
||||
LL | impl dyn Trait {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:25:5
|
||||
|
|
||||
LL | impl<T: Trait> Trait for Vec<T> { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:28:5
|
||||
|
|
||||
LL | impl Trait for &dyn Trait {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:31:5
|
||||
|
|
||||
LL | impl Trait for *mut Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:34:5
|
||||
|
|
||||
LL | impl Trait for *mut [Test] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:37:5
|
||||
|
|
||||
LL | impl Trait for [Test; 8] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:40:5
|
||||
|
|
||||
LL | impl Trait for (Test,) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:43:5
|
||||
|
|
||||
LL | impl Trait for fn(Test) -> () {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:46:5
|
||||
|
|
||||
LL | impl Trait for fn() -> Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:50:9
|
||||
|
|
||||
LL | impl Trait for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current closure `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:58:5
|
||||
|
|
||||
LL | impl Trait for *mut InsideMain {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:60:5
|
||||
|
|
||||
LL | impl Trait for *mut [InsideMain] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:62:5
|
||||
|
|
||||
LL | impl Trait for [InsideMain; 8] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:64:5
|
||||
|
|
||||
LL | impl Trait for (InsideMain,) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:66:5
|
||||
|
|
||||
LL | impl Trait for fn(InsideMain) -> () {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:68:5
|
||||
|
|
||||
LL | impl Trait for fn() -> InsideMain {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:72:9
|
||||
|
|
||||
LL | / impl Display for InsideMain {
|
||||
LL | |
|
||||
LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `inside_inside` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/exhaustive.rs:79:9
|
||||
|
|
||||
LL | / impl InsideMain {
|
||||
LL | |
|
||||
LL | | fn bar() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `inside_inside` 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>
|
||||
|
||||
warning: 20 warnings emitted
|
||||
|
103
tests/ui/lint/non-local-defs/from-local-for-global.rs
Normal file
103
tests/ui/lint/non-local-defs/from-local-for-global.rs
Normal file
@ -0,0 +1,103 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
|
||||
#![feature(inline_const)]
|
||||
|
||||
struct Cat;
|
||||
struct Wrap<T>(T);
|
||||
|
||||
fn main() {
|
||||
impl From<Cat> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(_: Cat) -> () {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Elephant;
|
||||
|
||||
impl From<Wrap<Wrap<Elephant>>> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(_: Wrap<Wrap<Elephant>>) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait StillNonLocal {}
|
||||
|
||||
impl StillNonLocal for &str {}
|
||||
|
||||
fn only_global() {
|
||||
struct Foo;
|
||||
impl StillNonLocal for &Foo {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
|
||||
struct GlobalSameFunction;
|
||||
|
||||
fn same_function() {
|
||||
struct Local1(GlobalSameFunction);
|
||||
impl From<Local1> for GlobalSameFunction {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(x: Local1) -> GlobalSameFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
|
||||
struct Local2(GlobalSameFunction);
|
||||
impl From<Local2> for GlobalSameFunction {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(x: Local2) -> GlobalSameFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct GlobalDifferentFunction;
|
||||
|
||||
fn diff_function_1() {
|
||||
struct Local(GlobalDifferentFunction);
|
||||
|
||||
impl From<Local> for GlobalDifferentFunction {
|
||||
// FIXME(Urgau): Should warn but doesn't since we currently consider
|
||||
// the other impl to be "global", but that's not the case for the type-system
|
||||
fn from(x: Local) -> GlobalDifferentFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn diff_function_2() {
|
||||
struct Local(GlobalDifferentFunction);
|
||||
|
||||
impl From<Local> for GlobalDifferentFunction {
|
||||
// FIXME(Urgau): Should warn but doesn't since we currently consider
|
||||
// the other impl to be "global", but that's not the case for the type-system
|
||||
fn from(x: Local) -> GlobalDifferentFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/121621#issuecomment-1976826895
|
||||
fn commonly_reported() {
|
||||
struct Local(u8);
|
||||
impl From<Local> for u8 {
|
||||
fn from(x: Local) -> u8 {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/121621#issue-2153187542
|
||||
pub trait Serde {}
|
||||
|
||||
impl Serde for &[u8] {}
|
||||
impl Serde for &str {}
|
||||
|
||||
fn serde() {
|
||||
struct Thing;
|
||||
impl Serde for &Thing {}
|
||||
}
|
78
tests/ui/lint/non-local-defs/from-local-for-global.stderr
Normal file
78
tests/ui/lint/non-local-defs/from-local-for-global.stderr
Normal file
@ -0,0 +1,78 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/from-local-for-global.rs:10:5
|
||||
|
|
||||
LL | / impl From<Cat> for () {
|
||||
LL | |
|
||||
LL | | fn from(_: Cat) -> () {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/from-local-for-global.rs:20:5
|
||||
|
|
||||
LL | / impl From<Wrap<Wrap<Elephant>>> for () {
|
||||
LL | |
|
||||
LL | | fn from(_: Wrap<Wrap<Elephant>>) -> Self {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/from-local-for-global.rs:34:5
|
||||
|
|
||||
LL | impl StillNonLocal for &Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `only_global`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/from-local-for-global.rs:42:5
|
||||
|
|
||||
LL | / impl From<Local1> for GlobalSameFunction {
|
||||
LL | |
|
||||
LL | | fn from(x: Local1) -> GlobalSameFunction {
|
||||
LL | | x.0
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `same_function`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/from-local-for-global.rs:50:5
|
||||
|
|
||||
LL | / impl From<Local2> for GlobalSameFunction {
|
||||
LL | |
|
||||
LL | | fn from(x: Local2) -> GlobalSameFunction {
|
||||
LL | | x.0
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `same_function`
|
||||
= 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>
|
||||
|
||||
warning: 5 warnings emitted
|
||||
|
88
tests/ui/lint/non-local-defs/generics.rs
Normal file
88
tests/ui/lint/non-local-defs/generics.rs
Normal file
@ -0,0 +1,88 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
|
||||
trait Global {}
|
||||
|
||||
fn main() {
|
||||
trait Local {};
|
||||
|
||||
impl<T: Local> Global for Vec<T> { }
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
|
||||
trait Uto7 {}
|
||||
trait Uto8 {}
|
||||
|
||||
struct Test;
|
||||
|
||||
fn bad() {
|
||||
struct Local;
|
||||
impl Uto7 for Test where Local: std::any::Any {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl<T> Uto8 for T {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
|
||||
struct UwU<T>(T);
|
||||
|
||||
fn fun() {
|
||||
#[derive(Debug)]
|
||||
struct OwO;
|
||||
impl Default for UwU<OwO> {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn default() -> Self {
|
||||
UwU(OwO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn meow() {
|
||||
#[derive(Debug)]
|
||||
struct Cat;
|
||||
impl AsRef<Cat> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn as_ref(&self) -> &Cat { &Cat }
|
||||
}
|
||||
}
|
||||
|
||||
struct G;
|
||||
|
||||
fn fun2() {
|
||||
#[derive(Debug, Default)]
|
||||
struct B;
|
||||
impl PartialEq<B> for G {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &B) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Wrap<T>(T);
|
||||
|
||||
impl Wrap<Wrap<Wrap<()>>> {}
|
||||
|
||||
fn rawr() {
|
||||
struct Lion;
|
||||
|
||||
impl From<Wrap<Wrap<Lion>>> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(_: Wrap<Wrap<Lion>>) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<()> for Wrap<Lion> {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(_: ()) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn side_effects() {
|
||||
dbg!(().as_ref()); // prints `Cat`
|
||||
dbg!(UwU::default().0);
|
||||
let _ = G::eq(&G, dbg!(&<_>::default()));
|
||||
}
|
114
tests/ui/lint/non-local-defs/generics.stderr
Normal file
114
tests/ui/lint/non-local-defs/generics.stderr
Normal file
@ -0,0 +1,114 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:9:5
|
||||
|
|
||||
LL | impl<T: Local> Global for Vec<T> { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:20:5
|
||||
|
|
||||
LL | impl Uto7 for Test where Local: std::any::Any {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `bad`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:23:5
|
||||
|
|
||||
LL | impl<T> Uto8 for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `bad`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:32:5
|
||||
|
|
||||
LL | / impl Default for UwU<OwO> {
|
||||
LL | |
|
||||
LL | | fn default() -> Self {
|
||||
LL | | UwU(OwO)
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `fun`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:43:5
|
||||
|
|
||||
LL | / impl AsRef<Cat> for () {
|
||||
LL | |
|
||||
LL | | fn as_ref(&self) -> &Cat { &Cat }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `meow`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:54:5
|
||||
|
|
||||
LL | / impl PartialEq<B> for G {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &B) -> bool {
|
||||
LL | | true
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `fun2`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:69:5
|
||||
|
|
||||
LL | / impl From<Wrap<Wrap<Lion>>> for () {
|
||||
LL | |
|
||||
LL | | fn from(_: Wrap<Wrap<Lion>>) -> Self {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `rawr`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/generics.rs:76:5
|
||||
|
|
||||
LL | / impl From<()> for Wrap<Lion> {
|
||||
LL | |
|
||||
LL | | fn from(_: ()) -> Self {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `rawr`
|
||||
= 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>
|
||||
|
||||
warning: 8 warnings emitted
|
||||
|
17
tests/ui/lint/non-local-defs/inside-macro_rules.rs
Normal file
17
tests/ui/lint/non-local-defs/inside-macro_rules.rs
Normal file
@ -0,0 +1,17 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
|
||||
macro_rules! m {
|
||||
() => {
|
||||
trait MacroTrait {}
|
||||
struct OutsideStruct;
|
||||
fn my_func() {
|
||||
impl MacroTrait for OutsideStruct {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m!();
|
||||
|
||||
fn main() {}
|
18
tests/ui/lint/non-local-defs/inside-macro_rules.stderr
Normal file
18
tests/ui/lint/non-local-defs/inside-macro_rules.stderr
Normal file
@ -0,0 +1,18 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/inside-macro_rules.rs:9:13
|
||||
|
|
||||
LL | impl MacroTrait for OutsideStruct {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | m!();
|
||||
| ---- in this macro invocation
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `my_func`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
53
tests/ui/lint/non-local-defs/local.rs
Normal file
53
tests/ui/lint/non-local-defs/local.rs
Normal file
@ -0,0 +1,53 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
trait GlobalTrait {}
|
||||
|
||||
fn main() {
|
||||
struct InsideMain;
|
||||
|
||||
impl InsideMain {
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
impl GlobalTrait for InsideMain {}
|
||||
|
||||
impl Debug for InsideMain {
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<()> for InsideMain {
|
||||
fn eq(&self, _: &()) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn dyn_weirdness() {
|
||||
trait LocalTrait {}
|
||||
impl dyn LocalTrait {}
|
||||
impl GlobalTrait for dyn LocalTrait {}
|
||||
}
|
||||
|
||||
struct Test;
|
||||
mod do_not_lint_mod {
|
||||
pub trait Tait {}
|
||||
|
||||
impl super::Test {
|
||||
fn hugo() {}
|
||||
}
|
||||
|
||||
impl Tait for super::Test {}
|
||||
}
|
||||
|
||||
fn bitflags() {
|
||||
struct Flags;
|
||||
|
||||
const _: () = {
|
||||
impl Flags {}
|
||||
};
|
||||
}
|
33
tests/ui/lint/non-local-defs/macro_rules.rs
Normal file
33
tests/ui/lint/non-local-defs/macro_rules.rs
Normal file
@ -0,0 +1,33 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
//@ aux-build:non_local_macro.rs
|
||||
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
|
||||
|
||||
extern crate non_local_macro;
|
||||
|
||||
const B: u32 = {
|
||||
#[macro_export]
|
||||
macro_rules! m0 { () => { } };
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
non_local_macro::non_local_macro_rules!(my_macro);
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
|
||||
fn main() {
|
||||
#[macro_export]
|
||||
macro_rules! m { () => { } };
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
|
||||
struct InsideMain;
|
||||
|
||||
impl InsideMain {
|
||||
fn bar() {
|
||||
#[macro_export]
|
||||
macro_rules! m2 { () => { } };
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
}
|
||||
}
|
||||
}
|
49
tests/ui/lint/non-local-defs/macro_rules.stderr
Normal file
49
tests/ui/lint/non-local-defs/macro_rules.stderr
Normal file
@ -0,0 +1,49 @@
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/macro_rules.rs:10:5
|
||||
|
|
||||
LL | macro_rules! m0 { () => { } };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/macro_rules.rs:16:1
|
||||
|
|
||||
LL | non_local_macro::non_local_macro_rules!(my_macro);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `_MACRO_EXPORT`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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 macro `non_local_macro::non_local_macro_rules` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
|
||||
= note: this warning originates in the macro `non_local_macro::non_local_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/macro_rules.rs:21:5
|
||||
|
|
||||
LL | macro_rules! m { () => { } };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current function `main`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/macro_rules.rs:29:13
|
||||
|
|
||||
LL | macro_rules! m2 { () => { } };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current associated function `bar` and up 2 bodies
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
53
tests/ui/lint/non-local-defs/weird-exprs.rs
Normal file
53
tests/ui/lint/non-local-defs/weird-exprs.rs
Normal file
@ -0,0 +1,53 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
|
||||
trait Uto {}
|
||||
struct Test;
|
||||
|
||||
type A = [u32; {
|
||||
impl Uto for *mut Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
enum Enum {
|
||||
Discr = {
|
||||
impl Uto for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _array = [0i32; {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn bar() {}
|
||||
}
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
type A = [u32; {
|
||||
impl Uto for &Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
fn a(_: [u32; {
|
||||
impl Uto for &(Test,) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}]) {}
|
||||
|
||||
fn b() -> [u32; {
|
||||
impl Uto for &(Test,Test) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}] { todo!() }
|
||||
}
|
72
tests/ui/lint/non-local-defs/weird-exprs.stderr
Normal file
72
tests/ui/lint/non-local-defs/weird-exprs.stderr
Normal file
@ -0,0 +1,72 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/weird-exprs.rs:8:5
|
||||
|
|
||||
LL | impl Uto for *mut Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/weird-exprs.rs:16:9
|
||||
|
|
||||
LL | impl Uto for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/weird-exprs.rs:25:9
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn bar() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/weird-exprs.rs:34:9
|
||||
|
|
||||
LL | impl Uto for &Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/weird-exprs.rs:41:9
|
||||
|
|
||||
LL | impl Uto for &(Test,) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/weird-exprs.rs:48:9
|
||||
|
|
||||
LL | impl Uto for &(Test,Test) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: 6 warnings emitted
|
||||
|
@ -1,491 +0,0 @@
|
||||
//@ check-pass
|
||||
//@ edition:2021
|
||||
//@ aux-build:non_local_macro.rs
|
||||
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
|
||||
|
||||
#![feature(inline_const)]
|
||||
|
||||
extern crate non_local_macro;
|
||||
|
||||
use std::fmt::{Debug, Display};
|
||||
|
||||
struct Test;
|
||||
|
||||
impl Debug for Test {
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
mod do_not_lint_mod {
|
||||
pub trait Tait {}
|
||||
|
||||
impl super::Test {
|
||||
fn hugo() {}
|
||||
}
|
||||
|
||||
impl Tait for super::Test {}
|
||||
}
|
||||
|
||||
trait Uto {}
|
||||
const Z: () = {
|
||||
trait Uto1 {}
|
||||
|
||||
impl Uto1 for Test {} // the trait is local, don't lint
|
||||
|
||||
impl Uto for &Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
};
|
||||
|
||||
trait Ano {}
|
||||
const _: () = {
|
||||
impl Ano for &Test {} // ignored since the parent is an anon-const
|
||||
};
|
||||
|
||||
type A = [u32; {
|
||||
impl Uto for *mut Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
enum Enum {
|
||||
Discr = {
|
||||
impl Uto for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
trait Uto2 {}
|
||||
static A: u32 = {
|
||||
impl Uto2 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
trait Uto3 {}
|
||||
const B: u32 = {
|
||||
impl Uto3 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! m0 { () => { } };
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
|
||||
trait Uto4 {}
|
||||
impl Uto4 for Test {}
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
trait Uto5 {}
|
||||
fn main() {
|
||||
#[macro_export]
|
||||
macro_rules! m { () => { } };
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
let _array = [0i32; {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn bar() {}
|
||||
}
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
const {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn hoo() {}
|
||||
}
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
const _: u32 = {
|
||||
impl Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn foo2() {}
|
||||
}
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
impl Display for Test {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl dyn Uto5 {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl<T: Uto5> Uto5 for Vec<T> { }
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Uto5 for &dyn Uto5 {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Uto5 for *mut Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Uto5 for *mut [Test] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Uto5 for [Test; 8] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Uto5 for (Test,) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Uto5 for fn(Test) -> () {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Uto5 for fn() -> Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
let _a = || {
|
||||
impl Uto5 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
type A = [u32; {
|
||||
impl Uto5 for &Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
fn a(_: [u32; {
|
||||
impl Uto5 for &(Test,) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}]) {}
|
||||
|
||||
fn b() -> [u32; {
|
||||
impl Uto5 for &(Test,Test) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}] { todo!() }
|
||||
|
||||
struct InsideMain;
|
||||
|
||||
impl Uto5 for *mut InsideMain {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Uto5 for *mut [InsideMain] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Uto5 for [InsideMain; 8] {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Uto5 for (InsideMain,) {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Uto5 for fn(InsideMain) -> () {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
impl Uto5 for fn() -> InsideMain {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl Debug for InsideMain {
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl InsideMain {
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
fn inside_inside() {
|
||||
impl Display for InsideMain {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl InsideMain {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn bar() {
|
||||
#[macro_export]
|
||||
macro_rules! m2 { () => { } };
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait Uto6 {}
|
||||
impl dyn Uto6 {}
|
||||
impl Uto5 for dyn Uto6 {}
|
||||
|
||||
impl<T: Uto6> Uto3 for Vec<T> { }
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
|
||||
trait Uto7 {}
|
||||
trait Uto8 {}
|
||||
|
||||
fn bad() {
|
||||
struct Local;
|
||||
impl Uto7 for Test where Local: std::any::Any {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
impl<T> Uto8 for T {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
|
||||
trait Uto9 {}
|
||||
trait Uto10 {}
|
||||
const _: u32 = {
|
||||
let _a = || {
|
||||
impl Uto9 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
type A = [u32; {
|
||||
impl Uto10 for Test {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
1
|
||||
}];
|
||||
|
||||
1
|
||||
};
|
||||
|
||||
struct UwU<T>(T);
|
||||
|
||||
fn fun() {
|
||||
#[derive(Debug)]
|
||||
struct OwO;
|
||||
impl Default for UwU<OwO> {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn default() -> Self {
|
||||
UwU(OwO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Cat;
|
||||
|
||||
fn meow() {
|
||||
impl From<Cat> for () {
|
||||
fn from(_: Cat) -> () {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Cat;
|
||||
impl AsRef<Cat> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn as_ref(&self) -> &Cat { &Cat }
|
||||
}
|
||||
}
|
||||
|
||||
struct G;
|
||||
|
||||
fn fun2() {
|
||||
#[derive(Debug, Default)]
|
||||
struct B;
|
||||
impl PartialEq<B> for G {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &B) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn side_effects() {
|
||||
dbg!(().as_ref()); // prints `Cat`
|
||||
dbg!(UwU::default().0);
|
||||
let _ = G::eq(&G, dbg!(&<_>::default()));
|
||||
}
|
||||
|
||||
struct Dog;
|
||||
|
||||
fn woof() {
|
||||
impl PartialEq<Dog> for &Dog {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &Dog) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<()> for Dog {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &()) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<()> for &Dog {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &()) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<Dog> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn eq(&self, _: &Dog) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
struct Test;
|
||||
impl PartialEq<Dog> for Test {
|
||||
fn eq(&self, _: &Dog) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Wrap<T>(T);
|
||||
|
||||
impl Wrap<Wrap<Wrap<()>>> {}
|
||||
|
||||
fn rawr() {
|
||||
struct Lion;
|
||||
|
||||
impl From<Wrap<Wrap<Lion>>> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(_: Wrap<Wrap<Lion>>) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<()> for Wrap<Lion> {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(_: ()) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Elephant;
|
||||
|
||||
impl From<Wrap<Wrap<Elephant>>> for () {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(_: Wrap<Wrap<Elephant>>) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait StillNonLocal {}
|
||||
|
||||
impl StillNonLocal for &str {}
|
||||
|
||||
fn only_global() {
|
||||
struct Foo;
|
||||
impl StillNonLocal for &Foo {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
|
||||
struct GlobalSameFunction;
|
||||
|
||||
fn same_function() {
|
||||
struct Local1(GlobalSameFunction);
|
||||
impl From<Local1> for GlobalSameFunction {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(x: Local1) -> GlobalSameFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
|
||||
struct Local2(GlobalSameFunction);
|
||||
impl From<Local2> for GlobalSameFunction {
|
||||
//~^ WARN non-local `impl` definition
|
||||
fn from(x: Local2) -> GlobalSameFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct GlobalDifferentFunction;
|
||||
|
||||
fn diff_foo() {
|
||||
struct Local(GlobalDifferentFunction);
|
||||
|
||||
impl From<Local> for GlobalDifferentFunction {
|
||||
// FIXME(Urgau): Should warn but doesn't since we currently consider
|
||||
// the other impl to be "global", but that's not the case for the type-system
|
||||
fn from(x: Local) -> GlobalDifferentFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn diff_bar() {
|
||||
struct Local(GlobalDifferentFunction);
|
||||
|
||||
impl From<Local> for GlobalDifferentFunction {
|
||||
// FIXME(Urgau): Should warn but doesn't since we currently consider
|
||||
// the other impl to be "global", but that's not the case for the type-system
|
||||
fn from(x: Local) -> GlobalDifferentFunction {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! m {
|
||||
() => {
|
||||
trait MacroTrait {}
|
||||
struct OutsideStruct;
|
||||
fn my_func() {
|
||||
impl MacroTrait for OutsideStruct {}
|
||||
//~^ WARN non-local `impl` definition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m!();
|
||||
|
||||
struct CargoUpdate;
|
||||
|
||||
non_local_macro::non_local_impl!(CargoUpdate);
|
||||
//~^ WARN non-local `impl` definition
|
||||
|
||||
non_local_macro::non_local_macro_rules!(my_macro);
|
||||
//~^ WARN non-local `macro_rules!` definition
|
||||
|
||||
fn bitflags() {
|
||||
struct Flags;
|
||||
|
||||
const _: () = {
|
||||
impl Flags {}
|
||||
};
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/121621#issuecomment-1976826895
|
||||
fn commonly_reported() {
|
||||
struct Local(u8);
|
||||
impl From<Local> for u8 {
|
||||
fn from(x: Local) -> u8 {
|
||||
x.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/121621#issue-2153187542
|
||||
pub trait Serde {}
|
||||
|
||||
impl Serde for &[u8] {}
|
||||
impl Serde for &str {}
|
||||
|
||||
fn serde() {
|
||||
struct Thing;
|
||||
impl Serde for &Thing {}
|
||||
}
|
@ -1,705 +0,0 @@
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:36:5
|
||||
|
|
||||
LL | const Z: () = {
|
||||
| - help: use a const-anon item to suppress this lint: `_`
|
||||
...
|
||||
LL | impl Uto for &Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `Z`
|
||||
= 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: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:46:5
|
||||
|
|
||||
LL | impl Uto for *mut Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:54:9
|
||||
|
|
||||
LL | impl Uto for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:63:5
|
||||
|
|
||||
LL | impl Uto2 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current static `A`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:71:5
|
||||
|
|
||||
LL | impl Uto3 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `B`
|
||||
= 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>
|
||||
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:75:5
|
||||
|
|
||||
LL | macro_rules! m0 { () => { } };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:87:5
|
||||
|
|
||||
LL | macro_rules! m { () => { } };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current function `main`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:90:5
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn foo() {}
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:96:9
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn bar() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:105:9
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn hoo() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current inline constant `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:114:9
|
||||
|
|
||||
LL | / impl Test {
|
||||
LL | |
|
||||
LL | | fn foo2() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `_` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:122:5
|
||||
|
|
||||
LL | / impl Display for Test {
|
||||
LL | |
|
||||
LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:129:5
|
||||
|
|
||||
LL | impl dyn Uto5 {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:132:5
|
||||
|
|
||||
LL | impl<T: Uto5> Uto5 for Vec<T> { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:135:5
|
||||
|
|
||||
LL | impl Uto5 for &dyn Uto5 {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:138:5
|
||||
|
|
||||
LL | impl Uto5 for *mut Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:141:5
|
||||
|
|
||||
LL | impl Uto5 for *mut [Test] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:144:5
|
||||
|
|
||||
LL | impl Uto5 for [Test; 8] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:147:5
|
||||
|
|
||||
LL | impl Uto5 for (Test,) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:150:5
|
||||
|
|
||||
LL | impl Uto5 for fn(Test) -> () {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:153:5
|
||||
|
|
||||
LL | impl Uto5 for fn() -> Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:157:9
|
||||
|
|
||||
LL | impl Uto5 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current closure `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:164:9
|
||||
|
|
||||
LL | impl Uto5 for &Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:171:9
|
||||
|
|
||||
LL | impl Uto5 for &(Test,) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:178:9
|
||||
|
|
||||
LL | impl Uto5 for &(Test,Test) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:186:5
|
||||
|
|
||||
LL | impl Uto5 for *mut InsideMain {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:188:5
|
||||
|
|
||||
LL | impl Uto5 for *mut [InsideMain] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:190:5
|
||||
|
|
||||
LL | impl Uto5 for [InsideMain; 8] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:192:5
|
||||
|
|
||||
LL | impl Uto5 for (InsideMain,) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:194:5
|
||||
|
|
||||
LL | impl Uto5 for fn(InsideMain) -> () {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:196:5
|
||||
|
|
||||
LL | impl Uto5 for fn() -> InsideMain {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:210:9
|
||||
|
|
||||
LL | / impl Display for InsideMain {
|
||||
LL | |
|
||||
LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `inside_inside` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:217:9
|
||||
|
|
||||
LL | / impl InsideMain {
|
||||
LL | |
|
||||
LL | | fn bar() {
|
||||
LL | | #[macro_export]
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `inside_inside` 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>
|
||||
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:221:17
|
||||
|
|
||||
LL | macro_rules! m2 { () => { } };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current associated function `bar` and up 3 bodies
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:231:5
|
||||
|
|
||||
LL | impl<T: Uto6> Uto3 for Vec<T> { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `main`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:240:5
|
||||
|
|
||||
LL | impl Uto7 for Test where Local: std::any::Any {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `bad`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:243:5
|
||||
|
|
||||
LL | impl<T> Uto8 for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `bad`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:251:9
|
||||
|
|
||||
LL | impl Uto9 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current closure `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:258:9
|
||||
|
|
||||
LL | impl Uto10 for Test {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant expression `<unnameable>` 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:272:5
|
||||
|
|
||||
LL | / impl Default for UwU<OwO> {
|
||||
LL | |
|
||||
LL | | fn default() -> Self {
|
||||
LL | | UwU(OwO)
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `fun`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:291:5
|
||||
|
|
||||
LL | / impl AsRef<Cat> for () {
|
||||
LL | |
|
||||
LL | | fn as_ref(&self) -> &Cat { &Cat }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `meow`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:302:5
|
||||
|
|
||||
LL | / impl PartialEq<B> for G {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &B) -> bool {
|
||||
LL | | true
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `fun2`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:319:5
|
||||
|
|
||||
LL | / impl PartialEq<Dog> for &Dog {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &Dog) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `woof`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:326:5
|
||||
|
|
||||
LL | / impl PartialEq<()> for Dog {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &()) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `woof`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:333:5
|
||||
|
|
||||
LL | / impl PartialEq<()> for &Dog {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &()) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `woof`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:340:5
|
||||
|
|
||||
LL | / impl PartialEq<Dog> for () {
|
||||
LL | |
|
||||
LL | | fn eq(&self, _: &Dog) -> bool {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `woof`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:362:5
|
||||
|
|
||||
LL | / impl From<Wrap<Wrap<Lion>>> for () {
|
||||
LL | |
|
||||
LL | | fn from(_: Wrap<Wrap<Lion>>) -> Self {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `rawr`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:369:5
|
||||
|
|
||||
LL | / impl From<()> for Wrap<Lion> {
|
||||
LL | |
|
||||
LL | | fn from(_: ()) -> Self {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `rawr`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:379:5
|
||||
|
|
||||
LL | / impl From<Wrap<Wrap<Elephant>>> for () {
|
||||
LL | |
|
||||
LL | | fn from(_: Wrap<Wrap<Elephant>>) -> Self {
|
||||
LL | | todo!()
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `rawr`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:393:5
|
||||
|
|
||||
LL | impl StillNonLocal for &Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `only_global`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:401:5
|
||||
|
|
||||
LL | / impl From<Local1> for GlobalSameFunction {
|
||||
LL | |
|
||||
LL | | fn from(x: Local1) -> GlobalSameFunction {
|
||||
LL | | x.0
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `same_function`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:409:5
|
||||
|
|
||||
LL | / impl From<Local2> for GlobalSameFunction {
|
||||
LL | |
|
||||
LL | | fn from(x: Local2) -> GlobalSameFunction {
|
||||
LL | | x.0
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `same_function`
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:448:13
|
||||
|
|
||||
LL | impl MacroTrait for OutsideStruct {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | m!();
|
||||
| ---- in this macro invocation
|
||||
|
|
||||
= help: move this `impl` block outside the of the current function `my_func`
|
||||
= 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: this warning originates in the macro `m` (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
|
||||
--> $DIR/non_local_definitions.rs:458:1
|
||||
|
|
||||
LL | non_local_macro::non_local_impl!(CargoUpdate);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: move this `impl` block outside the of the current constant `_IMPL_DEBUG`
|
||||
= 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 macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
|
||||
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
|
||||
--> $DIR/non_local_definitions.rs:461:1
|
||||
|
|
||||
LL | non_local_macro::non_local_macro_rules!(my_macro);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `_MACRO_EXPORT`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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 macro `non_local_macro::non_local_macro_rules` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
|
||||
= note: this warning originates in the macro `non_local_macro::non_local_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: 55 warnings emitted
|
||||
|
Loading…
Reference in New Issue
Block a user