@@ -4,13 +4,13 @@ use std::iter;
4
4
5
5
use super :: assembly:: { self , Candidate , CandidateSource } ;
6
6
use super :: infcx_ext:: InferCtxtExt ;
7
- use super :: { EvalCtxt , Goal , QueryResult } ;
7
+ use super :: { Certainty , EvalCtxt , Goal , QueryResult } ;
8
8
use rustc_hir:: def_id:: DefId ;
9
9
use rustc_infer:: infer:: InferCtxt ;
10
10
use rustc_infer:: traits:: query:: NoSolution ;
11
11
use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams } ;
12
- use rustc_middle:: ty:: TraitPredicate ;
13
12
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
13
+ use rustc_middle:: ty:: { TraitPredicate , TypeVisitable } ;
14
14
use rustc_span:: DUMMY_SP ;
15
15
16
16
mod structural_traits;
@@ -127,6 +127,29 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
127
127
structural_traits:: instantiate_constituent_tys_for_copy_clone_trait,
128
128
)
129
129
}
130
+
131
+ fn consider_builtin_pointer_sized_candidate (
132
+ ecx : & mut EvalCtxt < ' _ , ' tcx > ,
133
+ goal : Goal < ' tcx , Self > ,
134
+ ) -> QueryResult < ' tcx > {
135
+ if goal. predicate . self_ty ( ) . has_non_region_infer ( ) {
136
+ return ecx. make_canonical_response ( Certainty :: Maybe ( MaybeCause :: Ambiguity ) ) ;
137
+ }
138
+
139
+ let tcx = ecx. tcx ( ) ;
140
+ let self_ty = tcx. erase_regions ( goal. predicate . self_ty ( ) ) ;
141
+
142
+ if let Ok ( layout) = tcx. layout_of ( goal. param_env . and ( self_ty) )
143
+ && let usize_layout = tcx. layout_of ( ty:: ParamEnv :: empty ( ) . and ( tcx. types . usize ) ) . unwrap ( ) . layout
144
+ && layout. layout . size ( ) == usize_layout. size ( )
145
+ && layout. layout . align ( ) . abi == usize_layout. align ( ) . abi
146
+ {
147
+ // FIXME: We could make this faster by making a no-constraints response
148
+ ecx. make_canonical_response ( Certainty :: Yes )
149
+ } else {
150
+ Err ( NoSolution )
151
+ }
152
+ }
130
153
}
131
154
132
155
impl < ' tcx > EvalCtxt < ' _ , ' tcx > {
0 commit comments