Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8bcc301

Browse files
authoredJun 29, 2024
Unrolled build for rust-lang#127015
Rollup merge of rust-lang#127015 - Urgau:non_local_def-tmp-allow, r=lqd Switch back `non_local_definitions` lint to allow-by-default This PR switch back (again) the `non_local_definitions` lint to allow-by-default as T-lang is requesting some (major) changes in the lint inner workings in rust-lang#126768 (comment). This PR will need to be beta-backported, as the lint is currently warn-by-default in beta.
2 parents 9ed2ab3 + 0c0dfb8 commit 8bcc301

27 files changed

+169
-95
lines changed
 

‎compiler/rustc_lint/src/non_local_def.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ declare_lint! {
5050
/// All nested bodies (functions, enum discriminant, array length, consts) (expect for
5151
/// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked.
5252
pub NON_LOCAL_DEFINITIONS,
53-
Warn,
53+
Allow,
5454
"checks for non-local definitions",
5555
report_in_external_macro
5656
}

‎tests/rustdoc-ui/doctest/non_local_defs.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//@ normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
55
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
66

7+
#![doc(test(attr(warn(non_local_definitions))))]
8+
79
//! ```
810
//! #[macro_export]
911
//! macro_rules! a_macro { () => {} }
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
2-
--> $DIR/non_local_defs.rs:9:1
2+
--> $DIR/non_local_defs.rs:11:1
33
|
44
LL | macro_rules! a_macro { () => {} }
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }`
88
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
99
= 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>
10-
= note: `#[warn(non_local_definitions)]` on by default
10+
note: the lint level is defined here
11+
--> $DIR/non_local_defs.rs:8:9
12+
|
13+
LL | #![warn(non_local_definitions)]
14+
| ^^^^^^^^^^^^^^^^^^^^^
1115

1216
warning: 1 warning emitted
1317

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
running 1 test
3-
test $DIR/non_local_defs.rs - (line 7) ... ok
3+
test $DIR/non_local_defs.rs - (line 9) ... ok
44

55
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
66

‎tests/ui/lint/non-local-defs/cargo-update.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// of the `cargo update` suggestion we assert it here.
1111
//@ error-pattern: `cargo update -p non_local_macro`
1212

13+
#![warn(non_local_definitions)]
14+
1315
extern crate non_local_macro;
1416

1517
struct LocalStruct;

‎tests/ui/lint/non-local-defs/cargo-update.stderr‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/cargo-update.rs:17:1
2+
--> $DIR/cargo-update.rs:19:1
33
|
44
LL | non_local_macro::non_local_impl!(LocalStruct);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -14,7 +14,11 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
1414
= 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`
1515
= 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
1616
= 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>
17-
= note: `#[warn(non_local_definitions)]` on by default
17+
note: the lint level is defined here
18+
--> $DIR/cargo-update.rs:13:9
19+
|
20+
LL | #![warn(non_local_definitions)]
21+
| ^^^^^^^^^^^^^^^^^^^^^
1822
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
1923

2024
warning: 1 warning emitted

‎tests/ui/lint/non-local-defs/consts.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//@ edition:2021
33
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
44

5+
#![warn(non_local_definitions)]
6+
57
struct Test;
68

79
trait Uto {}

‎tests/ui/lint/non-local-defs/consts.stderr‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/consts.rs:13:5
2+
--> $DIR/consts.rs:15:5
33
|
44
LL | const Z: () = {
55
| -----------
@@ -17,10 +17,14 @@ LL | impl Uto for &Test {}
1717
= 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`
1818
= 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
1919
= 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>
20-
= note: `#[warn(non_local_definitions)]` on by default
20+
note: the lint level is defined here
21+
--> $DIR/consts.rs:5:9
22+
|
23+
LL | #![warn(non_local_definitions)]
24+
| ^^^^^^^^^^^^^^^^^^^^^
2125

2226
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
23-
--> $DIR/consts.rs:24:5
27+
--> $DIR/consts.rs:26:5
2428
|
2529
LL | static A: u32 = {
2630
| ------------- move the `impl` block outside of this static `A`
@@ -36,7 +40,7 @@ LL | impl Uto2 for Test {}
3640
= 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>
3741

3842
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
39-
--> $DIR/consts.rs:32:5
43+
--> $DIR/consts.rs:34:5
4044
|
4145
LL | const B: u32 = {
4246
| ------------ move the `impl` block outside of this constant `B`
@@ -52,7 +56,7 @@ LL | impl Uto3 for Test {}
5256
= 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>
5357

5458
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
55-
--> $DIR/consts.rs:43:5
59+
--> $DIR/consts.rs:45:5
5660
|
5761
LL | fn main() {
5862
| --------- move the `impl` block outside of this function `main`
@@ -65,7 +69,7 @@ LL | impl Test {
6569
= 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>
6670

6771
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
68-
--> $DIR/consts.rs:50:9
72+
--> $DIR/consts.rs:52:9
6973
|
7074
LL | const {
7175
| ___________-
@@ -84,7 +88,7 @@ LL | | };
8488
= 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>
8589

8690
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
87-
--> $DIR/consts.rs:59:9
91+
--> $DIR/consts.rs:61:9
8892
|
8993
LL | const _: u32 = {
9094
| ------------ move the `impl` block outside of this constant `_` and up 2 bodies
@@ -98,7 +102,7 @@ LL | impl Test {
98102
= 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>
99103

100104
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
101-
--> $DIR/consts.rs:72:9
105+
--> $DIR/consts.rs:74:9
102106
|
103107
LL | let _a = || {
104108
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@@ -113,7 +117,7 @@ LL | impl Uto9 for Test {}
113117
= 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>
114118

115119
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
116-
--> $DIR/consts.rs:79:9
120+
--> $DIR/consts.rs:81:9
117121
|
118122
LL | type A = [u32; {
119123
| ____________________-

‎tests/ui/lint/non-local-defs/exhaustive-trait.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
struct Dog;
57

68
fn main() {

‎tests/ui/lint/non-local-defs/exhaustive-trait.stderr‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/exhaustive-trait.rs:7:5
2+
--> $DIR/exhaustive-trait.rs:9:5
33
|
44
LL | fn main() {
55
| --------- move the `impl` block outside of this function `main`
@@ -12,10 +12,14 @@ LL | impl PartialEq<()> for Dog {
1212
= 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
1313
= 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`
1414
= 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>
15-
= note: `#[warn(non_local_definitions)]` on by default
15+
note: the lint level is defined here
16+
--> $DIR/exhaustive-trait.rs:4:9
17+
|
18+
LL | #![warn(non_local_definitions)]
19+
| ^^^^^^^^^^^^^^^^^^^^^
1620

1721
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
18-
--> $DIR/exhaustive-trait.rs:14:5
22+
--> $DIR/exhaustive-trait.rs:16:5
1923
|
2024
LL | fn main() {
2125
| --------- move the `impl` block outside of this function `main`
@@ -31,7 +35,7 @@ LL | impl PartialEq<()> for &Dog {
3135
= 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>
3236

3337
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
34-
--> $DIR/exhaustive-trait.rs:21:5
38+
--> $DIR/exhaustive-trait.rs:23:5
3539
|
3640
LL | fn main() {
3741
| --------- move the `impl` block outside of this function `main`
@@ -47,7 +51,7 @@ LL | impl PartialEq<Dog> for () {
4751
= 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>
4852

4953
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
50-
--> $DIR/exhaustive-trait.rs:28:5
54+
--> $DIR/exhaustive-trait.rs:30:5
5155
|
5256
LL | fn main() {
5357
| --------- move the `impl` block outside of this function `main`
@@ -63,7 +67,7 @@ LL | impl PartialEq<&Dog> for () {
6367
= 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>
6468

6569
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
66-
--> $DIR/exhaustive-trait.rs:35:5
70+
--> $DIR/exhaustive-trait.rs:37:5
6771
|
6872
LL | fn main() {
6973
| --------- move the `impl` block outside of this function `main`
@@ -79,7 +83,7 @@ LL | impl PartialEq<Dog> for &Dog {
7983
= 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>
8084

8185
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
82-
--> $DIR/exhaustive-trait.rs:42:5
86+
--> $DIR/exhaustive-trait.rs:44:5
8387
|
8488
LL | fn main() {
8589
| --------- move the `impl` block outside of this function `main`

‎tests/ui/lint/non-local-defs/exhaustive.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
use std::fmt::Display;
57

68
trait Trait {}

‎tests/ui/lint/non-local-defs/exhaustive.stderr‎

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/exhaustive.rs:10:5
2+
--> $DIR/exhaustive.rs:12:5
33
|
44
LL | fn main() {
55
| --------- move the `impl` block outside of this function `main`
@@ -10,10 +10,14 @@ LL | impl Test {
1010
|
1111
= 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`
1212
= 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>
13-
= note: `#[warn(non_local_definitions)]` on by default
13+
note: the lint level is defined here
14+
--> $DIR/exhaustive.rs:4:9
15+
|
16+
LL | #![warn(non_local_definitions)]
17+
| ^^^^^^^^^^^^^^^^^^^^^
1418

1519
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
16-
--> $DIR/exhaustive.rs:15:5
20+
--> $DIR/exhaustive.rs:17:5
1721
|
1822
LL | fn main() {
1923
| --------- move the `impl` block outside of this function `main`
@@ -29,7 +33,7 @@ LL | impl Display for Test {
2933
= 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>
3034

3135
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
32-
--> $DIR/exhaustive.rs:22:5
36+
--> $DIR/exhaustive.rs:24:5
3337
|
3438
LL | fn main() {
3539
| --------- move the `impl` block outside of this function `main`
@@ -43,7 +47,7 @@ LL | impl dyn Trait {}
4347
= 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>
4448

4549
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
46-
--> $DIR/exhaustive.rs:25:5
50+
--> $DIR/exhaustive.rs:27:5
4751
|
4852
LL | fn main() {
4953
| --------- move the `impl` block outside of this function `main`
@@ -59,7 +63,7 @@ LL | impl<T: Trait> Trait for Vec<T> { }
5963
= 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>
6064

6165
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
62-
--> $DIR/exhaustive.rs:28:5
66+
--> $DIR/exhaustive.rs:30:5
6367
|
6468
LL | fn main() {
6569
| --------- move the `impl` block outside of this function `main`
@@ -75,7 +79,7 @@ LL | impl Trait for &dyn Trait {}
7579
= 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>
7680

7781
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
78-
--> $DIR/exhaustive.rs:31:5
82+
--> $DIR/exhaustive.rs:33:5
7983
|
8084
LL | fn main() {
8185
| --------- move the `impl` block outside of this function `main`
@@ -91,7 +95,7 @@ LL | impl Trait for *mut Test {}
9195
= 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>
9296

9397
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
94-
--> $DIR/exhaustive.rs:34:5
98+
--> $DIR/exhaustive.rs:36:5
9599
|
96100
LL | fn main() {
97101
| --------- move the `impl` block outside of this function `main`
@@ -107,7 +111,7 @@ LL | impl Trait for *mut [Test] {}
107111
= 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>
108112

109113
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
110-
--> $DIR/exhaustive.rs:37:5
114+
--> $DIR/exhaustive.rs:39:5
111115
|
112116
LL | fn main() {
113117
| --------- move the `impl` block outside of this function `main`
@@ -123,7 +127,7 @@ LL | impl Trait for [Test; 8] {}
123127
= 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>
124128

125129
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
126-
--> $DIR/exhaustive.rs:40:5
130+
--> $DIR/exhaustive.rs:42:5
127131
|
128132
LL | fn main() {
129133
| --------- move the `impl` block outside of this function `main`
@@ -139,7 +143,7 @@ LL | impl Trait for (Test,) {}
139143
= 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>
140144

141145
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
142-
--> $DIR/exhaustive.rs:43:5
146+
--> $DIR/exhaustive.rs:45:5
143147
|
144148
LL | fn main() {
145149
| --------- move the `impl` block outside of this function `main`
@@ -155,7 +159,7 @@ LL | impl Trait for fn(Test) -> () {}
155159
= 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>
156160

157161
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
158-
--> $DIR/exhaustive.rs:46:5
162+
--> $DIR/exhaustive.rs:48:5
159163
|
160164
LL | fn main() {
161165
| --------- move the `impl` block outside of this function `main`
@@ -171,7 +175,7 @@ LL | impl Trait for fn() -> Test {}
171175
= 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>
172176

173177
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
174-
--> $DIR/exhaustive.rs:50:9
178+
--> $DIR/exhaustive.rs:52:9
175179
|
176180
LL | let _a = || {
177181
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@@ -186,7 +190,7 @@ LL | impl Trait for Test {}
186190
= 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>
187191

188192
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
189-
--> $DIR/exhaustive.rs:58:5
193+
--> $DIR/exhaustive.rs:60:5
190194
|
191195
LL | impl Trait for *mut InsideMain {}
192196
| ^^^^^-----^^^^^---------------
@@ -198,7 +202,7 @@ LL | impl Trait for *mut InsideMain {}
198202
= 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
199203
= 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`
200204
help: move the `impl` block outside of this function `main`
201-
--> $DIR/exhaustive.rs:9:1
205+
--> $DIR/exhaustive.rs:11:1
202206
|
203207
LL | fn main() {
204208
| ^^^^^^^^^
@@ -208,7 +212,7 @@ LL | struct InsideMain;
208212
= 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>
209213

210214
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
211-
--> $DIR/exhaustive.rs:60:5
215+
--> $DIR/exhaustive.rs:62:5
212216
|
213217
LL | impl Trait for *mut [InsideMain] {}
214218
| ^^^^^-----^^^^^-----------------
@@ -219,7 +223,7 @@ LL | impl Trait for *mut [InsideMain] {}
219223
= 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
220224
= 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`
221225
help: move the `impl` block outside of this function `main`
222-
--> $DIR/exhaustive.rs:9:1
226+
--> $DIR/exhaustive.rs:11:1
223227
|
224228
LL | fn main() {
225229
| ^^^^^^^^^
@@ -229,7 +233,7 @@ LL | struct InsideMain;
229233
= 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>
230234

231235
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
232-
--> $DIR/exhaustive.rs:62:5
236+
--> $DIR/exhaustive.rs:64:5
233237
|
234238
LL | impl Trait for [InsideMain; 8] {}
235239
| ^^^^^-----^^^^^---------------
@@ -240,7 +244,7 @@ LL | impl Trait for [InsideMain; 8] {}
240244
= 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
241245
= 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`
242246
help: move the `impl` block outside of this function `main`
243-
--> $DIR/exhaustive.rs:9:1
247+
--> $DIR/exhaustive.rs:11:1
244248
|
245249
LL | fn main() {
246250
| ^^^^^^^^^
@@ -250,7 +254,7 @@ LL | struct InsideMain;
250254
= 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>
251255

252256
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
253-
--> $DIR/exhaustive.rs:64:5
257+
--> $DIR/exhaustive.rs:66:5
254258
|
255259
LL | impl Trait for (InsideMain,) {}
256260
| ^^^^^-----^^^^^-------------
@@ -261,7 +265,7 @@ LL | impl Trait for (InsideMain,) {}
261265
= 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
262266
= 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`
263267
help: move the `impl` block outside of this function `main`
264-
--> $DIR/exhaustive.rs:9:1
268+
--> $DIR/exhaustive.rs:11:1
265269
|
266270
LL | fn main() {
267271
| ^^^^^^^^^
@@ -271,7 +275,7 @@ LL | struct InsideMain;
271275
= 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>
272276

273277
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
274-
--> $DIR/exhaustive.rs:66:5
278+
--> $DIR/exhaustive.rs:68:5
275279
|
276280
LL | impl Trait for fn(InsideMain) -> () {}
277281
| ^^^^^-----^^^^^--------------------
@@ -282,7 +286,7 @@ LL | impl Trait for fn(InsideMain) -> () {}
282286
= 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
283287
= 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`
284288
help: move the `impl` block outside of this function `main`
285-
--> $DIR/exhaustive.rs:9:1
289+
--> $DIR/exhaustive.rs:11:1
286290
|
287291
LL | fn main() {
288292
| ^^^^^^^^^
@@ -292,7 +296,7 @@ LL | struct InsideMain;
292296
= 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>
293297

294298
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
295-
--> $DIR/exhaustive.rs:68:5
299+
--> $DIR/exhaustive.rs:70:5
296300
|
297301
LL | impl Trait for fn() -> InsideMain {}
298302
| ^^^^^-----^^^^^------------------
@@ -303,7 +307,7 @@ LL | impl Trait for fn() -> InsideMain {}
303307
= 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
304308
= 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`
305309
help: move the `impl` block outside of this function `main`
306-
--> $DIR/exhaustive.rs:9:1
310+
--> $DIR/exhaustive.rs:11:1
307311
|
308312
LL | fn main() {
309313
| ^^^^^^^^^
@@ -313,7 +317,7 @@ LL | struct InsideMain;
313317
= 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>
314318

315319
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
316-
--> $DIR/exhaustive.rs:72:9
320+
--> $DIR/exhaustive.rs:74:9
317321
|
318322
LL | fn inside_inside() {
319323
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies
@@ -328,7 +332,7 @@ LL | impl Display for InsideMain {
328332
= 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>
329333

330334
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
331-
--> $DIR/exhaustive.rs:79:9
335+
--> $DIR/exhaustive.rs:81:9
332336
|
333337
LL | fn inside_inside() {
334338
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies

‎tests/ui/lint/non-local-defs/from-local-for-global.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
struct Cat;
57
struct Wrap<T>(T);
68

‎tests/ui/lint/non-local-defs/from-local-for-global.stderr‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/from-local-for-global.rs:8:5
2+
--> $DIR/from-local-for-global.rs:10:5
33
|
44
LL | fn main() {
55
| --------- move the `impl` block outside of this function `main`
@@ -12,10 +12,14 @@ LL | impl From<Cat> for () {
1212
= 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
1313
= 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`
1414
= 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>
15-
= note: `#[warn(non_local_definitions)]` on by default
15+
note: the lint level is defined here
16+
--> $DIR/from-local-for-global.rs:4:9
17+
|
18+
LL | #![warn(non_local_definitions)]
19+
| ^^^^^^^^^^^^^^^^^^^^^
1620

1721
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
18-
--> $DIR/from-local-for-global.rs:18:5
22+
--> $DIR/from-local-for-global.rs:20:5
1923
|
2024
LL | impl From<Wrap<Wrap<Elephant>>> for () {
2125
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@@ -25,7 +29,7 @@ LL | impl From<Wrap<Wrap<Elephant>>> for () {
2529
= 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
2630
= 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`
2731
help: move the `impl` block outside of this function `main`
28-
--> $DIR/from-local-for-global.rs:7:1
32+
--> $DIR/from-local-for-global.rs:9:1
2933
|
3034
LL | fn main() {
3135
| ^^^^^^^^^
@@ -35,7 +39,7 @@ LL | struct Elephant;
3539
= 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>
3640

3741
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
38-
--> $DIR/from-local-for-global.rs:32:5
42+
--> $DIR/from-local-for-global.rs:34:5
3943
|
4044
LL | impl StillNonLocal for &Foo {}
4145
| ^^^^^-------------^^^^^----
@@ -47,7 +51,7 @@ LL | impl StillNonLocal for &Foo {}
4751
= 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
4852
= 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`
4953
help: move the `impl` block outside of this function `only_global`
50-
--> $DIR/from-local-for-global.rs:30:1
54+
--> $DIR/from-local-for-global.rs:32:1
5155
|
5256
LL | fn only_global() {
5357
| ^^^^^^^^^^^^^^^^
@@ -56,7 +60,7 @@ LL | struct Foo;
5660
= 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>
5761

5862
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
59-
--> $DIR/from-local-for-global.rs:40:5
63+
--> $DIR/from-local-for-global.rs:42:5
6064
|
6165
LL | impl From<Local1> for GlobalSameFunction {
6266
| ^^^^^----^^^^^^^^^^^^^------------------
@@ -67,7 +71,7 @@ LL | impl From<Local1> for GlobalSameFunction {
6771
= 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
6872
= 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`
6973
help: move the `impl` block outside of this function `same_function`
70-
--> $DIR/from-local-for-global.rs:38:1
74+
--> $DIR/from-local-for-global.rs:40:1
7175
|
7276
LL | fn same_function() {
7377
| ^^^^^^^^^^^^^^^^^^
@@ -76,7 +80,7 @@ LL | struct Local1(GlobalSameFunction);
7680
= 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>
7781

7882
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
79-
--> $DIR/from-local-for-global.rs:48:5
83+
--> $DIR/from-local-for-global.rs:50:5
8084
|
8185
LL | impl From<Local2> for GlobalSameFunction {
8286
| ^^^^^----^^^^^^^^^^^^^------------------
@@ -87,7 +91,7 @@ LL | impl From<Local2> for GlobalSameFunction {
8791
= 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
8892
= 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`
8993
help: move the `impl` block outside of this function `same_function`
90-
--> $DIR/from-local-for-global.rs:38:1
94+
--> $DIR/from-local-for-global.rs:40:1
9195
|
9296
LL | fn same_function() {
9397
| ^^^^^^^^^^^^^^^^^^

‎tests/ui/lint/non-local-defs/generics.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
trait Global {}
57

68
fn main() {

‎tests/ui/lint/non-local-defs/generics.stderr‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/generics.rs:9:5
2+
--> $DIR/generics.rs:11:5
33
|
44
LL | impl<T: Local> Global for Vec<T> { }
55
| ^^^^^^^^^^^^^^^------^^^^^---^^^
@@ -10,17 +10,21 @@ LL | impl<T: Local> Global for Vec<T> { }
1010
= 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
1111
= 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`
1212
help: move the `impl` block outside of this function `main`
13-
--> $DIR/generics.rs:6:1
13+
--> $DIR/generics.rs:8:1
1414
|
1515
LL | fn main() {
1616
| ^^^^^^^^^
1717
LL | trait Local {};
1818
| ----------- may need to be moved as well
1919
= 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>
20-
= note: `#[warn(non_local_definitions)]` on by default
20+
note: the lint level is defined here
21+
--> $DIR/generics.rs:4:9
22+
|
23+
LL | #![warn(non_local_definitions)]
24+
| ^^^^^^^^^^^^^^^^^^^^^
2125

2226
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
23-
--> $DIR/generics.rs:20:5
27+
--> $DIR/generics.rs:22:5
2428
|
2529
LL | impl Uto7 for Test where Local: std::any::Any {}
2630
| ^^^^^----^^^^^----
@@ -31,7 +35,7 @@ LL | impl Uto7 for Test where Local: std::any::Any {}
3135
= 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
3236
= 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`
3337
help: move the `impl` block outside of this function `bad`
34-
--> $DIR/generics.rs:18:1
38+
--> $DIR/generics.rs:20:1
3539
|
3640
LL | fn bad() {
3741
| ^^^^^^^^
@@ -40,7 +44,7 @@ LL | struct Local;
4044
= 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>
4145

4246
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
43-
--> $DIR/generics.rs:23:5
47+
--> $DIR/generics.rs:25:5
4448
|
4549
LL | fn bad() {
4650
| -------- move the `impl` block outside of this function `bad`
@@ -56,7 +60,7 @@ LL | impl<T> Uto8 for T {}
5660
= 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>
5761

5862
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
59-
--> $DIR/generics.rs:32:5
63+
--> $DIR/generics.rs:34:5
6064
|
6165
LL | impl Default for UwU<OwO> {
6266
| ^^^^^-------^^^^^---^^^^^
@@ -67,7 +71,7 @@ LL | impl Default for UwU<OwO> {
6771
= 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
6872
= 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`
6973
help: move the `impl` block outside of this function `fun`
70-
--> $DIR/generics.rs:29:1
74+
--> $DIR/generics.rs:31:1
7175
|
7276
LL | fn fun() {
7377
| ^^^^^^^^
@@ -77,7 +81,7 @@ LL | struct OwO;
7781
= 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>
7882

7983
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
80-
--> $DIR/generics.rs:43:5
84+
--> $DIR/generics.rs:45:5
8185
|
8286
LL | impl AsRef<Cat> for () {
8387
| ^^^^^-----^^^^^^^^^^--
@@ -88,7 +92,7 @@ LL | impl AsRef<Cat> for () {
8892
= 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
8993
= 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`
9094
help: move the `impl` block outside of this function `meow`
91-
--> $DIR/generics.rs:40:1
95+
--> $DIR/generics.rs:42:1
9296
|
9397
LL | fn meow() {
9498
| ^^^^^^^^^
@@ -98,7 +102,7 @@ LL | struct Cat;
98102
= 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>
99103

100104
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
101-
--> $DIR/generics.rs:54:5
105+
--> $DIR/generics.rs:56:5
102106
|
103107
LL | impl PartialEq<B> for G {
104108
| ^^^^^---------^^^^^^^^-
@@ -109,7 +113,7 @@ LL | impl PartialEq<B> for G {
109113
= 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
110114
= 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`
111115
help: move the `impl` block outside of this function `fun2`
112-
--> $DIR/generics.rs:51:1
116+
--> $DIR/generics.rs:53:1
113117
|
114118
LL | fn fun2() {
115119
| ^^^^^^^^^
@@ -119,7 +123,7 @@ LL | struct B;
119123
= 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>
120124

121125
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
122-
--> $DIR/generics.rs:69:5
126+
--> $DIR/generics.rs:71:5
123127
|
124128
LL | impl From<Wrap<Wrap<Lion>>> for () {
125129
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^--
@@ -129,7 +133,7 @@ LL | impl From<Wrap<Wrap<Lion>>> for () {
129133
= 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
130134
= 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`
131135
help: move the `impl` block outside of this function `rawr`
132-
--> $DIR/generics.rs:66:1
136+
--> $DIR/generics.rs:68:1
133137
|
134138
LL | fn rawr() {
135139
| ^^^^^^^^^
@@ -138,7 +142,7 @@ LL | struct Lion;
138142
= 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>
139143

140144
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
141-
--> $DIR/generics.rs:76:5
145+
--> $DIR/generics.rs:78:5
142146
|
143147
LL | impl From<()> for Wrap<Lion> {
144148
| ^^^^^----^^^^^^^^^----^^^^^^
@@ -149,7 +153,7 @@ LL | impl From<()> for Wrap<Lion> {
149153
= 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
150154
= 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`
151155
help: move the `impl` block outside of this function `rawr`
152-
--> $DIR/generics.rs:66:1
156+
--> $DIR/generics.rs:68:1
153157
|
154158
LL | fn rawr() {
155159
| ^^^^^^^^^

‎tests/ui/lint/non-local-defs/inside-macro_rules.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
macro_rules! m {
57
() => {
68
trait MacroTrait {}

‎tests/ui/lint/non-local-defs/inside-macro_rules.stderr‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/inside-macro_rules.rs:9:13
2+
--> $DIR/inside-macro_rules.rs:11:13
33
|
44
LL | fn my_func() {
55
| ------------ move the `impl` block outside of this function `my_func`
@@ -16,7 +16,11 @@ LL | m!();
1616
= 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
1717
= 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`
1818
= 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>
19-
= note: `#[warn(non_local_definitions)]` on by default
19+
note: the lint level is defined here
20+
--> $DIR/inside-macro_rules.rs:4:9
21+
|
22+
LL | #![warn(non_local_definitions)]
23+
| ^^^^^^^^^^^^^^^^^^^^^
2024
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
2125

2226
warning: 1 warning emitted

‎tests/ui/lint/non-local-defs/local.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
use std::fmt::Debug;
57

68
trait GlobalTrait {}

‎tests/ui/lint/non-local-defs/macro_rules.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//@ aux-build:non_local_macro.rs
44
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
55

6+
#![warn(non_local_definitions)]
7+
68
extern crate non_local_macro;
79

810
const B: u32 = {

‎tests/ui/lint/non-local-defs/macro_rules.stderr‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
2-
--> $DIR/macro_rules.rs:10:5
2+
--> $DIR/macro_rules.rs:12:5
33
|
44
LL | macro_rules! m0 { () => { } };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B`
88
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
99
= 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>
10-
= note: `#[warn(non_local_definitions)]` on by default
10+
note: the lint level is defined here
11+
--> $DIR/macro_rules.rs:6:9
12+
|
13+
LL | #![warn(non_local_definitions)]
14+
| ^^^^^^^^^^^^^^^^^^^^^
1115

1216
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
13-
--> $DIR/macro_rules.rs:16:1
17+
--> $DIR/macro_rules.rs:18:1
1418
|
1519
LL | non_local_macro::non_local_macro_rules!(my_macro);
1620
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -22,7 +26,7 @@ LL | non_local_macro::non_local_macro_rules!(my_macro);
2226
= 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)
2327

2428
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
25-
--> $DIR/macro_rules.rs:21:5
29+
--> $DIR/macro_rules.rs:23:5
2630
|
2731
LL | macro_rules! m { () => { } };
2832
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -32,7 +36,7 @@ LL | macro_rules! m { () => { } };
3236
= 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>
3337

3438
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
35-
--> $DIR/macro_rules.rs:29:13
39+
--> $DIR/macro_rules.rs:31:13
3640
|
3741
LL | macro_rules! m2 { () => { } };
3842
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/lint/non-local-defs/suggest-moving-inner.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ check-pass
22

3+
#![warn(non_local_definitions)]
4+
35
trait Trait<T> {}
46

57
fn main() {

‎tests/ui/lint/non-local-defs/suggest-moving-inner.stderr‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/suggest-moving-inner.rs:12:5
2+
--> $DIR/suggest-moving-inner.rs:14:5
33
|
44
LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
55
| ^^^^^^^^-----^^^^^^^^^^^^^^^^^----------------------------------
@@ -10,7 +10,7 @@ LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
1010
= 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
1111
= 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`
1212
help: move the `impl` block outside of this function `main`
13-
--> $DIR/suggest-moving-inner.rs:5:1
13+
--> $DIR/suggest-moving-inner.rs:7:1
1414
|
1515
LL | fn main() {
1616
| ^^^^^^^^^
@@ -23,7 +23,11 @@ LL | struct InsideMain;
2323
LL | trait HasFoo {}
2424
| ------------ may need to be moved as well
2525
= 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>
26-
= note: `#[warn(non_local_definitions)]` on by default
26+
note: the lint level is defined here
27+
--> $DIR/suggest-moving-inner.rs:3:9
28+
|
29+
LL | #![warn(non_local_definitions)]
30+
| ^^^^^^^^^^^^^^^^^^^^^
2731

2832
warning: 1 warning emitted
2933

‎tests/ui/lint/non-local-defs/trait-solver-overflow-123573.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
// https://github.com/rust-lang/rust/issues/123573#issue-2229428739
55

6+
#![warn(non_local_definitions)]
7+
68
pub trait Test {}
79

810
impl<'a, T: 'a> Test for &[T] where &'a T: Test {}

‎tests/ui/lint/non-local-defs/trait-solver-overflow-123573.stderr‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/trait-solver-overflow-123573.rs:12:5
2+
--> $DIR/trait-solver-overflow-123573.rs:14:5
33
|
44
LL | impl Test for &Local {}
55
| ^^^^^----^^^^^------
@@ -11,14 +11,18 @@ LL | impl Test for &Local {}
1111
= 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
1212
= 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`
1313
help: move the `impl` block outside of this function `main`
14-
--> $DIR/trait-solver-overflow-123573.rs:10:1
14+
--> $DIR/trait-solver-overflow-123573.rs:12:1
1515
|
1616
LL | fn main() {
1717
| ^^^^^^^^^
1818
LL | struct Local {}
1919
| ------------ may need to be moved as well
2020
= 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>
21-
= note: `#[warn(non_local_definitions)]` on by default
21+
note: the lint level is defined here
22+
--> $DIR/trait-solver-overflow-123573.rs:6:9
23+
|
24+
LL | #![warn(non_local_definitions)]
25+
| ^^^^^^^^^^^^^^^^^^^^^
2226

2327
warning: 1 warning emitted
2428

‎tests/ui/lint/non-local-defs/weird-exprs.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
trait Uto {}
57
struct Test;
68

‎tests/ui/lint/non-local-defs/weird-exprs.stderr‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/weird-exprs.rs:8:5
2+
--> $DIR/weird-exprs.rs:10:5
33
|
44
LL | type A = [u32; {
55
| ________________-
@@ -16,10 +16,14 @@ LL | | }];
1616
= 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
1717
= 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`
1818
= 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>
19-
= note: `#[warn(non_local_definitions)]` on by default
19+
note: the lint level is defined here
20+
--> $DIR/weird-exprs.rs:4:9
21+
|
22+
LL | #![warn(non_local_definitions)]
23+
| ^^^^^^^^^^^^^^^^^^^^^
2024

2125
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
22-
--> $DIR/weird-exprs.rs:16:9
26+
--> $DIR/weird-exprs.rs:18:9
2327
|
2428
LL | Discr = {
2529
| _____________-
@@ -38,7 +42,7 @@ LL | | }
3842
= 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>
3943

4044
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
41-
--> $DIR/weird-exprs.rs:25:9
45+
--> $DIR/weird-exprs.rs:27:9
4246
|
4347
LL | let _array = [0i32; {
4448
| _________________________-
@@ -57,7 +61,7 @@ LL | | }];
5761
= 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>
5862

5963
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
60-
--> $DIR/weird-exprs.rs:34:9
64+
--> $DIR/weird-exprs.rs:36:9
6165
|
6266
LL | type A = [u32; {
6367
| ____________________-
@@ -76,7 +80,7 @@ LL | | }];
7680
= 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>
7781

7882
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
79-
--> $DIR/weird-exprs.rs:41:9
83+
--> $DIR/weird-exprs.rs:43:9
8084
|
8185
LL | fn a(_: [u32; {
8286
| ___________________-
@@ -95,7 +99,7 @@ LL | | }]) {}
9599
= 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>
96100

97101
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
98-
--> $DIR/weird-exprs.rs:48:9
102+
--> $DIR/weird-exprs.rs:50:9
99103
|
100104
LL | fn b() -> [u32; {
101105
| _____________________-

0 commit comments

Comments
 (0)
This repository has been archived.