Use Arena inside hir::Body.

This commit is contained in:
Camille GILLOT 2019-11-29 11:09:23 +01:00
parent 42c03e4bb4
commit 9694ab9e18
24 changed files with 69 additions and 65 deletions

View File

@ -130,6 +130,7 @@ macro_rules! arena_types {
[] foreign_item: rustc::hir::ForeignItem<$tcx>, [] foreign_item: rustc::hir::ForeignItem<$tcx>,
[] impl_item_ref: rustc::hir::ImplItemRef, [] impl_item_ref: rustc::hir::ImplItemRef,
[] macro_def: rustc::hir::MacroDef<$tcx>, [] macro_def: rustc::hir::MacroDef<$tcx>,
[] param: rustc::hir::Param,
[] path: rustc::hir::Path, [] path: rustc::hir::Path,
[] struct_field: rustc::hir::StructField<$tcx>, [] struct_field: rustc::hir::StructField<$tcx>,
[] trait_item_ref: rustc::hir::TraitItemRef, [] trait_item_ref: rustc::hir::TraitItemRef,

View File

@ -222,7 +222,7 @@ pub trait Visitor<'v>: Sized {
walk_item(self, i) walk_item(self, i)
} }
fn visit_body(&mut self, b: &'v Body) { fn visit_body(&mut self, b: &'v Body<'v>) {
walk_body(self, b); walk_body(self, b);
} }
@ -401,8 +401,8 @@ pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod<'v>, mod_hi
} }
} }
pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body) { pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) {
walk_list!(visitor, visit_param, &body.params); walk_list!(visitor, visit_param, body.params);
visitor.visit_expr(&body.value); visitor.visit_expr(&body.value);
} }

View File

@ -99,7 +99,7 @@ pub struct LoweringContext<'a, 'hir: 'a> {
trait_items: BTreeMap<hir::TraitItemId, hir::TraitItem<'hir>>, trait_items: BTreeMap<hir::TraitItemId, hir::TraitItem<'hir>>,
impl_items: BTreeMap<hir::ImplItemId, hir::ImplItem<'hir>>, impl_items: BTreeMap<hir::ImplItemId, hir::ImplItem<'hir>>,
bodies: BTreeMap<hir::BodyId, hir::Body>, bodies: BTreeMap<hir::BodyId, hir::Body<'hir>>,
exported_macros: Vec<hir::MacroDef<'hir>>, exported_macros: Vec<hir::MacroDef<'hir>>,
non_exported_macro_attrs: Vec<ast::Attribute>, non_exported_macro_attrs: Vec<ast::Attribute>,
@ -3428,7 +3428,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} }
} }
fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body>) -> Vec<hir::BodyId> { fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'hir>>) -> Vec<hir::BodyId> {
// Sorting by span ensures that we get things in order within a // Sorting by span ensures that we get things in order within a
// file, and also puts the files in a sensible order. // file, and also puts the files in a sensible order.
let mut body_ids: Vec<_> = bodies.keys().cloned().collect(); let mut body_ids: Vec<_> = bodies.keys().cloned().collect();

View File

@ -5,7 +5,7 @@ use super::ImplTraitTypeIdVisitor;
use super::AnonymousLifetimeMode; use super::AnonymousLifetimeMode;
use super::ParamMode; use super::ParamMode;
use crate::hir::{self, HirVec}; use crate::hir;
use crate::hir::ptr::P; use crate::hir::ptr::P;
use crate::hir::def_id::DefId; use crate::hir::def_id::DefId;
use crate::hir::def::{Res, DefKind}; use crate::hir::def::{Res, DefKind};
@ -107,7 +107,7 @@ impl<'a, 'lowering, 'hir> Visitor<'a> for ItemLowerer<'a, 'lowering, 'hir> {
} }
} }
impl LoweringContext<'_, 'hir> { impl<'hir> LoweringContext<'_, 'hir> {
// Same as the method above, but accepts `hir::GenericParam`s // Same as the method above, but accepts `hir::GenericParam`s
// instead of `ast::GenericParam`s. // instead of `ast::GenericParam`s.
// This should only be used with generics that have already had their // This should only be used with generics that have already had their
@ -1052,7 +1052,7 @@ impl LoweringContext<'_, 'hir> {
} }
} }
fn record_body(&mut self, params: HirVec<hir::Param>, value: hir::Expr) -> hir::BodyId { fn record_body(&mut self, params: &'hir [hir::Param], value: hir::Expr) -> hir::BodyId {
let body = hir::Body { let body = hir::Body {
generator_kind: self.generator_kind, generator_kind: self.generator_kind,
params, params,
@ -1065,7 +1065,7 @@ impl LoweringContext<'_, 'hir> {
fn lower_body( fn lower_body(
&mut self, &mut self,
f: impl FnOnce(&mut LoweringContext<'_, '_>) -> (HirVec<hir::Param>, hir::Expr), f: impl FnOnce(&mut Self) -> (&'hir [hir::Param], hir::Expr),
) -> hir::BodyId { ) -> hir::BodyId {
let prev_gen_kind = self.generator_kind.take(); let prev_gen_kind = self.generator_kind.take();
let (parameters, result) = f(self); let (parameters, result) = f(self);
@ -1089,7 +1089,9 @@ impl LoweringContext<'_, 'hir> {
body: impl FnOnce(&mut LoweringContext<'_, '_>) -> hir::Expr, body: impl FnOnce(&mut LoweringContext<'_, '_>) -> hir::Expr,
) -> hir::BodyId { ) -> hir::BodyId {
self.lower_body(|this| ( self.lower_body(|this| (
decl.inputs.iter().map(|x| this.lower_param(x)).collect(), this.arena.alloc_from_iter(
decl.inputs.iter().map(|x| this.lower_param(x))
),
body(this), body(this),
)) ))
} }
@ -1111,7 +1113,7 @@ impl LoweringContext<'_, 'hir> {
} }
pub(super) fn lower_const_body(&mut self, span: Span, expr: Option<&Expr>) -> hir::BodyId { pub(super) fn lower_const_body(&mut self, span: Span, expr: Option<&Expr>) -> hir::BodyId {
self.lower_body(|this| (hir_vec![], match expr { self.lower_body(|this| (&[], match expr {
Some(expr) => this.lower_expr(expr), Some(expr) => this.lower_expr(expr),
None => this.expr_err(span), None => this.expr_err(span),
})) }))
@ -1299,7 +1301,8 @@ impl LoweringContext<'_, 'hir> {
); );
this.expr_block(P(body), AttrVec::new()) this.expr_block(P(body), AttrVec::new())
}); });
(HirVec::from(parameters), this.expr(body_span, async_expr, AttrVec::new()))
(this.arena.alloc_from_iter(parameters), this.expr(body_span, async_expr, AttrVec::new()))
}) })
} }

View File

@ -459,7 +459,7 @@ impl<'hir> Map<'hir> {
self.forest.krate.impl_item(id) self.forest.krate.impl_item(id)
} }
pub fn body(&self, id: BodyId) -> &'hir Body { pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
self.read(id.hir_id); self.read(id.hir_id);
// N.B., intentionally bypass `self.forest.krate()` so that we // N.B., intentionally bypass `self.forest.krate()` so that we

View File

@ -760,7 +760,7 @@ pub struct Crate<'hir> {
pub trait_items: BTreeMap<TraitItemId, TraitItem<'hir>>, pub trait_items: BTreeMap<TraitItemId, TraitItem<'hir>>,
pub impl_items: BTreeMap<ImplItemId, ImplItem<'hir>>, pub impl_items: BTreeMap<ImplItemId, ImplItem<'hir>>,
pub bodies: BTreeMap<BodyId, Body>, pub bodies: BTreeMap<BodyId, Body<'hir>>,
pub trait_impls: BTreeMap<DefId, Vec<HirId>>, pub trait_impls: BTreeMap<DefId, Vec<HirId>>,
/// A list of the body ids written out in the order in which they /// A list of the body ids written out in the order in which they
@ -787,7 +787,7 @@ impl Crate<'hir> {
&self.impl_items[&id] &self.impl_items[&id]
} }
pub fn body(&self, id: BodyId) -> &Body { pub fn body(&self, id: BodyId) -> &Body<'hir> {
&self.bodies[&id] &self.bodies[&id]
} }
} }
@ -1353,13 +1353,13 @@ pub struct BodyId {
/// All bodies have an **owner**, which can be accessed via the HIR /// All bodies have an **owner**, which can be accessed via the HIR
/// map using `body_owner_def_id()`. /// map using `body_owner_def_id()`.
#[derive(RustcEncodable, RustcDecodable, Debug)] #[derive(RustcEncodable, RustcDecodable, Debug)]
pub struct Body { pub struct Body<'hir> {
pub params: HirVec<Param>, pub params: &'hir [Param],
pub value: Expr, pub value: Expr,
pub generator_kind: Option<GeneratorKind>, pub generator_kind: Option<GeneratorKind>,
} }
impl Body { impl Body<'hir> {
pub fn id(&self) -> BodyId { pub fn id(&self) -> BodyId {
BodyId { BodyId {
hir_id: self.value.hir_id, hir_id: self.value.hir_id,

View File

@ -61,7 +61,7 @@ struct BodyResolver<'tcx>(&'tcx hir::Crate<'tcx>);
impl<'tcx> BodyResolver<'tcx> { impl<'tcx> BodyResolver<'tcx> {
/// Returns a reference to the `hir::Body` with the given `BodyId`. /// Returns a reference to the `hir::Body` with the given `BodyId`.
/// **Does not do any tracking**; use carefully. /// **Does not do any tracking**; use carefully.
fn body(self, id: hir::BodyId) -> &'tcx hir::Body { fn body(self, id: hir::BodyId) -> &'tcx hir::Body<'tcx> {
self.0.body(id) self.0.body(id)
} }
} }

View File

@ -266,7 +266,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item<'_> {
} }
} }
impl<'a> HashStable<StableHashingContext<'a>> for hir::Body { impl<'a> HashStable<StableHashingContext<'a>> for hir::Body<'_> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
let hir::Body { let hir::Body {
params, params,

View File

@ -83,8 +83,8 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
intravisit::walk_local(self, local); intravisit::walk_local(self, local);
} }
fn visit_body(&mut self, body: &'tcx Body) { fn visit_body(&mut self, body: &'tcx Body<'tcx>) {
for param in &body.params { for param in body.params {
if let (None, Some(ty)) = ( if let (None, Some(ty)) = (
self.found_arg_pattern, self.found_arg_pattern,
self.node_matches_type(param.hir_id), self.node_matches_type(param.hir_id),
@ -113,7 +113,7 @@ fn closure_return_type_suggestion(
span: Span, span: Span,
err: &mut DiagnosticBuilder<'_>, err: &mut DiagnosticBuilder<'_>,
output: &FunctionRetTy, output: &FunctionRetTy,
body: &Body, body: &Body<'_>,
descr: &str, descr: &str,
name: &str, name: &str,
ret: &str, ret: &str,

View File

@ -924,7 +924,7 @@ for LateContextAndPass<'a, 'tcx, T> {
}); });
} }
fn visit_body(&mut self, body: &'tcx hir::Body) { fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
lint_callback!(self, check_body, body); lint_callback!(self, check_body, body);
hir_visit::walk_body(self, body); hir_visit::walk_body(self, body);
lint_callback!(self, check_body_post, body); lint_callback!(self, check_body_post, body);

View File

@ -87,8 +87,8 @@ macro_rules! late_lint_methods {
($macro:path, $args:tt, [$hir:tt]) => ( ($macro:path, $args:tt, [$hir:tt]) => (
$macro!($args, [$hir], [ $macro!($args, [$hir], [
fn check_param(a: &$hir hir::Param); fn check_param(a: &$hir hir::Param);
fn check_body(a: &$hir hir::Body); fn check_body(a: &$hir hir::Body<$hir>);
fn check_body_post(a: &$hir hir::Body); fn check_body_post(a: &$hir hir::Body<$hir>);
fn check_name(a: Span, b: ast::Name); fn check_name(a: Span, b: ast::Name);
fn check_crate(a: &$hir hir::Crate<$hir>); fn check_crate(a: &$hir hir::Crate<$hir>);
fn check_crate_post(a: &$hir hir::Crate<$hir>); fn check_crate_post(a: &$hir hir::Crate<$hir>);
@ -114,13 +114,13 @@ macro_rules! late_lint_methods {
fn check_fn( fn check_fn(
a: hir::intravisit::FnKind<$hir>, a: hir::intravisit::FnKind<$hir>,
b: &$hir hir::FnDecl, b: &$hir hir::FnDecl,
c: &$hir hir::Body, c: &$hir hir::Body<$hir>,
d: Span, d: Span,
e: hir::HirId); e: hir::HirId);
fn check_fn_post( fn check_fn_post(
a: hir::intravisit::FnKind<$hir>, a: hir::intravisit::FnKind<$hir>,
b: &$hir hir::FnDecl, b: &$hir hir::FnDecl,
c: &$hir hir::Body, c: &$hir hir::Body<$hir>,
d: Span, d: Span,
e: hir::HirId e: hir::HirId
); );

View File

@ -715,7 +715,7 @@ impl<'tcx> ScopeTree {
pub fn yield_in_scope_for_expr(&self, pub fn yield_in_scope_for_expr(&self,
scope: Scope, scope: Scope,
expr_hir_id: hir::HirId, expr_hir_id: hir::HirId,
body: &'tcx hir::Body) -> Option<Span> { body: &'tcx hir::Body<'tcx>) -> Option<Span> {
self.yield_in_scope(scope).and_then(|YieldData { span, expr_and_pat_count, .. }| { self.yield_in_scope(scope).and_then(|YieldData { span, expr_and_pat_count, .. }| {
let mut visitor = ExprLocatorVisitor { let mut visitor = ExprLocatorVisitor {
hir_id: expr_hir_id, hir_id: expr_hir_id,
@ -1362,7 +1362,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
resolve_block(self, b); resolve_block(self, b);
} }
fn visit_body(&mut self, body: &'tcx hir::Body) { fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
let body_id = body.id(); let body_id = body.id();
let owner_id = self.tcx.hir().body_owner(body_id); let owner_id = self.tcx.hir().body_owner(body_id);
@ -1387,7 +1387,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
// The arguments and `self` are parented to the fn. // The arguments and `self` are parented to the fn.
self.cx.var_parent = self.cx.parent.take(); self.cx.var_parent = self.cx.parent.take();
for param in &body.params { for param in body.params {
self.visit_pat(&param.pat); self.visit_pat(&param.pat);
} }

View File

@ -1167,7 +1167,7 @@ fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: ast::Name, orig: Original, sh
// Adds all labels in `b` to `ctxt.labels_in_fn`, signalling a warning // Adds all labels in `b` to `ctxt.labels_in_fn`, signalling a warning
// if one of the label shadows a lifetime or another label. // if one of the label shadows a lifetime or another label.
fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body<'_>) {
struct GatherLabels<'a, 'tcx> { struct GatherLabels<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
scope: ScopeRef<'a>, scope: ScopeRef<'a>,

View File

@ -298,7 +298,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
cx: &LateContext<'_, '_>, cx: &LateContext<'_, '_>,
fk: FnKind<'_>, fk: FnKind<'_>,
_: &hir::FnDecl, _: &hir::FnDecl,
_: &hir::Body, _: &hir::Body<'_>,
_: Span, _: Span,
id: hir::HirId, id: hir::HirId,
) { ) {

View File

@ -552,7 +552,7 @@ fn construct_fn<'a, 'tcx, A>(
abi: Abi, abi: Abi,
return_ty: Ty<'tcx>, return_ty: Ty<'tcx>,
return_ty_span: Span, return_ty_span: Span,
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
) -> Body<'tcx> ) -> Body<'tcx>
where where
A: Iterator<Item=ArgInfo<'tcx>> A: Iterator<Item=ArgInfo<'tcx>>

View File

@ -76,10 +76,10 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> {
self.check_patterns(false, &loc.pat); self.check_patterns(false, &loc.pat);
} }
fn visit_body(&mut self, body: &'tcx hir::Body) { fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
intravisit::walk_body(self, body); intravisit::walk_body(self, body);
for param in &body.params { for param in body.params {
self.check_irrefutable(&param.pat, "function argument", None); self.check_irrefutable(&param.pat, "function argument", None);
self.check_patterns(false, &param.pat); self.check_patterns(false, &param.pat);
} }

View File

@ -75,7 +75,7 @@ enum ConstKind {
} }
impl ConstKind { impl ConstKind {
fn for_body(body: &hir::Body, hir_map: &Map<'_>) -> Option<Self> { fn for_body(body: &hir::Body<'_>, hir_map: &Map<'_>) -> Option<Self> {
let is_const_fn = |id| hir_map.fn_sig_by_hir_id(id).unwrap().header.is_const(); let is_const_fn = |id| hir_map.fn_sig_by_hir_id(id).unwrap().header.is_const();
let owner = hir_map.body_owner(body.id()); let owner = hir_map.body_owner(body.id());
@ -215,7 +215,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
self.recurse_into(kind, |this| hir::intravisit::walk_anon_const(this, anon)); self.recurse_into(kind, |this| hir::intravisit::walk_anon_const(this, anon));
} }
fn visit_body(&mut self, body: &'tcx hir::Body) { fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
let kind = ConstKind::for_body(body, self.tcx.hir()); let kind = ConstKind::for_body(body, self.tcx.hir());
self.recurse_into(kind, |this| hir::intravisit::walk_body(this, body)); self.recurse_into(kind, |this| hir::intravisit::walk_body(this, body));
} }

View File

@ -371,7 +371,7 @@ fn visit_fn<'tcx>(
let body = ir.tcx.hir().body(body_id); let body = ir.tcx.hir().body(body_id);
for param in &body.params { for param in body.params {
let is_shorthand = match param.pat.kind { let is_shorthand = match param.pat.kind {
rustc::hir::PatKind::Struct(..) => true, rustc::hir::PatKind::Struct(..) => true,
_ => false, _ => false,
@ -1463,8 +1463,8 @@ impl<'tcx> Liveness<'_, 'tcx> {
} }
} }
fn warn_about_unused_args(&self, body: &hir::Body, entry_ln: LiveNode) { fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) {
for p in &body.params { for p in body.params {
self.check_unused_vars_in_pat(&p.pat, Some(entry_ln), |spans, hir_id, ln, var| { self.check_unused_vars_in_pat(&p.pat, Some(entry_ln), |spans, hir_id, ln, var| {
if self.live_on_entry(ln, var).is_none() { if self.live_on_entry(ln, var).is_none() {
self.report_dead_assign(hir_id, spans, var, true); self.report_dead_assign(hir_id, spans, var, true);

View File

@ -63,7 +63,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expr: &hir::Expr, expr: &hir::Expr,
opt_kind: Option<ty::ClosureKind>, opt_kind: Option<ty::ClosureKind>,
decl: &'tcx hir::FnDecl, decl: &'tcx hir::FnDecl,
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
gen: Option<hir::Movability>, gen: Option<hir::Movability>,
expected_sig: Option<ExpectedSig<'tcx>>, expected_sig: Option<ExpectedSig<'tcx>>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
@ -316,7 +316,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
expr_def_id: DefId, expr_def_id: DefId,
decl: &hir::FnDecl, decl: &hir::FnDecl,
body: &hir::Body, body: &hir::Body<'_>,
expected_sig: Option<ExpectedSig<'tcx>>, expected_sig: Option<ExpectedSig<'tcx>>,
) -> ClosureSignatures<'tcx> { ) -> ClosureSignatures<'tcx> {
if let Some(e) = expected_sig { if let Some(e) = expected_sig {
@ -332,7 +332,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
expr_def_id: DefId, expr_def_id: DefId,
decl: &hir::FnDecl, decl: &hir::FnDecl,
body: &hir::Body, body: &hir::Body<'_>,
) -> ClosureSignatures<'tcx> { ) -> ClosureSignatures<'tcx> {
debug!("sig_of_closure_no_expectation()"); debug!("sig_of_closure_no_expectation()");
@ -392,7 +392,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
expr_def_id: DefId, expr_def_id: DefId,
decl: &hir::FnDecl, decl: &hir::FnDecl,
body: &hir::Body, body: &hir::Body<'_>,
expected_sig: ExpectedSig<'tcx>, expected_sig: ExpectedSig<'tcx>,
) -> ClosureSignatures<'tcx> { ) -> ClosureSignatures<'tcx> {
debug!( debug!(
@ -450,7 +450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
expr_def_id: DefId, expr_def_id: DefId,
decl: &hir::FnDecl, decl: &hir::FnDecl,
body: &hir::Body, body: &hir::Body<'_>,
expected_sig: ExpectedSig<'tcx>, expected_sig: ExpectedSig<'tcx>,
) -> ClosureSignatures<'tcx> { ) -> ClosureSignatures<'tcx> {
let expr_map_node = self.tcx.hir().get_if_local(expr_def_id).unwrap(); let expr_map_node = self.tcx.hir().get_if_local(expr_def_id).unwrap();
@ -482,7 +482,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
expr_def_id: DefId, expr_def_id: DefId,
decl: &hir::FnDecl, decl: &hir::FnDecl,
body: &hir::Body, body: &hir::Body<'_>,
expected_sigs: &ClosureSignatures<'tcx>, expected_sigs: &ClosureSignatures<'tcx>,
) -> InferResult<'tcx, ()> { ) -> InferResult<'tcx, ()> {
// Get the signature S that the user gave. // Get the signature S that the user gave.
@ -590,7 +590,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
expr_def_id: DefId, expr_def_id: DefId,
decl: &hir::FnDecl, decl: &hir::FnDecl,
body: &hir::Body, body: &hir::Body<'_>,
) -> ty::PolyFnSig<'tcx> { ) -> ty::PolyFnSig<'tcx> {
let astconv: &dyn AstConv<'_> = self; let astconv: &dyn AstConv<'_> = self;
@ -788,7 +788,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn closure_sigs( fn closure_sigs(
&self, &self,
expr_def_id: DefId, expr_def_id: DefId,
body: &hir::Body, body: &hir::Body<'_>,
bound_sig: ty::PolyFnSig<'tcx>, bound_sig: ty::PolyFnSig<'tcx>,
) -> ClosureSignatures<'tcx> { ) -> ClosureSignatures<'tcx> {
let liberated_sig = self.tcx() let liberated_sig = self.tcx()

View File

@ -1260,7 +1260,7 @@ fn check_fn<'a, 'tcx>(
fn_sig: ty::FnSig<'tcx>, fn_sig: ty::FnSig<'tcx>,
decl: &'tcx hir::FnDecl, decl: &'tcx hir::FnDecl,
fn_id: hir::HirId, fn_id: hir::HirId,
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
can_be_generator: Option<hir::Movability>, can_be_generator: Option<hir::Movability>,
) -> (FnCtxt<'a, 'tcx>, Option<GeneratorTypes<'tcx>>) { ) -> (FnCtxt<'a, 'tcx>, Option<GeneratorTypes<'tcx>>) {
let mut fn_sig = fn_sig.clone(); let mut fn_sig = fn_sig.clone();
@ -1327,7 +1327,7 @@ fn check_fn<'a, 'tcx>(
for (param_ty, param) in for (param_ty, param) in
fn_sig.inputs().iter().copied() fn_sig.inputs().iter().copied()
.chain(maybe_va_list) .chain(maybe_va_list)
.zip(&body.params) .zip(body.params)
{ {
// Check the pattern. // Check the pattern.
fcx.check_pat_top(&param.pat, param_ty, None); fcx.check_pat_top(&param.pat, param_ty, None);

View File

@ -106,7 +106,7 @@ macro_rules! ignore_err {
// PUBLIC ENTRY POINTS // PUBLIC ENTRY POINTS
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn regionck_expr(&self, body: &'tcx hir::Body) { pub fn regionck_expr(&self, body: &'tcx hir::Body<'tcx>) {
let subject = self.tcx.hir().body_owner_def_id(body.id()); let subject = self.tcx.hir().body_owner_def_id(body.id());
let id = body.value.hir_id; let id = body.value.hir_id;
let mut rcx = RegionCtxt::new( let mut rcx = RegionCtxt::new(
@ -159,7 +159,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// rest of type check and because sometimes we need type /// rest of type check and because sometimes we need type
/// inference to have completed before we can determine which /// inference to have completed before we can determine which
/// constraints to add. /// constraints to add.
pub fn regionck_fn(&self, fn_id: hir::HirId, body: &'tcx hir::Body) { pub fn regionck_fn(&self, fn_id: hir::HirId, body: &'tcx hir::Body<'tcx>) {
debug!("regionck_fn(id={})", fn_id); debug!("regionck_fn(id={})", fn_id);
let subject = self.tcx.hir().body_owner_def_id(body.id()); let subject = self.tcx.hir().body_owner_def_id(body.id());
let hir_id = body.value.hir_id; let hir_id = body.value.hir_id;
@ -300,7 +300,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
fn visit_fn_body( fn visit_fn_body(
&mut self, &mut self,
id: hir::HirId, // the id of the fn itself id: hir::HirId, // the id of the fn itself
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
span: Span, span: Span,
) { ) {
// When we enter a function, we can derive // When we enter a function, we can derive

View File

@ -46,7 +46,7 @@ use syntax::ast;
use syntax_pos::Span; use syntax_pos::Span;
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn closure_analyze(&self, body: &'tcx hir::Body) { pub fn closure_analyze(&self, body: &'tcx hir::Body<'tcx>) {
InferBorrowKindVisitor { fcx: self }.visit_body(body); InferBorrowKindVisitor { fcx: self }.visit_body(body);
// it's our job to process these. // it's our job to process these.
@ -81,7 +81,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
closure_hir_id: hir::HirId, closure_hir_id: hir::HirId,
span: Span, span: Span,
body: &hir::Body, body: &hir::Body<'_>,
capture_clause: hir::CaptureBy, capture_clause: hir::CaptureBy,
) { ) {

View File

@ -32,7 +32,7 @@ use std::mem;
// resolve_type_vars_in_body, which creates a new TypeTables which // resolve_type_vars_in_body, which creates a new TypeTables which
// doesn't contain any inference types. // doesn't contain any inference types.
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn resolve_type_vars_in_body(&self, body: &'tcx hir::Body) -> &'tcx ty::TypeckTables<'tcx> { pub fn resolve_type_vars_in_body(&self, body: &'tcx hir::Body<'tcx>) -> &'tcx ty::TypeckTables<'tcx> {
let item_id = self.tcx.hir().body_owner(body.id()); let item_id = self.tcx.hir().body_owner(body.id());
let item_def_id = self.tcx.hir().local_def_id(item_id); let item_def_id = self.tcx.hir().local_def_id(item_id);
@ -41,7 +41,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let rustc_dump_user_substs = self.tcx.has_attr(item_def_id, sym::rustc_dump_user_substs); let rustc_dump_user_substs = self.tcx.has_attr(item_def_id, sym::rustc_dump_user_substs);
let mut wbcx = WritebackCx::new(self, body, rustc_dump_user_substs); let mut wbcx = WritebackCx::new(self, body, rustc_dump_user_substs);
for param in &body.params { for param in body.params {
wbcx.visit_node_id(param.pat.span, param.hir_id); wbcx.visit_node_id(param.pat.span, param.hir_id);
} }
// Type only exists for constants and statics, not functions. // Type only exists for constants and statics, not functions.
@ -102,7 +102,7 @@ struct WritebackCx<'cx, 'tcx> {
tables: ty::TypeckTables<'tcx>, tables: ty::TypeckTables<'tcx>,
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
rustc_dump_user_substs: bool, rustc_dump_user_substs: bool,
} }
@ -110,7 +110,7 @@ struct WritebackCx<'cx, 'tcx> {
impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
fn new( fn new(
fcx: &'cx FnCtxt<'cx, 'tcx>, fcx: &'cx FnCtxt<'cx, 'tcx>,
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
rustc_dump_user_substs: bool, rustc_dump_user_substs: bool,
) -> WritebackCx<'cx, 'tcx> { ) -> WritebackCx<'cx, 'tcx> {
let owner = body.id().hir_id; let owner = body.id().hir_id;
@ -265,7 +265,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
match e.kind { match e.kind {
hir::ExprKind::Closure(_, _, body, _, _) => { hir::ExprKind::Closure(_, _, body, _, _) => {
let body = self.fcx.tcx.hir().body(body); let body = self.fcx.tcx.hir().body(body);
for param in &body.params { for param in body.params {
self.visit_node_id(e.span, param.hir_id); self.visit_node_id(e.span, param.hir_id);
} }
@ -698,14 +698,14 @@ struct Resolver<'cx, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
infcx: &'cx InferCtxt<'cx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
span: &'cx dyn Locatable, span: &'cx dyn Locatable,
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
} }
impl<'cx, 'tcx> Resolver<'cx, 'tcx> { impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
fn new( fn new(
fcx: &'cx FnCtxt<'cx, 'tcx>, fcx: &'cx FnCtxt<'cx, 'tcx>,
span: &'cx dyn Locatable, span: &'cx dyn Locatable,
body: &'tcx hir::Body, body: &'tcx hir::Body<'tcx>,
) -> Resolver<'cx, 'tcx> { ) -> Resolver<'cx, 'tcx> {
Resolver { Resolver {
tcx: fcx.tcx, tcx: fcx.tcx,

View File

@ -131,10 +131,10 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
} }
} }
pub fn consume_body(&mut self, body: &hir::Body) { pub fn consume_body(&mut self, body: &hir::Body<'_>) {
debug!("consume_body(body={:?})", body); debug!("consume_body(body={:?})", body);
for param in &body.params { for param in body.params {
let param_ty = return_if_err!(self.mc.pat_ty_adjusted(&param.pat)); let param_ty = return_if_err!(self.mc.pat_ty_adjusted(&param.pat));
debug!("consume_body: param_ty = {:?}", param_ty); debug!("consume_body: param_ty = {:?}", param_ty);