aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-14 20:58:20 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-14 20:58:20 +0000
commite8e82ce032f8678929b015e6f70ac060bb2cf94c (patch)
tree9fb158e9f7115bb70cf2b8623b70710c55497ed4 /crates/ra_ide_api/src
parent784ff638e549a27503b719e5c2f0009b40d25364 (diff)
parent37ba237e6686d94783d1f025d23823ad7c0cb0c8 (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_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/hover.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index d73c5bc31..107b23833 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -230,20 +230,19 @@ mod tests {
230 assert_eq!("[unknown]", &type_name); 230 assert_eq!("[unknown]", &type_name);
231 } 231 }
232 232
233 // FIXME: improve type_of to make this work
234 #[test] 233 #[test]
235 fn test_type_of_for_expr_2() { 234 fn test_type_of_for_expr_2() {
236 let (analysis, range) = single_file_with_range( 235 let (analysis, range) = single_file_with_range(
237 " 236 "
238 fn main() { 237 fn main() {
239 let foo: usize = 1; 238 let foo: usize = 1;
240 let bar = <|>1 + foo_test<|>; 239 let bar = <|>1 + foo<|>;
241 } 240 }
242 ", 241 ",
243 ); 242 );
244 243
245 let type_name = analysis.type_of(range).unwrap().unwrap(); 244 let type_name = analysis.type_of(range).unwrap().unwrap();
246 assert_eq!("[unknown]", &type_name); 245 assert_eq!("usize", &type_name);
247 } 246 }
248 247
249} 248}