1- use std:: mem;
21use std:: sync:: Arc ;
32
43use rustc_abi:: ExternAbi ;
@@ -391,7 +390,6 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
391390 body. as_deref ( ) ,
392391 attrs,
393392 contract. as_deref ( ) ,
394- header. constness ,
395393 ) ;
396394
397395 let itctx = ImplTraitContext :: Universal ;
@@ -1081,7 +1079,6 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
10811079 Some ( body) ,
10821080 attrs,
10831081 contract. as_deref ( ) ,
1084- sig. header . constness ,
10851082 ) ;
10861083 let ( generics, sig) = self . lower_method_sig (
10871084 generics,
@@ -1275,7 +1272,6 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
12751272 body. as_deref ( ) ,
12761273 attrs,
12771274 contract. as_deref ( ) ,
1278- sig. header . constness ,
12791275 ) ;
12801276 let ( generics, sig) = self . lower_method_sig (
12811277 generics,
@@ -1405,13 +1401,11 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
14051401 f : impl FnOnce ( & mut Self ) -> ( & ' hir [ hir:: Param < ' hir > ] , hir:: Expr < ' hir > ) ,
14061402 ) -> hir:: BodyId {
14071403 let prev_coroutine_kind = self . coroutine_kind . take ( ) ;
1408- let prev_is_in_const_context = mem:: take ( & mut self . is_in_const_context ) ;
14091404 let task_context = self . task_context . take ( ) ;
14101405 let ( parameters, result) = f ( self ) ;
14111406 let body_id = self . record_body ( parameters, result) ;
14121407 self . task_context = task_context;
14131408 self . coroutine_kind = prev_coroutine_kind;
1414- self . is_in_const_context = prev_is_in_const_context;
14151409 body_id
14161410 }
14171411
@@ -1430,13 +1424,9 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
14301424 & mut self ,
14311425 decl : & FnDecl ,
14321426 contract : Option < & FnContract > ,
1433- constness : Const ,
14341427 body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
14351428 ) -> hir:: BodyId {
14361429 self . lower_body ( |this| {
1437- if let Const :: Yes ( _) = constness {
1438- this. is_in_const_context = true ;
1439- }
14401430 let params =
14411431 this. arena . alloc_from_iter ( decl. inputs . iter ( ) . map ( |x| this. lower_param ( x) ) ) ;
14421432
@@ -1454,20 +1444,16 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
14541444 decl : & FnDecl ,
14551445 body : & Block ,
14561446 contract : Option < & FnContract > ,
1457- constness : Const ,
14581447 ) -> hir:: BodyId {
1459- self . lower_fn_body ( decl, contract, constness , |this| this. lower_block_expr ( body) )
1448+ self . lower_fn_body ( decl, contract, |this| this. lower_block_expr ( body) )
14601449 }
14611450
14621451 pub ( super ) fn lower_const_body ( & mut self , span : Span , expr : Option < & Expr > ) -> hir:: BodyId {
14631452 self . lower_body ( |this| {
14641453 (
14651454 & [ ] ,
14661455 match expr {
1467- Some ( expr) => {
1468- this. is_in_const_context = true ;
1469- this. lower_expr_mut ( expr)
1470- }
1456+ Some ( expr) => this. lower_expr_mut ( expr) ,
14711457 None => this. expr_err ( span, this. dcx ( ) . span_delayed_bug ( span, "no block" ) ) ,
14721458 } ,
14731459 )
@@ -1486,13 +1472,12 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
14861472 body : Option < & Block > ,
14871473 attrs : & ' hir [ hir:: Attribute ] ,
14881474 contract : Option < & FnContract > ,
1489- constness : Const ,
14901475 ) -> hir:: BodyId {
14911476 let Some ( body) = body else {
14921477 // Functions without a body are an error, except if this is an intrinsic. For those we
14931478 // create a fake body so that the entire rest of the compiler doesn't have to deal with
14941479 // this as a special case.
1495- return self . lower_fn_body ( decl, contract, constness , |this| {
1480+ return self . lower_fn_body ( decl, contract, |this| {
14961481 if find_attr ! ( attrs, RustcIntrinsic ) || this. tcx . is_sdylib_interface_build ( ) {
14971482 let span = this. lower_span ( span) ;
14981483 let empty_block = hir:: Block {
@@ -1517,7 +1502,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
15171502 } ;
15181503 let Some ( coroutine_kind) = coroutine_kind else {
15191504 // Typical case: not a coroutine.
1520- return self . lower_fn_body_block ( decl, body, contract, constness ) ;
1505+ return self . lower_fn_body_block ( decl, body, contract) ;
15211506 } ;
15221507 // FIXME(contracts): Support contracts on async fn.
15231508 self . lower_body ( |this| {
0 commit comments