diff options
| author | Chris Denton <chris@chrisdenton.dev> | 2025-04-23 00:43:08 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-23 00:43:08 +0000 |
| commit | ecb9775438ecb6fd0e00c0acdbbb0525ed3c8b74 (patch) | |
| tree | a4a447fa95c4c2ade650f26ed074e4341ece4962 /tests/ui | |
| parent | 45b5d8bb5a49a16b7a1d61b610f7142ea694aa9c (diff) | |
| parent | 44b19e5fe7c0fe91b4aa8a09c673b340f3177c64 (diff) | |
| download | rust-ecb9775438ecb6fd0e00c0acdbbb0525ed3c8b74.tar.gz rust-ecb9775438ecb6fd0e00c0acdbbb0525ed3c8b74.zip | |
Rollup merge of #140175 - Kivooeo:new-fix-one, r=compiler-errors
`rc""` more clear error message here is small fix that provides better error message when user is trying to use `rc""` the same way it was made for `rb""` example of it's work ```rust | 2 | rc"\n"; | ^^ unknown prefix | = note: prefixed identifiers and literals are reserved since Rust 2021 help: use `cr` for a raw C-string | 2 - rc"\n"; 2 + cr"\n"; | ``` **related issue** fixes #140170 cc `@cyrgani` (issue author)
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/suggestions/raw-c-string-prefix.rs | 10 | ||||
| -rw-r--r-- | tests/ui/suggestions/raw-c-string-prefix.stderr | 21 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/suggestions/raw-c-string-prefix.rs b/tests/ui/suggestions/raw-c-string-prefix.rs new file mode 100644 index 00000000000..6af72df4024 --- /dev/null +++ b/tests/ui/suggestions/raw-c-string-prefix.rs @@ -0,0 +1,10 @@ +// `rc` and `cr` are easy to confuse; check that we issue a suggestion to help. + +//@ edition:2021 + +fn main() { + rc"abc"; + //~^ ERROR: prefix `rc` is unknown + //~| HELP: use `cr` for a raw C-string + //~| ERROR: expected one of +} diff --git a/tests/ui/suggestions/raw-c-string-prefix.stderr b/tests/ui/suggestions/raw-c-string-prefix.stderr new file mode 100644 index 00000000000..5341e3d04e8 --- /dev/null +++ b/tests/ui/suggestions/raw-c-string-prefix.stderr @@ -0,0 +1,21 @@ +error: prefix `rc` is unknown + --> $DIR/raw-c-string-prefix.rs:6:5 + | +LL | rc"abc"; + | ^^ unknown prefix + | + = note: prefixed identifiers and literals are reserved since Rust 2021 +help: use `cr` for a raw C-string + | +LL - rc"abc"; +LL + cr"abc"; + | + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"abc"` + --> $DIR/raw-c-string-prefix.rs:6:7 + | +LL | rc"abc"; + | ^^^^^ expected one of 8 possible tokens + +error: aborting due to 2 previous errors + |
