@@ -6,7 +6,7 @@ use crate::errors;
6
6
use rustc_ast:: util:: parser:: PREC_POSTFIX ;
7
7
use rustc_errors:: { Applicability , Diagnostic , ErrorGuaranteed , StashKey } ;
8
8
use rustc_hir as hir;
9
- use rustc_hir:: def:: { self , CtorKind , DefKind , Namespace , Res } ;
9
+ use rustc_hir:: def:: { self , CtorKind , Namespace , Res } ;
10
10
use rustc_hir:: def_id:: DefId ;
11
11
use rustc_hir:: HirId ;
12
12
use rustc_hir_analysis:: autoderef:: Autoderef ;
@@ -781,38 +781,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
781
781
let generics = tcx. generics_of ( callee_did) ;
782
782
let Some ( host_effect_index) = generics. host_effect_index else { return } ;
783
783
784
- // if the callee does have the param, we need to equate the param to some const
785
- // value no matter whether the effects feature is enabled in the local crate,
786
- // because inference will fail if we don't.
787
- let mut host_always_on =
788
- !tcx. features ( ) . effects || tcx. sess . opts . unstable_opts . unleash_the_miri_inside_of_you ;
789
-
790
- // Compute the constness required by the context.
791
- let context = tcx. hir ( ) . enclosing_body_owner ( call_expr_hir) ;
792
- let const_context = tcx. hir ( ) . body_const_context ( context) ;
793
-
794
- let kind = tcx. def_kind ( context. to_def_id ( ) ) ;
795
- debug_assert_ne ! ( kind, DefKind :: ConstParam ) ;
796
-
797
- if tcx. has_attr ( context. to_def_id ( ) , sym:: rustc_do_not_const_check) {
798
- trace ! ( "do not const check this context" ) ;
799
- host_always_on = true ;
800
- }
801
-
802
- let effect = match const_context {
803
- _ if host_always_on => tcx. consts . true_ ,
804
- Some ( hir:: ConstContext :: Static ( _) | hir:: ConstContext :: Const { .. } ) => {
805
- tcx. consts . false_
806
- }
807
- Some ( hir:: ConstContext :: ConstFn ) => {
808
- let host_idx = tcx
809
- . generics_of ( context)
810
- . host_effect_index
811
- . expect ( "ConstContext::Maybe must have host effect param" ) ;
812
- ty:: GenericArgs :: identity_for_item ( tcx, context) . const_at ( host_idx)
813
- }
814
- None => tcx. consts . true_ ,
815
- } ;
784
+ let effect = tcx. expected_const_effect_param_for_body ( self . body_id ) ;
816
785
817
786
trace ! ( ?effect, ?generics, ?callee_args) ;
818
787
0 commit comments