diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index bfc4db32d37..97dfb783767 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -473,6 +473,7 @@ impl Token { kw::Extern, kw::Impl, kw::Unsafe, + kw::Const, kw::Static, kw::Union, kw::Macro, diff --git a/src/test/ui/parser/public-instead-of-pub-3.fixed b/src/test/ui/parser/public-instead-of-pub-3.fixed new file mode 100644 index 00000000000..14f620f41e8 --- /dev/null +++ b/src/test/ui/parser/public-instead-of-pub-3.fixed @@ -0,0 +1,9 @@ +// run-rustfix +mod test { + pub const X: i32 = 123; + //~^ ERROR expected one of `!` or `::`, found keyword `const` +} + +fn main() { + println!("{}", test::X); +} diff --git a/src/test/ui/parser/public-instead-of-pub-3.rs b/src/test/ui/parser/public-instead-of-pub-3.rs new file mode 100644 index 00000000000..ee27cb1a1a8 --- /dev/null +++ b/src/test/ui/parser/public-instead-of-pub-3.rs @@ -0,0 +1,9 @@ +// run-rustfix +mod test { + public const X: i32 = 123; + //~^ ERROR expected one of `!` or `::`, found keyword `const` +} + +fn main() { + println!("{}", test::X); +} diff --git a/src/test/ui/parser/public-instead-of-pub-3.stderr b/src/test/ui/parser/public-instead-of-pub-3.stderr new file mode 100644 index 00000000000..72efae08dda --- /dev/null +++ b/src/test/ui/parser/public-instead-of-pub-3.stderr @@ -0,0 +1,13 @@ +error: expected one of `!` or `::`, found keyword `const` + --> $DIR/public-instead-of-pub-3.rs:3:12 + | +LL | public const X: i32 = 123; + | ^^^^^ expected one of `!` or `::` + | +help: write `pub` instead of `public` to make the item public + | +LL | pub const X: i32 = 123; + | ~~~ + +error: aborting due to previous error +