@@ -2179,15 +2179,15 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
21792179 format ! ( "does not implement `{}`" , trait_pred. print_modifiers_and_trait_path( ) )
21802180 } ;
21812181
2182- let mut explain_yield = | interior_span : Span ,
2183- yield_span : Span ,
2184- scope_span : Option < Span > | {
2185- let mut span = MultiSpan :: from_span ( yield_span ) ;
2186- if let Ok ( snippet) = source_map . span_to_snippet ( interior_span ) {
2187- // #70935: If snippet contains newlines, display "the value" instead
2188- // so that we do not emit complex diagnostics.
2189- let snippet = & format ! ( "`{}`" , snippet ) ;
2190- let snippet = if snippet . contains ( '\n' ) { "the value" } else { snippet } ;
2182+ let mut explain_yield =
2183+ | interior_span : Span , yield_span : Span , scope_span : Option < Span > | {
2184+ let mut span = MultiSpan :: from_span ( yield_span ) ;
2185+ let snippet = match source_map . span_to_snippet ( interior_span ) {
2186+ // #70935: If snippet contains newlines, display "the value" instead
2187+ // so that we do not emit complex diagnostics.
2188+ Ok ( snippet ) if !snippet . contains ( '\n' ) => format ! ( "`{}`" , snippet ) ,
2189+ _ => "the value" . to_string ( ) ,
2190+ } ;
21912191 // note: future is not `Send` as this value is used across an await
21922192 // --> $DIR/issue-70935-complex-spans.rs:13:9
21932193 // |
@@ -2234,8 +2234,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
22342234 if let Some ( ( span, msg) ) = scope_note {
22352235 err. span_note ( span, & msg) ;
22362236 }
2237- }
2238- } ;
2237+ } ;
22392238 match interior_or_upvar_span {
22402239 GeneratorInteriorOrUpvar :: Interior ( interior_span, interior_extra_info) => {
22412240 if let Some ( ( scope_span, yield_span, expr, from_awaited_ty) ) = interior_extra_info {
0 commit comments