Skip to content

Commit cb58668

Browse files
committed
Revert "Switch back non_local_definitions lint to allow-by-default"
This reverts commit 0c0dfb8.
1 parent 702987f commit cb58668

27 files changed

+95
-169
lines changed

compiler/rustc_lint/src/non_local_def.rs

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

tests/rustdoc-ui/doctest/non_local_defs.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
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-
97
//! ```
108
//! #[macro_export]
119
//! macro_rules! a_macro { () => {} }
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
2-
--> $DIR/non_local_defs.rs:11:1
2+
--> $DIR/non_local_defs.rs:9: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: the lint level is defined here
11-
--> $DIR/non_local_defs.rs:8:9
12-
|
13-
LL | #![warn(non_local_definitions)]
14-
| ^^^^^^^^^^^^^^^^^^^^^
10+
= note: `#[warn(non_local_definitions)]` on by default
1511

1612
warning: 1 warning emitted
1713

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 9) ... ok
3+
test $DIR/non_local_defs.rs - (line 7) ... 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

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
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-
1513
extern crate non_local_macro;
1614

1715
struct LocalStruct;

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

+2-6
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:19:1
2+
--> $DIR/cargo-update.rs:17:1
33
|
44
LL | non_local_macro::non_local_impl!(LocalStruct);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -14,11 +14,7 @@ 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: the lint level is defined here
18-
--> $DIR/cargo-update.rs:13:9
19-
|
20-
LL | #![warn(non_local_definitions)]
21-
| ^^^^^^^^^^^^^^^^^^^^^
17+
= note: `#[warn(non_local_definitions)]` on by default
2218
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
2319

2420
warning: 1 warning emitted

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

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

5-
#![warn(non_local_definitions)]
6-
75
struct Test;
86

97
trait Uto {}

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

+9-13
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:15:5
2+
--> $DIR/consts.rs:13:5
33
|
44
LL | const Z: () = {
55
| -----------
@@ -17,14 +17,10 @@ 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: the lint level is defined here
21-
--> $DIR/consts.rs:5:9
22-
|
23-
LL | #![warn(non_local_definitions)]
24-
| ^^^^^^^^^^^^^^^^^^^^^
20+
= note: `#[warn(non_local_definitions)]` on by default
2521

2622
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
27-
--> $DIR/consts.rs:26:5
23+
--> $DIR/consts.rs:24:5
2824
|
2925
LL | static A: u32 = {
3026
| ------------- move the `impl` block outside of this static `A`
@@ -40,7 +36,7 @@ LL | impl Uto2 for Test {}
4036
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
4137

4238
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
43-
--> $DIR/consts.rs:34:5
39+
--> $DIR/consts.rs:32:5
4440
|
4541
LL | const B: u32 = {
4642
| ------------ move the `impl` block outside of this constant `B`
@@ -56,7 +52,7 @@ LL | impl Uto3 for Test {}
5652
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
5753

5854
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
59-
--> $DIR/consts.rs:45:5
55+
--> $DIR/consts.rs:43:5
6056
|
6157
LL | fn main() {
6258
| --------- move the `impl` block outside of this function `main`
@@ -69,7 +65,7 @@ LL | impl Test {
6965
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
7066

7167
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
72-
--> $DIR/consts.rs:52:9
68+
--> $DIR/consts.rs:50:9
7369
|
7470
LL | const {
7571
| ___________-
@@ -88,7 +84,7 @@ LL | | };
8884
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
8985

9086
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
91-
--> $DIR/consts.rs:61:9
87+
--> $DIR/consts.rs:59:9
9288
|
9389
LL | const _: u32 = {
9490
| ------------ move the `impl` block outside of this constant `_` and up 2 bodies
@@ -102,7 +98,7 @@ LL | impl Test {
10298
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
10399

104100
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
105-
--> $DIR/consts.rs:74:9
101+
--> $DIR/consts.rs:72:9
106102
|
107103
LL | let _a = || {
108104
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@@ -117,7 +113,7 @@ LL | impl Uto9 for Test {}
117113
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
118114

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

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//@ check-pass
22
//@ edition:2021
33

4-
#![warn(non_local_definitions)]
5-
64
struct Dog;
75

86
fn main() {

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

+7-11
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:9:5
2+
--> $DIR/exhaustive-trait.rs:7:5
33
|
44
LL | fn main() {
55
| --------- move the `impl` block outside of this function `main`
@@ -12,14 +12,10 @@ 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: the lint level is defined here
16-
--> $DIR/exhaustive-trait.rs:4:9
17-
|
18-
LL | #![warn(non_local_definitions)]
19-
| ^^^^^^^^^^^^^^^^^^^^^
15+
= note: `#[warn(non_local_definitions)]` on by default
2016

2117
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
22-
--> $DIR/exhaustive-trait.rs:16:5
18+
--> $DIR/exhaustive-trait.rs:14:5
2319
|
2420
LL | fn main() {
2521
| --------- move the `impl` block outside of this function `main`
@@ -35,7 +31,7 @@ LL | impl PartialEq<()> for &Dog {
3531
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
3632

3733
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
38-
--> $DIR/exhaustive-trait.rs:23:5
34+
--> $DIR/exhaustive-trait.rs:21:5
3935
|
4036
LL | fn main() {
4137
| --------- move the `impl` block outside of this function `main`
@@ -51,7 +47,7 @@ LL | impl PartialEq<Dog> for () {
5147
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
5248

5349
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
54-
--> $DIR/exhaustive-trait.rs:30:5
50+
--> $DIR/exhaustive-trait.rs:28:5
5551
|
5652
LL | fn main() {
5753
| --------- move the `impl` block outside of this function `main`
@@ -67,7 +63,7 @@ LL | impl PartialEq<&Dog> for () {
6763
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
6864

6965
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
70-
--> $DIR/exhaustive-trait.rs:37:5
66+
--> $DIR/exhaustive-trait.rs:35:5
7167
|
7268
LL | fn main() {
7369
| --------- move the `impl` block outside of this function `main`
@@ -83,7 +79,7 @@ LL | impl PartialEq<Dog> for &Dog {
8379
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
8480

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

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//@ check-pass
22
//@ edition:2021
33

4-
#![warn(non_local_definitions)]
5-
64
use std::fmt::Display;
75

86
trait Trait {}

0 commit comments

Comments
 (0)