mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Add test for T::Item
cycles
This commit is contained in:
parent
a040fde3ae
commit
69c8cfc4c1
1 changed files with 42 additions and 0 deletions
|
@ -4062,6 +4062,48 @@ fn test<F: FnOnce(u32) -> u64>(f: F) {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unselected_projection_in_trait_env() {
|
||||
let t = type_at(
|
||||
r#"
|
||||
//- /main.rs
|
||||
trait Trait {
|
||||
type Item;
|
||||
}
|
||||
|
||||
trait Trait2 {
|
||||
fn foo(&self) -> u32;
|
||||
}
|
||||
|
||||
fn test<T: Trait>() where T::Item: Trait2 {
|
||||
let x: T::Item = no_matter;
|
||||
x.foo()<|>;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
assert_eq!(t, "u32");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unselected_projection_in_trait_env_cycle() {
|
||||
let t = type_at(
|
||||
r#"
|
||||
//- /main.rs
|
||||
trait Trait {
|
||||
type Item;
|
||||
}
|
||||
|
||||
trait Trait2<T> {}
|
||||
|
||||
fn test<T: Trait>() where T: Trait2<T::Item> {
|
||||
let x: T::Item = no_matter<|>;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
// this is a legitimate cycle
|
||||
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…
Add table
Add a link
Reference in a new issue