Navigation Menu

Skip to content

Commit

Permalink
Fix rebase breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
flodiebold committed Nov 29, 2016
1 parent bf298ae commit 8575184
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 27 deletions.
15 changes: 9 additions & 6 deletions src/librustc/middle/cstore.rs
Expand Up @@ -140,7 +140,7 @@ pub struct NativeLibrary {
pub struct InlinedItem {
pub def_id: DefId,
pub body: P<hir::Expr>,
pub const_fn_args: Vec<DefId>,
pub const_fn_args: Vec<Option<DefId>>,
}

/// A borrowed version of `hir::InlinedItem`. This is what's encoded when saving
Expand All @@ -149,11 +149,14 @@ pub struct InlinedItem {
pub struct InlinedItemRef<'a> {
pub def_id: DefId,
pub body: &'a hir::Expr,
pub const_fn_args: Vec<DefId>,
pub const_fn_args: Vec<Option<DefId>>,
}

fn get_fn_args(tcx: TyCtxt, decl: &hir::FnDecl) -> Vec<DefId> {
decl.inputs.iter().map(|arg| tcx.expect_def(arg.pat.id).def_id()).collect()
fn get_fn_args(decl: &hir::FnDecl) -> Vec<Option<DefId>> {
decl.inputs.iter().map(|arg| match arg.pat.node {
hir::PatKind::Binding(_, def_id, _, _) => Some(def_id),
_ => None
}).collect()
}

impl<'a> InlinedItemRef<'a> {
Expand All @@ -163,7 +166,7 @@ impl<'a> InlinedItemRef<'a> {
-> InlinedItemRef<'a> {
let (body, args) = match item.node {
hir::ItemFn(ref decl, _, _, _, _, body_id) =>
(tcx.map.expr(body_id), get_fn_args(tcx, decl)),
(tcx.map.expr(body_id), get_fn_args(decl)),
hir::ItemConst(_, ref body) => (&**body, Vec::new()),
_ => bug!("InlinedItemRef::from_item wrong kind")
};
Expand Down Expand Up @@ -199,7 +202,7 @@ impl<'a> InlinedItemRef<'a> {
-> InlinedItemRef<'a> {
let (body, args) = match item.node {
hir::ImplItemKind::Method(ref sig, body_id) =>
(tcx.map.expr(body_id), get_fn_args(tcx, &sig.decl)),
(tcx.map.expr(body_id), get_fn_args(&sig.decl)),
hir::ImplItemKind::Const(_, ref body) =>
(&**body, Vec::new()),
_ => bug!("InlinedItemRef::from_impl_item wrong kind")
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dead.rs
Expand Up @@ -292,7 +292,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
}

fn visit_path(&mut self, path: &'tcx hir::Path, id: ast::NodeId) {
self.lookup_and_handle_definition(id);
self.handle_definition(id, path.def);
intravisit::walk_path(self, path);
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/librustc/middle/stability.rs
Expand Up @@ -328,8 +328,12 @@ impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
}
}

impl<'a, 'tcx, 'v> Visitor<'v> for MissingStabilityAnnotations<'a, 'tcx> {
fn visit_item(&mut self, i: &Item) {
impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
Some(&self.tcx.map)
}

fn visit_item(&mut self, i: &'tcx Item) {
match i.node {
// Inherent impls and foreign modules serve only as containers for other items,
// they don't have their own stability. They still can be annotated as unstable
Expand All @@ -343,35 +347,35 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MissingStabilityAnnotations<'a, 'tcx> {
intravisit::walk_item(self, i)
}

fn visit_trait_item(&mut self, ti: &hir::TraitItem) {
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
self.check_missing_stability(ti.id, ti.span);
intravisit::walk_trait_item(self, ti);
}

fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
let impl_def_id = self.tcx.map.local_def_id(self.tcx.map.get_parent(ii.id));
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
self.check_missing_stability(ii.id, ii.span);
}
intravisit::walk_impl_item(self, ii);
}

fn visit_variant(&mut self, var: &Variant, g: &Generics, item_id: NodeId) {
fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: NodeId) {
self.check_missing_stability(var.node.data.id(), var.span);
intravisit::walk_variant(self, var, g, item_id);
}

fn visit_struct_field(&mut self, s: &StructField) {
fn visit_struct_field(&mut self, s: &'tcx StructField) {
self.check_missing_stability(s.id, s.span);
intravisit::walk_struct_field(self, s);
}

fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) {
self.check_missing_stability(i.id, i.span);
intravisit::walk_foreign_item(self, i);
}

fn visit_macro_def(&mut self, md: &hir::MacroDef) {
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
if md.imported_from.is_none() {
self.check_missing_stability(md.id, md.span);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/mod.rs
Expand Up @@ -1280,13 +1280,13 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
}
Some(ast_map::NodeExpr(expr)) => {
// This is a convenience to allow closures to work.
if let hir::ExprClosure(.., ref body, _) = expr.node {
if let hir::ExprClosure(.., body, _) = expr.node {
let def_id = tcx.map.local_def_id(id);
let base_def_id = tcx.closure_base_def_id(def_id);
tcx.construct_parameter_environment(
expr.span,
base_def_id,
tcx.region_maps.call_site_extent(id, body.id))
tcx.region_maps.call_site_extent(id, body.node_id()))
} else {
tcx.empty_parameter_environment()
}
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_const_eval/eval.rs
Expand Up @@ -868,15 +868,18 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Some(ConstFnNode::Inlined(ii)) => (ii.const_fn_args.clone(), ii.body.expr_id()),
Some(ConstFnNode::Local(fn_like)) =>
(fn_like.decl().inputs.iter()
.map(|arg| tcx.expect_def(arg.pat.id).def_id()).collect(),
.map(|arg| match arg.pat.node {
hir::PatKind::Binding(_, def_id, _, _) => Some(def_id),
_ => None
}).collect(),
fn_like.body()),
None => signal!(e, NonConstPath),
};
let result = tcx.map.expr(body_id);
assert_eq!(arg_defs.len(), args.len());

let mut call_args = DefIdMap();
for (arg, arg_expr) in arg_defs.iter().zip(args.iter()) {
for (arg, arg_expr) in arg_defs.into_iter().zip(args.iter()) {
let arg_hint = ty_hint.erase_hint();
let arg_val = eval_const_expr_partial(
tcx,
Expand All @@ -885,7 +888,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn_args
)?;
debug!("const call arg: {:?}", arg);
if let PatKind::Binding(_, def_id, _, _) = arg.pat.node {
if let Some(def_id) = arg {
assert!(call_args.insert(def_id, arg_val).is_none());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/loops.rs
Expand Up @@ -61,7 +61,7 @@ pub fn check_crate(sess: &Session, map: &Map) {

impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> {
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
Some(&self.map)
Some(&self.hir_map)
}

fn visit_item(&mut self, i: &'ast hir::Item) {
Expand Down
16 changes: 10 additions & 6 deletions src/librustc_privacy/lib.rs
Expand Up @@ -1067,8 +1067,12 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
}
}

impl<'a, 'tcx, 'v> Visitor<'v> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) {
impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
Some(&self.tcx.map)
}

fn visit_item(&mut self, item: &'tcx hir::Item) {
let tcx = self.tcx;
let min = |vis1: ty::Visibility, vis2| {
if vis1.is_at_least(vis2, &tcx.map) { vis2 } else { vis1 }
Expand Down Expand Up @@ -1171,11 +1175,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivateItemsInPublicInterfacesVisitor<'a, 'tc
}
}

fn visit_impl_item(&mut self, _impl_item: &'v hir::ImplItem) {
fn visit_impl_item(&mut self, _impl_item: &'tcx hir::ImplItem) {
// handled in `visit_item` above
}

fn visit_ty(&mut self, ty: &hir::Ty) {
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
if let hir::TyImplTrait(..) = ty.node {
// Check the traits being exposed, as they're separate,
// e.g. `impl Iterator<Item=T>` has two predicates,
Expand All @@ -1189,9 +1193,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivateItemsInPublicInterfacesVisitor<'a, 'tc
}

// Don't recurse into expressions in array sizes or const initializers
fn visit_expr(&mut self, _: &hir::Expr) {}
fn visit_expr(&mut self, _: &'tcx hir::Expr) {}
// Don't recurse into patterns in function arguments
fn visit_pat(&mut self, _: &hir::Pat) {}
fn visit_pat(&mut self, _: &'tcx hir::Pat) {}
}

pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Expand Down

0 comments on commit 8575184

Please sign in to comment.