Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually walk into lifetimes and attrs in EarlyContextAndPass #133992

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!();
Loading