@@ -13,37 +13,23 @@ use rustc_middle::ty::{self, TyCtxt};
13
13
14
14
/// FIXME(-Znext-solver): This or public because it is shared with the
15
15
/// new trait solver implementation. We should deduplicate canonicalization.
16
- pub trait CanonicalExt < ' tcx , V > {
16
+ #[ extension]
17
+ pub impl < ' tcx , V > CanonicalExt < ' tcx , V > for Canonical < ' tcx , V > {
17
18
/// Instantiate the wrapped value, replacing each canonical value
18
19
/// with the value given in `var_values`.
19
20
fn instantiate ( & self , tcx : TyCtxt < ' tcx > , var_values : & CanonicalVarValues < ' tcx > ) -> V
20
21
where
21
- V : TypeFoldable < TyCtxt < ' tcx > > ;
22
+ V : TypeFoldable < TyCtxt < ' tcx > > ,
23
+ {
24
+ self . instantiate_projected ( tcx, var_values, |value| value. clone ( ) )
25
+ }
22
26
23
27
/// Allows one to apply a instantiation to some subset of
24
28
/// `self.value`. Invoke `projection_fn` with `self.value` to get
25
29
/// a value V that is expressed in terms of the same canonical
26
30
/// variables bound in `self` (usually this extracts from subset
27
31
/// of `self`). Apply the instantiation `var_values` to this value
28
32
/// V, replacing each of the canonical variables.
29
- fn instantiate_projected < T > (
30
- & self ,
31
- tcx : TyCtxt < ' tcx > ,
32
- var_values : & CanonicalVarValues < ' tcx > ,
33
- projection_fn : impl FnOnce ( & V ) -> T ,
34
- ) -> T
35
- where
36
- T : TypeFoldable < TyCtxt < ' tcx > > ;
37
- }
38
-
39
- impl < ' tcx , V > CanonicalExt < ' tcx , V > for Canonical < ' tcx , V > {
40
- fn instantiate ( & self , tcx : TyCtxt < ' tcx > , var_values : & CanonicalVarValues < ' tcx > ) -> V
41
- where
42
- V : TypeFoldable < TyCtxt < ' tcx > > ,
43
- {
44
- self . instantiate_projected ( tcx, var_values, |value| value. clone ( ) )
45
- }
46
-
47
33
fn instantiate_projected < T > (
48
34
& self ,
49
35
tcx : TyCtxt < ' tcx > ,
0 commit comments