diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-15 10:44:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-15 10:44:11 +0100 |
| commit | 769f231371d09ef81193f028be070a3bdec9a202 (patch) | |
| tree | 26da4b9297f9d93a726dcd81ba8648a6c8f3eca5 /src/test/ui | |
| parent | d8b416db0af5b26fb01db3a275f2f3c114b36c61 (diff) | |
| parent | b2b509491d55072d31935c4c3f267d3d46f61f03 (diff) | |
| download | rust-769f231371d09ef81193f028be070a3bdec9a202.tar.gz rust-769f231371d09ef81193f028be070a3bdec9a202.zip | |
Rollup merge of #104309 - chenyukang:yukang/fix-104088-identifier-error, r=davidtwco
Slightly improve error message for invalid identifier fixes #104088
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/parser/issues/issue-104088.rs | 26 | ||||
| -rw-r--r-- | src/test/ui/parser/issues/issue-104088.stderr | 29 | ||||
| -rw-r--r-- | src/test/ui/parser/slowparse-bstring.rs (renamed from src/test/ui/slowparse-bstring.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/parser/slowparse-string.rs (renamed from src/test/ui/slowparse-string.rs) | 0 |
4 files changed, 55 insertions, 0 deletions
diff --git a/src/test/ui/parser/issues/issue-104088.rs b/src/test/ui/parser/issues/issue-104088.rs new file mode 100644 index 00000000000..5f794fe2dc9 --- /dev/null +++ b/src/test/ui/parser/issues/issue-104088.rs @@ -0,0 +1,26 @@ +fn test() { + if let 123 = 123 { println!("yes"); } +} + +fn test_2() { + let 1x = 123; + //~^ ERROR expected identifier, found number literal +} + +fn test_3() { + let 2x: i32 = 123; + //~^ ERROR expected identifier, found number literal +} + +fn test_4() { + if let 2e1 = 123 { + //~^ ERROR mismatched types + } +} + +fn test_5() { + let 23name = 123; + //~^ ERROR expected identifier, found number literal +} + +fn main() {} diff --git a/src/test/ui/parser/issues/issue-104088.stderr b/src/test/ui/parser/issues/issue-104088.stderr new file mode 100644 index 00000000000..ff4b4bdb695 --- /dev/null +++ b/src/test/ui/parser/issues/issue-104088.stderr @@ -0,0 +1,29 @@ +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:6:9 + | +LL | let 1x = 123; + | ^^ identifiers cannot start with a number + +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:11:9 + | +LL | let 2x: i32 = 123; + | ^^ identifiers cannot start with a number + +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:22:9 + | +LL | let 23name = 123; + | ^^^^^^ identifiers cannot start with a number + +error[E0308]: mismatched types + --> $DIR/issue-104088.rs:16:12 + | +LL | if let 2e1 = 123 { + | ^^^ --- this expression has type `{integer}` + | | + | expected integer, found floating-point number + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/slowparse-bstring.rs b/src/test/ui/parser/slowparse-bstring.rs index f3a6a668372..f3a6a668372 100644 --- a/src/test/ui/slowparse-bstring.rs +++ b/src/test/ui/parser/slowparse-bstring.rs diff --git a/src/test/ui/slowparse-string.rs b/src/test/ui/parser/slowparse-string.rs index 6ebc61dae78..6ebc61dae78 100644 --- a/src/test/ui/slowparse-string.rs +++ b/src/test/ui/parser/slowparse-string.rs |
