Skip to content

Commit 5c0c8bd

Browse files
committed
Remove UsageKind::HasError
1 parent d6e48fd commit 5c0c8bd

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

compiler/rustc_hir_typeck/src/opaque_types.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_middle::ty::{
44
self, DefiningScopeKind, EarlyBinder, OpaqueHiddenType, OpaqueTypeKey, TypeVisitableExt,
55
TypingMode,
66
};
7-
use rustc_span::ErrorGuaranteed;
87
use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
98
use 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

7673
impl<'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
(
@@ -163,12 +155,6 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
163155
assert!(prev.is_none());
164156
}
165157
}
166-
UsageKind::HasError(guar) => {
167-
self.typeck_results
168-
.borrow_mut()
169-
.concrete_opaque_types
170-
.insert(def_id, OpaqueHiddenType::new_error(self.tcx, guar));
171-
}
172158
_ => {}
173159
}
174160

@@ -179,7 +165,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
179165
}
180166

181167
let guar = match usage_kind {
182-
UsageKind::HasDefiningUse(_) | UsageKind::HasError(_) => continue,
168+
UsageKind::HasDefiningUse(_) => continue,
183169
UsageKind::None => {
184170
if let Some(guar) = self.tainted_by_errors() {
185171
guar
@@ -240,7 +226,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
240226
) {
241227
match err {
242228
NonDefiningUseReason::Tainted(guar) => {
243-
return UsageKind::HasError(guar);
229+
return UsageKind::HasDefiningUse(OpaqueHiddenType::new_error(self.tcx, guar));
244230
}
245231
_ => return UsageKind::NonDefiningUse(opaque_type_key, hidden_type),
246232
};

0 commit comments

Comments
 (0)