mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +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(
|
||||
db: &impl HirDatabase,
|
||||
resolver: &Resolver,
|
||||
self_ty: Ty,
|
||||
segment: &PathSegment,
|
||||
_db: &impl HirDatabase,
|
||||
_resolver: &Resolver,
|
||||
_self_ty: Ty,
|
||||
_segment: &PathSegment,
|
||||
) -> 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
|
||||
}
|
||||
|
||||
|
|
|
@ -2740,17 +2740,17 @@ fn test() {
|
|||
[202; 203) 't': T
|
||||
[221; 223) '{}': ()
|
||||
[234; 300) '{ ...(S); }': ()
|
||||
[244; 245) 'x': u32
|
||||
[248; 252) 'foo1': fn foo1<S>(T) -> <T as Iterable>::Item
|
||||
[248; 255) 'foo1(S)': u32
|
||||
[244; 245) 'x': {unknown}
|
||||
[248; 252) 'foo1': fn foo1<S>(T) -> {unknown}
|
||||
[248; 255) 'foo1(S)': {unknown}
|
||||
[253; 254) 'S': S
|
||||
[265; 266) 'y': u32
|
||||
[269; 273) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item
|
||||
[269; 276) 'foo2(S)': u32
|
||||
[274; 275) 'S': S
|
||||
[286; 287) 'z': u32
|
||||
[290; 294) 'foo3': fn foo3<S>(T) -> <T as Iterable>::Item
|
||||
[290; 297) 'foo3(S)': u32
|
||||
[286; 287) 'z': {unknown}
|
||||
[290; 294) 'foo3': fn foo3<S>(T) -> {unknown}
|
||||
[290; 297) 'foo3(S)': {unknown}
|
||||
[295; 296) 'S': S
|
||||
"###
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue