This repository was archived by the owner on May 28, 2025. It is now read-only.
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> {
6868 pub var_values : IndexVec < BoundVar , GenericArg < ' tcx > > ,
6969}
7070
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+
7187/// When we canonicalize a value to form a query, we wind up replacing
7288/// various parts of it with canonical variables. This struct stores
7389/// 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> {
178178 let canonical_goal = infcx. canonicalize_query ( goal, & mut orig_values) ;
179179 let canonical_response = self . evaluate_canonical_goal ( canonical_goal) ?;
180180 Ok ( (
181- true , // FIXME: check whether ` var_values` are an identity substitution.
181+ !canonical_response . value . var_values . is_identity ( ) ,
182182 instantiate_canonical_query_response ( infcx, & orig_values, canonical_response) ,
183183 ) )
184184 }
You can’t perform that action at this time.
0 commit comments