Skip to content

Rust upgrade to rustc 1.35.0-nightly (9cd61f025 2019-04-14) #3961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty;
use rustc::{declare_tool_lint, lint_array};
use syntax::ast;

declare_clippy_lint! {
/// **What it does:** Checks for a read and a write to the same variable where
Expand Down Expand Up @@ -287,7 +286,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
struct ReadVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>,
/// The ID of the variable we're looking for.
var: ast::NodeId,
var: HirId,
/// The expressions where the write to the variable occurred (for reporting
/// in the lint).
write_expr: &'tcx Expr,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ 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 self.ptrs.contains(&self.cx.tcx.hir().node_to_hir_id(id)) {
if self.ptrs.contains(&id) {
span_lint(
self.cx,
NOT_UNSAFE_PTR_ARG_DEREF,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
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 self.id == self.cx.tcx.hir().node_to_hir_id(local_id);
if self.id == local_id;
then {
self.used = true;
return;
Expand All @@ -175,7 +175,7 @@ fn check_assign<'a, 'tcx>(
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 decl == cx.tcx.hir().node_to_hir_id(local_id);
if decl == local_id;
then {
let mut v = UsedVisitor {
cx,
Expand Down
18 changes: 8 additions & 10 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> bo
if path.segments.len() == 1;
if let Def::Local(local_id) = cx.tables.qpath_def(qpath, expr.hir_id);
// our variable!
if cx.tcx.hir().node_to_hir_id(local_id) == var;
if local_id == var;
then {
return true;
}
Expand Down Expand Up @@ -1657,13 +1657,13 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<HirId>
then {
let def = cx.tables.qpath_def(qpath, bound.hir_id);
if let Def::Local(node_id) = def {
let node_str = cx.tcx.hir().get(node_id);
let node_str = cx.tcx.hir().get_by_hir_id(node_id);
if_chain! {
if let Node::Binding(pat) = node_str;
if let PatKind::Binding(bind_ann, ..) = pat.node;
if let BindingAnnotation::Mutable = bind_ann;
then {
return Some(cx.tcx.hir().node_to_hir_id(node_id));
return Some(node_id);
}
}
}
Expand Down Expand Up @@ -1792,9 +1792,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
}
let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id);
match def {
Def::Local(node_id) | Def::Upvar(node_id, ..) => {
let hir_id = self.cx.tcx.hir().node_to_hir_id(node_id);

Def::Local(hir_id) | Def::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 Down Expand Up @@ -1856,15 +1854,15 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
then {
match self.cx.tables.qpath_def(qpath, expr.hir_id) {
Def::Upvar(local_id, ..) => {
if self.cx.tcx.hir().node_to_hir_id(local_id) == self.var {
if local_id == self.var {
// we are not indexing anything, record that
self.nonindex = true;
}
}
Def::Local(local_id) =>
{

if self.cx.tcx.hir().node_to_hir_id(local_id) == self.var {
if local_id == self.var {
self.nonindex = true;
} else {
// not the correct variable, but still a variable
Expand Down Expand Up @@ -2209,7 +2207,7 @@ 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 {
return Some(cx.tcx.hir().node_to_hir_id(node_id));
return Some(node_id);
}
}
None
Expand Down Expand Up @@ -2404,7 +2402,7 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> {
then {
match def {
Def::Local(node_id) | Def::Upvar(node_id, ..) => {
self.ids.insert(self.cx.tcx.hir().node_to_hir_id(node_id));
self.ids.insert(node_id);
},
Def::Static(def_id, mutable) => {
self.def_ids.insert(def_id, mutable);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn check_expression<'a, 'tcx: 'a>(
if let hir::ExprKind::Path(path) = &args[0].node;
if let Def::Local(ref local) = cx.tables.qpath_def(path, args[0].hir_id);
then {
if arg_id == cx.tcx.hir().node_to_hir_id(*local) {
if arg_id == *local {
return (false, false)
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ fn in_attributes_expansion(expr: &Expr) -> bool {
/// Tests whether `def` is a variable defined outside a macro.
fn non_macro_local(cx: &LateContext<'_, '_>, def: &def::Def) -> bool {
match *def {
def::Def::Local(id) | def::Def::Upvar(id, _, _) => !in_macro(cx.tcx.hir().span(id)),
def::Def::Local(id) | def::Def::Upvar(id, _, _) => !in_macro(cx.tcx.hir().span_by_hir_id(id)),
_ => false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unused_io_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount {
};

match expr.node {
hir::ExprKind::Match(ref res, _, _) if is_try(cx, expr).is_some() => {
hir::ExprKind::Match(ref res, _, _) if is_try(expr).is_some() => {
if let hir::ExprKind::Call(ref func, ref args) = res.node {
if let hir::ExprKind::Path(ref path) = func.node {
if match_qpath(path, &paths::TRY_INTO_RESULT) && args.len() == 1 {
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,15 +950,15 @@ pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<I

/// Checks if a given expression is a match expression expanded from the `?`
/// operator or the `try` macro.
pub fn is_try<'a>(cx: &'_ LateContext<'_, '_>, expr: &'a Expr) -> Option<&'a Expr> {
fn is_ok(cx: &'_ LateContext<'_, '_>, arm: &Arm) -> bool {
pub fn is_try(expr: &Expr) -> Option<&Expr> {
fn is_ok(arm: &Arm) -> bool {
if_chain! {
if let PatKind::TupleStruct(ref path, ref pat, None) = arm.pats[0].node;
if match_qpath(path, &paths::RESULT_OK[1..]);
if let PatKind::Binding(_, hir_id, _, None) = pat[0].node;
if let ExprKind::Path(QPath::Resolved(None, ref path)) = arm.body.node;
if let Def::Local(lid) = path.def;
if cx.tcx.hir().node_to_hir_id(lid) == hir_id;
if lid == hir_id;
then {
return true;
}
Expand All @@ -984,8 +984,8 @@ pub fn is_try<'a>(cx: &'_ LateContext<'_, '_>, expr: &'a Expr) -> Option<&'a Exp
if arms.len() == 2;
if arms[0].pats.len() == 1 && arms[0].guard.is_none();
if arms[1].pats.len() == 1 && arms[1].guard.is_none();
if (is_ok(cx, &arms[0]) && is_err(&arms[1])) ||
(is_ok(cx, &arms[1]) && is_err(&arms[0]));
if (is_ok(&arms[0]) && is_err(&arms[1])) ||
(is_ok(&arms[1]) && is_err(&arms[0]));
then {
return Some(expr);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn is_potentially_mutated<'a, 'tcx: 'a>(
Def::Local(id) | Def::Upvar(id, ..) => id,
_ => return true,
};
mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&cx.tcx.hir().node_to_hir_id(id)))
mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id))
}

struct MutVarsDelegate {
Expand Down