1
1
use crate :: solve:: assembly:: Candidate ;
2
2
3
3
use super :: EvalCtxt ;
4
- use rustc_infer:: infer:: InferCtxt ;
5
- use rustc_infer:: traits:: BuiltinImplSource ;
6
- use rustc_middle:: traits:: query:: NoSolution ;
7
- use rustc_middle:: traits:: solve:: { inspect, CandidateSource , QueryResult } ;
8
- use rustc_middle:: ty:: TyCtxt ;
4
+ use rustc_next_trait_solver:: solve:: {
5
+ inspect, BuiltinImplSource , CandidateSource , NoSolution , QueryResult ,
6
+ } ;
7
+ use rustc_type_ir:: { InferCtxtLike , Interner } ;
9
8
use std:: marker:: PhantomData ;
10
9
11
- pub ( in crate :: solve) struct ProbeCtxt < ' me , ' a , ' tcx , F , T > {
12
- ecx : & ' me mut EvalCtxt < ' a , InferCtxt < ' tcx > > ,
10
+ pub ( in crate :: solve) struct ProbeCtxt < ' me , ' a , Infcx , I , F , T >
11
+ where
12
+ Infcx : InferCtxtLike < Interner = I > ,
13
+ I : Interner ,
14
+ {
15
+ ecx : & ' me mut EvalCtxt < ' a , Infcx , I > ,
13
16
probe_kind : F ,
14
17
_result : PhantomData < T > ,
15
18
}
16
19
17
- impl < ' tcx , F , T > ProbeCtxt < ' _ , ' _ , ' tcx , F , T >
20
+ impl < Infcx , I , F , T > ProbeCtxt < ' _ , ' _ , Infcx , I , F , T >
18
21
where
19
- F : FnOnce ( & T ) -> inspect:: ProbeKind < TyCtxt < ' tcx > > ,
22
+ F : FnOnce ( & T ) -> inspect:: ProbeKind < I > ,
23
+ Infcx : InferCtxtLike < Interner = I > ,
24
+ I : Interner ,
20
25
{
21
- pub ( in crate :: solve) fn enter (
22
- self ,
23
- f : impl FnOnce ( & mut EvalCtxt < ' _ , InferCtxt < ' tcx > > ) -> T ,
24
- ) -> T {
26
+ pub ( in crate :: solve) fn enter ( self , f : impl FnOnce ( & mut EvalCtxt < ' _ , Infcx > ) -> T ) -> T {
25
27
let ProbeCtxt { ecx : outer_ecx, probe_kind, _result } = self ;
26
28
27
29
let infcx = outer_ecx. infcx ;
38
40
tainted : outer_ecx. tainted ,
39
41
inspect : outer_ecx. inspect . take_and_enter_probe ( ) ,
40
42
} ;
41
- let r = nested_ecx. infcx . probe ( |_ | {
43
+ let r = nested_ecx. infcx . probe ( || {
42
44
let r = f ( & mut nested_ecx) ;
43
45
nested_ecx. inspect . probe_final_state ( infcx, max_input_universe) ;
44
46
r
@@ -52,59 +54,64 @@ where
52
54
}
53
55
}
54
56
55
- pub ( in crate :: solve) struct TraitProbeCtxt < ' me , ' a , ' tcx , F > {
56
- cx : ProbeCtxt < ' me , ' a , ' tcx , F , QueryResult < ' tcx > > ,
57
- source : CandidateSource < ' tcx > ,
57
+ pub ( in crate :: solve) struct TraitProbeCtxt < ' me , ' a , Infcx , I , F >
58
+ where
59
+ Infcx : InferCtxtLike < Interner = I > ,
60
+ I : Interner ,
61
+ {
62
+ cx : ProbeCtxt < ' me , ' a , Infcx , I , F , QueryResult < I > > ,
63
+ source : CandidateSource < I > ,
58
64
}
59
65
60
- impl < ' tcx , F > TraitProbeCtxt < ' _ , ' _ , ' tcx , F >
66
+ impl < Infcx , I , F > TraitProbeCtxt < ' _ , ' _ , Infcx , I , F >
61
67
where
62
- F : FnOnce ( & QueryResult < ' tcx > ) -> inspect:: ProbeKind < TyCtxt < ' tcx > > ,
68
+ Infcx : InferCtxtLike < Interner = I > ,
69
+ I : Interner ,
70
+ F : FnOnce ( & QueryResult < I > ) -> inspect:: ProbeKind < I > ,
63
71
{
64
72
#[ instrument( level = "debug" , skip_all, fields( source = ?self . source) ) ]
65
73
pub ( in crate :: solve) fn enter (
66
74
self ,
67
- f : impl FnOnce ( & mut EvalCtxt < ' _ , InferCtxt < ' tcx > > ) -> QueryResult < ' tcx > ,
68
- ) -> Result < Candidate < TyCtxt < ' tcx > > , NoSolution > {
75
+ f : impl FnOnce ( & mut EvalCtxt < ' _ , Infcx > ) -> QueryResult < I > ,
76
+ ) -> Result < Candidate < I > , NoSolution > {
69
77
self . cx . enter ( |ecx| f ( ecx) ) . map ( |result| Candidate { source : self . source , result } )
70
78
}
71
79
}
72
80
73
- impl < ' a , ' tcx > EvalCtxt < ' a , InferCtxt < ' tcx > > {
81
+ impl < ' a , Infcx , I > EvalCtxt < ' a , Infcx , I >
82
+ where
83
+ Infcx : InferCtxtLike < Interner = I > ,
84
+ I : Interner ,
85
+ {
74
86
/// `probe_kind` is only called when proof tree building is enabled so it can be
75
87
/// as expensive as necessary to output the desired information.
76
- pub ( in crate :: solve) fn probe < F , T > ( & mut self , probe_kind : F ) -> ProbeCtxt < ' _ , ' a , ' tcx , F , T >
88
+ pub ( in crate :: solve) fn probe < F , T > (
89
+ & mut self ,
90
+ probe_kind : F ,
91
+ ) -> ProbeCtxt < ' _ , ' a , Infcx , I , F , T >
77
92
where
78
- F : FnOnce ( & T ) -> inspect:: ProbeKind < TyCtxt < ' tcx > > ,
93
+ F : FnOnce ( & T ) -> inspect:: ProbeKind < I > ,
79
94
{
80
95
ProbeCtxt { ecx : self , probe_kind, _result : PhantomData }
81
96
}
82
97
83
98
pub ( in crate :: solve) fn probe_builtin_trait_candidate (
84
99
& mut self ,
85
100
source : BuiltinImplSource ,
86
- ) -> TraitProbeCtxt <
87
- ' _ ,
88
- ' a ,
89
- ' tcx ,
90
- impl FnOnce ( & QueryResult < ' tcx > ) -> inspect:: ProbeKind < TyCtxt < ' tcx > > ,
91
- > {
101
+ ) -> TraitProbeCtxt < ' _ , ' a , Infcx , I , impl FnOnce ( & QueryResult < I > ) -> inspect:: ProbeKind < I > >
102
+ {
92
103
self . probe_trait_candidate ( CandidateSource :: BuiltinImpl ( source) )
93
104
}
94
105
95
106
pub ( in crate :: solve) fn probe_trait_candidate (
96
107
& mut self ,
97
- source : CandidateSource < ' tcx > ,
98
- ) -> TraitProbeCtxt <
99
- ' _ ,
100
- ' a ,
101
- ' tcx ,
102
- impl FnOnce ( & QueryResult < ' tcx > ) -> inspect:: ProbeKind < TyCtxt < ' tcx > > ,
103
- > {
108
+ source : CandidateSource < I > ,
109
+ ) -> TraitProbeCtxt < ' _ , ' a , Infcx , I , impl FnOnce ( & QueryResult < I > ) -> inspect:: ProbeKind < I > >
110
+ {
104
111
TraitProbeCtxt {
105
112
cx : ProbeCtxt {
106
113
ecx : self ,
107
- probe_kind : move |result : & QueryResult < ' tcx > | inspect:: ProbeKind :: TraitCandidate {
114
+ probe_kind : move |result : & QueryResult < I > | inspect:: ProbeKind :: TraitCandidate {
108
115
source,
109
116
result : * result,
110
117
} ,
0 commit comments