Skip to content

Commit

Permalink
Auto merge of #4061 - rust-lang:rustup, r=phansch
Browse files Browse the repository at this point in the history
Rustup to rustc 1.36.0-nightly (13fde05 2019-05-03)

Trying to deal with changes from #60462

Moved from rust-lang/rust-clippy#4060 so everyone can collab on the rustup branch.
  • Loading branch information
bors committed May 4, 2019
2 parents 19316b4 + d618637 commit fc96aa0
Show file tree
Hide file tree
Showing 39 changed files with 121 additions and 117 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
let parent_fn = cx.tcx.hir().get_parent_item(e.hir_id);
if_chain! {
if let Some(trait_ref) = trait_ref_of_method(cx, parent_fn);
if trait_ref.path.def.def_id() == trait_id;
if trait_ref.path.res.def_id() == trait_id;
then { return; }
}
implements_trait($cx, $ty, trait_id, &[$rty])
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ fn is_relevant_expr(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, exp
ExprKind::Ret(None) | ExprKind::Break(_, None) => false,
ExprKind::Call(path_expr, _) => {
if let ExprKind::Path(qpath) = &path_expr.node {
if let Some(fun_id) = tables.qpath_def(qpath, path_expr.hir_id).opt_def_id() {
if let Some(fun_id) = tables.qpath_res(qpath, path_expr.hir_id).opt_def_id() {
!cx.match_def_path(fun_id, &paths::BEGIN_PANIC)
} else {
true
Expand Down
18 changes: 9 additions & 9 deletions clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::utils::{clip, sext, unsext};
use if_chain::if_chain;
use rustc::hir::def::Def;
use rustc::hir::def::{DefKind, Res};
use rustc::hir::*;
use rustc::lint::LateContext;
use rustc::ty::subst::{Subst, SubstsRef};
Expand Down Expand Up @@ -247,8 +247,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
if_chain! {
if args.is_empty();
if let ExprKind::Path(qpath) = &callee.node;
let def = self.tables.qpath_def(qpath, callee.hir_id);
if let Some(def_id) = def.opt_def_id();
let res = self.tables.qpath_res(qpath, callee.hir_id);
if let Some(def_id) = res.opt_def_id();
let def_path = self.lcx.get_def_path(def_id)
.iter()
.map(LocalInternedString::get)
Expand Down Expand Up @@ -322,9 +322,9 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
fn fetch_path(&mut self, qpath: &QPath, id: HirId) -> Option<Constant> {
use rustc::mir::interpret::GlobalId;

let def = self.tables.qpath_def(qpath, id);
match def {
Def::Const(def_id) | Def::AssociatedConst(def_id) => {
let res = self.tables.qpath_res(qpath, id);
match res {
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssociatedConst, def_id) => {
let substs = self.tables.node_substs(id);
let substs = if self.substs.is_empty() {
substs
Expand All @@ -338,11 +338,11 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
};

let result = self.lcx.tcx.const_eval(self.param_env.and(gid)).ok()?;
let ret = miri_to_const(self.lcx.tcx, &result);
if ret.is_some() {
let result = miri_to_const(self.lcx.tcx, &result);
if result.is_some() {
self.needed_resolution = true;
}
ret
result
},
// FIXME: cover all usable cases.
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/default_trait_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
if let ExprKind::Call(ref path, ..) = expr.node;
if !any_parent_is_automatically_derived(cx.tcx, expr.hir_id);
if let ExprKind::Path(ref qpath) = path.node;
if let Some(def_id) = cx.tables.qpath_def(qpath, path.hir_id).opt_def_id();
if let Some(def_id) = cx.tables.qpath_res(qpath, path.hir_id).opt_def_id();
if cx.match_def_path(def_id, &paths::DEFAULT_TRAIT_METHOD);
then {
match qpath {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/drop_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropBounds {
fn lint_bound<'a, 'tcx>(cx: &rustc::lint::LateContext<'a, 'tcx>, bound: &'tcx GenericBound) {
if_chain! {
if let GenericBound::Trait(t, _) = bound;
if let Some(def_id) = t.trait_ref.path.def.opt_def_id();
if let Some(def_id) = t.trait_ref.path.res.opt_def_id();
if cx.match_def_path(def_id, &paths::DROP_TRAIT);
then {
span_lint(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/drop_forget_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef {
if let ExprKind::Call(ref path, ref args) = expr.node;
if let ExprKind::Path(ref qpath) = path.node;
if args.len() == 1;
if let Some(def_id) = cx.tables.qpath_def(qpath, path.hir_id).opt_def_id();
if let Some(def_id) = cx.tables.qpath_res(qpath, path.hir_id).opt_def_id();
then {
let lint;
let msg;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/enum_glob_use.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! lint on `use`ing all variants of an enum

use crate::utils::span_lint;
use rustc::hir::def::Def;
use rustc::hir::def::{DefKind, Res};
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -43,7 +43,7 @@ impl EnumGlobUse {
return; // re-exports are fine
}
if let ItemKind::Use(ref path, UseKind::Glob) = item.node {
if let Def::Enum(_) = path.def {
if let Res::Def(DefKind::Enum, _) = path.res {
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
if let ExprKind::Path(ref qpath) = lhs.node {
if let QPath::Resolved(_, ref path) = *qpath {
if path.segments.len() == 1 {
if let def::Def::Local(var) = cx.tables.qpath_def(qpath, lhs.hir_id) {
if let def::Res::Local(var) = cx.tables.qpath_res(qpath, lhs.hir_id) {
let mut visitor = ReadVisitor {
cx,
var,
Expand Down Expand Up @@ -295,7 +295,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
if_chain! {
if let QPath::Resolved(None, ref path) = *qpath;
if path.segments.len() == 1;
if let def::Def::Local(local_id) = self.cx.tables.qpath_def(qpath, expr.hir_id);
if let def::Res::Local(local_id) = self.cx.tables.qpath_res(qpath, expr.hir_id);
if local_id == self.var;
// Check that this is a read, not a write.
if !is_in_assignment_position(self.cx, expr);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
if_chain! {
if let ExprKind::Call(ref func_expr, _) = expr.node;
if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.node;
if let Some(path_def_id) = path.def.opt_def_id();
if let Some(path_def_id) = path.res.opt_def_id();
if self.lcx.match_def_path(path_def_id, &BEGIN_PANIC) ||
self.lcx.match_def_path(path_def_id, &BEGIN_PANIC_FMT);
if is_expn_of(expr.span, "unreachable").is_none();
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::convert::TryFrom;
use crate::utils::{iter_input_pats, snippet, snippet_opt, span_lint, type_is_unsafe_function};
use matches::matches;
use rustc::hir;
use rustc::hir::def::Def;
use rustc::hir::def::Res;
use rustc::hir::intravisit;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty;
Expand Down Expand Up @@ -333,7 +333,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> {
fn check_arg(&self, ptr: &hir::Expr) {
if let hir::ExprKind::Path(ref qpath) = ptr.node {
if let Def::Local(id) = self.cx.tables.qpath_def(qpath, ptr.hir_id) {
if let Res::Local(id) = self.cx.tables.qpath_res(qpath, ptr.hir_id) {
if self.ptrs.contains(&id) {
span_lint(
self.cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/invalid_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidRef {
if let ExprKind::Path(ref qpath) = path.node;
if args.len() == 0;
if let ty::Ref(..) = cx.tables.expr_ty(expr).sty;
if let Some(def_id) = cx.tables.qpath_def(qpath, path.hir_id).opt_def_id();
if let Some(def_id) = cx.tables.qpath_res(qpath, path.hir_id).opt_def_id();
then {
let msg = if cx.match_def_path(def_id, &paths::MEM_ZEROED) |
cx.match_def_path(def_id, &paths::INIT)
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::utils::{snippet, span_lint_and_then};
use if_chain::if_chain;
use rustc::hir;
use rustc::hir::def::Def;
use rustc::hir::def::Res;
use rustc::hir::BindingAnnotation;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -145,7 +145,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
if_chain! {
if let hir::ExprKind::Path(ref qpath) = expr.node;
if let Def::Local(local_id) = self.cx.tables.qpath_def(qpath, expr.hir_id);
if let Res::Local(local_id) = self.cx.tables.qpath_res(qpath, expr.hir_id);
if self.id == local_id;
then {
self.used = true;
Expand All @@ -170,7 +170,7 @@ fn check_assign<'a, 'tcx>(
if let hir::StmtKind::Semi(ref expr) = expr.node;
if let hir::ExprKind::Assign(ref var, ref value) = expr.node;
if let hir::ExprKind::Path(ref qpath) = var.node;
if let Def::Local(local_id) = cx.tables.qpath_def(qpath, var.hir_id);
if let Res::Local(local_id) = cx.tables.qpath_res(qpath, var.hir_id);
if decl == local_id;
then {
let mut v = UsedVisitor {
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use matches::matches;
use rustc::hir::def::Def;
use rustc::hir::def::{DefKind, Res};
use rustc::hir::intravisit::*;
use rustc::hir::*;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
Expand Down Expand Up @@ -310,14 +310,14 @@ impl<'v, 't> RefVisitor<'v, 't> {
})
{
let hir_id = ty.hir_id;
match self.cx.tables.qpath_def(qpath, hir_id) {
Def::TyAlias(def_id) | Def::Struct(def_id) => {
match self.cx.tables.qpath_res(qpath, hir_id) {
Res::Def(DefKind::TyAlias, def_id) | Res::Def(DefKind::Struct, def_id) => {
let generics = self.cx.tcx.generics_of(def_id);
for _ in generics.params.as_slice() {
self.record(&None);
}
},
Def::Trait(def_id) => {
Res::Def(DefKind::Trait, def_id) => {
let trait_def = self.cx.tcx.trait_def(def_id);
for _ in &self.cx.tcx.generics_of(trait_def.def_id).params {
self.record(&None);
Expand Down
34 changes: 17 additions & 17 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::reexport::*;
use if_chain::if_chain;
use itertools::Itertools;
use rustc::hir::def::Def;
use rustc::hir::def::{DefKind, Res};
use rustc::hir::def_id;
use rustc::hir::intravisit::{walk_block, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor};
use rustc::hir::*;
Expand Down Expand Up @@ -778,7 +778,7 @@ fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> bo
if let ExprKind::Path(ref qpath) = expr.node;
if let QPath::Resolved(None, ref path) = *qpath;
if path.segments.len() == 1;
if let Def::Local(local_id) = cx.tables.qpath_def(qpath, expr.hir_id);
if let Res::Local(local_id) = cx.tables.qpath_res(qpath, expr.hir_id);
// our variable!
if local_id == var;
then {
Expand Down Expand Up @@ -1637,8 +1637,8 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<HirId>
if let ExprKind::Path(ref qpath) = bound.node;
if let QPath::Resolved(None, _) = *qpath;
then {
let def = cx.tables.qpath_def(qpath, bound.hir_id);
if let Def::Local(node_id) = def {
let res = cx.tables.qpath_res(qpath, bound.hir_id);
if let Res::Local(node_id) = res {
let node_str = cx.tcx.hir().get_by_hir_id(node_id);
if_chain! {
if let Node::Binding(pat) = node_str;
Expand Down Expand Up @@ -1772,9 +1772,9 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
if self.prefer_mutable {
self.indexed_mut.insert(seqvar.segments[0].ident.name);
}
let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id);
match def {
Def::Local(hir_id) | Def::Upvar(hir_id, ..) => {
let res = self.cx.tables.qpath_res(seqpath, seqexpr.hir_id);
match res {
Res::Local(hir_id) | Res::Upvar(hir_id, ..) => {
let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
let parent_def_id = self.cx.tcx.hir().local_def_id_from_hir_id(parent_id);
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
Expand All @@ -1789,7 +1789,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
}
return false; // no need to walk further *on the variable*
}
Def::Static(..) | Def::Const(..) => {
Res::Def(DefKind::Static, ..) | Res::Def(DefKind::Const, ..) => {
if indexed_indirectly {
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, None);
}
Expand Down Expand Up @@ -1834,14 +1834,14 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
if let QPath::Resolved(None, ref path) = *qpath;
if path.segments.len() == 1;
then {
match self.cx.tables.qpath_def(qpath, expr.hir_id) {
Def::Upvar(local_id, ..) => {
match self.cx.tables.qpath_res(qpath, expr.hir_id) {
Res::Upvar(local_id, ..) => {
if local_id == self.var {
// we are not indexing anything, record that
self.nonindex = true;
}
}
Def::Local(local_id) =>
Res::Local(local_id) =>
{

if local_id == self.var {
Expand Down Expand Up @@ -2187,8 +2187,8 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {

fn var_def_id(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<HirId> {
if let ExprKind::Path(ref qpath) = expr.node {
let path_res = cx.tables.qpath_def(qpath, expr.hir_id);
if let Def::Local(node_id) = path_res {
let path_res = cx.tables.qpath_res(qpath, expr.hir_id);
if let Res::Local(node_id) = path_res {
return Some(node_id);
}
}
Expand Down Expand Up @@ -2380,13 +2380,13 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> {
if_chain! {
if let ExprKind::Path(ref qpath) = ex.node;
if let QPath::Resolved(None, _) = *qpath;
let def = self.cx.tables.qpath_def(qpath, ex.hir_id);
let res = self.cx.tables.qpath_res(qpath, ex.hir_id);
then {
match def {
Def::Local(node_id) | Def::Upvar(node_id, ..) => {
match res {
Res::Local(node_id) | Res::Upvar(node_id, ..) => {
self.ids.insert(node_id);
},
Def::Static(def_id) => {
Res::Def(DefKind::Static, def_id) => {
let mutable = self.cx.tcx.is_mutable_static(def_id);
self.def_ids.insert(def_id, mutable);
},
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ fn check_wild_enum_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) {
for pat in &arm.pats {
if let PatKind::Path(ref path) = pat.deref().node {
if let QPath::Resolved(_, p) = path {
missing_variants.retain(|e| e.ctor_def_id != Some(p.def.def_id()));
missing_variants.retain(|e| e.ctor_def_id != Some(p.res.def_id()));
}
} else if let PatKind::TupleStruct(ref path, ..) = pat.deref().node {
if let QPath::Resolved(_, p) = path {
missing_variants.retain(|e| e.ctor_def_id != Some(p.def.def_id()));
missing_variants.retain(|e| e.ctor_def_id != Some(p.res.def_id()));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mem_discriminant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemDiscriminant {
if let ExprKind::Call(ref func, ref func_args) = expr.node;
// is `mem::discriminant`
if let ExprKind::Path(ref func_qpath) = func.node;
if let Some(def_id) = cx.tables.qpath_def(func_qpath, func.hir_id).opt_def_id();
if let Some(def_id) = cx.tables.qpath_res(func_qpath, func.hir_id).opt_def_id();
if cx.match_def_path(def_id, &paths::MEM_DISCRIMINANT);
// type is non-enum
let ty_param = cx.tables.node_substs(func.hir_id).type_at(0);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mem_forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
if let ExprKind::Call(ref path_expr, ref args) = e.node {
if let ExprKind::Path(ref qpath) = path_expr.node {
if let Some(def_id) = cx.tables.qpath_def(qpath, path_expr.hir_id).opt_def_id() {
if let Some(def_id) = cx.tables.qpath_res(qpath, path_expr.hir_id).opt_def_id() {
if cx.match_def_path(def_id, &paths::MEM_FORGET) {
let forgot_ty = cx.tables.expr_ty(&args[0]);

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mem_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemReplace {
if let ExprKind::Call(ref func, ref func_args) = expr.node;
if func_args.len() == 2;
if let ExprKind::Path(ref func_qpath) = func.node;
if let Some(def_id) = cx.tables.qpath_def(func_qpath, func.hir_id).opt_def_id();
if let Some(def_id) = cx.tables.qpath_res(func_qpath, func.hir_id).opt_def_id();
if cx.match_def_path(def_id, &paths::MEM_REPLACE);

// Check that second argument is `Option::None`
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::iter;
use if_chain::if_chain;
use matches::matches;
use rustc::hir;
use rustc::hir::def::Def;
use rustc::hir::def::{DefKind, Res};
use rustc::lint::{in_external_macro, LateContext, LateLintPass, Lint, LintArray, LintContext, LintPass};
use rustc::ty::{self, Predicate, Ty};
use rustc::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -1504,7 +1504,7 @@ fn lint_cstring_as_ptr(cx: &LateContext<'_, '_>, expr: &hir::Expr, new: &hir::Ex
if let hir::ExprKind::Call(ref fun, ref args) = new.node;
if args.len() == 1;
if let hir::ExprKind::Path(ref path) = fun.node;
if let Def::Method(did) = cx.tables.qpath_def(path, fun.hir_id);
if let Res::Def(DefKind::Method, did) = cx.tables.qpath_res(path, fun.hir_id);
if cx.match_def_path(did, &paths::CSTRING_NEW);
then {
span_lint_and_then(
Expand Down
Loading

0 comments on commit fc96aa0

Please sign in to comment.