@@ -2,47 +2,14 @@ use std::fmt;
22
33use rustc_middle:: traits:: ObligationCause ;
44use rustc_middle:: traits:: query:: NoSolution ;
5- pub use rustc_middle:: traits:: query:: type_op:: { DeeplyNormalize , Normalize } ;
6- use rustc_middle:: ty:: {
7- self , Lift , ParamEnvAnd , Ty , TyCtxt , TypeFoldable , TypeVisitableExt , Unnormalized ,
8- } ;
5+ pub use rustc_middle:: traits:: query:: type_op:: Normalize ;
6+ use rustc_middle:: ty:: { self , Lift , ParamEnvAnd , Ty , TyCtxt , TypeFoldable , TypeVisitableExt } ;
97use rustc_span:: Span ;
108
119use crate :: infer:: canonical:: { CanonicalQueryInput , CanonicalQueryResponse } ;
1210use crate :: traits:: ObligationCtxt ;
1311
14- impl < ' tcx , T > super :: QueryTypeOp < ' tcx > for Normalize < T >
15- where
16- T : Normalizable < ' tcx > + ' tcx ,
17- {
18- type QueryResponse = T ;
19-
20- fn try_fast_path ( _tcx : TyCtxt < ' tcx > , key : & ParamEnvAnd < ' tcx , Self > ) -> Option < T > {
21- if !key. value . value . has_aliases ( ) { Some ( key. value . value ) } else { None }
22- }
23-
24- fn perform_query (
25- tcx : TyCtxt < ' tcx > ,
26- canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Self > > ,
27- ) -> Result < CanonicalQueryResponse < ' tcx , Self :: QueryResponse > , NoSolution > {
28- T :: type_op_method ( tcx, canonicalized)
29- }
30-
31- fn perform_locally_with_next_solver (
32- ocx : & ObligationCtxt < ' _ , ' tcx > ,
33- key : ParamEnvAnd < ' tcx , Self > ,
34- span : Span ,
35- ) -> Result < Self :: QueryResponse , NoSolution > {
36- ocx. deeply_normalize (
37- & ObligationCause :: dummy_with_span ( span) ,
38- key. param_env ,
39- Unnormalized :: new_wip ( key. value . value ) ,
40- )
41- . map_err ( |_| NoSolution )
42- }
43- }
44-
45- impl < ' tcx , T > super :: QueryTypeOp < ' tcx > for DeeplyNormalize < ' tcx , T >
12+ impl < ' tcx , T > super :: QueryTypeOp < ' tcx > for Normalize < ' tcx , T >
4613where
4714 T : Normalizable < ' tcx > + ' tcx ,
4815{
6027 tcx : TyCtxt < ' tcx > ,
6128 canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Self > > ,
6229 ) -> Result < CanonicalQueryResponse < ' tcx , Self :: QueryResponse > , NoSolution > {
63- T :: type_op_method (
64- tcx,
65- CanonicalQueryInput {
66- typing_mode : canonicalized. typing_mode ,
67- canonical : canonicalized. canonical . unchecked_map (
68- |ty:: ParamEnvAnd { param_env, value } | ty:: ParamEnvAnd {
69- param_env,
70- value : Normalize { value : value. value . skip_normalization ( ) } ,
71- } ,
72- ) ,
73- } ,
74- )
30+ T :: type_op_method ( tcx, canonicalized)
7531 }
7632
7733 fn perform_locally_with_next_solver (
@@ -93,14 +49,14 @@ pub trait Normalizable<'tcx>:
9349{
9450 fn type_op_method (
9551 tcx : TyCtxt < ' tcx > ,
96- canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < Self > > > ,
52+ canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < ' tcx , Self > > > ,
9753 ) -> Result < CanonicalQueryResponse < ' tcx , Self > , NoSolution > ;
9854}
9955
10056impl < ' tcx > Normalizable < ' tcx > for Ty < ' tcx > {
10157 fn type_op_method (
10258 tcx : TyCtxt < ' tcx > ,
103- canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < Self > > > ,
59+ canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < ' tcx , Self > > > ,
10460 ) -> Result < CanonicalQueryResponse < ' tcx , Self > , NoSolution > {
10561 tcx. type_op_normalize_ty ( canonicalized)
10662 }
@@ -109,7 +65,7 @@ impl<'tcx> Normalizable<'tcx> for Ty<'tcx> {
10965impl < ' tcx > Normalizable < ' tcx > for ty:: Clause < ' tcx > {
11066 fn type_op_method (
11167 tcx : TyCtxt < ' tcx > ,
112- canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < Self > > > ,
68+ canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < ' tcx , Self > > > ,
11369 ) -> Result < CanonicalQueryResponse < ' tcx , Self > , NoSolution > {
11470 tcx. type_op_normalize_clause ( canonicalized)
11571 }
@@ -118,7 +74,7 @@ impl<'tcx> Normalizable<'tcx> for ty::Clause<'tcx> {
11874impl < ' tcx > Normalizable < ' tcx > for ty:: PolyFnSig < ' tcx > {
11975 fn type_op_method (
12076 tcx : TyCtxt < ' tcx > ,
121- canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < Self > > > ,
77+ canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < ' tcx , Self > > > ,
12278 ) -> Result < CanonicalQueryResponse < ' tcx , Self > , NoSolution > {
12379 tcx. type_op_normalize_poly_fn_sig ( canonicalized)
12480 }
@@ -127,7 +83,7 @@ impl<'tcx> Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
12783impl < ' tcx > Normalizable < ' tcx > for ty:: FnSig < ' tcx > {
12884 fn type_op_method (
12985 tcx : TyCtxt < ' tcx > ,
130- canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < Self > > > ,
86+ canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < ' tcx , Self > > > ,
13187 ) -> Result < CanonicalQueryResponse < ' tcx , Self > , NoSolution > {
13288 tcx. type_op_normalize_fn_sig ( canonicalized)
13389 }
@@ -138,7 +94,7 @@ impl<'tcx> Normalizable<'tcx> for ty::FnSig<'tcx> {
13894impl < ' tcx > Normalizable < ' tcx > for ty:: PolyTypeOutlivesPredicate < ' tcx > {
13995 fn type_op_method (
14096 _tcx : TyCtxt < ' tcx > ,
141- _canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < Self > > > ,
97+ _canonicalized : CanonicalQueryInput < ' tcx , ParamEnvAnd < ' tcx , Normalize < ' tcx , Self > > > ,
14298 ) -> Result < CanonicalQueryResponse < ' tcx , Self > , NoSolution > {
14399 unreachable ! ( "we never normalize PolyTypeOutlivesPredicate" )
144100 }
0 commit comments