Prevent promotion of const fn calls in inline consts

This commit is contained in:
Oli Scherer 2023-09-18 15:30:07 +00:00
parent b30cefc775
commit 238dc2828e
2 changed files with 2 additions and 2 deletions

View File

@ -315,7 +315,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
let body_owner_def_id = cx.tcx.hir().body_owner_def_id(body.id()); let body_owner_def_id = cx.tcx.hir().body_owner_def_id(body.id());
let body_owner_kind = cx.tcx.hir().body_owner_kind(body_owner_def_id); let body_owner_kind = cx.tcx.hir().body_owner_kind(body_owner_def_id);
if let hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) = body_owner_kind { if let hir::BodyOwnerKind::Const { .. } | hir::BodyOwnerKind::Static(_) = body_owner_kind {
let body_span = cx.tcx.hir().span_with_body(body_owner); let body_span = cx.tcx.hir().span_with_body(body_owner);
if let Some(span) = self.const_span && span.contains(body_span) { if let Some(span) = self.const_span && span.contains(body_span) {
return; return;

View File

@ -72,7 +72,7 @@ impl Context {
let body_owner_def_id = cx.tcx.hir().body_owner_def_id(body.id()); let body_owner_def_id = cx.tcx.hir().body_owner_def_id(body.id());
match cx.tcx.hir().body_owner_kind(body_owner_def_id) { match cx.tcx.hir().body_owner_kind(body_owner_def_id) {
hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const => { hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const { .. } => {
let body_span = cx.tcx.hir().span_with_body(body_owner); let body_span = cx.tcx.hir().span_with_body(body_owner);
if let Some(span) = self.const_span { if let Some(span) = self.const_span {