mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
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 {
|
||||
InlineAsmOperand::In { reg, ref expr } => hir::InlineAsmOperand::In {
|
||||
reg: lower_reg(reg),
|
||||
expr: self.lower_expr_mut(expr),
|
||||
expr: self.lower_expr(expr),
|
||||
},
|
||||
InlineAsmOperand::Out { reg, late, ref expr } => hir::InlineAsmOperand::Out {
|
||||
reg: lower_reg(reg),
|
||||
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 } => {
|
||||
hir::InlineAsmOperand::InOut {
|
||||
reg: lower_reg(reg),
|
||||
late,
|
||||
expr: self.lower_expr_mut(expr),
|
||||
expr: self.lower_expr(expr),
|
||||
}
|
||||
}
|
||||
InlineAsmOperand::SplitInOut { reg, late, ref in_expr, ref out_expr } => {
|
||||
hir::InlineAsmOperand::SplitInOut {
|
||||
reg: lower_reg(reg),
|
||||
late,
|
||||
in_expr: self.lower_expr_mut(in_expr),
|
||||
out_expr: out_expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
|
||||
in_expr: self.lower_expr(in_expr),
|
||||
out_expr: out_expr.as_ref().map(|expr| self.lower_expr(expr)),
|
||||
}
|
||||
}
|
||||
InlineAsmOperand::Const { ref anon_const } => {
|
||||
|
@ -947,7 +947,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
params: &'hir [hir::Param<'hir>],
|
||||
value: hir::Expr<'hir>,
|
||||
) -> 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();
|
||||
debug_assert_eq!(id.hir_id.owner, self.current_hir_id_owner);
|
||||
self.bodies.push((id.hir_id.local_id, self.arena.alloc(body)));
|
||||
|
@ -1438,7 +1438,7 @@ pub struct BodyId {
|
||||
#[derive(Debug, HashStable_Generic)]
|
||||
pub struct Body<'hir> {
|
||||
pub params: &'hir [Param<'hir>],
|
||||
pub value: Expr<'hir>,
|
||||
pub value: &'hir Expr<'hir>,
|
||||
pub generator_kind: Option<GeneratorKind>,
|
||||
}
|
||||
|
||||
@ -2561,23 +2561,23 @@ pub enum TyKind<'hir> {
|
||||
pub enum InlineAsmOperand<'hir> {
|
||||
In {
|
||||
reg: InlineAsmRegOrRegClass,
|
||||
expr: Expr<'hir>,
|
||||
expr: &'hir Expr<'hir>,
|
||||
},
|
||||
Out {
|
||||
reg: InlineAsmRegOrRegClass,
|
||||
late: bool,
|
||||
expr: Option<Expr<'hir>>,
|
||||
expr: Option<&'hir Expr<'hir>>,
|
||||
},
|
||||
InOut {
|
||||
reg: InlineAsmRegOrRegClass,
|
||||
late: bool,
|
||||
expr: Expr<'hir>,
|
||||
expr: &'hir Expr<'hir>,
|
||||
},
|
||||
SplitInOut {
|
||||
reg: InlineAsmRegOrRegClass,
|
||||
late: bool,
|
||||
in_expr: Expr<'hir>,
|
||||
out_expr: Option<Expr<'hir>>,
|
||||
in_expr: &'hir Expr<'hir>,
|
||||
out_expr: Option<&'hir Expr<'hir>>,
|
||||
},
|
||||
Const {
|
||||
anon_const: AnonConst,
|
||||
@ -3496,7 +3496,7 @@ mod size_asserts {
|
||||
use super::*;
|
||||
// These are in alphabetical order, which is easy to maintain.
|
||||
static_assert_size!(Block<'_>, 48);
|
||||
static_assert_size!(Body<'_>, 80);
|
||||
static_assert_size!(Body<'_>, 32);
|
||||
static_assert_size!(Expr<'_>, 56);
|
||||
static_assert_size!(ExprKind<'_>, 40);
|
||||
static_assert_size!(FnDecl<'_>, 40);
|
||||
|
@ -974,7 +974,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
self.process_macro_use(trait_item.span);
|
||||
match trait_item.kind {
|
||||
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());
|
||||
self.process_assoc_const(
|
||||
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, .. } => {
|
||||
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, .. } => {
|
||||
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::SymFn { .. }
|
||||
|
@ -595,7 +595,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
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);
|
||||
out!("let {expr} = &cx.tcx.hir().body({body_id}).value;");
|
||||
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 {
|
||||
match expr.kind {
|
||||
#[rustfmt::skip]
|
||||
|
Loading…
Reference in New Issue
Block a user