Remove unnecessary option wrapping
This commit is contained in:
parent
27fad2ad75
commit
d8b1ec6a25
@ -35,7 +35,7 @@ fn resolve_value_path(&mut self, path: &Path, id: ExprOrPatId) -> Option<Ty> {
|
|||||||
let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1);
|
let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1);
|
||||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
|
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
|
||||||
let (ty, _) = ctx.lower_ty_relative_path(ty, None, remaining_segments_for_ty);
|
let (ty, _) = ctx.lower_ty_relative_path(ty, None, remaining_segments_for_ty);
|
||||||
self.resolve_ty_assoc_item(ty, last.name, id)?
|
self.resolve_ty_assoc_item(ty, last.name, id).map(|(it, substs)| (it, Some(substs)))?
|
||||||
} else {
|
} else {
|
||||||
// FIXME: report error, unresolved first path segment
|
// FIXME: report error, unresolved first path segment
|
||||||
let value_or_partial =
|
let value_or_partial =
|
||||||
@ -43,9 +43,9 @@ fn resolve_value_path(&mut self, path: &Path, id: ExprOrPatId) -> Option<Ty> {
|
|||||||
|
|
||||||
match value_or_partial {
|
match value_or_partial {
|
||||||
ResolveValueResult::ValueNs(it) => (it, None),
|
ResolveValueResult::ValueNs(it) => (it, None),
|
||||||
ResolveValueResult::Partial(def, remaining_index) => {
|
ResolveValueResult::Partial(def, remaining_index) => self
|
||||||
self.resolve_assoc_item(def, path, remaining_index, id)?
|
.resolve_assoc_item(def, path, remaining_index, id)
|
||||||
}
|
.map(|(it, substs)| (it, Some(substs)))?,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ fn resolve_assoc_item(
|
|||||||
path: &Path,
|
path: &Path,
|
||||||
remaining_index: usize,
|
remaining_index: usize,
|
||||||
id: ExprOrPatId,
|
id: ExprOrPatId,
|
||||||
) -> Option<(ValueNs, Option<Substitution>)> {
|
) -> Option<(ValueNs, Substitution)> {
|
||||||
assert!(remaining_index < path.segments().len());
|
assert!(remaining_index < path.segments().len());
|
||||||
// there may be more intermediate segments between the resolved one and
|
// there may be more intermediate segments between the resolved one and
|
||||||
// the end. Only the last segment needs to be resolved to a value; from
|
// the end. Only the last segment needs to be resolved to a value; from
|
||||||
@ -166,7 +166,7 @@ fn resolve_trait_assoc_item(
|
|||||||
trait_ref: TraitRef,
|
trait_ref: TraitRef,
|
||||||
segment: PathSegment<'_>,
|
segment: PathSegment<'_>,
|
||||||
id: ExprOrPatId,
|
id: ExprOrPatId,
|
||||||
) -> Option<(ValueNs, Option<Substitution>)> {
|
) -> Option<(ValueNs, Substitution)> {
|
||||||
let trait_ = trait_ref.hir_trait_id();
|
let trait_ = trait_ref.hir_trait_id();
|
||||||
let item =
|
let item =
|
||||||
self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id)).find_map(|item| {
|
self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id)).find_map(|item| {
|
||||||
@ -202,16 +202,15 @@ fn resolve_trait_assoc_item(
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.write_assoc_resolution(id, item, trait_ref.substitution.clone());
|
self.write_assoc_resolution(id, item, trait_ref.substitution.clone());
|
||||||
Some((def, Some(trait_ref.substitution)))
|
Some((def, trait_ref.substitution))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Change sig to -> Option<(ValueNs, Substitution)>, subs aren't optional from here anymore
|
|
||||||
fn resolve_ty_assoc_item(
|
fn resolve_ty_assoc_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
ty: Ty,
|
ty: Ty,
|
||||||
name: &Name,
|
name: &Name,
|
||||||
id: ExprOrPatId,
|
id: ExprOrPatId,
|
||||||
) -> Option<(ValueNs, Option<Substitution>)> {
|
) -> Option<(ValueNs, Substitution)> {
|
||||||
if let TyKind::Error = ty.kind(Interner) {
|
if let TyKind::Error = ty.kind(Interner) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -280,7 +279,7 @@ fn resolve_ty_assoc_item(
|
|||||||
if !visible {
|
if !visible {
|
||||||
self.push_diagnostic(InferenceDiagnostic::PrivateAssocItem { id, item });
|
self.push_diagnostic(InferenceDiagnostic::PrivateAssocItem { id, item });
|
||||||
}
|
}
|
||||||
Some((def, Some(substs)))
|
Some((def, substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_enum_variant_on_ty(
|
fn resolve_enum_variant_on_ty(
|
||||||
@ -288,7 +287,7 @@ fn resolve_enum_variant_on_ty(
|
|||||||
ty: &Ty,
|
ty: &Ty,
|
||||||
name: &Name,
|
name: &Name,
|
||||||
id: ExprOrPatId,
|
id: ExprOrPatId,
|
||||||
) -> Option<(ValueNs, Option<Substitution>)> {
|
) -> Option<(ValueNs, Substitution)> {
|
||||||
let ty = self.resolve_ty_shallow(ty);
|
let ty = self.resolve_ty_shallow(ty);
|
||||||
let (enum_id, subst) = match ty.as_adt() {
|
let (enum_id, subst) = match ty.as_adt() {
|
||||||
Some((AdtId::EnumId(e), subst)) => (e, subst),
|
Some((AdtId::EnumId(e), subst)) => (e, subst),
|
||||||
@ -298,6 +297,6 @@ fn resolve_enum_variant_on_ty(
|
|||||||
let local_id = enum_data.variant(name)?;
|
let local_id = enum_data.variant(name)?;
|
||||||
let variant = EnumVariantId { parent: enum_id, local_id };
|
let variant = EnumVariantId { parent: enum_id, local_id };
|
||||||
self.write_variant_resolution(id, variant.into());
|
self.write_variant_resolution(id, variant.into());
|
||||||
Some((ValueNs::EnumVariantId(variant), Some(subst.clone())))
|
Some((ValueNs::EnumVariantId(variant), subst.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user