mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Add test for autoderef infinite recursion
This commit is contained in:
parent
96c2b9c41d
commit
ad3673d8d8
1 changed files with 25 additions and 0 deletions
|
@ -2796,6 +2796,31 @@ fn test() {
|
|||
assert_eq!(t, "S");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deref_trait_infinite_recursion() {
|
||||
let t = type_at(
|
||||
r#"
|
||||
//- /main.rs
|
||||
#[lang = "deref"]
|
||||
trait Deref {
|
||||
type Target;
|
||||
fn deref(&self) -> &Self::Target;
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl Deref for S {
|
||||
type Target = S;
|
||||
}
|
||||
|
||||
fn test(s: S) {
|
||||
s.foo()<|>;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
assert_eq!(t, "{unknown}");
|
||||
}
|
||||
|
||||
fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
|
||||
let file = db.parse(pos.file_id).ok().unwrap();
|
||||
let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();
|
||||
|
|
Loading…
Reference in a new issue