diff options
8 files changed, 53 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/lexer.rs b/crates/ra_syntax/src/lexer.rs index c6acd095e..0c3847120 100644 --- a/crates/ra_syntax/src/lexer.rs +++ b/crates/ra_syntax/src/lexer.rs | |||
@@ -190,13 +190,12 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
190 | } | 190 | } |
191 | 191 | ||
192 | fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { | 192 | fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { |
193 | let is_single_letter = match ptr.current() { | 193 | match (c, ptr.current()) { |
194 | None => true, | 194 | ('r', Some('#')) => { |
195 | Some(c) if !is_ident_continue(c) => true, | 195 | ptr.bump(); |
196 | _ => false, | 196 | } |
197 | }; | 197 | ('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE, |
198 | if is_single_letter { | 198 | _ => {} |
199 | return if c == '_' { UNDERSCORE } else { IDENT }; | ||
200 | } | 199 | } |
201 | ptr.bump_while(is_ident_continue); | 200 | ptr.bump_while(is_ident_continue); |
202 | if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { | 201 | if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { |
diff --git a/crates/ra_syntax/src/lexer/strings.rs b/crates/ra_syntax/src/lexer/strings.rs index 0865b7f3b..5c1cf3e9c 100644 --- a/crates/ra_syntax/src/lexer/strings.rs +++ b/crates/ra_syntax/src/lexer/strings.rs | |||
@@ -5,7 +5,8 @@ use crate::lexer::ptr::Ptr; | |||
5 | pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { | 5 | pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { |
6 | match (c, c1, c2) { | 6 | match (c, c1, c2) { |
7 | ('r', Some('"'), _) | 7 | ('r', Some('"'), _) |
8 | | ('r', Some('#'), _) | 8 | | ('r', Some('#'), Some('"')) |
9 | | ('r', Some('#'), Some('#')) | ||
9 | | ('b', Some('"'), _) | 10 | | ('b', Some('"'), _) |
10 | | ('b', Some('\''), _) | 11 | | ('b', Some('\''), _) |
11 | | ('b', Some('r'), Some('"')) | 12 | | ('b', Some('r'), Some('"')) |
diff --git a/crates/ra_syntax/tests/data/lexer/0016_raw_ident.rs b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.rs new file mode 100644 index 000000000..b40a1b6a2 --- /dev/null +++ b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.rs | |||
@@ -0,0 +1 @@ | |||
r#raw_ident | |||
diff --git a/crates/ra_syntax/tests/data/lexer/0016_raw_ident.txt b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.txt new file mode 100644 index 000000000..484689693 --- /dev/null +++ b/crates/ra_syntax/tests/data/lexer/0016_raw_ident.txt | |||
@@ -0,0 +1,2 @@ | |||
1 | IDENT 11 "r#raw_ident" | ||
2 | WHITESPACE 1 "\n" | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.rs b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.rs new file mode 100644 index 000000000..8380d1e79 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.rs | |||
@@ -0,0 +1,2 @@ | |||
1 | fn r#foo() { | ||
2 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.txt b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.txt new file mode 100644 index 000000000..dcd055d86 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0039_raw_fn_item.txt | |||
@@ -0,0 +1,15 @@ | |||
1 | SOURCE_FILE@[0; 15) | ||
2 | FN_DEF@[0; 14) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 8) | ||
6 | IDENT@[3; 8) "r#foo" | ||
7 | PARAM_LIST@[8; 10) | ||
8 | L_PAREN@[8; 9) | ||
9 | R_PAREN@[9; 10) | ||
10 | WHITESPACE@[10; 11) | ||
11 | BLOCK@[11; 14) | ||
12 | L_CURLY@[11; 12) | ||
13 | WHITESPACE@[12; 13) | ||
14 | R_CURLY@[13; 14) | ||
15 | WHITESPACE@[14; 15) | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.rs b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.rs new file mode 100644 index 000000000..098a60a72 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | struct S { | ||
2 | r#foo: u32 | ||
3 | } \ No newline at end of file | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.txt b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.txt new file mode 100644 index 000000000..361e53152 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0040_raw_struct_item_field.txt | |||
@@ -0,0 +1,22 @@ | |||
1 | SOURCE_FILE@[0; 27) | ||
2 | STRUCT_DEF@[0; 27) | ||
3 | STRUCT_KW@[0; 6) | ||
4 | WHITESPACE@[6; 7) | ||
5 | NAME@[7; 8) | ||
6 | IDENT@[7; 8) "S" | ||
7 | WHITESPACE@[8; 9) | ||
8 | NAMED_FIELD_DEF_LIST@[9; 27) | ||
9 | L_CURLY@[9; 10) | ||
10 | WHITESPACE@[10; 15) | ||
11 | NAMED_FIELD_DEF@[15; 25) | ||
12 | NAME@[15; 20) | ||
13 | IDENT@[15; 20) "r#foo" | ||
14 | COLON@[20; 21) | ||
15 | WHITESPACE@[21; 22) | ||
16 | PATH_TYPE@[22; 25) | ||
17 | PATH@[22; 25) | ||
18 | PATH_SEGMENT@[22; 25) | ||
19 | NAME_REF@[22; 25) | ||
20 | IDENT@[22; 25) "u32" | ||
21 | WHITESPACE@[25; 26) | ||
22 | R_CURLY@[26; 27) | ||