remove unused return types such as empty Results or Options that would always be Some(..)
remove unused return type of dropck::check_drop_obligations() don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..) remove redundant return type of back::write::optimize() don't Option-wrap return type of compute_type_parameters() since we always return Some(..) don't return empty Result in assemble_generator_candidates() don't return empty Result in assemble_closure_candidates() don't return empty result in assemble_fn_pointer_candidates() don't return empty result in assemble_candidates_from_impls() don't return empty result in assemble_candidates_from_auto_impls() don't return emtpy result in assemble_candidates_for_trait_alias() don't return empty result in assemble_builtin_bound_candidates() don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait() remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..) remove unused return type of assemble_extension_candidates_for_all_traits()
This commit is contained in:
parent
b9c403be11
commit
e5ead5fc58
12 changed files with 56 additions and 81 deletions
|
@ -267,15 +267,13 @@ crate fn check_drop_obligations<'a, 'tcx>(
|
|||
ty: Ty<'tcx>,
|
||||
span: Span,
|
||||
body_id: hir::HirId,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) {
|
||||
debug!("check_drop_obligations typ: {:?}", ty);
|
||||
|
||||
let cause = &ObligationCause::misc(span, body_id);
|
||||
let infer_ok = rcx.infcx.at(cause, rcx.fcx.param_env).dropck_outlives(ty);
|
||||
debug!("dropck_outlives = {:#?}", infer_ok);
|
||||
rcx.fcx.register_infer_ok_obligations(infer_ok);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// This is an implementation of the TypeRelation trait with the
|
||||
|
|
|
@ -423,9 +423,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
probe_cx.assemble_inherent_candidates();
|
||||
match scope {
|
||||
ProbeScope::TraitsInScope => {
|
||||
probe_cx.assemble_extension_candidates_for_traits_in_scope(scope_expr_id)?
|
||||
probe_cx.assemble_extension_candidates_for_traits_in_scope(scope_expr_id)
|
||||
}
|
||||
ProbeScope::AllTraits => probe_cx.assemble_extension_candidates_for_all_traits()?,
|
||||
ProbeScope::AllTraits => probe_cx.assemble_extension_candidates_for_all_traits(),
|
||||
};
|
||||
op(probe_cx)
|
||||
})
|
||||
|
@ -866,35 +866,29 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn assemble_extension_candidates_for_traits_in_scope(
|
||||
&mut self,
|
||||
expr_hir_id: hir::HirId,
|
||||
) -> Result<(), MethodError<'tcx>> {
|
||||
fn assemble_extension_candidates_for_traits_in_scope(&mut self, expr_hir_id: hir::HirId) {
|
||||
let mut duplicates = FxHashSet::default();
|
||||
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
|
||||
if let Some(applicable_traits) = opt_applicable_traits {
|
||||
for trait_candidate in applicable_traits.iter() {
|
||||
let trait_did = trait_candidate.def_id;
|
||||
if duplicates.insert(trait_did) {
|
||||
let result = self.assemble_extension_candidates_for_trait(
|
||||
self.assemble_extension_candidates_for_trait(
|
||||
&trait_candidate.import_ids,
|
||||
trait_did,
|
||||
);
|
||||
result?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn assemble_extension_candidates_for_all_traits(&mut self) -> Result<(), MethodError<'tcx>> {
|
||||
fn assemble_extension_candidates_for_all_traits(&mut self) {
|
||||
let mut duplicates = FxHashSet::default();
|
||||
for trait_info in suggest::all_traits(self.tcx) {
|
||||
if duplicates.insert(trait_info.def_id) {
|
||||
self.assemble_extension_candidates_for_trait(&smallvec![], trait_info.def_id)?;
|
||||
self.assemble_extension_candidates_for_trait(&smallvec![], trait_info.def_id);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn matches_return_type(
|
||||
|
@ -932,7 +926,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
&mut self,
|
||||
import_ids: &SmallVec<[LocalDefId; 1]>,
|
||||
trait_def_id: DefId,
|
||||
) -> Result<(), MethodError<'tcx>> {
|
||||
) {
|
||||
debug!("assemble_extension_candidates_for_trait(trait_def_id={:?})", trait_def_id);
|
||||
let trait_substs = self.fresh_item_substs(trait_def_id);
|
||||
let trait_ref = ty::TraitRef::new(trait_def_id, trait_substs);
|
||||
|
@ -980,7 +974,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn candidate_method_names(&self) -> Vec<Ident> {
|
||||
|
@ -1027,7 +1020,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
let span = self.span;
|
||||
let tcx = self.tcx;
|
||||
|
||||
self.assemble_extension_candidates_for_all_traits()?;
|
||||
self.assemble_extension_candidates_for_all_traits();
|
||||
|
||||
let out_of_scope_traits = match self.pick_core() {
|
||||
Some(Ok(p)) => vec![p.item.container.id()],
|
||||
|
|
|
@ -325,7 +325,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
pat.each_binding(|_, hir_id, span, _| {
|
||||
let typ = self.resolve_node_type(hir_id);
|
||||
let body_id = self.body_id;
|
||||
let _ = dropck::check_drop_obligations(self, typ, span, body_id);
|
||||
dropck::check_drop_obligations(self, typ, span, body_id);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
if place_with_id.place.projections.is_empty() {
|
||||
let typ = self.resolve_type(place_with_id.place.ty());
|
||||
let body_id = self.body_id;
|
||||
let _ = dropck::check_drop_obligations(self, typ, span, body_id);
|
||||
dropck::check_drop_obligations(self, typ, span, body_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue