diff options
| author | bors <bors@rust-lang.org> | 2023-06-17 06:26:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-17 06:26:55 +0000 |
| commit | f90d57d06ebc7f250b60b9cab583f111d9a5fb9d (patch) | |
| tree | 700356c39dce158d2b3c87d9593766137140fb14 /compiler/rustc_const_eval/src/transform | |
| parent | 1d7d82472617a4a0fea59c7e239c8a48c8ac5c34 (diff) | |
| parent | d97d4ebecc502bcb5eda2cdaa513e0e7922a377e (diff) | |
| download | rust-f90d57d06ebc7f250b60b9cab583f111d9a5fb9d.tar.gz rust-f90d57d06ebc7f250b60b9cab583f111d9a5fb9d.zip | |
Auto merge of #112687 - compiler-errors:simplify-impl-source, r=lcnr
Simplify `ImplSource` candidates a bit Reduce the number of impl source candidates, which will hopefully make our life easier when trying to adapt things like `SelectionContext::select` and `codegen_select_candidate` for the new solver. r? `@lcnr` but feel free to reassign
Diffstat (limited to 'compiler/rustc_const_eval/src/transform')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/check.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 57d939747aa..106cf111474 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -781,8 +781,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { ); return; } - Ok(Some(ImplSource::Closure(data))) => { - if !tcx.is_const_fn_raw(data.closure_def_id) { + // Closure: Fn{Once|Mut} + Ok(Some(ImplSource::Builtin(_))) + if poly_trait_pred.self_ty().skip_binder().is_closure() + && tcx.fn_trait_kind_from_def_id(trait_id).is_some() => + { + let ty::Closure(closure_def_id, substs) = + *poly_trait_pred.self_ty().no_bound_vars().unwrap().kind() + else { + unreachable!() + }; + if !tcx.is_const_fn_raw(closure_def_id) { self.check_op(ops::FnCallNonConst { caller, callee, diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index 1da20579021..a2d23425f3b 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -172,7 +172,7 @@ impl Qualif for NeedsNonConstDrop { if !matches!( impl_src, - ImplSource::ConstDestruct(_) | ImplSource::Param(_, ty::BoundConstness::ConstIfConst) + ImplSource::Builtin(_) | ImplSource::Param(_, ty::BoundConstness::ConstIfConst) ) { // If our const destruct candidate is not ConstDestruct or implied by the param env, // then it's bad |
