mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
parent
1cc6879576
commit
073a1ef834
3 changed files with 95 additions and 1 deletions
|
@ -50,6 +50,47 @@ fn test() {
|
|||
assert_eq!("Nat", type_at_pos(&db, pos));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn self_in_struct_lit() {
|
||||
assert_snapshot!(infer(
|
||||
r#"
|
||||
//- /main.rs
|
||||
struct S<T> { x: T }
|
||||
|
||||
impl S<u32> {
|
||||
fn foo() {
|
||||
Self { x: 1 };
|
||||
}
|
||||
}
|
||||
"#,
|
||||
), @r###"
|
||||
[63; 93) '{ ... }': ()
|
||||
[73; 86) 'Self { x: 1 }': S<u32>
|
||||
[83; 84) '1': u32
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_alias_in_struct_lit() {
|
||||
assert_snapshot!(infer(
|
||||
r#"
|
||||
//- /main.rs
|
||||
struct S<T> { x: T }
|
||||
|
||||
type SS = S<u32>;
|
||||
|
||||
fn foo() {
|
||||
SS { x: 1 };
|
||||
}
|
||||
|
||||
"#,
|
||||
), @r###"
|
||||
[64; 84) '{ ...1 }; }': ()
|
||||
[70; 81) 'SS { x: 1 }': S<u32>
|
||||
[78; 79) '1': u32
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_ranges() {
|
||||
let (db, pos) = TestDB::with_position(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue