diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-09-12 15:21:31 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-12 15:21:31 +0530 |
| commit | d7bad03cabe350b5d8aa6669108272ac06e8bea3 (patch) | |
| tree | 30bbade7064c28bd8b356180c72ca46a058270c7 | |
| parent | 93177758fccdaac08d606348f79b20e9cd9df022 (diff) | |
| parent | 975dd6cdea09253f4f3ae0e5c4217ea2cc2d5319 (diff) | |
| download | rust-d7bad03cabe350b5d8aa6669108272ac06e8bea3.tar.gz rust-d7bad03cabe350b5d8aa6669108272ac06e8bea3.zip | |
Rollup merge of #101668 - chenyukang:fix-101626, r=TaKO8Ki
Suggest pub instead of public for const type item Fixes #101626
| -rw-r--r-- | compiler/rustc_ast/src/token.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/parser/public-instead-of-pub-3.fixed | 9 | ||||
| -rw-r--r-- | src/test/ui/parser/public-instead-of-pub-3.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/parser/public-instead-of-pub-3.stderr | 13 |
4 files changed, 32 insertions, 0 deletions
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 + |
