rustup to 2017-01-12

This commit is contained in:
Oliver Schneider
2017-01-13 17:04:56 +01:00
parent d93b96949d
commit d944d7df9a
56 changed files with 245 additions and 239 deletions

View File

@@ -159,11 +159,11 @@ pub fn vec_macro<'e>(cx: &LateContext, expr: &'e hir::Expr) -> Option<VecArgs<'e
is_expn_of(cx, fun.span, "vec").is_some(),
], {
let fun_def = resolve_node(cx, path, fun.id);
return if match_def_path(cx, fun_def.def_id(), &paths::VEC_FROM_ELEM) && args.len() == 2 {
return if match_def_path(cx.tcx, fun_def.def_id(), &paths::VEC_FROM_ELEM) && args.len() == 2 {
// `vec![elem; size]` case
Some(VecArgs::Repeat(&args[0], &args[1]))
}
else if match_def_path(cx, fun_def.def_id(), &paths::SLICE_INTO_VEC) && args.len() == 1 {
else if match_def_path(cx.tcx, fun_def.def_id(), &paths::SLICE_INTO_VEC) && args.len() == 1 {
// `vec![a, b, c]` case
if_let_chain!{[
let hir::ExprBox(ref boxed) = args[0].node,

View File

@@ -527,7 +527,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_name(&path.name);
},
}
// self.cx.tcx.tables().qpath_def(p, id).hash(&mut self.s);
// self.cx.tables.qpath_def(p, id).hash(&mut self.s);
}
pub fn hash_path(&mut self, p: &Path) {

View File

@@ -138,7 +138,7 @@ fn has_attr(attrs: &[Attribute]) -> bool {
fn print_decl(cx: &LateContext, decl: &hir::Decl) {
match decl.node {
hir::DeclLocal(ref local) => {
println!("local variable of type {}", cx.tcx.tables().node_id_to_type(local.id));
println!("local variable of type {}", cx.tables.node_id_to_type(local.id));
println!("pattern:");
print_pat(cx, &local.pat, 0);
if let Some(ref e) = local.init {
@@ -152,7 +152,7 @@ fn print_decl(cx: &LateContext, decl: &hir::Decl) {
fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
let ind = " ".repeat(indent);
let ty = cx.tcx.tables().node_id_to_type(expr.id);
let ty = cx.tables.node_id_to_type(expr.id);
println!("{}+", ind);
match expr.node {
hir::ExprBox(ref e) => {

View File

@@ -141,11 +141,11 @@ pub fn in_external_macro<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool {
///
/// # Examples
/// ```rust,ignore
/// match_def_path(cx, id, &["core", "option", "Option"])
/// match_def_path(cx.tcx, id, &["core", "option", "Option"])
/// ```
///
/// See also the `paths` module.
pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
pub fn match_def_path(tcx: ty::TyCtxt, def_id: DefId, path: &[&str]) -> bool {
use syntax::symbol;
struct AbsolutePathBuffer {
@@ -165,7 +165,7 @@ pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
let mut apb = AbsolutePathBuffer { names: vec![] };
cx.tcx.push_item_path(&mut apb, def_id);
tcx.push_item_path(&mut apb, def_id);
apb.names.len() == path.len() && apb.names.iter().zip(path.iter()).all(|(a, &b)| &**a == b)
}
@@ -173,7 +173,7 @@ pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
/// Check if type is struct, enum or union type with given def path.
pub fn match_type(cx: &LateContext, ty: ty::Ty, path: &[&str]) -> bool {
match ty.sty {
ty::TyAdt(adt, _) => match_def_path(cx, adt.did, path),
ty::TyAdt(adt, _) => match_def_path(cx.tcx, adt.did, path),
_ => false,
}
}
@@ -182,14 +182,12 @@ pub fn match_type(cx: &LateContext, ty: ty::Ty, path: &[&str]) -> bool {
pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
let method_call = ty::MethodCall::expr(expr.id);
let trt_id = cx.tcx
.tables
.borrow()
let trt_id = cx.tables
.method_map
.get(&method_call)
.and_then(|callee| cx.tcx.impl_of_method(callee.def_id));
if let Some(trt_id) = trt_id {
match_def_path(cx, trt_id, path)
match_def_path(cx.tcx, trt_id, path)
} else {
false
}
@@ -199,14 +197,12 @@ pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
let method_call = ty::MethodCall::expr(expr.id);
let trt_id = cx.tcx
.tables
.borrow()
let trt_id = cx.tables
.method_map
.get(&method_call)
.and_then(|callee| cx.tcx.trait_of_item(callee.def_id));
if let Some(trt_id) = trt_id {
match_def_path(cx, trt_id, path)
match_def_path(cx.tcx, trt_id, path)
} else {
false
}
@@ -327,7 +323,7 @@ pub fn implements_trait<'a, 'tcx>(
cx.tcx.populate_implementations_for_trait_if_necessary(trait_id);
let ty = cx.tcx.erase_regions(&ty);
cx.tcx.infer_ctxt(None, None, Reveal::All).enter(|infcx| {
cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx| {
let obligation = cx.tcx.predicate_for_trait_def(traits::ObligationCause::dummy(), trait_id, 0, ty, &ty_params);
traits::SelectionContext::new(&infcx).evaluate_obligation_conservatively(&obligation)
@@ -336,7 +332,7 @@ pub fn implements_trait<'a, 'tcx>(
/// Resolve the definition of a node from its `NodeId`.
pub fn resolve_node(cx: &LateContext, qpath: &QPath, id: NodeId) -> def::Def {
cx.tcx.tables().qpath_def(qpath, id)
cx.tables.qpath_def(qpath, id)
}
/// Match an `Expr` against a chain of methods, and return the matched `Expr`s.
@@ -622,7 +618,7 @@ pub fn is_integer_literal(expr: &Expr, value: u128) -> bool {
}
pub fn is_adjusted(cx: &LateContext, e: &Expr) -> bool {
cx.tcx.tables.borrow().adjustments.get(&e.id).is_some()
cx.tables.adjustments.get(&e.id).is_some()
}
pub struct LimitStack {
@@ -787,7 +783,7 @@ pub fn same_tys<'a, 'tcx>(
parameter_item: NodeId
) -> bool {
let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, parameter_item);
cx.tcx.infer_ctxt(None, Some(parameter_env), Reveal::All).enter(|infcx| {
cx.tcx.infer_ctxt(parameter_env, Reveal::All).enter(|infcx| {
let new_a = a.subst(infcx.tcx, infcx.parameter_environment.free_substs);
let new_b = b.subst(infcx.tcx, infcx.parameter_environment.free_substs);
infcx.can_equate(&new_a, &new_b).is_ok()
@@ -811,7 +807,7 @@ pub fn is_copy<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, env: Node
/// Return whether a pattern is refutable.
pub fn is_refutable(cx: &LateContext, pat: &Pat) -> bool {
fn is_enum_variant(cx: &LateContext, qpath: &QPath, did: NodeId) -> bool {
matches!(cx.tcx.tables().qpath_def(qpath, did),
matches!(cx.tables.qpath_def(qpath, did),
def::Def::Variant(..) | def::Def::VariantCtor(..))
}