@@ -13,37 +13,23 @@ use rustc_middle::ty::{self, TyCtxt};
1313
1414/// FIXME(-Znext-solver): This or public because it is shared with the
1515/// 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 > {
1718 /// Instantiate the wrapped value, replacing each canonical value
1819 /// with the value given in `var_values`.
1920 fn instantiate ( & self , tcx : TyCtxt < ' tcx > , var_values : & CanonicalVarValues < ' tcx > ) -> V
2021 where
21- V : TypeFoldable < TyCtxt < ' tcx > > ;
22+ V : TypeFoldable < TyCtxt < ' tcx > > ,
23+ {
24+ self . instantiate_projected ( tcx, var_values, |value| value. clone ( ) )
25+ }
2226
2327 /// Allows one to apply a instantiation to some subset of
2428 /// `self.value`. Invoke `projection_fn` with `self.value` to get
2529 /// a value V that is expressed in terms of the same canonical
2630 /// variables bound in `self` (usually this extracts from subset
2731 /// of `self`). Apply the instantiation `var_values` to this value
2832 /// 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-
4733 fn instantiate_projected < T > (
4834 & self ,
4935 tcx : TyCtxt < ' tcx > ,
0 commit comments