From: Maybe Waffle Date: Tue, 22 Nov 2022 19:03:26 +0000 (+0000) Subject: Use `TyCtxt::is_fn_trait` is a couple more places X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=5ba0056346a745e61cb2cb90d69a3304a255ff42;p=rust.git Use `TyCtxt::is_fn_trait` is a couple more places --- diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index 3a74ac51b2c..1f554c81eff 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -399,10 +399,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self_ty.highlight.maybe_highlighting_region(vid, actual_has_vid); if self_ty.value.is_closure() - && self - .tcx() - .fn_trait_kind_from_def_id(expected_trait_ref.value.def_id) - .is_some() + && self.tcx().is_fn_trait(expected_trait_ref.value.def_id) { let closure_sig = self_ty.map(|closure| { if let ty::Closure(_, substs) = closure.kind() { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index ddffe25bc26..2cb04b94954 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1764,8 +1764,7 @@ fn note_conflicting_closure_bounds( .enumerate() .find(|(other_idx, (pred, _))| match pred.kind().skip_binder() { ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) - if self.tcx.fn_trait_kind_from_def_id(trait_pred.def_id()) - .is_some() + if self.tcx.is_fn_trait(trait_pred.def_id()) && other_idx != idx // Make sure that the self type matches // (i.e. constraining this closure)