mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Remove assoc type selection code for now to fix crashes
This commit is contained in:
parent
69c8cfc4c1
commit
c2f9558e1a
2 changed files with 10 additions and 25 deletions
|
@ -189,26 +189,11 @@ impl Ty {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_associated_type(
|
fn select_associated_type(
|
||||||
db: &impl HirDatabase,
|
_db: &impl HirDatabase,
|
||||||
resolver: &Resolver,
|
_resolver: &Resolver,
|
||||||
self_ty: Ty,
|
_self_ty: Ty,
|
||||||
segment: &PathSegment,
|
_segment: &PathSegment,
|
||||||
) -> Ty {
|
) -> Ty {
|
||||||
let env = trait_env(db, resolver);
|
|
||||||
let traits_from_env = env.trait_predicates_for_self_ty(&self_ty).map(|tr| tr.trait_);
|
|
||||||
let traits = traits_from_env.flat_map(|t| t.all_super_traits(db));
|
|
||||||
for t in traits {
|
|
||||||
if let Some(associated_ty) = t.associated_type_by_name(db, &segment.name) {
|
|
||||||
let generics = t.generic_params(db);
|
|
||||||
let mut substs = Vec::new();
|
|
||||||
substs.push(self_ty.clone());
|
|
||||||
substs.extend(
|
|
||||||
iter::repeat(Ty::Unknown).take(generics.count_params_including_parent() - 1),
|
|
||||||
);
|
|
||||||
// FIXME handle type parameters on the segment
|
|
||||||
return Ty::Projection(ProjectionTy { associated_ty, parameters: substs.into() });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ty::Unknown
|
Ty::Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2740,17 +2740,17 @@ fn test() {
|
||||||
[202; 203) 't': T
|
[202; 203) 't': T
|
||||||
[221; 223) '{}': ()
|
[221; 223) '{}': ()
|
||||||
[234; 300) '{ ...(S); }': ()
|
[234; 300) '{ ...(S); }': ()
|
||||||
[244; 245) 'x': u32
|
[244; 245) 'x': {unknown}
|
||||||
[248; 252) 'foo1': fn foo1<S>(T) -> <T as Iterable>::Item
|
[248; 252) 'foo1': fn foo1<S>(T) -> {unknown}
|
||||||
[248; 255) 'foo1(S)': u32
|
[248; 255) 'foo1(S)': {unknown}
|
||||||
[253; 254) 'S': S
|
[253; 254) 'S': S
|
||||||
[265; 266) 'y': u32
|
[265; 266) 'y': u32
|
||||||
[269; 273) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item
|
[269; 273) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item
|
||||||
[269; 276) 'foo2(S)': u32
|
[269; 276) 'foo2(S)': u32
|
||||||
[274; 275) 'S': S
|
[274; 275) 'S': S
|
||||||
[286; 287) 'z': u32
|
[286; 287) 'z': {unknown}
|
||||||
[290; 294) 'foo3': fn foo3<S>(T) -> <T as Iterable>::Item
|
[290; 294) 'foo3': fn foo3<S>(T) -> {unknown}
|
||||||
[290; 297) 'foo3(S)': u32
|
[290; 297) 'foo3(S)': {unknown}
|
||||||
[295; 296) 'S': S
|
[295; 296) 'S': S
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue