1- use std:: mem;
2-
31use rustc_abi:: ExternAbi ;
42use rustc_ast:: visit:: AssocCtxt ;
53use rustc_ast:: * ;
@@ -378,7 +376,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
378376 body. as_deref ( ) ,
379377 attrs,
380378 contract. as_deref ( ) ,
381- header. constness ,
382379 ) ;
383380
384381 let itctx = ImplTraitContext :: Universal ;
@@ -1068,7 +1065,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
10681065 Some ( body) ,
10691066 attrs,
10701067 contract. as_deref ( ) ,
1071- sig. header . constness ,
10721068 ) ;
10731069 let ( generics, sig) = self . lower_method_sig (
10741070 generics,
@@ -1262,7 +1258,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
12621258 body. as_deref ( ) ,
12631259 attrs,
12641260 contract. as_deref ( ) ,
1265- sig. header . constness ,
12661261 ) ;
12671262 let ( generics, sig) = self . lower_method_sig (
12681263 generics,
@@ -1391,13 +1386,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
13911386 f : impl FnOnce ( & mut Self ) -> ( & ' hir [ hir:: Param < ' hir > ] , hir:: Expr < ' hir > ) ,
13921387 ) -> hir:: BodyId {
13931388 let prev_coroutine_kind = self . coroutine_kind . take ( ) ;
1394- let prev_is_in_const_context = mem:: take ( & mut self . is_in_const_context ) ;
13951389 let task_context = self . task_context . take ( ) ;
13961390 let ( parameters, result) = f ( self ) ;
13971391 let body_id = self . record_body ( parameters, result) ;
13981392 self . task_context = task_context;
13991393 self . coroutine_kind = prev_coroutine_kind;
1400- self . is_in_const_context = prev_is_in_const_context;
14011394 body_id
14021395 }
14031396
@@ -1416,13 +1409,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
14161409 & mut self ,
14171410 decl : & FnDecl ,
14181411 contract : Option < & FnContract > ,
1419- constness : Const ,
14201412 body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
14211413 ) -> hir:: BodyId {
14221414 self . lower_body ( |this| {
1423- if let Const :: Yes ( _) = constness {
1424- this. is_in_const_context = true ;
1425- }
14261415 let params =
14271416 this. arena . alloc_from_iter ( decl. inputs . iter ( ) . map ( |x| this. lower_param ( x) ) ) ;
14281417
@@ -1440,20 +1429,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
14401429 decl : & FnDecl ,
14411430 body : & Block ,
14421431 contract : Option < & FnContract > ,
1443- constness : Const ,
14441432 ) -> hir:: BodyId {
1445- self . lower_fn_body ( decl, contract, constness , |this| this. lower_block_expr ( body) )
1433+ self . lower_fn_body ( decl, contract, |this| this. lower_block_expr ( body) )
14461434 }
14471435
14481436 pub ( super ) fn lower_const_body ( & mut self , span : Span , expr : Option < & Expr > ) -> hir:: BodyId {
14491437 self . lower_body ( |this| {
14501438 (
14511439 & [ ] ,
14521440 match expr {
1453- Some ( expr) => {
1454- this. is_in_const_context = true ;
1455- this. lower_expr_mut ( expr)
1456- }
1441+ Some ( expr) => this. lower_expr_mut ( expr) ,
14571442 None => this. expr_err ( span, this. dcx ( ) . span_delayed_bug ( span, "no block" ) ) ,
14581443 } ,
14591444 )
@@ -1472,13 +1457,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
14721457 body : Option < & Block > ,
14731458 attrs : & ' hir [ hir:: Attribute ] ,
14741459 contract : Option < & FnContract > ,
1475- constness : Const ,
14761460 ) -> hir:: BodyId {
14771461 let Some ( body) = body else {
14781462 // Functions without a body are an error, except if this is an intrinsic. For those we
14791463 // create a fake body so that the entire rest of the compiler doesn't have to deal with
14801464 // this as a special case.
1481- return self . lower_fn_body ( decl, contract, constness , |this| {
1465+ return self . lower_fn_body ( decl, contract, |this| {
14821466 if find_attr ! ( attrs, RustcIntrinsic ) || this. tcx . is_sdylib_interface_build ( ) {
14831467 let span = this. lower_span ( span) ;
14841468 let empty_block = hir:: Block {
@@ -1503,7 +1487,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15031487 } ;
15041488 let Some ( coroutine_kind) = coroutine_kind else {
15051489 // Typical case: not a coroutine.
1506- return self . lower_fn_body_block ( decl, body, contract, constness ) ;
1490+ return self . lower_fn_body_block ( decl, body, contract) ;
15071491 } ;
15081492 // FIXME(contracts): Support contracts on async fn.
15091493 self . lower_body ( |this| {
0 commit comments