Use &'hir Expr
everywhere.
For consistency, and because it makes HIR measurement simpler and more accurate.
This commit is contained in:
parent
854219d2ad
commit
db35b685a7
@ -155,26 +155,26 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
let op = match *op {
|
let op = match *op {
|
||||||
InlineAsmOperand::In { reg, ref expr } => hir::InlineAsmOperand::In {
|
InlineAsmOperand::In { reg, ref expr } => hir::InlineAsmOperand::In {
|
||||||
reg: lower_reg(reg),
|
reg: lower_reg(reg),
|
||||||
expr: self.lower_expr_mut(expr),
|
expr: self.lower_expr(expr),
|
||||||
},
|
},
|
||||||
InlineAsmOperand::Out { reg, late, ref expr } => hir::InlineAsmOperand::Out {
|
InlineAsmOperand::Out { reg, late, ref expr } => hir::InlineAsmOperand::Out {
|
||||||
reg: lower_reg(reg),
|
reg: lower_reg(reg),
|
||||||
late,
|
late,
|
||||||
expr: expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
|
expr: expr.as_ref().map(|expr| self.lower_expr(expr)),
|
||||||
},
|
},
|
||||||
InlineAsmOperand::InOut { reg, late, ref expr } => {
|
InlineAsmOperand::InOut { reg, late, ref expr } => {
|
||||||
hir::InlineAsmOperand::InOut {
|
hir::InlineAsmOperand::InOut {
|
||||||
reg: lower_reg(reg),
|
reg: lower_reg(reg),
|
||||||
late,
|
late,
|
||||||
expr: self.lower_expr_mut(expr),
|
expr: self.lower_expr(expr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineAsmOperand::SplitInOut { reg, late, ref in_expr, ref out_expr } => {
|
InlineAsmOperand::SplitInOut { reg, late, ref in_expr, ref out_expr } => {
|
||||||
hir::InlineAsmOperand::SplitInOut {
|
hir::InlineAsmOperand::SplitInOut {
|
||||||
reg: lower_reg(reg),
|
reg: lower_reg(reg),
|
||||||
late,
|
late,
|
||||||
in_expr: self.lower_expr_mut(in_expr),
|
in_expr: self.lower_expr(in_expr),
|
||||||
out_expr: out_expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
|
out_expr: out_expr.as_ref().map(|expr| self.lower_expr(expr)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineAsmOperand::Const { ref anon_const } => {
|
InlineAsmOperand::Const { ref anon_const } => {
|
||||||
|
@ -947,7 +947,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
params: &'hir [hir::Param<'hir>],
|
params: &'hir [hir::Param<'hir>],
|
||||||
value: hir::Expr<'hir>,
|
value: hir::Expr<'hir>,
|
||||||
) -> hir::BodyId {
|
) -> hir::BodyId {
|
||||||
let body = hir::Body { generator_kind: self.generator_kind, params, value };
|
let body = hir::Body {
|
||||||
|
generator_kind: self.generator_kind,
|
||||||
|
params,
|
||||||
|
value: self.arena.alloc(value),
|
||||||
|
};
|
||||||
let id = body.id();
|
let id = body.id();
|
||||||
debug_assert_eq!(id.hir_id.owner, self.current_hir_id_owner);
|
debug_assert_eq!(id.hir_id.owner, self.current_hir_id_owner);
|
||||||
self.bodies.push((id.hir_id.local_id, self.arena.alloc(body)));
|
self.bodies.push((id.hir_id.local_id, self.arena.alloc(body)));
|
||||||
|
@ -1438,7 +1438,7 @@ pub struct BodyId {
|
|||||||
#[derive(Debug, HashStable_Generic)]
|
#[derive(Debug, HashStable_Generic)]
|
||||||
pub struct Body<'hir> {
|
pub struct Body<'hir> {
|
||||||
pub params: &'hir [Param<'hir>],
|
pub params: &'hir [Param<'hir>],
|
||||||
pub value: Expr<'hir>,
|
pub value: &'hir Expr<'hir>,
|
||||||
pub generator_kind: Option<GeneratorKind>,
|
pub generator_kind: Option<GeneratorKind>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2561,23 +2561,23 @@ pub enum TyKind<'hir> {
|
|||||||
pub enum InlineAsmOperand<'hir> {
|
pub enum InlineAsmOperand<'hir> {
|
||||||
In {
|
In {
|
||||||
reg: InlineAsmRegOrRegClass,
|
reg: InlineAsmRegOrRegClass,
|
||||||
expr: Expr<'hir>,
|
expr: &'hir Expr<'hir>,
|
||||||
},
|
},
|
||||||
Out {
|
Out {
|
||||||
reg: InlineAsmRegOrRegClass,
|
reg: InlineAsmRegOrRegClass,
|
||||||
late: bool,
|
late: bool,
|
||||||
expr: Option<Expr<'hir>>,
|
expr: Option<&'hir Expr<'hir>>,
|
||||||
},
|
},
|
||||||
InOut {
|
InOut {
|
||||||
reg: InlineAsmRegOrRegClass,
|
reg: InlineAsmRegOrRegClass,
|
||||||
late: bool,
|
late: bool,
|
||||||
expr: Expr<'hir>,
|
expr: &'hir Expr<'hir>,
|
||||||
},
|
},
|
||||||
SplitInOut {
|
SplitInOut {
|
||||||
reg: InlineAsmRegOrRegClass,
|
reg: InlineAsmRegOrRegClass,
|
||||||
late: bool,
|
late: bool,
|
||||||
in_expr: Expr<'hir>,
|
in_expr: &'hir Expr<'hir>,
|
||||||
out_expr: Option<Expr<'hir>>,
|
out_expr: Option<&'hir Expr<'hir>>,
|
||||||
},
|
},
|
||||||
Const {
|
Const {
|
||||||
anon_const: AnonConst,
|
anon_const: AnonConst,
|
||||||
@ -3496,7 +3496,7 @@ mod size_asserts {
|
|||||||
use super::*;
|
use super::*;
|
||||||
// These are in alphabetical order, which is easy to maintain.
|
// These are in alphabetical order, which is easy to maintain.
|
||||||
static_assert_size!(Block<'_>, 48);
|
static_assert_size!(Block<'_>, 48);
|
||||||
static_assert_size!(Body<'_>, 80);
|
static_assert_size!(Body<'_>, 32);
|
||||||
static_assert_size!(Expr<'_>, 56);
|
static_assert_size!(Expr<'_>, 56);
|
||||||
static_assert_size!(ExprKind<'_>, 40);
|
static_assert_size!(ExprKind<'_>, 40);
|
||||||
static_assert_size!(FnDecl<'_>, 40);
|
static_assert_size!(FnDecl<'_>, 40);
|
||||||
|
@ -974,7 +974,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||||||
self.process_macro_use(trait_item.span);
|
self.process_macro_use(trait_item.span);
|
||||||
match trait_item.kind {
|
match trait_item.kind {
|
||||||
hir::TraitItemKind::Const(ref ty, body) => {
|
hir::TraitItemKind::Const(ref ty, body) => {
|
||||||
let body = body.map(|b| &self.tcx.hir().body(b).value);
|
let body = body.map(|b| self.tcx.hir().body(b).value);
|
||||||
let attrs = self.tcx.hir().attrs(trait_item.hir_id());
|
let attrs = self.tcx.hir().attrs(trait_item.hir_id());
|
||||||
self.process_assoc_const(
|
self.process_assoc_const(
|
||||||
trait_item.def_id,
|
trait_item.def_id,
|
||||||
|
@ -178,9 +178,9 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
|
|||||||
InlineAsmOperand::In { expr, .. } | InlineAsmOperand::InOut { expr, .. } => {
|
InlineAsmOperand::In { expr, .. } | InlineAsmOperand::InOut { expr, .. } => {
|
||||||
never_loop_expr(expr, main_loop_id)
|
never_loop_expr(expr, main_loop_id)
|
||||||
},
|
},
|
||||||
InlineAsmOperand::Out { expr, .. } => never_loop_expr_all(&mut expr.iter(), main_loop_id),
|
InlineAsmOperand::Out { expr, .. } => never_loop_expr_all(&mut expr.iter().copied(), main_loop_id),
|
||||||
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
||||||
never_loop_expr_all(&mut once(in_expr).chain(out_expr.iter()), main_loop_id)
|
never_loop_expr_all(&mut once(*in_expr).chain(out_expr.iter().copied()), main_loop_id)
|
||||||
},
|
},
|
||||||
InlineAsmOperand::Const { .. }
|
InlineAsmOperand::Const { .. }
|
||||||
| InlineAsmOperand::SymFn { .. }
|
| InlineAsmOperand::SymFn { .. }
|
||||||
|
@ -595,7 +595,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn body(&self, body_id: &Binding<hir::BodyId>) {
|
fn body(&self, body_id: &Binding<hir::BodyId>) {
|
||||||
let expr = &self.cx.tcx.hir().body(body_id.value).value;
|
let expr = self.cx.tcx.hir().body(body_id.value).value;
|
||||||
bind!(self, expr);
|
bind!(self, expr);
|
||||||
out!("let {expr} = &cx.tcx.hir().body({body_id}).value;");
|
out!("let {expr} = &cx.tcx.hir().body({body_id}).value;");
|
||||||
self.expr(expr);
|
self.expr(expr);
|
||||||
|
@ -1804,7 +1804,7 @@ pub fn is_expr_identity_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut expr = &func.value;
|
let mut expr = func.value;
|
||||||
loop {
|
loop {
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user