Skip to content

Commit d4b5345

Browse files
authored
Rollup merge of rust-lang#133992 - compiler-errors:walk-fully, r=jieyouxu
Actually walk into lifetimes and attrs in `EarlyContextAndPass` Visitors that don't also call `walk_*` are kinda a footgun... I believe all the other early lint functions walk into their types correctly at this point.
2 parents a12f3aa + db9e368 commit d4b5345

File tree

6 files changed

+95
-5
lines changed

6 files changed

+95
-5
lines changed

Diff for: compiler/rustc_lint/src/early.rs

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
245245

246246
fn visit_lifetime(&mut self, lt: &'a ast::Lifetime, _: ast_visit::LifetimeCtxt) {
247247
self.check_id(lt.id);
248+
ast_visit::walk_lifetime(self, lt);
248249
}
249250

250251
fn visit_path(&mut self, p: &'a ast::Path, id: ast::NodeId) {
@@ -259,6 +260,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
259260

260261
fn visit_attribute(&mut self, attr: &'a ast::Attribute) {
261262
lint_callback!(self, check_attribute, attr);
263+
ast_visit::walk_attribute(self, attr);
262264
}
263265

264266
fn visit_mac_def(&mut self, mac: &'a ast::MacroDef, id: ast::NodeId) {

Diff for: compiler/rustc_lint/src/hidden_unicode_codepoints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::lints::{
99
use crate::{EarlyContext, EarlyLintPass, LintContext};
1010

1111
declare_lint! {
12+
#[allow(text_direction_codepoint_in_literal)]
1213
/// The `text_direction_codepoint_in_literal` lint detects Unicode codepoints that change the
1314
/// visual representation of text on screen in a way that does not correspond to their on
1415
/// memory representation.

Diff for: compiler/rustc_lint_defs/src/builtin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3929,6 +3929,7 @@ declare_lint! {
39293929
}
39303930

39313931
declare_lint! {
3932+
#[allow(text_direction_codepoint_in_literal)]
39323933
/// The `text_direction_codepoint_in_comment` lint detects Unicode codepoints in comments that
39333934
/// change the visual representation of text on screen in a way that does not correspond to
39343935
/// their on memory representation.

Diff for: tests/ui/rust-2024/gen-kw.e2015.stderr

+38-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,47 @@ LL | () => { mod test { fn gen() {} } }
3434
error: `gen` is a keyword in the 2024 edition
3535
--> $DIR/gen-kw.rs:25:9
3636
|
37-
LL | fn test<'gen>() {}
37+
LL | fn test<'gen>(_: &'gen i32) {}
3838
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
3939
|
4040
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
4141
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
4242

43-
error: aborting due to 4 previous errors
43+
error: `gen` is a keyword in the 2024 edition
44+
--> $DIR/gen-kw.rs:25:19
45+
|
46+
LL | fn test<'gen>(_: &'gen i32) {}
47+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
48+
|
49+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
50+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
51+
52+
error: `gen` is a keyword in the 2024 edition
53+
--> $DIR/gen-kw.rs:33:13
54+
|
55+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
56+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
57+
|
58+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
59+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
60+
61+
error: `gen` is a keyword in the 2024 edition
62+
--> $DIR/gen-kw.rs:33:28
63+
|
64+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
65+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
66+
|
67+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
68+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
69+
70+
error: `gen` is a keyword in the 2024 edition
71+
--> $DIR/gen-kw.rs:33:37
72+
|
73+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
74+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
75+
|
76+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
77+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
78+
79+
error: aborting due to 8 previous errors
4480

Diff for: tests/ui/rust-2024/gen-kw.e2018.stderr

+38-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,47 @@ LL | () => { mod test { fn gen() {} } }
3434
error: `gen` is a keyword in the 2024 edition
3535
--> $DIR/gen-kw.rs:25:9
3636
|
37-
LL | fn test<'gen>() {}
37+
LL | fn test<'gen>(_: &'gen i32) {}
3838
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
3939
|
4040
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
4141
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
4242

43-
error: aborting due to 4 previous errors
43+
error: `gen` is a keyword in the 2024 edition
44+
--> $DIR/gen-kw.rs:25:19
45+
|
46+
LL | fn test<'gen>(_: &'gen i32) {}
47+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
48+
|
49+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
50+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
51+
52+
error: `gen` is a keyword in the 2024 edition
53+
--> $DIR/gen-kw.rs:33:13
54+
|
55+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
56+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
57+
|
58+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
59+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
60+
61+
error: `gen` is a keyword in the 2024 edition
62+
--> $DIR/gen-kw.rs:33:28
63+
|
64+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
65+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
66+
|
67+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
68+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
69+
70+
error: `gen` is a keyword in the 2024 edition
71+
--> $DIR/gen-kw.rs:33:37
72+
|
73+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
74+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
75+
|
76+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
77+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
78+
79+
error: aborting due to 8 previous errors
4480

Diff for: tests/ui/rust-2024/gen-kw.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,23 @@ macro_rules! t {
2222
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
2323
}
2424

25-
fn test<'gen>() {}
25+
fn test<'gen>(_: &'gen i32) {}
2626
//~^ ERROR `gen` is a keyword in the 2024 edition
27+
//~| ERROR `gen` is a keyword in the 2024 edition
2728
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
29+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
30+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
31+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
32+
33+
struct Test<'gen>(Box<Test<'gen>>, &'gen ());
34+
//~^ ERROR `gen` is a keyword in the 2024 edition
35+
//~| ERROR `gen` is a keyword in the 2024 edition
36+
//~| ERROR `gen` is a keyword in the 2024 edition
37+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
38+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
39+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
40+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
41+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
2842
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
2943

3044
t!();

0 commit comments

Comments
 (0)