about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-07-30 20:39:50 +0530
committerGitHub <noreply@github.com>2022-07-30 20:39:50 +0530
commitdf2cf97830dde8f563b898820ffbba200253326b (patch)
tree0bebcbcecc95ad4ab6936bdc0f04c484e453f71b /src/test/ui
parent79c947443f55bcbfc4a93fdd2ba98cbe50dc3c42 (diff)
parentd0e881eefe871d807fd7527a1366154f1712ada1 (diff)
downloadrust-df2cf97830dde8f563b898820ffbba200253326b.tar.gz
rust-df2cf97830dde8f563b898820ffbba200253326b.zip
Rollup merge of #99903 - gimbles:pub, r=davidtwco
Add diagnostic when using public instead of pub

Forwarding from https://github.com/rust-lang/rust/pull/99706

I accidentally broke something(??) in git and the commits in that PR are absolutely not what I did in that branch

Anyways, this is the PR for this now. Adding tests again in a minute.

cc `@davidtwco`
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/parser/public-instead-of-pub.fixed8
-rw-r--r--src/test/ui/parser/public-instead-of-pub.rs8
-rw-r--r--src/test/ui/parser/public-instead-of-pub.stderr13
3 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/parser/public-instead-of-pub.fixed b/src/test/ui/parser/public-instead-of-pub.fixed
new file mode 100644
index 00000000000..01db609990e
--- /dev/null
+++ b/src/test/ui/parser/public-instead-of-pub.fixed
@@ -0,0 +1,8 @@
+// Checks what happens when `public` is used instead of the correct, `pub`
+// edition:2018
+// run-rustfix
+pub struct X;
+//~^ ERROR expected one of `!` or `::`, found keyword `struct`
+//~^^ HELP write `pub` instead of `public` to make the item public
+
+fn main() {}
diff --git a/src/test/ui/parser/public-instead-of-pub.rs b/src/test/ui/parser/public-instead-of-pub.rs
new file mode 100644
index 00000000000..18e0fd3af1c
--- /dev/null
+++ b/src/test/ui/parser/public-instead-of-pub.rs
@@ -0,0 +1,8 @@
+// Checks what happens when `public` is used instead of the correct, `pub`
+// edition:2018
+// run-rustfix
+public struct X;
+//~^ ERROR expected one of `!` or `::`, found keyword `struct`
+//~^^ HELP write `pub` instead of `public` to make the item public
+
+fn main() {}
diff --git a/src/test/ui/parser/public-instead-of-pub.stderr b/src/test/ui/parser/public-instead-of-pub.stderr
new file mode 100644
index 00000000000..af875491e85
--- /dev/null
+++ b/src/test/ui/parser/public-instead-of-pub.stderr
@@ -0,0 +1,13 @@
+error: expected one of `!` or `::`, found keyword `struct`
+  --> $DIR/public-instead-of-pub.rs:4:8
+   |
+LL | public struct X;
+   |        ^^^^^^ expected one of `!` or `::`
+   |
+help: write `pub` instead of `public` to make the item public
+   |
+LL | pub struct X;
+   | ~~~
+
+error: aborting due to previous error
+