Skip to content

Commit 35bb73e

Browse files
committed
Add test for pub let inside function recovery
1 parent f270bb1 commit 35bb73e

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

tests/ui/parser/pub-let.fixed

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// run-rustfix
2+
3+
#![allow(unused_variables)]
4+
5+
fn main() {
6+
let x = 1;
7+
//~^ ERROR visibility `pub` is not followed by an item
8+
//~^^ ERROR visibility does not apply to `let` statement
9+
}

tests/ui/parser/pub-let.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// run-rustfix
2+
3+
#![allow(unused_variables)]
4+
5+
fn main() {
6+
pub let x = 1;
7+
//~^ ERROR visibility `pub` is not followed by an item
8+
//~^^ ERROR visibility does not apply to `let` statement
9+
}

tests/ui/parser/pub-let.stderr

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: visibility `pub` is not followed by an item
2+
--> $DIR/pub-let.rs:6:5
3+
|
4+
LL | pub let x = 1;
5+
| ^^^ the visibility
6+
|
7+
= help: you likely meant to define an item, e.g., `pub fn foo() {}`
8+
9+
error: visibility does not apply to `let` statement
10+
--> $DIR/pub-let.rs:6:5
11+
|
12+
LL | pub let x = 1;
13+
| ^^^^^^^ help: remove pub: `let`
14+
15+
error: aborting due to 2 previous errors
16+

0 commit comments

Comments
 (0)