File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
rustc_trait_selection/src/solve Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,22 @@ pub struct CanonicalVarValues<'tcx> {
68
68
pub var_values : IndexVec < BoundVar , GenericArg < ' tcx > > ,
69
69
}
70
70
71
+ impl CanonicalVarValues < ' _ > {
72
+ pub fn is_identity ( & self ) -> bool {
73
+ self . var_values . iter_enumerated ( ) . all ( |( bv, arg) | match arg. unpack ( ) {
74
+ ty:: GenericArgKind :: Lifetime ( r) => {
75
+ matches ! ( * r, ty:: ReLateBound ( ty:: INNERMOST , br) if br. var == bv)
76
+ }
77
+ ty:: GenericArgKind :: Type ( ty) => {
78
+ matches ! ( * ty. kind( ) , ty:: Bound ( ty:: INNERMOST , bt) if bt. var == bv)
79
+ }
80
+ ty:: GenericArgKind :: Const ( ct) => {
81
+ matches ! ( ct. kind( ) , ty:: ConstKind :: Bound ( ty:: INNERMOST , bc) if bc == bv)
82
+ }
83
+ } )
84
+ }
85
+ }
86
+
71
87
/// When we canonicalize a value to form a query, we wind up replacing
72
88
/// various parts of it with canonical variables. This struct stores
73
89
/// those replaced bits to remember for when we process the query
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ impl<'tcx> EvalCtxt<'tcx> {
178
178
let canonical_goal = infcx. canonicalize_query ( goal, & mut orig_values) ;
179
179
let canonical_response = self . evaluate_canonical_goal ( canonical_goal) ?;
180
180
Ok ( (
181
- true , // FIXME: check whether ` var_values` are an identity substitution.
181
+ !canonical_response . value . var_values . is_identity ( ) ,
182
182
instantiate_canonical_query_response ( infcx, & orig_values, canonical_response) ,
183
183
) )
184
184
}
You can’t perform that action at this time.
0 commit comments