mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Move assist test, add literal type inference test
This commit is contained in:
parent
fab8e9bb8a
commit
d79dc38e99
2 changed files with 15 additions and 26 deletions
|
@ -69,21 +69,6 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/rust-analyzer/rust-analyzer/issues/1592
|
|
||||||
#[test]
|
|
||||||
fn add_explicit_type_infers_correct_type_for_floating_point_literal() {
|
|
||||||
check_assist(
|
|
||||||
add_explicit_type,
|
|
||||||
"fn f() { let a<|> = 42f64; }",
|
|
||||||
"fn f() { let a<|>: f64 = 42f64; }",
|
|
||||||
);
|
|
||||||
check_assist(
|
|
||||||
add_explicit_type,
|
|
||||||
"fn f() { let a<|> = 42f32; }",
|
|
||||||
"fn f() { let a<|>: f32 = 42f32; }",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add_explicit_type_not_applicable_if_ty_not_inferred() {
|
fn add_explicit_type_not_applicable_if_ty_not_inferred() {
|
||||||
check_assist_not_applicable(add_explicit_type, "fn f() { let a<|> = None; }");
|
check_assist_not_applicable(add_explicit_type, "fn f() { let a<|> = None; }");
|
||||||
|
|
|
@ -334,6 +334,8 @@ fn infer_literals() {
|
||||||
infer(r##"
|
infer(r##"
|
||||||
fn test() {
|
fn test() {
|
||||||
5i32;
|
5i32;
|
||||||
|
5f32;
|
||||||
|
5f64;
|
||||||
"hello";
|
"hello";
|
||||||
b"bytes";
|
b"bytes";
|
||||||
'c';
|
'c';
|
||||||
|
@ -351,18 +353,20 @@ fn test() {
|
||||||
}
|
}
|
||||||
"##),
|
"##),
|
||||||
@r###"
|
@r###"
|
||||||
[11; 201) '{ ...o"#; }': ()
|
[11; 221) '{ ...o"#; }': ()
|
||||||
[17; 21) '5i32': i32
|
[17; 21) '5i32': i32
|
||||||
[27; 34) '"hello"': &str
|
[27; 31) '5f32': f32
|
||||||
[40; 48) 'b"bytes"': &[u8]
|
[37; 41) '5f64': f64
|
||||||
[54; 57) ''c'': char
|
[47; 54) '"hello"': &str
|
||||||
[63; 67) 'b'b'': u8
|
[60; 68) 'b"bytes"': &[u8]
|
||||||
[73; 77) '3.14': f64
|
[74; 77) ''c'': char
|
||||||
[83; 87) '5000': i32
|
[83; 87) 'b'b'': u8
|
||||||
[93; 98) 'false': bool
|
[93; 97) '3.14': f64
|
||||||
[104; 108) 'true': bool
|
[103; 107) '5000': i32
|
||||||
[114; 182) 'r#" ... "#': &str
|
[113; 118) 'false': bool
|
||||||
[188; 198) 'br#"yolo"#': &[u8]"###
|
[124; 128) 'true': bool
|
||||||
|
[134; 202) 'r#" ... "#': &str
|
||||||
|
[208; 218) 'br#"yolo"#': &[u8]"###
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue