Skip to content

Commit d79dc38

Browse files
committed
Move assist test, add literal type inference test
1 parent fab8e9b commit d79dc38

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

crates/ra_assists/src/add_explicit_type.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ mod tests {
6969
);
7070
}
7171

72-
// https://github.com/rust-analyzer/rust-analyzer/issues/1592
73-
#[test]
74-
fn add_explicit_type_infers_correct_type_for_floating_point_literal() {
75-
check_assist(
76-
add_explicit_type,
77-
"fn f() { let a<|> = 42f64; }",
78-
"fn f() { let a<|>: f64 = 42f64; }",
79-
);
80-
check_assist(
81-
add_explicit_type,
82-
"fn f() { let a<|> = 42f32; }",
83-
"fn f() { let a<|>: f32 = 42f32; }",
84-
);
85-
}
86-
8772
#[test]
8873
fn add_explicit_type_not_applicable_if_ty_not_inferred() {
8974
check_assist_not_applicable(add_explicit_type, "fn f() { let a<|> = None; }");

crates/ra_hir/src/ty/tests.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ fn infer_literals() {
334334
infer(r##"
335335
fn test() {
336336
5i32;
337+
5f32;
338+
5f64;
337339
"hello";
338340
b"bytes";
339341
'c';
@@ -351,18 +353,20 @@ fn test() {
351353
}
352354
"##),
353355
@r###"
354-
[11; 201) '{ ...o"#; }': ()
356+
[11; 221) '{ ...o"#; }': ()
355357
[17; 21) '5i32': i32
356-
[27; 34) '"hello"': &str
357-
[40; 48) 'b"bytes"': &[u8]
358-
[54; 57) ''c'': char
359-
[63; 67) 'b'b'': u8
360-
[73; 77) '3.14': f64
361-
[83; 87) '5000': i32
362-
[93; 98) 'false': bool
363-
[104; 108) 'true': bool
364-
[114; 182) 'r#" ... "#': &str
365-
[188; 198) 'br#"yolo"#': &[u8]"###
358+
[27; 31) '5f32': f32
359+
[37; 41) '5f64': f64
360+
[47; 54) '"hello"': &str
361+
[60; 68) 'b"bytes"': &[u8]
362+
[74; 77) ''c'': char
363+
[83; 87) 'b'b'': u8
364+
[93; 97) '3.14': f64
365+
[103; 107) '5000': i32
366+
[113; 118) 'false': bool
367+
[124; 128) 'true': bool
368+
[134; 202) 'r#" ... "#': &str
369+
[208; 218) 'br#"yolo"#': &[u8]"###
366370
);
367371
}
368372

0 commit comments

Comments
 (0)