Skip to content

Commit dd2d87b

Browse files
committed
Auto merge of #143929 - petrochenkov:depresolve, r=<try>
Mark all deprecation lints in name resolution as deny-by-default and report-in-deps This affects the next lints: - `MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS` - no tracking issue - `LEGACY_DERIVE_HELPERS` - #79202 - `PRIVATE_MACRO_USE` - #120192 - `OUT_OF_SCOPE_MACRO_CALLS` - no tracking issue
2 parents 64b185e + 624f453 commit dd2d87b

14 files changed

+296
-41
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,7 @@ declare_lint! {
21552155
@future_incompatible = FutureIncompatibleInfo {
21562156
reason: FutureIncompatibilityReason::FutureReleaseError,
21572157
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
2158+
report_in_deps: true,
21582159
};
21592160
crate_level_only
21602161
}
@@ -2886,11 +2887,12 @@ declare_lint! {
28862887
/// struct S { /* fields */ }
28872888
/// ```
28882889
pub LEGACY_DERIVE_HELPERS,
2889-
Warn,
2890+
Deny,
28902891
"detects derive helper attributes that are used before they are introduced",
28912892
@future_incompatible = FutureIncompatibleInfo {
28922893
reason: FutureIncompatibilityReason::FutureReleaseError,
28932894
reference: "issue #79202 <https://github.com/rust-lang/rust/issues/79202>",
2895+
report_in_deps: true,
28942896
};
28952897
}
28962898

@@ -4623,11 +4625,12 @@ declare_lint! {
46234625
///
46244626
/// [future-incompatible]: ../index.md#future-incompatible-lints
46254627
pub PRIVATE_MACRO_USE,
4626-
Warn,
4628+
Deny,
46274629
"detects certain macro bindings that should not be re-exported",
46284630
@future_incompatible = FutureIncompatibleInfo {
46294631
reason: FutureIncompatibilityReason::FutureReleaseError,
46304632
reference: "issue #120192 <https://github.com/rust-lang/rust/issues/120192>",
4633+
report_in_deps: true,
46314634
};
46324635
}
46334636

@@ -4852,11 +4855,12 @@ declare_lint! {
48524855
///
48534856
/// [future-incompatible]: ../index.md#future-incompatible-lints
48544857
pub OUT_OF_SCOPE_MACRO_CALLS,
4855-
Warn,
4858+
Deny,
48564859
"detects out of scope calls to `macro_rules` in key-value attributes",
48574860
@future_incompatible = FutureIncompatibleInfo {
48584861
reason: FutureIncompatibilityReason::FutureReleaseError,
48594862
reference: "issue #124535 <https://github.com/rust-lang/rust/issues/124535>",
4863+
report_in_deps: true,
48604864
};
48614865
}
48624866

tests/ui/attributes/key-value-expansion-scope.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#![doc = in_root!()] //~ WARN cannot find macro `in_root`
1+
#![doc = in_root!()] //~ ERROR cannot find macro `in_root`
22
//~| WARN this was previously accepted by the compiler
33
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
4-
#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape`
4+
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape`
55
//~| WARN this was previously accepted by the compiler
66
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
77

@@ -18,10 +18,10 @@ fn before() {
1818

1919
macro_rules! in_root { () => { "" } }
2020

21-
#[doc = in_mod!()] //~ WARN cannot find macro `in_mod`
21+
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod`
2222
//~| WARN this was previously accepted by the compiler
2323
mod macros_stay {
24-
#![doc = in_mod!()] //~ WARN cannot find macro `in_mod`
24+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod`
2525
//~| WARN this was previously accepted by the compiler
2626

2727
macro_rules! in_mod { () => { "" } }
@@ -33,10 +33,10 @@ mod macros_stay {
3333
}
3434

3535
#[macro_use]
36-
#[doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape`
36+
#[doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape`
3737
//~| WARN this was previously accepted by the compiler
3838
mod macros_escape {
39-
#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape`
39+
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape`
4040
//~| WARN this was previously accepted by the compiler
4141

4242
macro_rules! in_mod_escape { () => { "" } }

tests/ui/attributes/key-value-expansion-scope.stderr

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ LL | #![doc = in_block!()]
126126
|
127127
= help: have you added the `#[macro_use]` on the module/import?
128128

129-
warning: cannot find macro `in_root` in the current scope when looking from the crate root
129+
error: cannot find macro `in_root` in the current scope when looking from the crate root
130130
--> $DIR/key-value-expansion-scope.rs:1:10
131131
|
132132
LL | #![doc = in_root!()]
@@ -135,9 +135,9 @@ LL | #![doc = in_root!()]
135135
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
136136
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
137137
= help: import `macro_rules` with `use` to make it callable above its definition
138-
= note: `#[warn(out_of_scope_macro_calls)]` on by default
138+
= note: `#[deny(out_of_scope_macro_calls)]` on by default
139139

140-
warning: cannot find macro `in_mod_escape` in the current scope when looking from the crate root
140+
error: cannot find macro `in_mod_escape` in the current scope when looking from the crate root
141141
--> $DIR/key-value-expansion-scope.rs:4:10
142142
|
143143
LL | #![doc = in_mod_escape!()]
@@ -147,7 +147,7 @@ LL | #![doc = in_mod_escape!()]
147147
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
148148
= help: import `macro_rules` with `use` to make it callable above its definition
149149

150-
warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
150+
error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
151151
--> $DIR/key-value-expansion-scope.rs:21:9
152152
|
153153
LL | #[doc = in_mod!()]
@@ -157,7 +157,7 @@ LL | #[doc = in_mod!()]
157157
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
158158
= help: import `macro_rules` with `use` to make it callable above its definition
159159

160-
warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
160+
error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
161161
--> $DIR/key-value-expansion-scope.rs:24:14
162162
|
163163
LL | #![doc = in_mod!()]
@@ -167,7 +167,7 @@ LL | #![doc = in_mod!()]
167167
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
168168
= help: import `macro_rules` with `use` to make it callable above its definition
169169

170-
warning: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape`
170+
error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape`
171171
--> $DIR/key-value-expansion-scope.rs:36:9
172172
|
173173
LL | #[doc = in_mod_escape!()]
@@ -177,7 +177,7 @@ LL | #[doc = in_mod_escape!()]
177177
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
178178
= help: import `macro_rules` with `use` to make it callable above its definition
179179

180-
warning: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape`
180+
error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape`
181181
--> $DIR/key-value-expansion-scope.rs:39:14
182182
|
183183
LL | #![doc = in_mod_escape!()]
@@ -187,5 +187,77 @@ LL | #![doc = in_mod_escape!()]
187187
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
188188
= help: import `macro_rules` with `use` to make it callable above its definition
189189

190-
error: aborting due to 16 previous errors; 6 warnings emitted
190+
error: aborting due to 22 previous errors
191+
192+
Future incompatibility report: Future breakage diagnostic:
193+
error: cannot find macro `in_root` in the current scope when looking from the crate root
194+
--> $DIR/key-value-expansion-scope.rs:1:10
195+
|
196+
LL | #![doc = in_root!()]
197+
| ^^^^^^^ not found from the crate root
198+
|
199+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
200+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
201+
= help: import `macro_rules` with `use` to make it callable above its definition
202+
= note: `#[deny(out_of_scope_macro_calls)]` on by default
203+
204+
Future breakage diagnostic:
205+
error: cannot find macro `in_mod_escape` in the current scope when looking from the crate root
206+
--> $DIR/key-value-expansion-scope.rs:4:10
207+
|
208+
LL | #![doc = in_mod_escape!()]
209+
| ^^^^^^^^^^^^^ not found from the crate root
210+
|
211+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
212+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
213+
= help: import `macro_rules` with `use` to make it callable above its definition
214+
= note: `#[deny(out_of_scope_macro_calls)]` on by default
215+
216+
Future breakage diagnostic:
217+
error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
218+
--> $DIR/key-value-expansion-scope.rs:21:9
219+
|
220+
LL | #[doc = in_mod!()]
221+
| ^^^^^^ not found from module `macros_stay`
222+
|
223+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
224+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
225+
= help: import `macro_rules` with `use` to make it callable above its definition
226+
= note: `#[deny(out_of_scope_macro_calls)]` on by default
227+
228+
Future breakage diagnostic:
229+
error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
230+
--> $DIR/key-value-expansion-scope.rs:24:14
231+
|
232+
LL | #![doc = in_mod!()]
233+
| ^^^^^^ not found from module `macros_stay`
234+
|
235+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
236+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
237+
= help: import `macro_rules` with `use` to make it callable above its definition
238+
= note: `#[deny(out_of_scope_macro_calls)]` on by default
239+
240+
Future breakage diagnostic:
241+
error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape`
242+
--> $DIR/key-value-expansion-scope.rs:36:9
243+
|
244+
LL | #[doc = in_mod_escape!()]
245+
| ^^^^^^^^^^^^^ not found from module `macros_escape`
246+
|
247+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
248+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
249+
= help: import `macro_rules` with `use` to make it callable above its definition
250+
= note: `#[deny(out_of_scope_macro_calls)]` on by default
251+
252+
Future breakage diagnostic:
253+
error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape`
254+
--> $DIR/key-value-expansion-scope.rs:39:14
255+
|
256+
LL | #![doc = in_mod_escape!()]
257+
| ^^^^^^^^^^^^^ not found from module `macros_escape`
258+
|
259+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
260+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
261+
= help: import `macro_rules` with `use` to make it callable above its definition
262+
= note: `#[deny(out_of_scope_macro_calls)]` on by default
191263

tests/ui/extern/issue-80074.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern crate issue_80074_2;
1111

1212
fn main() {
1313
foo!();
14-
//~^ WARN: macro `foo` is private
14+
//~^ ERROR: macro `foo` is private
1515
//~| WARN: it will become a hard error in a future release!
1616
bar!();
1717
//~^ ERROR: cannot find macro `bar` in this scope

tests/ui/extern/issue-80074.stderr

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,27 @@ error: cannot find macro `m` in this scope
1616
LL | m!();
1717
| ^
1818

19-
warning: macro `foo` is private
19+
error: macro `foo` is private
2020
--> $DIR/issue-80074.rs:13:5
2121
|
2222
LL | foo!();
2323
| ^^^
2424
|
2525
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2626
= note: for more information, see issue #120192 <https://github.com/rust-lang/rust/issues/120192>
27-
= note: `#[warn(private_macro_use)]` on by default
27+
= note: `#[deny(private_macro_use)]` on by default
2828

29-
error: aborting due to 3 previous errors; 1 warning emitted
29+
error: aborting due to 4 previous errors
3030

3131
For more information about this error, try `rustc --explain E0469`.
32+
Future incompatibility report: Future breakage diagnostic:
33+
error: macro `foo` is private
34+
--> $DIR/issue-80074.rs:13:5
35+
|
36+
LL | foo!();
37+
| ^^^
38+
|
39+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
40+
= note: for more information, see issue #120192 <https://github.com/rust-lang/rust/issues/120192>
41+
= note: `#[deny(private_macro_use)]` on by default
42+

tests/ui/imports/local-modularized-tricky-fail-2.stderr

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,47 @@ LL | define_exported!();
4141

4242
error: aborting due to 2 previous errors
4343

44+
Future incompatibility report: Future breakage diagnostic:
45+
error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
46+
--> $DIR/local-modularized-tricky-fail-2.rs:13:9
47+
|
48+
LL | use crate::exported;
49+
| ^^^^^^^^^^^^^^^
50+
|
51+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
52+
= note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234>
53+
note: the macro is defined here
54+
--> $DIR/local-modularized-tricky-fail-2.rs:5:5
55+
|
56+
LL | / macro_rules! exported {
57+
LL | | () => ()
58+
LL | | }
59+
| |_____^
60+
...
61+
LL | define_exported!();
62+
| ------------------ in this macro invocation
63+
= note: `#[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)]` on by default
64+
= note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
65+
66+
Future breakage diagnostic:
67+
error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
68+
--> $DIR/local-modularized-tricky-fail-2.rs:19:5
69+
|
70+
LL | crate::exported!();
71+
| ^^^^^^^^^^^^^^^
72+
|
73+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
74+
= note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234>
75+
note: the macro is defined here
76+
--> $DIR/local-modularized-tricky-fail-2.rs:5:5
77+
|
78+
LL | / macro_rules! exported {
79+
LL | | () => ()
80+
LL | | }
81+
| |_____^
82+
...
83+
LL | define_exported!();
84+
| ------------------ in this macro invocation
85+
= note: `#[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)]` on by default
86+
= note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
87+

tests/ui/proc-macro/derive-helper-shadowing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! gen_helper_use {
1717
}
1818

1919
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
20-
//~| WARN derive helper attribute is used before it is introduced
20+
//~| ERROR derive helper attribute is used before it is introduced
2121
//~| WARN this was previously accepted
2222
#[derive(Empty)]
2323
struct S {

tests/ui/proc-macro/derive-helper-shadowing.stderr

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ LL | use test_macros::empty_attr as empty_helper;
5858
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5959
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously
6060

61-
warning: derive helper attribute is used before it is introduced
61+
error: derive helper attribute is used before it is introduced
6262
--> $DIR/derive-helper-shadowing.rs:19:3
6363
|
6464
LL | #[empty_helper]
@@ -69,8 +69,22 @@ LL | #[derive(Empty)]
6969
|
7070
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
7171
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
72-
= note: `#[warn(legacy_derive_helpers)]` on by default
72+
= note: `#[deny(legacy_derive_helpers)]` on by default
7373

74-
error: aborting due to 4 previous errors; 1 warning emitted
74+
error: aborting due to 5 previous errors
7575

7676
For more information about this error, try `rustc --explain E0659`.
77+
Future incompatibility report: Future breakage diagnostic:
78+
error: derive helper attribute is used before it is introduced
79+
--> $DIR/derive-helper-shadowing.rs:19:3
80+
|
81+
LL | #[empty_helper]
82+
| ^^^^^^^^^^^^
83+
...
84+
LL | #[derive(Empty)]
85+
| ----- the attribute is introduced here
86+
|
87+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
88+
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
89+
= note: `#[deny(legacy_derive_helpers)]` on by default
90+

tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate test_macros;
55
use test_macros::empty_attr as empty_helper;
66

77
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
8-
//~| WARN derive helper attribute is used before it is introduced
8+
//~| ERROR derive helper attribute is used before it is introduced
99
//~| WARN this was previously accepted
1010
#[derive(Empty)]
1111
struct S;

tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LL | use test_macros::empty_attr as empty_helper;
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously
1919

20-
warning: derive helper attribute is used before it is introduced
20+
error: derive helper attribute is used before it is introduced
2121
--> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3
2222
|
2323
LL | #[empty_helper]
@@ -28,8 +28,22 @@ LL | #[derive(Empty)]
2828
|
2929
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3030
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
31-
= note: `#[warn(legacy_derive_helpers)]` on by default
31+
= note: `#[deny(legacy_derive_helpers)]` on by default
3232

33-
error: aborting due to 1 previous error; 1 warning emitted
33+
error: aborting due to 2 previous errors
3434

3535
For more information about this error, try `rustc --explain E0659`.
36+
Future incompatibility report: Future breakage diagnostic:
37+
error: derive helper attribute is used before it is introduced
38+
--> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3
39+
|
40+
LL | #[empty_helper]
41+
| ^^^^^^^^^^^^
42+
...
43+
LL | #[derive(Empty)]
44+
| ----- the attribute is introduced here
45+
|
46+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47+
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
48+
= note: `#[deny(legacy_derive_helpers)]` on by default
49+

0 commit comments

Comments
 (0)