From 89080c1022276eb7867ec6ac8e58a2b95566c9f3 Mon Sep 17 00:00:00 2001 From: sjwang05 <63834813+sjwang05@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:17:17 -0800 Subject: [PATCH] Fix ICE --- .../src/traits/error_reporting/suggestions.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 a5fe0c694b15..4b4a5c72be7a 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -910,7 +910,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { steps -= 1; } if steps == 0 { - msg = msg.trim_end_matches(" and dereferencing instead"); + return ( + msg.trim_end_matches(" and dereferencing instead"), + vec![(prefix_span, String::new())], + ); } let derefs = "*".repeat(steps); let needs_parens = steps > 0 @@ -933,7 +936,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { format!("{derefs}"), )] }; - suggestion.push((prefix_span, "".to_string())); + suggestion.push((prefix_span, String::new())); (msg, suggestion) };