@@ -4,7 +4,6 @@ use rustc_middle::ty::{
44 self , DefiningScopeKind , EarlyBinder , OpaqueHiddenType , OpaqueTypeKey , TypeVisitableExt ,
55 TypingMode ,
66} ;
7- use rustc_span:: ErrorGuaranteed ;
87use rustc_trait_selection:: error_reporting:: infer:: need_type_info:: TypeAnnotationNeeded ;
98use rustc_trait_selection:: opaque_types:: {
109 NonDefiningUseReason , opaque_type_has_defining_use_args, report_item_does_not_constrain_error,
@@ -69,20 +68,13 @@ enum UsageKind<'tcx> {
6968 NonDefiningUse ( OpaqueTypeKey < ' tcx > , OpaqueHiddenType < ' tcx > ) ,
7069 UnconstrainedHiddenType ( OpaqueHiddenType < ' tcx > ) ,
7170 HasDefiningUse ( OpaqueHiddenType < ' tcx > ) ,
72- // `type_of_opaque_hir_typeck` reported an error
73- HasError ( ErrorGuaranteed ) ,
7471}
7572
7673impl < ' tcx > UsageKind < ' tcx > {
7774 fn merge ( & mut self , other : UsageKind < ' tcx > ) {
7875 match ( & * self , & other) {
7976 ( UsageKind :: HasDefiningUse ( _) , _) | ( _, UsageKind :: None ) => unreachable ! ( ) ,
8077 ( UsageKind :: None , _) => * self = other,
81- // If `type_of_opaque_hir_typeck` reported an error, then the hidden
82- // type is an error, but we also want to still report errors for
83- // remaining hidden types (really just normalization errors).
84- ( UsageKind :: HasError ( _) , _) => { }
85- ( _, UsageKind :: HasError ( _) ) => * self = other,
8678 // When mergining non-defining uses, prefer earlier ones. This means
8779 // the error happens as early as possible.
8880 (
@@ -160,12 +152,6 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
160152 assert ! ( prev. is_none( ) ) ;
161153 }
162154 }
163- UsageKind :: HasError ( guar) => {
164- self . typeck_results
165- . borrow_mut ( )
166- . hidden_types
167- . insert ( def_id, OpaqueHiddenType :: new_error ( self . tcx , guar) ) ;
168- }
169155 _ => { }
170156 }
171157
@@ -176,7 +162,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
176162 }
177163
178164 let guar = match usage_kind {
179- UsageKind :: HasDefiningUse ( _) | UsageKind :: HasError ( _ ) => continue ,
165+ UsageKind :: HasDefiningUse ( _) => continue ,
180166 UsageKind :: None => {
181167 if let Some ( guar) = self . tainted_by_errors ( ) {
182168 guar
@@ -237,7 +223,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
237223 ) {
238224 match err {
239225 NonDefiningUseReason :: Tainted ( guar) => {
240- return UsageKind :: HasError ( guar) ;
226+ return UsageKind :: HasDefiningUse ( OpaqueHiddenType :: new_error ( self . tcx , guar) ) ;
241227 }
242228 _ => return UsageKind :: NonDefiningUse ( opaque_type_key, hidden_type) ,
243229 } ;
0 commit comments