1
1
use crate :: traits:: error_reporting:: TypeErrCtxtExt ;
2
2
use crate :: traits:: query:: evaluate_obligation:: InferCtxtExt ;
3
- use crate :: traits:: { needs_normalization, TraitEngineExt as _} ;
4
- use crate :: traits:: { BoundVarReplacer , PlaceholderReplacer } ;
3
+ use crate :: traits:: { needs_normalization, BoundVarReplacer , PlaceholderReplacer } ;
5
4
use rustc_data_structures:: stack:: ensure_sufficient_stack;
6
5
use rustc_infer:: infer:: at:: At ;
7
6
use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
@@ -13,22 +12,23 @@ use rustc_middle::ty::{self, AliasTy, Ty, TyCtxt, UniverseIndex};
13
12
use rustc_middle:: ty:: { FallibleTypeFolder , TypeSuperFoldable } ;
14
13
use rustc_middle:: ty:: { TypeFoldable , TypeVisitableExt } ;
15
14
15
+ use super :: FulfillmentCtxt ;
16
+
16
17
/// Deeply normalize all aliases in `value`. This does not handle inference and expects
17
18
/// its input to be already fully resolved.
18
19
pub ( crate ) fn deeply_normalize < ' tcx , T : TypeFoldable < TyCtxt < ' tcx > > > (
19
20
at : At < ' _ , ' tcx > ,
20
21
value : T ,
21
22
) -> Result < T , Vec < FulfillmentError < ' tcx > > > {
22
- let mut fulfill_cx = <dyn TraitEngine < ' tcx > >:: new ( & at. infcx ) ;
23
- let mut folder =
24
- NormalizationFolder { at, fulfill_cx : & mut * fulfill_cx, depth : 0 , universes : Vec :: new ( ) } ;
23
+ let fulfill_cx = FulfillmentCtxt :: new ( ) ;
24
+ let mut folder = NormalizationFolder { at, fulfill_cx, depth : 0 , universes : Vec :: new ( ) } ;
25
25
26
26
value. try_fold_with ( & mut folder)
27
27
}
28
28
29
29
struct NormalizationFolder < ' me , ' tcx > {
30
30
at : At < ' me , ' tcx > ,
31
- fulfill_cx : & ' me mut dyn TraitEngine < ' tcx > ,
31
+ fulfill_cx : FulfillmentCtxt < ' tcx > ,
32
32
depth : usize ,
33
33
universes : Vec < Option < UniverseIndex > > ,
34
34
}
@@ -163,16 +163,14 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
163
163
return Ok ( ty) ;
164
164
}
165
165
166
- let ( kind, data) = match * ty. kind ( ) {
167
- ty:: Alias ( kind, alias_ty) => ( kind, alias_ty) ,
168
- _ => return ty. try_super_fold_with ( self ) ,
169
- } ;
170
-
171
166
// We don't normalize opaque types unless we have
172
167
// `Reveal::All`, even if we're in the defining scope.
173
- if matches ! ( kind, ty:: Opaque ) && reveal == Reveal :: UserFacing {
174
- return ty. try_super_fold_with ( self ) ;
175
- }
168
+ let data = match * ty. kind ( ) {
169
+ ty:: Alias ( kind, alias_ty) if kind != ty:: Opaque || reveal == Reveal :: UserFacing => {
170
+ alias_ty
171
+ }
172
+ _ => return ty. try_super_fold_with ( self ) ,
173
+ } ;
176
174
177
175
if data. has_escaping_bound_vars ( ) {
178
176
let ( data, mapped_regions, mapped_types, mapped_consts) =
0 commit comments