Revert "Switch back non_local_definitions lint to allow-by-default"

This reverts commit 0c0dfb88ee.
This commit is contained in:
Urgau 2024-06-29 12:10:33 +02:00
parent 702987f75b
commit cb58668748
27 changed files with 119 additions and 193 deletions

View File

@ -49,7 +49,7 @@ declare_lint! {
/// All nested bodies (functions, enum discriminant, array length, consts) (expect for /// All nested bodies (functions, enum discriminant, array length, consts) (expect for
/// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked. /// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked.
pub NON_LOCAL_DEFINITIONS, pub NON_LOCAL_DEFINITIONS,
Allow, Warn,
"checks for non-local definitions", "checks for non-local definitions",
report_in_external_macro report_in_external_macro
} }

View File

@ -4,8 +4,6 @@
//@ normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME" //@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
#![doc(test(attr(warn(non_local_definitions))))]
//! ``` //! ```
//! #[macro_export] //! #[macro_export]
//! macro_rules! a_macro { () => {} } //! macro_rules! a_macro { () => {} }

View File

@ -1,5 +1,5 @@
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/non_local_defs.rs:11:1 --> $DIR/non_local_defs.rs:9:1
| |
LL | macro_rules! a_macro { () => {} } LL | macro_rules! a_macro { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,11 +7,7 @@ LL | macro_rules! a_macro { () => {} }
= help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }` = help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }`
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute = note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/non_local_defs.rs:8:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted warning: 1 warning emitted

View File

@ -1,6 +1,6 @@
running 1 test running 1 test
test $DIR/non_local_defs.rs - (line 9) ... ok test $DIR/non_local_defs.rs - (line 7) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

View File

@ -10,8 +10,6 @@
// of the `cargo update` suggestion we assert it here. // of the `cargo update` suggestion we assert it here.
//@ error-pattern: `cargo update -p non_local_macro` //@ error-pattern: `cargo update -p non_local_macro`
#![warn(non_local_definitions)]
extern crate non_local_macro; extern crate non_local_macro;
struct LocalStruct; struct LocalStruct;

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/cargo-update.rs:19:1 --> $DIR/cargo-update.rs:17:1
| |
LL | non_local_macro::non_local_impl!(LocalStruct); LL | non_local_macro::non_local_impl!(LocalStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -14,11 +14,7 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/cargo-update.rs:13:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info) = 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 warning: 1 warning emitted

View File

@ -2,8 +2,6 @@
//@ edition:2021 //@ edition:2021
//@ rustc-env:CARGO_CRATE_NAME=non_local_def //@ rustc-env:CARGO_CRATE_NAME=non_local_def
#![warn(non_local_definitions)]
struct Test; struct Test;
trait Uto {} trait Uto {}

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:15:5 --> $DIR/consts.rs:13:5
| |
LL | const Z: () = { LL | const Z: () = {
| ----------- | -----------
@ -17,14 +17,10 @@ LL | impl Uto for &Test {}
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/consts.rs:5:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:26:5 --> $DIR/consts.rs:24:5
| |
LL | static A: u32 = { LL | static A: u32 = {
| ------------- move the `impl` block outside of this static `A` | ------------- move the `impl` block outside of this static `A`
@ -40,7 +36,7 @@ LL | impl Uto2 for Test {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:34:5 --> $DIR/consts.rs:32:5
| |
LL | const B: u32 = { LL | const B: u32 = {
| ------------ move the `impl` block outside of this constant `B` | ------------ move the `impl` block outside of this constant `B`
@ -56,7 +52,7 @@ LL | impl Uto3 for Test {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:45:5 --> $DIR/consts.rs:43:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -69,7 +65,7 @@ LL | impl Test {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:52:9 --> $DIR/consts.rs:50:9
| |
LL | const { LL | const {
| ___________- | ___________-
@ -88,7 +84,7 @@ LL | | };
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:61:9 --> $DIR/consts.rs:59:9
| |
LL | const _: u32 = { LL | const _: u32 = {
| ------------ move the `impl` block outside of this constant `_` and up 2 bodies | ------------ move the `impl` block outside of this constant `_` and up 2 bodies
@ -102,7 +98,7 @@ LL | impl Test {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:74:9 --> $DIR/consts.rs:72:9
| |
LL | let _a = || { LL | let _a = || {
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies | -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@ -117,7 +113,7 @@ LL | impl Uto9 for Test {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:81:9 --> $DIR/consts.rs:79:9
| |
LL | type A = [u32; { LL | type A = [u32; {
| ____________________- | ____________________-

View File

@ -1,8 +1,6 @@
//@ check-pass //@ check-pass
//@ edition:2021 //@ edition:2021
#![warn(non_local_definitions)]
struct Dog; struct Dog;
fn main() { fn main() {

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:9:5 --> $DIR/exhaustive-trait.rs:7:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -12,14 +12,10 @@ LL | impl PartialEq<()> for Dog {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/exhaustive-trait.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:16:5 --> $DIR/exhaustive-trait.rs:14:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -35,7 +31,7 @@ LL | impl PartialEq<()> for &Dog {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:23:5 --> $DIR/exhaustive-trait.rs:21:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -51,7 +47,7 @@ LL | impl PartialEq<Dog> for () {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:30:5 --> $DIR/exhaustive-trait.rs:28:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -67,7 +63,7 @@ LL | impl PartialEq<&Dog> for () {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:37:5 --> $DIR/exhaustive-trait.rs:35:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -83,7 +79,7 @@ LL | impl PartialEq<Dog> for &Dog {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:44:5 --> $DIR/exhaustive-trait.rs:42:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`

View File

@ -1,8 +1,6 @@
//@ check-pass //@ check-pass
//@ edition:2021 //@ edition:2021
#![warn(non_local_definitions)]
use std::fmt::Display; use std::fmt::Display;
trait Trait {} trait Trait {}

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:12:5 --> $DIR/exhaustive.rs:10:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -10,14 +10,10 @@ LL | impl Test {
| |
= note: methods and associated constants are still usable outside the current expression, only `impl Local` and `impl dyn Local` can ever be private, and only if the type is nested in the same item as the `impl` = note: methods and associated constants are still usable outside the current expression, only `impl Local` and `impl dyn Local` can ever be private, and only if the type is nested in the same item as the `impl`
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/exhaustive.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:17:5 --> $DIR/exhaustive.rs:15:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -33,7 +29,7 @@ LL | impl Display for Test {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:24:5 --> $DIR/exhaustive.rs:22:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -47,7 +43,7 @@ LL | impl dyn Trait {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:27:5 --> $DIR/exhaustive.rs:25:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -63,7 +59,7 @@ LL | impl<T: Trait> Trait for Vec<T> { }
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:30:5 --> $DIR/exhaustive.rs:28:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -79,7 +75,7 @@ LL | impl Trait for &dyn Trait {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:33:5 --> $DIR/exhaustive.rs:31:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -95,7 +91,7 @@ LL | impl Trait for *mut Test {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:36:5 --> $DIR/exhaustive.rs:34:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -111,7 +107,7 @@ LL | impl Trait for *mut [Test] {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:39:5 --> $DIR/exhaustive.rs:37:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -127,7 +123,7 @@ LL | impl Trait for [Test; 8] {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:42:5 --> $DIR/exhaustive.rs:40:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -143,7 +139,7 @@ LL | impl Trait for (Test,) {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:45:5 --> $DIR/exhaustive.rs:43:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -159,7 +155,7 @@ LL | impl Trait for fn(Test) -> () {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:48:5 --> $DIR/exhaustive.rs:46:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -175,7 +171,7 @@ LL | impl Trait for fn() -> Test {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:52:9 --> $DIR/exhaustive.rs:50:9
| |
LL | let _a = || { LL | let _a = || {
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies | -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@ -190,7 +186,7 @@ LL | impl Trait for Test {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:60:5 --> $DIR/exhaustive.rs:58:5
| |
LL | impl Trait for *mut InsideMain {} LL | impl Trait for *mut InsideMain {}
| ^^^^^-----^^^^^--------------- | ^^^^^-----^^^^^---------------
@ -202,7 +198,28 @@ LL | impl Trait for *mut InsideMain {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:11:1 --> $DIR/exhaustive.rs:9:1
|
LL | fn main() {
| ^^^^^^^^^
...
LL | struct InsideMain;
| ----------------- may need to be moved as well
= 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, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:60:5
|
LL | impl Trait for *mut [InsideMain] {}
| ^^^^^-----^^^^^-----------------
| | |
| | `*mut [InsideMain]` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:9:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -214,16 +231,16 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:62:5 --> $DIR/exhaustive.rs:62:5
| |
LL | impl Trait for *mut [InsideMain] {} LL | impl Trait for [InsideMain; 8] {}
| ^^^^^-----^^^^^----------------- | ^^^^^-----^^^^^---------------
| | | | | |
| | `*mut [InsideMain]` is not local | | `[InsideMain; 8]` is not local
| `Trait` is not local | `Trait` is not local
| |
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:11:1 --> $DIR/exhaustive.rs:9:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -235,16 +252,16 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:64:5 --> $DIR/exhaustive.rs:64:5
| |
LL | impl Trait for [InsideMain; 8] {} LL | impl Trait for (InsideMain,) {}
| ^^^^^-----^^^^^--------------- | ^^^^^-----^^^^^-------------
| | | | | |
| | `[InsideMain; 8]` is not local | | `(InsideMain,)` is not local
| `Trait` is not local | `Trait` is not local
| |
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:11:1 --> $DIR/exhaustive.rs:9:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -256,16 +273,16 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:66:5 --> $DIR/exhaustive.rs:66:5
| |
LL | impl Trait for (InsideMain,) {} LL | impl Trait for fn(InsideMain) -> () {}
| ^^^^^-----^^^^^------------- | ^^^^^-----^^^^^--------------------
| | | | | |
| | `(InsideMain,)` is not local | | `fn(: InsideMain) -> ()` is not local
| `Trait` is not local | `Trait` is not local
| |
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:11:1 --> $DIR/exhaustive.rs:9:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -277,27 +294,6 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:68:5 --> $DIR/exhaustive.rs:68:5
| |
LL | impl Trait for fn(InsideMain) -> () {}
| ^^^^^-----^^^^^--------------------
| | |
| | `fn(: InsideMain) -> ()` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
...
LL | struct InsideMain;
| ----------------- may need to be moved as well
= 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, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:70:5
|
LL | impl Trait for fn() -> InsideMain {} LL | impl Trait for fn() -> InsideMain {}
| ^^^^^-----^^^^^------------------ | ^^^^^-----^^^^^------------------
| | | | | |
@ -307,7 +303,7 @@ LL | impl Trait for fn() -> InsideMain {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:11:1 --> $DIR/exhaustive.rs:9:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -317,7 +313,7 @@ LL | struct InsideMain;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:74:9 --> $DIR/exhaustive.rs:72:9
| |
LL | fn inside_inside() { LL | fn inside_inside() {
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies | ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies
@ -332,7 +328,7 @@ LL | impl Display for InsideMain {
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:81:9 --> $DIR/exhaustive.rs:79:9
| |
LL | fn inside_inside() { LL | fn inside_inside() {
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies | ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies

View File

@ -1,8 +1,6 @@
//@ check-pass //@ check-pass
//@ edition:2021 //@ edition:2021
#![warn(non_local_definitions)]
struct Cat; struct Cat;
struct Wrap<T>(T); struct Wrap<T>(T);

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:10:5 --> $DIR/from-local-for-global.rs:8:5
| |
LL | fn main() { LL | fn main() {
| --------- move the `impl` block outside of this function `main` | --------- move the `impl` block outside of this function `main`
@ -12,14 +12,10 @@ LL | impl From<Cat> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/from-local-for-global.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:20:5 --> $DIR/from-local-for-global.rs:18:5
| |
LL | impl From<Wrap<Wrap<Elephant>>> for () { LL | impl From<Wrap<Wrap<Elephant>>> for () {
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^-- | ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@ -29,7 +25,7 @@ LL | impl From<Wrap<Wrap<Elephant>>> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/from-local-for-global.rs:9:1 --> $DIR/from-local-for-global.rs:7:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -39,7 +35,7 @@ LL | struct Elephant;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:34:5 --> $DIR/from-local-for-global.rs:32:5
| |
LL | impl StillNonLocal for &Foo {} LL | impl StillNonLocal for &Foo {}
| ^^^^^-------------^^^^^---- | ^^^^^-------------^^^^^----
@ -51,7 +47,7 @@ LL | impl StillNonLocal for &Foo {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `only_global` help: move the `impl` block outside of this function `only_global`
--> $DIR/from-local-for-global.rs:32:1 --> $DIR/from-local-for-global.rs:30:1
| |
LL | fn only_global() { LL | fn only_global() {
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
@ -60,7 +56,7 @@ LL | struct Foo;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:42:5 --> $DIR/from-local-for-global.rs:40:5
| |
LL | impl From<Local1> for GlobalSameFunction { LL | impl From<Local1> for GlobalSameFunction {
| ^^^^^----^^^^^^^^^^^^^------------------ | ^^^^^----^^^^^^^^^^^^^------------------
@ -71,7 +67,7 @@ LL | impl From<Local1> for GlobalSameFunction {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `same_function` help: move the `impl` block outside of this function `same_function`
--> $DIR/from-local-for-global.rs:40:1 --> $DIR/from-local-for-global.rs:38:1
| |
LL | fn same_function() { LL | fn same_function() {
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
@ -80,7 +76,7 @@ LL | struct Local1(GlobalSameFunction);
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:50:5 --> $DIR/from-local-for-global.rs:48:5
| |
LL | impl From<Local2> for GlobalSameFunction { LL | impl From<Local2> for GlobalSameFunction {
| ^^^^^----^^^^^^^^^^^^^------------------ | ^^^^^----^^^^^^^^^^^^^------------------
@ -91,7 +87,7 @@ LL | impl From<Local2> for GlobalSameFunction {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `same_function` help: move the `impl` block outside of this function `same_function`
--> $DIR/from-local-for-global.rs:40:1 --> $DIR/from-local-for-global.rs:38:1
| |
LL | fn same_function() { LL | fn same_function() {
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^

View File

@ -1,8 +1,6 @@
//@ check-pass //@ check-pass
//@ edition:2021 //@ edition:2021
#![warn(non_local_definitions)]
trait Global {} trait Global {}
fn main() { fn main() {

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:11:5 --> $DIR/generics.rs:9:5
| |
LL | impl<T: Local> Global for Vec<T> { } LL | impl<T: Local> Global for Vec<T> { }
| ^^^^^^^^^^^^^^^------^^^^^---^^^ | ^^^^^^^^^^^^^^^------^^^^^---^^^
@ -10,21 +10,17 @@ LL | impl<T: Local> Global for Vec<T> { }
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/generics.rs:8:1 --> $DIR/generics.rs:6:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
LL | trait Local {}; LL | trait Local {};
| ----------- may need to be moved as well | ----------- may need to be moved as well
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/generics.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:22:5 --> $DIR/generics.rs:20:5
| |
LL | impl Uto7 for Test where Local: std::any::Any {} LL | impl Uto7 for Test where Local: std::any::Any {}
| ^^^^^----^^^^^---- | ^^^^^----^^^^^----
@ -35,7 +31,7 @@ LL | impl Uto7 for Test where Local: std::any::Any {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `bad` help: move the `impl` block outside of this function `bad`
--> $DIR/generics.rs:20:1 --> $DIR/generics.rs:18:1
| |
LL | fn bad() { LL | fn bad() {
| ^^^^^^^^ | ^^^^^^^^
@ -44,7 +40,7 @@ LL | struct Local;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:25:5 --> $DIR/generics.rs:23:5
| |
LL | fn bad() { LL | fn bad() {
| -------- move the `impl` block outside of this function `bad` | -------- move the `impl` block outside of this function `bad`
@ -60,7 +56,7 @@ LL | impl<T> Uto8 for T {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:34:5 --> $DIR/generics.rs:32:5
| |
LL | impl Default for UwU<OwO> { LL | impl Default for UwU<OwO> {
| ^^^^^-------^^^^^---^^^^^ | ^^^^^-------^^^^^---^^^^^
@ -71,7 +67,7 @@ LL | impl Default for UwU<OwO> {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `fun` help: move the `impl` block outside of this function `fun`
--> $DIR/generics.rs:31:1 --> $DIR/generics.rs:29:1
| |
LL | fn fun() { LL | fn fun() {
| ^^^^^^^^ | ^^^^^^^^
@ -81,7 +77,7 @@ LL | struct OwO;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:45:5 --> $DIR/generics.rs:43:5
| |
LL | impl AsRef<Cat> for () { LL | impl AsRef<Cat> for () {
| ^^^^^-----^^^^^^^^^^-- | ^^^^^-----^^^^^^^^^^--
@ -92,7 +88,7 @@ LL | impl AsRef<Cat> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `meow` help: move the `impl` block outside of this function `meow`
--> $DIR/generics.rs:42:1 --> $DIR/generics.rs:40:1
| |
LL | fn meow() { LL | fn meow() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -102,7 +98,7 @@ LL | struct Cat;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:56:5 --> $DIR/generics.rs:54:5
| |
LL | impl PartialEq<B> for G { LL | impl PartialEq<B> for G {
| ^^^^^---------^^^^^^^^- | ^^^^^---------^^^^^^^^-
@ -113,7 +109,7 @@ LL | impl PartialEq<B> for G {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `fun2` help: move the `impl` block outside of this function `fun2`
--> $DIR/generics.rs:53:1 --> $DIR/generics.rs:51:1
| |
LL | fn fun2() { LL | fn fun2() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -123,7 +119,7 @@ LL | struct B;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:71:5 --> $DIR/generics.rs:69:5
| |
LL | impl From<Wrap<Wrap<Lion>>> for () { LL | impl From<Wrap<Wrap<Lion>>> for () {
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^-- | ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^--
@ -133,7 +129,7 @@ LL | impl From<Wrap<Wrap<Lion>>> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `rawr` help: move the `impl` block outside of this function `rawr`
--> $DIR/generics.rs:68:1 --> $DIR/generics.rs:66:1
| |
LL | fn rawr() { LL | fn rawr() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -142,7 +138,7 @@ LL | struct Lion;
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:78:5 --> $DIR/generics.rs:76:5
| |
LL | impl From<()> for Wrap<Lion> { LL | impl From<()> for Wrap<Lion> {
| ^^^^^----^^^^^^^^^----^^^^^^ | ^^^^^----^^^^^^^^^----^^^^^^
@ -153,7 +149,7 @@ LL | impl From<()> for Wrap<Lion> {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `rawr` help: move the `impl` block outside of this function `rawr`
--> $DIR/generics.rs:68:1 --> $DIR/generics.rs:66:1
| |
LL | fn rawr() { LL | fn rawr() {
| ^^^^^^^^^ | ^^^^^^^^^

View File

@ -1,8 +1,6 @@
//@ check-pass //@ check-pass
//@ edition:2021 //@ edition:2021
#![warn(non_local_definitions)]
macro_rules! m { macro_rules! m {
() => { () => {
trait MacroTrait {} trait MacroTrait {}

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/inside-macro_rules.rs:11:13 --> $DIR/inside-macro_rules.rs:9:13
| |
LL | fn my_func() { LL | fn my_func() {
| ------------ move the `impl` block outside of this function `my_func` | ------------ move the `impl` block outside of this function `my_func`
@ -16,11 +16,7 @@ LL | m!();
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/inside-macro_rules.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted warning: 1 warning emitted

View File

@ -1,8 +1,6 @@
//@ check-pass //@ check-pass
//@ edition:2021 //@ edition:2021
#![warn(non_local_definitions)]
use std::fmt::Debug; use std::fmt::Debug;
trait GlobalTrait {} trait GlobalTrait {}

View File

@ -3,8 +3,6 @@
//@ aux-build:non_local_macro.rs //@ aux-build:non_local_macro.rs
//@ rustc-env:CARGO_CRATE_NAME=non_local_def //@ rustc-env:CARGO_CRATE_NAME=non_local_def
#![warn(non_local_definitions)]
extern crate non_local_macro; extern crate non_local_macro;
const B: u32 = { const B: u32 = {

View File

@ -1,5 +1,5 @@
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:12:5 --> $DIR/macro_rules.rs:10:5
| |
LL | macro_rules! m0 { () => { } }; LL | macro_rules! m0 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,14 +7,10 @@ LL | macro_rules! m0 { () => { } };
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B` = 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: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/macro_rules.rs:6:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:18:1 --> $DIR/macro_rules.rs:16:1
| |
LL | non_local_macro::non_local_macro_rules!(my_macro); LL | non_local_macro::non_local_macro_rules!(my_macro);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -26,7 +22,7 @@ LL | non_local_macro::non_local_macro_rules!(my_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) = 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, `#[macro_export]` macro should be written at top level module warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:23:5 --> $DIR/macro_rules.rs:21:5
| |
LL | macro_rules! m { () => { } }; LL | macro_rules! m { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -36,7 +32,7 @@ LL | macro_rules! m { () => { } };
= 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 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, `#[macro_export]` macro should be written at top level module warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:31:13 --> $DIR/macro_rules.rs:29:13
| |
LL | macro_rules! m2 { () => { } }; LL | macro_rules! m2 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,7 +1,5 @@
//@ check-pass //@ check-pass
#![warn(non_local_definitions)]
trait Trait<T> {} trait Trait<T> {}
fn main() { fn main() {

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/suggest-moving-inner.rs:14:5 --> $DIR/suggest-moving-inner.rs:12:5
| |
LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>> LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
| ^^^^^^^^-----^^^^^^^^^^^^^^^^^---------------------------------- | ^^^^^^^^-----^^^^^^^^^^^^^^^^^----------------------------------
@ -10,7 +10,7 @@ LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/suggest-moving-inner.rs:7:1 --> $DIR/suggest-moving-inner.rs:5:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
@ -23,11 +23,7 @@ LL | struct InsideMain;
LL | trait HasFoo {} LL | trait HasFoo {}
| ------------ may need to be moved as well | ------------ may need to be moved as well
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/suggest-moving-inner.rs:3:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted warning: 1 warning emitted

View File

@ -3,8 +3,6 @@
// https://github.com/rust-lang/rust/issues/123573#issue-2229428739 // https://github.com/rust-lang/rust/issues/123573#issue-2229428739
#![warn(non_local_definitions)]
pub trait Test {} pub trait Test {}
impl<'a, T: 'a> Test for &[T] where &'a T: Test {} impl<'a, T: 'a> Test for &[T] where &'a T: Test {}

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/trait-solver-overflow-123573.rs:14:5 --> $DIR/trait-solver-overflow-123573.rs:12:5
| |
LL | impl Test for &Local {} LL | impl Test for &Local {}
| ^^^^^----^^^^^------ | ^^^^^----^^^^^------
@ -11,18 +11,14 @@ LL | impl Test for &Local {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main` help: move the `impl` block outside of this function `main`
--> $DIR/trait-solver-overflow-123573.rs:12:1 --> $DIR/trait-solver-overflow-123573.rs:10:1
| |
LL | fn main() { LL | fn main() {
| ^^^^^^^^^ | ^^^^^^^^^
LL | struct Local {} LL | struct Local {}
| ------------ may need to be moved as well | ------------ may need to be moved as well
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/trait-solver-overflow-123573.rs:6:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted warning: 1 warning emitted

View File

@ -1,8 +1,6 @@
//@ check-pass //@ check-pass
//@ edition:2021 //@ edition:2021
#![warn(non_local_definitions)]
trait Uto {} trait Uto {}
struct Test; struct Test;

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:10:5 --> $DIR/weird-exprs.rs:8:5
| |
LL | type A = [u32; { LL | type A = [u32; {
| ________________- | ________________-
@ -16,14 +16,10 @@ LL | | }];
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= 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 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 lint level is defined here = note: `#[warn(non_local_definitions)]` on by default
--> $DIR/weird-exprs.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:18:9 --> $DIR/weird-exprs.rs:16:9
| |
LL | Discr = { LL | Discr = {
| _____________- | _____________-
@ -42,7 +38,7 @@ LL | | }
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:27:9 --> $DIR/weird-exprs.rs:25:9
| |
LL | let _array = [0i32; { LL | let _array = [0i32; {
| _________________________- | _________________________-
@ -61,7 +57,7 @@ LL | | }];
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:36:9 --> $DIR/weird-exprs.rs:34:9
| |
LL | type A = [u32; { LL | type A = [u32; {
| ____________________- | ____________________-
@ -80,7 +76,7 @@ LL | | }];
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:43:9 --> $DIR/weird-exprs.rs:41:9
| |
LL | fn a(_: [u32; { LL | fn a(_: [u32; {
| ___________________- | ___________________-
@ -99,7 +95,7 @@ LL | | }]) {}
= 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 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, `impl` blocks should be written at the same level as their item warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:50:9 --> $DIR/weird-exprs.rs:48:9
| |
LL | fn b() -> [u32; { LL | fn b() -> [u32; {
| _____________________- | _____________________-