1- use std:: mem;
21
32use rustc_abi:: ExternAbi ;
43use rustc_ast:: visit:: AssocCtxt ;
@@ -378,7 +377,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
378377 body. as_deref ( ) ,
379378 attrs,
380379 contract. as_deref ( ) ,
381- header. constness ,
382380 ) ;
383381
384382 let itctx = ImplTraitContext :: Universal ;
@@ -1068,7 +1066,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
10681066 Some ( body) ,
10691067 attrs,
10701068 contract. as_deref ( ) ,
1071- sig. header . constness ,
10721069 ) ;
10731070 let ( generics, sig) = self . lower_method_sig (
10741071 generics,
@@ -1262,7 +1259,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
12621259 body. as_deref ( ) ,
12631260 attrs,
12641261 contract. as_deref ( ) ,
1265- sig. header . constness ,
12661262 ) ;
12671263 let ( generics, sig) = self . lower_method_sig (
12681264 generics,
@@ -1391,13 +1387,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
13911387 f : impl FnOnce ( & mut Self ) -> ( & ' hir [ hir:: Param < ' hir > ] , hir:: Expr < ' hir > ) ,
13921388 ) -> hir:: BodyId {
13931389 let prev_coroutine_kind = self . coroutine_kind . take ( ) ;
1394- let prev_is_in_const_context = mem:: take ( & mut self . is_in_const_context ) ;
13951390 let task_context = self . task_context . take ( ) ;
13961391 let ( parameters, result) = f ( self ) ;
13971392 let body_id = self . record_body ( parameters, result) ;
13981393 self . task_context = task_context;
13991394 self . coroutine_kind = prev_coroutine_kind;
1400- self . is_in_const_context = prev_is_in_const_context;
14011395 body_id
14021396 }
14031397
@@ -1416,13 +1410,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
14161410 & mut self ,
14171411 decl : & FnDecl ,
14181412 contract : Option < & FnContract > ,
1419- constness : Const ,
14201413 body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
14211414 ) -> hir:: BodyId {
14221415 self . lower_body ( |this| {
1423- if let Const :: Yes ( _) = constness {
1424- this. is_in_const_context = true ;
1425- }
14261416 let params =
14271417 this. arena . alloc_from_iter ( decl. inputs . iter ( ) . map ( |x| this. lower_param ( x) ) ) ;
14281418
@@ -1440,20 +1430,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
14401430 decl : & FnDecl ,
14411431 body : & Block ,
14421432 contract : Option < & FnContract > ,
1443- constness : Const ,
14441433 ) -> hir:: BodyId {
1445- self . lower_fn_body ( decl, contract, constness , |this| this. lower_block_expr ( body) )
1434+ self . lower_fn_body ( decl, contract, |this| this. lower_block_expr ( body) )
14461435 }
14471436
14481437 pub ( super ) fn lower_const_body ( & mut self , span : Span , expr : Option < & Expr > ) -> hir:: BodyId {
14491438 self . lower_body ( |this| {
14501439 (
14511440 & [ ] ,
14521441 match expr {
1453- Some ( expr) => {
1454- this. is_in_const_context = true ;
1455- this. lower_expr_mut ( expr)
1456- }
1442+ Some ( expr) => this. lower_expr_mut ( expr) ,
14571443 None => this. expr_err ( span, this. dcx ( ) . span_delayed_bug ( span, "no block" ) ) ,
14581444 } ,
14591445 )
@@ -1472,13 +1458,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
14721458 body : Option < & Block > ,
14731459 attrs : & ' hir [ hir:: Attribute ] ,
14741460 contract : Option < & FnContract > ,
1475- constness : Const ,
14761461 ) -> hir:: BodyId {
14771462 let Some ( body) = body else {
14781463 // Functions without a body are an error, except if this is an intrinsic. For those we
14791464 // create a fake body so that the entire rest of the compiler doesn't have to deal with
14801465 // this as a special case.
1481- return self . lower_fn_body ( decl, contract, constness , |this| {
1466+ return self . lower_fn_body ( decl, contract, |this| {
14821467 if find_attr ! ( attrs, RustcIntrinsic ) || this. tcx . is_sdylib_interface_build ( ) {
14831468 let span = this. lower_span ( span) ;
14841469 let empty_block = hir:: Block {
@@ -1503,7 +1488,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15031488 } ;
15041489 let Some ( coroutine_kind) = coroutine_kind else {
15051490 // Typical case: not a coroutine.
1506- return self . lower_fn_body_block ( decl, body, contract, constness ) ;
1491+ return self . lower_fn_body_block ( decl, body, contract) ;
15071492 } ;
15081493 // FIXME(contracts): Support contracts on async fn.
15091494 self . lower_body ( |this| {
0 commit comments