Rustup to rustc 1.16.0-nightly (468227129 2017-01-03): Fix various type errors for rustup

This commit is contained in:
Manish Goregaokar 2017-01-03 09:19:17 -08:00
parent e0ab332303
commit f552f170db
9 changed files with 27 additions and 24 deletions

View file

@ -172,8 +172,8 @@ fn is_relevant_impl(cx: &LateContext, item: &ImplItem) -> bool {
fn is_relevant_trait(cx: &LateContext, item: &TraitItem) -> bool { fn is_relevant_trait(cx: &LateContext, item: &TraitItem) -> bool {
match item.node { match item.node {
MethodTraitItem(_, None) => true, TraitItemKind::Method(_, None) => true,
MethodTraitItem(_, Some(eid)) => is_relevant_expr(cx, cx.tcx.map.expr(eid)), TraitItemKind::Method(_, Some(eid)) => is_relevant_expr(cx, cx.tcx.map.expr(eid)),
_ => false, _ => false,
} }
} }

View file

@ -106,7 +106,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CyclomaticComplexity {
} }
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if let MethodTraitItem(_, Some(eid)) = item.node { if let TraitItemKind::Method(_, Some(eid)) = item.node {
self.check(cx, cx.tcx.map.expr(eid), item.span); self.check(cx, cx.tcx.map.expr(eid), item.span);
} }
} }

View file

@ -106,7 +106,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
} }
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
if let hir::MethodTraitItem(ref sig, eid) = item.node { if let hir::TraitItemKind::Method(ref sig, eid) = item.node {
// don't lint extern functions decls, it's not their fault // don't lint extern functions decls, it's not their fault
if sig.abi == Abi::Rust { if sig.abi == Abi::Rust {
self.check_arg_number(cx, &sig.decl, item.span); self.check_arg_number(cx, &sig.decl, item.span);

View file

@ -90,7 +90,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItem]) { fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItem]) {
fn is_named_self(item: &TraitItem, name: &str) -> bool { fn is_named_self(item: &TraitItem, name: &str) -> bool {
&*item.name.as_str() == name && &*item.name.as_str() == name &&
if let MethodTraitItem(ref sig, _) = item.node { if let TraitItemKind::Method(ref sig, _) = item.node {
if sig.decl.has_self() { if sig.decl.has_self() {
sig.decl.inputs.len() == 1 sig.decl.inputs.len() == 1
} else { } else {

View file

@ -70,7 +70,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
} }
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if let MethodTraitItem(ref sig, _) = item.node { if let TraitItemKind::Method(ref sig, _) = item.node {
check_fn_inner(cx, &sig.decl, &sig.generics, item.span); check_fn_inner(cx, &sig.decl, &sig.generics, item.span);
} }
} }

View file

@ -1,7 +1,6 @@
use rustc::hir; use rustc::hir;
use rustc::lint::*; use rustc::lint::*;
use rustc::middle::const_val::ConstVal; use rustc::middle::const_val::ConstVal;
use rustc::middle::const_qualif::ConstQualif;
use rustc::ty; use rustc::ty;
use rustc::hir::def::Def; use rustc::hir::def::Def;
use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::EvalHint::ExprTypeChecked;
@ -638,7 +637,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let item = cx.tcx.map.expect_item(parent); let item = cx.tcx.map.expect_item(parent);
if_let_chain! {[ if_let_chain! {[
let hir::ImplItemKind::Method(ref sig, _) = implitem.node, let hir::ImplItemKind::Method(ref sig, _) = implitem.node,
let Some(explicit_self) = sig.decl.inputs.get(0).and_then(hir::Arg::to_self), let Some(first_arg) = sig.decl.inputs.get(0),
let hir::ItemImpl(_, _, _, None, _, _) = item.node, let hir::ItemImpl(_, _, _, None, _, _) = item.node,
], { ], {
// check missing trait implementations // check missing trait implementations
@ -646,7 +645,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
if &*name.as_str() == method_name && if &*name.as_str() == method_name &&
sig.decl.inputs.len() == n_args && sig.decl.inputs.len() == n_args &&
out_type.matches(&sig.decl.output) && out_type.matches(&sig.decl.output) &&
self_kind.matches(&explicit_self, false) { self_kind.matches(&first_arg, false) {
span_lint(cx, SHOULD_IMPLEMENT_TRAIT, implitem.span, &format!( span_lint(cx, SHOULD_IMPLEMENT_TRAIT, implitem.span, &format!(
"defining a method called `{}` on this type; consider implementing \ "defining a method called `{}` on this type; consider implementing \
the `{}` trait or choosing a less ambiguous name", name, trait_name)); the `{}` trait or choosing a less ambiguous name", name, trait_name));
@ -752,11 +751,12 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir:
) { ) {
// don't lint for constant values // don't lint for constant values
// FIXME: can we `expect` here instead of match? // FIXME: can we `expect` here instead of match?
if let Some(qualif) = cx.tcx.const_qualif_map.borrow().get(&arg.id) { let promotable = cx.tcx().rvalue_promotable_to_static.borrow()
if !qualif.contains(ConstQualif::NOT_CONST) { .get(&arg.id).cloned().unwrap_or(true);
if !promotable {
return; return;
} }
}
// (path, fn_has_argument, methods, suffix) // (path, fn_has_argument, methods, suffix)
let know_types: &[(&[_], _, &[_], _)] = let know_types: &[(&[_], _, &[_], _)] =
&[(&paths::BTREEMAP_ENTRY, false, &["or_insert"], "with"), &[(&paths::BTREEMAP_ENTRY, false, &["or_insert"], "with"),
@ -1347,7 +1347,10 @@ enum SelfKind {
} }
impl SelfKind { impl SelfKind {
fn matches(self, slf: &hir::ExplicitSelf, allow_value_for_ref: bool) -> bool { fn matches(self, slf: &hir::Arg, allow_value_for_ref: bool) -> bool {
if !slf.has_self() {
return self == No;
}
match (self, &slf.node) { match (self, &slf.node) {
(SelfKind::Value, &hir::SelfKind::Value(_)) | (SelfKind::Value, &hir::SelfKind::Value(_)) |
(SelfKind::Ref, &hir::SelfKind::Region(_, hir::Mutability::MutImmutable)) | (SelfKind::Ref, &hir::SelfKind::Region(_, hir::Mutability::MutImmutable)) |

View file

@ -136,9 +136,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem) {
let desc = match trait_item.node { let desc = match trait_item.node {
hir::ConstTraitItem(..) => "an associated constant", hir::TraitItemKind::Const(..) => "an associated constant",
hir::MethodTraitItem(..) => "a trait method", hir::TraitItemKind::Method(..) => "a trait method",
hir::TypeTraitItem(..) => "an associated type", hir::TraitItemKind::Type(..) => "an associated type",
}; };
self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, desc); self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, desc);

View file

@ -73,7 +73,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
} }
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if let MethodTraitItem(ref sig, _) = item.node { if let TraitItemKind::Method(ref sig, _) = item.node {
check_fn(cx, &sig.decl, item.id); check_fn(cx, &sig.decl, item.id);
} }
} }

View file

@ -87,9 +87,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass {
fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) { fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) {
match item.node { match item.node {
ConstTraitItem(ref ty, _) | TraitItemKind::Const(ref ty, _) |
TypeTraitItem(_, Some(ref ty)) => check_ty(cx, ty), TraitItemKind::Type(_, Some(ref ty)) => check_ty(cx, ty),
MethodTraitItem(ref sig, _) => check_fn_decl(cx, &sig.decl), TraitItemKind::Method(ref sig, _) => check_fn_decl(cx, &sig.decl),
_ => (), _ => (),
} }
} }
@ -624,9 +624,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexityPass {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
match item.node { match item.node {
ConstTraitItem(ref ty, _) | TraitItemKind::Const(ref ty, _) |
TypeTraitItem(_, Some(ref ty)) => self.check_type(cx, ty), TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty),
MethodTraitItem(MethodSig { ref decl, .. }, None) => self.check_fndecl(cx, decl), TraitItemKind::Method(MethodSig { ref decl, .. }, None) => self.check_fndecl(cx, decl),
// methods with default impl are covered by check_fn // methods with default impl are covered by check_fn
_ => (), _ => (),
} }