Skip to content

Commit ed43263

Browse files
committed
fix tests
1 parent dd14f10 commit ed43263

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

src/tools/rust-analyzer/crates/parser/src/lexed_str.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,8 @@ impl<'a> Converter<'a> {
331331
}
332332
C_STRING
333333
}
334-
rustc_lexer::LiteralKind::GuardedStr { n_hashes } => {
335-
if n_hashes.is_none() {
336-
err = "Invalid string literal";
337-
}
334+
rustc_lexer::LiteralKind::GuardedStr { .. } => {
335+
err = "Invalid string literal";
338336
STRING
339337
}
340338
};

tests/ui/rust-2024/reserved-guarded-strings.rs

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ fn main() {
4444
demo4!("foo"###);
4545

4646
demo2!(blah"xx"); //~ ERROR prefix `blah` is unknown
47+
demo2!(blah#"xx"#); //~ ERROR prefix `blah` is unknown
48+
//~^ ERROR invalid string literal
4749

4850
demo1!(#""); //~ ERROR invalid string literal
4951
demo1!(#""#); //~ ERROR invalid string literal

tests/ui/rust-2024/reserved-guarded-strings.stderr

+34-10
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,32 @@ help: consider inserting whitespace here
1010
LL | demo2!(blah "xx");
1111
| +
1212

13+
error: prefix `blah` is unknown
14+
--> $DIR/reserved-guarded-strings.rs:47:12
15+
|
16+
LL | demo2!(blah#"xx"#);
17+
| ^^^^ unknown prefix
18+
|
19+
= note: prefixed identifiers and literals are reserved since Rust 2021
20+
help: consider inserting whitespace here
21+
|
22+
LL | demo2!(blah #"xx"#);
23+
| +
24+
25+
error: invalid string literal
26+
--> $DIR/reserved-guarded-strings.rs:47:16
27+
|
28+
LL | demo2!(blah#"xx"#);
29+
| ^^^^^^
30+
|
31+
= note: unprefixed guarded string literals are reserved for future use since Rust 2024
32+
help: consider inserting whitespace here
33+
|
34+
LL | demo2!(blah# "xx"#);
35+
| +
36+
1337
error: invalid string literal
14-
--> $DIR/reserved-guarded-strings.rs:48:12
38+
--> $DIR/reserved-guarded-strings.rs:50:12
1539
|
1640
LL | demo1!(#"");
1741
| ^^^
@@ -23,7 +47,7 @@ LL | demo1!(# "");
2347
| +
2448

2549
error: invalid string literal
26-
--> $DIR/reserved-guarded-strings.rs:49:12
50+
--> $DIR/reserved-guarded-strings.rs:51:12
2751
|
2852
LL | demo1!(#""#);
2953
| ^^^^
@@ -35,7 +59,7 @@ LL | demo1!(# ""#);
3559
| +
3660

3761
error: invalid string literal
38-
--> $DIR/reserved-guarded-strings.rs:50:12
62+
--> $DIR/reserved-guarded-strings.rs:52:12
3963
|
4064
LL | demo1!(####"");
4165
| ^^^^^^
@@ -47,7 +71,7 @@ LL | demo1!(#### "");
4771
| +
4872

4973
error: invalid string literal
50-
--> $DIR/reserved-guarded-strings.rs:51:12
74+
--> $DIR/reserved-guarded-strings.rs:53:12
5175
|
5276
LL | demo1!(#"foo");
5377
| ^^^^^^
@@ -59,7 +83,7 @@ LL | demo1!(# "foo");
5983
| +
6084

6185
error: invalid string literal
62-
--> $DIR/reserved-guarded-strings.rs:52:12
86+
--> $DIR/reserved-guarded-strings.rs:54:12
6387
|
6488
LL | demo1!(###"foo");
6589
| ^^^^^^^^
@@ -71,7 +95,7 @@ LL | demo1!(### "foo");
7195
| +
7296

7397
error: invalid string literal
74-
--> $DIR/reserved-guarded-strings.rs:53:12
98+
--> $DIR/reserved-guarded-strings.rs:55:12
7599
|
76100
LL | demo1!(#"foo"#);
77101
| ^^^^^^^
@@ -83,7 +107,7 @@ LL | demo1!(# "foo"#);
83107
| +
84108

85109
error: invalid string literal
86-
--> $DIR/reserved-guarded-strings.rs:54:12
110+
--> $DIR/reserved-guarded-strings.rs:56:12
87111
|
88112
LL | demo1!(###"foo"#);
89113
| ^^^^^^^^^
@@ -95,7 +119,7 @@ LL | demo1!(### "foo"#);
95119
| +
96120

97121
error: invalid string literal
98-
--> $DIR/reserved-guarded-strings.rs:55:12
122+
--> $DIR/reserved-guarded-strings.rs:57:12
99123
|
100124
LL | demo1!(###"foo"##);
101125
| ^^^^^^^^^^
@@ -107,7 +131,7 @@ LL | demo1!(### "foo"##);
107131
| +
108132

109133
error: invalid string literal
110-
--> $DIR/reserved-guarded-strings.rs:56:12
134+
--> $DIR/reserved-guarded-strings.rs:58:12
111135
|
112136
LL | demo1!(###"foo"###);
113137
| ^^^^^^^^^^^
@@ -118,5 +142,5 @@ help: consider inserting whitespace here
118142
LL | demo1!(### "foo"###);
119143
| +
120144

121-
error: aborting due to 10 previous errors
145+
error: aborting due to 12 previous errors
122146

0 commit comments

Comments
 (0)