diff options
Diffstat (limited to 'crates/ra_syntax')
6 files changed, 95 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/validation/byte.rs b/crates/ra_syntax/src/validation/byte.rs index 2f9b7fac7..d0897eeed 100644 --- a/crates/ra_syntax/src/validation/byte.rs +++ b/crates/ra_syntax/src/validation/byte.rs | |||
@@ -28,7 +28,10 @@ pub(super) fn validate_byte_node(node: ast::Byte, errors: &mut Vec<SyntaxError>) | |||
28 | } | 28 | } |
29 | 29 | ||
30 | if let Some(range) = components.suffix { | 30 | if let Some(range) = components.suffix { |
31 | errors.push(SyntaxError::new(InvalidSuffix, range)); | 31 | errors.push(SyntaxError::new( |
32 | InvalidSuffix, | ||
33 | range + literal_range.start(), | ||
34 | )); | ||
32 | } | 35 | } |
33 | 36 | ||
34 | if len == 0 { | 37 | if len == 0 { |
diff --git a/crates/ra_syntax/src/validation/byte_string.rs b/crates/ra_syntax/src/validation/byte_string.rs index bf4c934a7..f7a4fb156 100644 --- a/crates/ra_syntax/src/validation/byte_string.rs +++ b/crates/ra_syntax/src/validation/byte_string.rs | |||
@@ -34,7 +34,10 @@ pub(crate) fn validate_byte_string_node(node: ast::ByteString, errors: &mut Vec< | |||
34 | } | 34 | } |
35 | 35 | ||
36 | if let Some(range) = components.suffix { | 36 | if let Some(range) = components.suffix { |
37 | errors.push(SyntaxError::new(InvalidSuffix, range)); | 37 | errors.push(SyntaxError::new( |
38 | InvalidSuffix, | ||
39 | range + literal_range.start(), | ||
40 | )); | ||
38 | } | 41 | } |
39 | } | 42 | } |
40 | 43 | ||
diff --git a/crates/ra_syntax/src/validation/char.rs b/crates/ra_syntax/src/validation/char.rs index 50184aaf8..19cd3830f 100644 --- a/crates/ra_syntax/src/validation/char.rs +++ b/crates/ra_syntax/src/validation/char.rs | |||
@@ -31,7 +31,10 @@ pub(super) fn validate_char_node(node: ast::Char, errors: &mut Vec<SyntaxError>) | |||
31 | } | 31 | } |
32 | 32 | ||
33 | if let Some(range) = components.suffix { | 33 | if let Some(range) = components.suffix { |
34 | errors.push(SyntaxError::new(InvalidSuffix, range)); | 34 | errors.push(SyntaxError::new( |
35 | InvalidSuffix, | ||
36 | range + literal_range.start(), | ||
37 | )); | ||
35 | } | 38 | } |
36 | 39 | ||
37 | if len == 0 { | 40 | if len == 0 { |
diff --git a/crates/ra_syntax/src/validation/string.rs b/crates/ra_syntax/src/validation/string.rs index ff1fb6edc..1371bb1f0 100644 --- a/crates/ra_syntax/src/validation/string.rs +++ b/crates/ra_syntax/src/validation/string.rs | |||
@@ -29,7 +29,10 @@ pub(crate) fn validate_string_node(node: ast::String, errors: &mut Vec<SyntaxErr | |||
29 | } | 29 | } |
30 | 30 | ||
31 | if let Some(range) = components.suffix { | 31 | if let Some(range) = components.suffix { |
32 | errors.push(SyntaxError::new(InvalidSuffix, range)); | 32 | errors.push(SyntaxError::new( |
33 | InvalidSuffix, | ||
34 | range + literal_range.start(), | ||
35 | )); | ||
33 | } | 36 | } |
34 | } | 37 | } |
35 | 38 | ||
diff --git a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.rs b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.rs new file mode 100644 index 000000000..261aad1fb --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.rs | |||
@@ -0,0 +1,6 @@ | |||
1 | fn main() { | ||
2 | let _ = 'c'u32; | ||
3 | let _ = "string"invalid; | ||
4 | let _ = b'b'_suff; | ||
5 | let _ = b"bs"invalid; | ||
6 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt new file mode 100644 index 000000000..dc10e9ee7 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt | |||
@@ -0,0 +1,73 @@ | |||
1 | SOURCE_FILE@[0; 112) | ||
2 | FN_DEF@[0; 111) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 7) | ||
6 | IDENT@[3; 7) "main" | ||
7 | PARAM_LIST@[7; 9) | ||
8 | L_PAREN@[7; 8) | ||
9 | R_PAREN@[8; 9) | ||
10 | WHITESPACE@[9; 10) | ||
11 | BLOCK@[10; 111) | ||
12 | L_CURLY@[10; 11) | ||
13 | WHITESPACE@[11; 16) | ||
14 | LET_STMT@[16; 27) | ||
15 | LET_KW@[16; 19) | ||
16 | WHITESPACE@[19; 20) | ||
17 | PLACEHOLDER_PAT@[20; 21) | ||
18 | UNDERSCORE@[20; 21) | ||
19 | WHITESPACE@[21; 22) | ||
20 | EQ@[22; 23) | ||
21 | WHITESPACE@[23; 24) | ||
22 | LITERAL@[24; 27) | ||
23 | CHAR@[24; 27) | ||
24 | err: `expected SEMI` | ||
25 | EXPR_STMT@[27; 31) | ||
26 | PATH_EXPR@[27; 30) | ||
27 | PATH@[27; 30) | ||
28 | PATH_SEGMENT@[27; 30) | ||
29 | NAME_REF@[27; 30) | ||
30 | IDENT@[27; 30) "u32" | ||
31 | SEMI@[30; 31) | ||
32 | WHITESPACE@[31; 36) | ||
33 | LET_STMT@[36; 60) | ||
34 | LET_KW@[36; 39) | ||
35 | WHITESPACE@[39; 40) | ||
36 | PLACEHOLDER_PAT@[40; 41) | ||
37 | UNDERSCORE@[40; 41) | ||
38 | WHITESPACE@[41; 42) | ||
39 | EQ@[42; 43) | ||
40 | WHITESPACE@[43; 44) | ||
41 | LITERAL@[44; 59) | ||
42 | STRING@[44; 59) | ||
43 | err: `Invalid literal suffix` | ||
44 | SEMI@[59; 60) | ||
45 | WHITESPACE@[60; 65) | ||
46 | LET_STMT@[65; 83) | ||
47 | LET_KW@[65; 68) | ||
48 | WHITESPACE@[68; 69) | ||
49 | PLACEHOLDER_PAT@[69; 70) | ||
50 | UNDERSCORE@[69; 70) | ||
51 | WHITESPACE@[70; 71) | ||
52 | EQ@[71; 72) | ||
53 | WHITESPACE@[72; 73) | ||
54 | LITERAL@[73; 82) | ||
55 | BYTE@[73; 82) | ||
56 | err: `Invalid literal suffix` | ||
57 | SEMI@[82; 83) | ||
58 | WHITESPACE@[83; 88) | ||
59 | LET_STMT@[88; 109) | ||
60 | LET_KW@[88; 91) | ||
61 | WHITESPACE@[91; 92) | ||
62 | PLACEHOLDER_PAT@[92; 93) | ||
63 | UNDERSCORE@[92; 93) | ||
64 | WHITESPACE@[93; 94) | ||
65 | EQ@[94; 95) | ||
66 | WHITESPACE@[95; 96) | ||
67 | LITERAL@[96; 108) | ||
68 | BYTE_STRING@[96; 108) | ||
69 | err: `Invalid literal suffix` | ||
70 | SEMI@[108; 109) | ||
71 | WHITESPACE@[109; 110) | ||
72 | R_CURLY@[110; 111) | ||
73 | WHITESPACE@[111; 112) | ||