@@ -1201,7 +1201,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12011201 ( _, _) => {
12021202 let got = if let Some ( _) = term. ty ( ) { "type" } else { "constant" } ;
12031203 let expected = def_kind. descr ( assoc_item_def_id) ;
1204- tcx. sess
1204+ let reported = tcx
1205+ . sess
12051206 . struct_span_err (
12061207 binding. span ,
12071208 & format ! ( "expected {expected} bound, found {got}" ) ,
@@ -1212,11 +1213,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12121213 )
12131214 . emit ( ) ;
12141215 term = match def_kind {
1215- hir:: def:: DefKind :: AssocTy => tcx. ty_error ( ) . into ( ) ,
1216+ hir:: def:: DefKind :: AssocTy => {
1217+ tcx. ty_error_with_guaranteed ( reported) . into ( )
1218+ }
12161219 hir:: def:: DefKind :: AssocConst => tcx
1217- . const_error (
1220+ . const_error_with_guaranteed (
12181221 tcx. bound_type_of ( assoc_item_def_id)
12191222 . subst ( tcx, projection_ty. skip_binder ( ) . substs ) ,
1223+ reported,
12201224 )
12211225 . into ( ) ,
12221226 _ => unreachable ! ( ) ,
@@ -1334,8 +1338,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13341338 . map ( |& ( trait_ref, _, _) | trait_ref. def_id ( ) )
13351339 . find ( |& trait_ref| tcx. is_trait_alias ( trait_ref) )
13361340 . map ( |trait_ref| tcx. def_span ( trait_ref) ) ;
1337- tcx. sess . emit_err ( TraitObjectDeclaredWithNoTraits { span, trait_alias_span } ) ;
1338- return tcx. ty_error ( ) ;
1341+ let reported =
1342+ tcx. sess . emit_err ( TraitObjectDeclaredWithNoTraits { span, trait_alias_span } ) ;
1343+ return tcx. ty_error_with_guaranteed ( reported) ;
13391344 }
13401345
13411346 // Check that there are no gross object safety violations;
@@ -1345,14 +1350,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13451350 let object_safety_violations =
13461351 astconv_object_safety_violations ( tcx, item. trait_ref ( ) . def_id ( ) ) ;
13471352 if !object_safety_violations. is_empty ( ) {
1348- report_object_safety_error (
1353+ let reported = report_object_safety_error (
13491354 tcx,
13501355 span,
13511356 item. trait_ref ( ) . def_id ( ) ,
13521357 & object_safety_violations,
13531358 )
13541359 . emit ( ) ;
1355- return tcx. ty_error ( ) ;
1360+ return tcx. ty_error_with_guaranteed ( reported ) ;
13561361 }
13571362 }
13581363
@@ -2112,13 +2117,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21122117 "Type"
21132118 } ;
21142119
2115- self . report_ambiguous_associated_type (
2120+ let reported = self . report_ambiguous_associated_type (
21162121 span,
21172122 type_name,
21182123 & path_str,
21192124 item_segment. ident . name ,
21202125 ) ;
2121- return tcx. ty_error ( ) ;
2126+ return tcx. ty_error_with_guaranteed ( reported )
21222127 } ;
21232128
21242129 debug ! ( "qpath_to_ty: self_type={:?}" , self_ty) ;
@@ -2560,8 +2565,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25602565 {
25612566 err. span_note ( impl_. self_ty . span , "not a concrete type" ) ;
25622567 }
2563- err. emit ( ) ;
2564- tcx. ty_error ( )
2568+ tcx. ty_error_with_guaranteed ( err. emit ( ) )
25652569 } else {
25662570 self . normalize_ty ( span, ty)
25672571 }
0 commit comments