use hir_def::{
path::{Path, PathSegment},
resolver::{ResolveValueResult, Resolver, TypeNs, ValueNs},
- AdtId, AssocContainerId, AssocItemId, EnumVariantId, Lookup,
+ AdtId, AssocItemId, EnumVariantId, ItemContainerId, Lookup,
};
use hir_expand::name::Name;
}
let ty = self.make_ty(type_ref);
let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1);
- let ctx = crate::lower::TyLoweringContext::new(self.db, &resolver);
+ let ctx = crate::lower::TyLoweringContext::new(self.db, resolver);
let (ty, _) = ctx.lower_ty_relative_path(ty, None, remaining_segments_for_ty);
self.resolve_ty_assoc_item(
ty,
- &path.segments().last().expect("path had at least one segment").name,
+ path.segments().last().expect("path had at least one segment").name,
id,
)?
} else {
let typable: ValueTyDefId = match value {
ValueNs::LocalBinding(pat) => {
let ty = self.result.type_of_pat.get(pat)?.clone();
- let ty = self.resolve_ty_as_possible(ty);
return Some(ty);
}
ValueNs::FunctionId(it) => it.into(),
ValueNs::ImplSelf(impl_id) => {
let generics = crate::utils::generics(self.db.upcast(), impl_id.into());
let substs = generics.type_params_subst(self.db);
- let ty = self.db.impl_self_ty(impl_id).substitute(&Interner, &substs);
+ let ty = self.db.impl_self_ty(impl_id).substitute(Interner, &substs);
if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() {
- let ty = self.db.value_ty(struct_id.into()).substitute(&Interner, &substs);
+ let ty = self.db.value_ty(struct_id.into()).substitute(Interner, &substs);
return Some(ty);
} else {
// FIXME: diagnostic, invalid Self reference
ValueNs::GenericParam(it) => return Some(self.db.const_param_ty(it)),
};
- let parent_substs = self_subst.unwrap_or_else(|| Substitution::empty(&Interner));
+ let parent_substs = self_subst.unwrap_or_else(|| Substitution::empty(Interner));
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
let substs = ctx.substs_from_path(path, typable, true);
let ty = TyBuilder::value_ty(self.db, typable)
.use_parent_substs(&parent_substs)
- .fill(substs.as_slice(&Interner)[parent_substs.len(&Interner)..].iter().cloned())
+ .fill(substs.as_slice(Interner)[parent_substs.len(Interner)..].iter().cloned())
.build();
Some(ty)
}
remaining_segments_for_ty,
true,
);
- if let TyKind::Error = ty.kind(&Interner) {
+ if let TyKind::Error = ty.kind(Interner) {
return None;
}
let segment =
remaining_segments.last().expect("there should be at least one segment here");
- self.resolve_ty_assoc_item(ty, &segment.name, id)
+ self.resolve_ty_assoc_item(ty, segment.name, id)
}
}
}
name: &Name,
id: ExprOrPatId,
) -> Option<(ValueNs, Option<Substitution>)> {
- if let TyKind::Error = ty.kind(&Interner) {
+ if let TyKind::Error = ty.kind(Interner) {
return None;
}
return Some(result);
}
- let canonical_ty = self.canonicalizer().canonicalize_ty(ty.clone());
+ let canonical_ty = self.canonicalize(ty.clone());
let krate = self.resolver.krate()?;
let traits_in_scope = self.resolver.traits_in_scope(self.db.upcast());
method_resolution::iterate_method_candidates(
&canonical_ty.value,
self.db,
- self.trait_env.clone(),
+ self.table.trait_env.clone(),
krate,
&traits_in_scope,
- None,
+ self.resolver.module().into(),
Some(name),
method_resolution::LookupMode::Path,
move |_ty, item| {
AssocItemId::TypeAliasId(_) => unreachable!(),
};
let substs = match container {
- AssocContainerId::ImplId(impl_id) => {
+ ItemContainerId::ImplId(impl_id) => {
let impl_substs = TyBuilder::subst_for_def(self.db, impl_id)
.fill(iter::repeat_with(|| self.table.new_type_var()))
.build();
let impl_self_ty =
- self.db.impl_self_ty(impl_id).substitute(&Interner, &impl_substs);
+ self.db.impl_self_ty(impl_id).substitute(Interner, &impl_substs);
self.unify(&impl_self_ty, &ty);
Some(impl_substs)
}
- AssocContainerId::TraitId(trait_) => {
+ ItemContainerId::TraitId(trait_) => {
// we're picking this method
let trait_ref = TyBuilder::trait_ref(self.db, trait_)
.push(ty.clone())
.fill(std::iter::repeat_with(|| self.table.new_type_var()))
.build();
- self.push_obligation(trait_ref.clone().cast(&Interner));
+ self.push_obligation(trait_ref.clone().cast(Interner));
Some(trait_ref.substitution)
}
- AssocContainerId::ModuleId(_) => None,
+ ItemContainerId::ModuleId(_) | ItemContainerId::ExternBlockId(_) => None,
};
self.write_assoc_resolution(id, item);
name: &Name,
id: ExprOrPatId,
) -> Option<(ValueNs, Option<Substitution>)> {
+ let ty = self.resolve_ty_shallow(ty);
let (enum_id, subst) = match ty.as_adt() {
Some((AdtId::EnumId(e), subst)) => (e, subst),
_ => return None,