Rustup to rustc 1.16.0-nightly (468227129 2017-01-03): Body fixes for rustup

This commit is contained in:
Josh Holmer
2017-01-03 23:40:42 -05:00
committed by Manish Goregaokar
parent f552f170db
commit 64f5dbc9f8
26 changed files with 117 additions and 103 deletions

View File

@@ -112,7 +112,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
!self.ignore_fn && l_name.node == r_name.node && over(l_tys, r_tys, |l, r| self.eq_ty(l, r)) &&
self.eq_exprs(l_args, r_args)
},
(&ExprRepeat(ref le, ref ll), &ExprRepeat(ref re, ref rl)) => self.eq_expr(le, re) && self.eq_expr(ll, rl),
(&ExprRepeat(ref le, llId), &ExprRepeat(ref re, rlId)) => self.eq_expr(le, re) && self.eq_expr(&self.cx.tcx.map.body(llId).value, &self.cx.tcx.map.body(rlId).value),
(&ExprRet(ref l), &ExprRet(ref r)) => both(l, r, |l, r| self.eq_expr(l, r)),
(&ExprPath(ref l), &ExprPath(ref r)) => self.eq_qpath(l, r),
(&ExprStruct(ref l_path, ref lf, ref lo), &ExprStruct(ref r_path, ref rf, ref ro)) => {
@@ -183,7 +183,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
}
fn eq_path(&self, left: &Path, right: &Path) -> bool {
left.global == right.global && over(&left.segments, &right.segments, |l, r| self.eq_path_segment(l, r))
left.is_global() == right.is_global() && over(&left.segments, &right.segments, |l, r| self.eq_path_segment(l, r))
}
fn eq_path_parameters(&self, left: &PathParameters, right: &PathParameters) -> bool {
@@ -211,7 +211,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
fn eq_ty(&self, left: &Ty, right: &Ty) -> bool {
match (&left.node, &right.node) {
(&TySlice(ref l_vec), &TySlice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
(&TyArray(ref lt, ref ll), &TyArray(ref rt, ref rl)) => self.eq_ty(lt, rt) && self.eq_expr(ll, rl),
(&TyArray(ref lt, llId), &TyArray(ref rt, rlId)) => self.eq_ty(lt, rt) && self.eq_expr(&self.cx.tcx.map.body(llId).value, &self.cx.tcx.map.body(rlId).value),
(&TyPtr(ref l_mut), &TyPtr(ref r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(&*l_mut.ty, &*r_mut.ty),
(&TyRptr(_, ref l_rmut), &TyRptr(_, ref r_rmut)) => {
l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(&*l_rmut.ty, &*r_rmut.ty)
@@ -363,7 +363,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
let c: fn(_, _, _, _) -> _ = ExprClosure;
c.hash(&mut self.s);
cap.hash(&mut self.s);
self.hash_expr(self.cx.tcx.map.expr(eid));
self.hash_expr(&self.cx.tcx.map.body(eid).value);
},
ExprField(ref e, ref f) => {
let c: fn(_, _) -> _ = ExprField;
@@ -424,11 +424,11 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_name(&name.node);
self.hash_exprs(args);
},
ExprRepeat(ref e, ref l) => {
ExprRepeat(ref e, lId) => {
let c: fn(_, _) -> _ = ExprRepeat;
c.hash(&mut self.s);
self.hash_expr(e);
self.hash_expr(l);
self.hash_expr(&self.cx.tcx.map.body(lId).value);
},
ExprRet(ref e) => {
let c: fn(_) -> _ = ExprRet;
@@ -524,7 +524,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
}
pub fn hash_path(&mut self, p: &Path) {
p.global.hash(&mut self.s);
p.is_global().hash(&mut self.s);
for p in &p.segments {
self.hash_name(&p.name);
}

View File

@@ -4,6 +4,7 @@
use rustc::lint::*;
use rustc::hir;
use rustc::hir::print;
use syntax::ast::Attribute;
use syntax::attr;
@@ -52,16 +53,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
match item.vis {
hir::Visibility::Public => println!("public"),
hir::Visibility::Crate => println!("visible crate wide"),
hir::Visibility::Restricted { ref path, .. } => println!("visible in module `{}`", path),
hir::Visibility::Restricted { ref path, .. } => println!("visible in module `{}`", print::to_string(print::NO_ANN, |s| s.print_path(path, false))),
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
}
if item.defaultness.is_default() {
println!("default");
}
match item.node {
hir::ImplItemKind::Const(_, ref e) => {
hir::ImplItemKind::Const(_, bodyId) => {
println!("associated constant");
print_expr(cx, e, 1);
print_expr(cx, &cx.tcx.map.body(bodyId).value, 1);
},
hir::ImplItemKind::Method(..) => println!("method"),
hir::ImplItemKind::Type(_) => println!("associated type"),
@@ -323,12 +324,12 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
print_expr(cx, base, indent + 1);
}
},
hir::ExprRepeat(ref val, ref n) => {
hir::ExprRepeat(ref val, bodyId) => {
println!("{}Repeat, {}", ind, ty);
println!("{}value:", ind);
print_expr(cx, val, indent + 1);
println!("{}repeat count:", ind);
print_expr(cx, n, indent + 1);
print_expr(cx, &cx.tcx.map.body(bodyId).value, indent + 1);
},
}
}
@@ -339,7 +340,7 @@ fn print_item(cx: &LateContext, item: &hir::Item) {
match item.vis {
hir::Visibility::Public => println!("public"),
hir::Visibility::Crate => println!("visible crate wide"),
hir::Visibility::Restricted { ref path, .. } => println!("visible in module `{}`", path),
hir::Visibility::Restricted { ref path, .. } => println!("visible in module `{}`", print::to_string(print::NO_ANN, |s| s.print_path(path, false))),
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
}
match item.node {
@@ -413,7 +414,7 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
},
hir::PatKind::Struct(ref path, ref fields, ignore) => {
println!("{}Struct", ind);
println!("{}name: {}", ind, path);
println!("{}name: {}", ind, print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
println!("{}ignore leftover fields: {}", ind, ignore);
println!("{}fields:", ind);
for field in fields {
@@ -426,7 +427,7 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
},
hir::PatKind::TupleStruct(ref path, ref fields, opt_dots_position) => {
println!("{}TupleStruct", ind);
println!("{}path: {}", ind, path);
println!("{}path: {}", ind, print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
if let Some(dot_position) = opt_dots_position {
println!("{}dot position: {}", ind, dot_position);
}

View File

@@ -106,7 +106,7 @@ impl LintPass for LintWithoutLintPass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemStatic(ref ty, MutImmutable, ref expr) = item.node {
if let ItemStatic(ref ty, MutImmutable, bodyId) = item.node {
if is_lint_ref_type(ty) {
self.declared_lints.insert(item.name, item.span);
} else if is_lint_array_type(ty) && item.vis == Visibility::Inherited && item.name == "ARRAY" {
@@ -114,7 +114,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
output: &mut self.registered_lints,
cx: cx,
};
collector.visit_expr(expr);
collector.visit_expr(&cx.tcx.map.body(bodyId).value);
}
}
}

View File

@@ -19,6 +19,7 @@ use syntax::attr;
use syntax::codemap::{ExpnFormat, ExpnInfo, MultiSpan, Span, DUMMY_SP};
use syntax::errors::DiagnosticBuilder;
use syntax::ptr::P;
use syntax::symbol::keywords;
pub mod cargo;
pub mod comparisons;
@@ -487,7 +488,7 @@ pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: NodeI
match node {
Node::NodeBlock(block) => Some(block),
Node::NodeItem(&Item { node: ItemFn(_, _, _, _, _, eid), .. }) => {
match cx.tcx.map.expr(eid).node {
match cx.tcx.map.body(eid).value.node {
ExprBlock(ref block) => Some(block),
_ => None,
}
@@ -896,3 +897,15 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => None,
}
}
pub fn is_self(slf: &Arg) -> bool {
if let PatKind::Binding(_, _, name, _) = slf.pat.node {
name.node == keywords::SelfValue.name()
} else {
false
}
}
pub fn has_self(slf: &FnDecl) -> bool {
slf.inputs.get(0).map(|arg| is_self(&arg)).unwrap_or(false)
}