From 2fc94cefc5b784011e276a8d7893cc05e84dcdaa Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 16 Feb 2024 05:40:46 +1100 Subject: [PATCH] Remove an unnecessary `span_delayed_bug` call. The existing code calls a function that returns `Result<_, ErrorGuaranteed>`, and then calls `span_delayed_bug` pointlessly in the `Err` case. --- .../src/type_check/free_region_relations.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index 897918fb0a4..86d20599a2a 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -311,17 +311,14 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { // Add implied bounds from impl header. if matches!(tcx.def_kind(defining_ty_def_id), DefKind::AssocFn | DefKind::AssocConst) { for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) { - let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = self + let result: Result<_, ErrorGuaranteed> = self .param_env .and(type_op::normalize::Normalize::new(ty)) - .fully_perform(self.infcx, span) - else { - // Note: this path is currently not reached in any test, so - // any example that triggers this would be worth minimizing - // and converting into a test. - tcx.dcx().span_delayed_bug(span, format!("failed to normalize {ty:?}")); + .fully_perform(self.infcx, span); + let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else { continue; }; + constraints.extend(c); // We currently add implied bounds from the normalized ty only.