diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 19c80ac7f1af7c4fad8a0cf2bcb22ecd7aec9f2b..7d950b79cdd8da671d4c1835370355b5c02ffcc1 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -325,12 +325,6 @@ pub fn suggest_constraining_type_params<'a>( } } - // This check is always run on non-valid code - // to not trigger ICE - if constraints.is_empty() && suggestions.is_empty() { - return false; - } - if constraints.is_empty() { continue; } @@ -518,7 +512,7 @@ pub fn suggest_constraining_type_params<'a>( }; err.span_suggestion_verbose(span, msg, suggestion, applicability); - } else { + } else if suggestions.len() > 1 { err.multipart_suggestion_verbose( "consider restricting type parameters", suggestions.into_iter().map(|(span, suggestion, _)| (span, suggestion)).collect(),