Skip to content

Commit ecab35b

Browse files
committed
note for ty::Error.
1 parent 0385239 commit ecab35b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/librustc_trait_selection/traits/structural_match.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
187187
| ty::Uint(_)
188188
| ty::Float(_)
189189
| ty::Str
190-
| ty::Never
191-
| ty::Error => {
190+
| ty::Never => {
192191
// These primitive types are always structural match.
193192
//
194193
// `Never` is kind of special here, but as it is not inhabitable, this should be fine.
@@ -200,17 +199,25 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
200199
| ty::Ref(..)
201200
| ty::Closure(..)
202201
| ty::Generator(..)
203-
| ty::GeneratorWitness(..)
204202
| ty::Tuple(..)
205203
| ty::Projection(..)
206-
| ty::UnnormalizedProjection(..)
207204
| ty::Opaque(..)
208-
| ty::Bound(..)
209-
| ty::Placeholder(_)
210-
| ty::Infer(_) => {
205+
| ty::GeneratorWitness(..) => {
211206
ty.super_visit_with(self);
212207
return false;
213208
}
209+
| ty::Infer(_)
210+
| ty::Placeholder(_)
211+
| ty::UnnormalizedProjection(..)
212+
| ty::Bound(..) => {
213+
bug!("unexpected type during structural-match checking: {:?}", ty);
214+
}
215+
ty::Error => {
216+
self.tcx().delay_span_bug(self.span, "ty::Error in structural-match check");
217+
// We still want to check other types after encountering an error,
218+
// as this may still emit relevant errors.
219+
return false;
220+
}
214221
};
215222

216223
if !self.seen.insert(adt_def.did) {

0 commit comments

Comments
 (0)