|
3 | 3 | // substitutions.
|
4 | 4 |
|
5 | 5 | use crate::FnCtxt;
|
6 |
| -use hir::def_id::LocalDefId; |
7 | 6 | use rustc_data_structures::unord::ExtendUnord;
|
8 | 7 | use rustc_errors::{ErrorGuaranteed, StashKey};
|
9 | 8 | use rustc_hir as hir;
|
10 | 9 | use rustc_hir::intravisit::{self, Visitor};
|
11 | 10 | use rustc_infer::infer::error_reporting::TypeAnnotationNeeded::E0282;
|
12 | 11 | use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
|
13 | 12 | use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
|
14 |
| -use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt}; |
| 13 | +use rustc_middle::ty::visit::TypeVisitableExt; |
15 | 14 | use rustc_middle::ty::{self, Ty, TyCtxt};
|
16 | 15 | use rustc_span::symbol::sym;
|
17 | 16 | use rustc_span::Span;
|
18 | 17 |
|
19 | 18 | use std::mem;
|
20 |
| -use std::ops::ControlFlow; |
21 | 19 |
|
22 | 20 | ///////////////////////////////////////////////////////////////////////////
|
23 | 21 | // Entry point
|
@@ -565,23 +563,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
565 | 563 | let hidden_type = self.resolve(decl.hidden_type, &decl.hidden_type.span);
|
566 | 564 | let opaque_type_key = self.resolve(opaque_type_key, &decl.hidden_type.span);
|
567 | 565 |
|
568 |
| - struct RecursionChecker { |
569 |
| - def_id: LocalDefId, |
570 |
| - } |
571 |
| - impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for RecursionChecker { |
572 |
| - type BreakTy = (); |
573 |
| - fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> { |
574 |
| - if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *t.kind() { |
575 |
| - if def_id == self.def_id.to_def_id() { |
576 |
| - return ControlFlow::Break(()); |
577 |
| - } |
578 |
| - } |
579 |
| - t.super_visit_with(self) |
580 |
| - } |
581 |
| - } |
582 |
| - if hidden_type |
583 |
| - .visit_with(&mut RecursionChecker { def_id: opaque_type_key.def_id }) |
584 |
| - .is_break() |
| 566 | + if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind() |
| 567 | + && alias_ty.def_id == opaque_type_key.def_id.to_def_id() |
| 568 | + && alias_ty.args == opaque_type_key.args |
585 | 569 | {
|
586 | 570 | continue;
|
587 | 571 | }
|
|
0 commit comments