@@ -2179,15 +2179,15 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2179
2179
format ! ( "does not implement `{}`" , trait_pred. print_modifiers_and_trait_path( ) )
2180
2180
} ;
2181
2181
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
+ } ;
2191
2191
// note: future is not `Send` as this value is used across an await
2192
2192
// --> $DIR/issue-70935-complex-spans.rs:13:9
2193
2193
// |
@@ -2234,8 +2234,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2234
2234
if let Some ( ( span, msg) ) = scope_note {
2235
2235
err. span_note ( span, & msg) ;
2236
2236
}
2237
- }
2238
- } ;
2237
+ } ;
2239
2238
match interior_or_upvar_span {
2240
2239
GeneratorInteriorOrUpvar :: Interior ( interior_span, interior_extra_info) => {
2241
2240
if let Some ( ( scope_span, yield_span, expr, from_awaited_ty) ) = interior_extra_info {
0 commit comments