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]
|
||||
fn add_explicit_type_not_applicable_if_ty_not_inferred() {
|
||||
check_assist_not_applicable(add_explicit_type, "fn f() { let a<|> = None; }");
|
||||
|
|
|
@ -334,6 +334,8 @@ fn infer_literals() {
|
|||
infer(r##"
|
||||
fn test() {
|
||||
5i32;
|
||||
5f32;
|
||||
5f64;
|
||||
"hello";
|
||||
b"bytes";
|
||||
'c';
|
||||
|
@ -351,18 +353,20 @@ fn test() {
|
|||
}
|
||||
"##),
|
||||
@r###"
|
||||
[11; 201) '{ ...o"#; }': ()
|
||||
[11; 221) '{ ...o"#; }': ()
|
||||
[17; 21) '5i32': i32
|
||||
[27; 34) '"hello"': &str
|
||||
[40; 48) 'b"bytes"': &[u8]
|
||||
[54; 57) ''c'': char
|
||||
[63; 67) 'b'b'': u8
|
||||
[73; 77) '3.14': f64
|
||||
[83; 87) '5000': i32
|
||||
[93; 98) 'false': bool
|
||||
[104; 108) 'true': bool
|
||||
[114; 182) 'r#" ... "#': &str
|
||||
[188; 198) 'br#"yolo"#': &[u8]"###
|
||||
[27; 31) '5f32': f32
|
||||
[37; 41) '5f64': f64
|
||||
[47; 54) '"hello"': &str
|
||||
[60; 68) 'b"bytes"': &[u8]
|
||||
[74; 77) ''c'': char
|
||||
[83; 87) 'b'b'': u8
|
||||
[93; 97) '3.14': f64
|
||||
[103; 107) '5000': i32
|
||||
[113; 118) 'false': bool
|
||||
[124; 128) 'true': bool
|
||||
[134; 202) 'r#" ... "#': &str
|
||||
[208; 218) 'br#"yolo"#': &[u8]"###
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue