@@ -6,9 +6,8 @@ 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
- use rustc_hir:: HirId ;
12
11
use rustc_hir_analysis:: autoderef:: Autoderef ;
13
12
use rustc_infer:: {
14
13
infer,
@@ -373,7 +372,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
373
372
) -> Ty < ' tcx > {
374
373
let ( fn_sig, def_id) = match * callee_ty. kind ( ) {
375
374
ty:: FnDef ( def_id, args) => {
376
- self . enforce_context_effects ( call_expr. hir_id , call_expr . span , def_id, args) ;
375
+ self . enforce_context_effects ( call_expr. span , def_id, args) ;
377
376
let fn_sig = self . tcx . fn_sig ( def_id) . instantiate ( self . tcx , args) ;
378
377
379
378
// Unit testing: function items annotated with
@@ -770,7 +769,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
770
769
#[ tracing:: instrument( level = "debug" , skip( self , span) ) ]
771
770
pub ( super ) fn enforce_context_effects (
772
771
& self ,
773
- call_expr_hir : HirId ,
774
772
span : Span ,
775
773
callee_did : DefId ,
776
774
callee_args : GenericArgsRef < ' tcx > ,
@@ -781,38 +779,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
781
779
let generics = tcx. generics_of ( callee_did) ;
782
780
let Some ( host_effect_index) = generics. host_effect_index else { return } ;
783
781
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
- } ;
782
+ let effect = tcx. expected_const_effect_param_for_body ( self . body_id ) ;
816
783
817
784
trace ! ( ?effect, ?generics, ?callee_args) ;
818
785
0 commit comments