mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 11:12:43 +00:00
Prevent promotion of const fn calls in inline consts
This commit is contained in:
parent
b30cefc775
commit
238dc2828e
@ -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;
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user