diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-14 20:58:20 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-14 20:58:20 +0000 |
commit | e8e82ce032f8678929b015e6f70ac060bb2cf94c (patch) | |
tree | 9fb158e9f7115bb70cf2b8623b70710c55497ed4 /crates/ra_syntax/src/lexer | |
parent | 784ff638e549a27503b719e5c2f0009b40d25364 (diff) | |
parent | 37ba237e6686d94783d1f025d23823ad7c0cb0c8 (diff) |
Merge #485
485: Add type inference for a bunch of primitives r=flodiebold a=marcusklaas
This PR adds inference for `&str`, `&[u8]`, `char`, `bool`, floats and integers. For floats and integers it uses type variables to infer the exact type, i.e. `u32`, from context when it's not annotated explicitly.
I'm not quite happy with the implementation yet, but I think it mostly works now.
Co-authored-by: Marcus Klaas de Vries <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/lexer')
-rw-r--r-- | crates/ra_syntax/src/lexer/strings.rs | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/crates/ra_syntax/src/lexer/strings.rs b/crates/ra_syntax/src/lexer/strings.rs index 5090feae6..0865b7f3b 100644 --- a/crates/ra_syntax/src/lexer/strings.rs +++ b/crates/ra_syntax/src/lexer/strings.rs | |||
@@ -49,7 +49,7 @@ pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind { | |||
49 | BYTE_STRING | 49 | BYTE_STRING |
50 | } | 50 | } |
51 | 'r' => { | 51 | 'r' => { |
52 | scan_raw_byte_string(ptr); | 52 | scan_raw_string(ptr); |
53 | RAW_BYTE_STRING | 53 | RAW_BYTE_STRING |
54 | } | 54 | } |
55 | _ => unreachable!(), | 55 | _ => unreachable!(), |
@@ -108,16 +108,3 @@ fn scan_byte(ptr: &mut Ptr) { | |||
108 | fn scan_byte_string(ptr: &mut Ptr) { | 108 | fn scan_byte_string(ptr: &mut Ptr) { |
109 | scan_string(ptr) | 109 | scan_string(ptr) |
110 | } | 110 | } |
111 | |||
112 | fn scan_raw_byte_string(ptr: &mut Ptr) { | ||
113 | if !ptr.at('"') { | ||
114 | return; | ||
115 | } | ||
116 | ptr.bump(); | ||
117 | |||
118 | while let Some(c) = ptr.bump() { | ||
119 | if c == '"' { | ||
120 | return; | ||
121 | } | ||
122 | } | ||
123 | } | ||