Skip to content

Commit

Permalink
Rollup merge of rust-lang#133992 - compiler-errors:walk-fully, r=jiey…
Browse files Browse the repository at this point in the history
…ouxu

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.
  • Loading branch information
workingjubilee authored Dec 7, 2024
2 parents 01cb534 + db9e368 commit c62e2da
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 5 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>

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

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

fn visit_attribute(&mut self, attr: &'a ast::Attribute) {
lint_callback!(self, check_attribute, attr);
ast_visit::walk_attribute(self, attr);
}

fn visit_mac_def(&mut self, mac: &'a ast::MacroDef, id: ast::NodeId) {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/hidden_unicode_codepoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::lints::{
use crate::{EarlyContext, EarlyLintPass, LintContext};

declare_lint! {
#[allow(text_direction_codepoint_in_literal)]
/// The `text_direction_codepoint_in_literal` lint detects Unicode codepoints that change the
/// visual representation of text on screen in a way that does not correspond to their on
/// memory representation.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3929,6 +3929,7 @@ declare_lint! {
}

declare_lint! {
#[allow(text_direction_codepoint_in_literal)]
/// The `text_direction_codepoint_in_comment` lint detects Unicode codepoints in comments that
/// change the visual representation of text on screen in a way that does not correspond to
/// their on memory representation.
Expand Down
40 changes: 38 additions & 2 deletions tests/ui/rust-2024/gen-kw.e2015.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,47 @@ LL | () => { mod test { fn gen() {} } }
error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:25:9
|
LL | fn test<'gen>() {}
LL | fn test<'gen>(_: &'gen i32) {}
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: aborting due to 4 previous errors
error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:25:19
|
LL | fn test<'gen>(_: &'gen i32) {}
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:33:13
|
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:33:28
|
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:33:37
|
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: aborting due to 8 previous errors

40 changes: 38 additions & 2 deletions tests/ui/rust-2024/gen-kw.e2018.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,47 @@ LL | () => { mod test { fn gen() {} } }
error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:25:9
|
LL | fn test<'gen>() {}
LL | fn test<'gen>(_: &'gen i32) {}
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: aborting due to 4 previous errors
error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:25:19
|
LL | fn test<'gen>(_: &'gen i32) {}
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:33:13
|
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:33:28
|
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `gen` is a keyword in the 2024 edition
--> $DIR/gen-kw.rs:33:37
|
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: aborting due to 8 previous errors

16 changes: 15 additions & 1 deletion tests/ui/rust-2024/gen-kw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,23 @@ macro_rules! t {
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
}

fn test<'gen>() {}
fn test<'gen>(_: &'gen i32) {}
//~^ ERROR `gen` is a keyword in the 2024 edition
//~| ERROR `gen` is a keyword in the 2024 edition
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!

struct Test<'gen>(Box<Test<'gen>>, &'gen ());
//~^ ERROR `gen` is a keyword in the 2024 edition
//~| ERROR `gen` is a keyword in the 2024 edition
//~| ERROR `gen` is a keyword in the 2024 edition
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!

t!();

0 comments on commit c62e2da

Please sign in to comment.