diff options
| author | lcnr <rust@lcnr.de> | 2022-07-20 14:32:58 +0200 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-03-27 12:16:54 +0000 |
| commit | 0c13565ca66d25d15ee9146919dd74e57cdfda89 (patch) | |
| tree | b0a7561ac7421c0df2e6daa3a047cf3dfb107627 /compiler/rustc_trait_selection/src/solve/trait_goals.rs | |
| parent | 7a0600714ab1a4cb2d1a88cd0660b9f9a2c07309 (diff) | |
| download | rust-0c13565ca66d25d15ee9146919dd74e57cdfda89.tar.gz rust-0c13565ca66d25d15ee9146919dd74e57cdfda89.zip | |
Add a builtin `FnPtr` trait
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve/trait_goals.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/trait_goals.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index ade45d199f0..718c82c8f1f 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -222,9 +222,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { let self_ty = tcx.erase_regions(goal.predicate.self_ty()); if let Ok(layout) = tcx.layout_of(goal.param_env.and(self_ty)) - && let usize_layout = tcx.layout_of(ty::ParamEnv::empty().and(tcx.types.usize)).unwrap().layout - && layout.layout.size() == usize_layout.size() - && layout.layout.align().abi == usize_layout.align().abi + && layout.layout.size() == tcx.data_layout.pointer_size + && layout.layout.align().abi == tcx.data_layout.pointer_align.abi { // FIXME: We could make this faster by making a no-constraints response ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) @@ -233,6 +232,17 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { } } + fn consider_builtin_fn_ptr_trait_candidate( + ecx: &mut EvalCtxt<'_, 'tcx>, + goal: Goal<'tcx, Self>, + ) -> QueryResult<'tcx> { + if let ty::FnPtr(..) = goal.predicate.self_ty().kind() { + ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) + } else { + Err(NoSolution) + } + } + fn consider_builtin_fn_trait_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, |
