From bdc9528e7ca3ab774a6d030c15c7f4062dd961d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 28 Apr 2020 15:05:56 +0200 Subject: [PATCH] rustup https://github.com/rust-lang/rust/pull/71292/ --- clippy_lints/src/escape.rs | 2 +- clippy_lints/src/functions.rs | 9 +++++++-- clippy_lints/src/loops.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 3 +-- clippy_lints/src/utils/mod.rs | 6 ++++-- clippy_lints/src/utils/usage.rs | 2 +- clippy_lints/src/wildcard_imports.rs | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 6907e021a00b..1ec60a0e6e67 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal { let fn_def_id = cx.tcx.hir().local_def_id(hir_id); cx.tcx.infer_ctxt().enter(|infcx| { - ExprUseVisitor::new(&mut v, &infcx, fn_def_id.to_def_id(), cx.param_env, cx.tables).consume_body(body); + ExprUseVisitor::new(&mut v, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body); }); for node in v.set { diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index c8c562fe29f5..c24a24733d7f 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -489,7 +489,12 @@ fn is_mutable_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>, tys: &mut FxHash } let def_id = pat.hir_id.owner.to_def_id(); if cx.tcx.has_typeck_tables(def_id) { - is_mutable_ty(cx, &cx.tcx.typeck_tables_of(def_id).pat_ty(pat), pat.span, tys) + is_mutable_ty( + cx, + &cx.tcx.typeck_tables_of(def_id.expect_local()).pat_ty(pat), + pat.span, + tys, + ) } else { false } @@ -606,7 +611,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> { if self.cx.tcx.has_typeck_tables(def_id) && is_mutable_ty( self.cx, - self.cx.tcx.typeck_tables_of(def_id).expr_ty(arg), + self.cx.tcx.typeck_tables_of(def_id.expect_local()).expr_ty(arg), arg.span, &mut tys, ) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index cb44eccae684..f7c7fd82d833 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1695,7 +1695,7 @@ fn check_for_mutation( }; let def_id = body.hir_id.owner.to_def_id(); cx.tcx.infer_ctxt().enter(|infcx| { - ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(body); + ExprUseVisitor::new(&mut delegate, &infcx, def_id.expect_local(), cx.param_env, cx.tables).walk_expr(body); }); delegate.mutation_span() } diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 200fd5656b4f..a21818701dac 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -135,8 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { } = { let mut ctx = MovedVariablesCtxt::default(); cx.tcx.infer_ctxt().enter(|infcx| { - euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id.to_def_id(), cx.param_env, cx.tables) - .consume_body(body); + euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body); }); ctx }; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 1b21eaeb13ab..04b4b4237619 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -293,7 +293,9 @@ pub fn qpath_res(cx: &LateContext<'_, '_>, qpath: &hir::QPath<'_>, id: hir::HirI hir::QPath::Resolved(_, path) => path.res, hir::QPath::TypeRelative(..) => { if cx.tcx.has_typeck_tables(id.owner.to_def_id()) { - cx.tcx.typeck_tables_of(id.owner.to_def_id()).qpath_res(qpath, id) + cx.tcx + .typeck_tables_of(id.owner.to_def_id().expect_local()) + .qpath_res(qpath, id) } else { Res::Err } @@ -436,7 +438,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option, def_id: DefId) -> bool { cx.tcx .entry_fn(LOCAL_CRATE) - .map_or(false, |(entry_fn_def_id, _)| def_id == entry_fn_def_id) + .map_or(false, |(entry_fn_def_id, _)| def_id == entry_fn_def_id.to_def_id()) } /// Gets the name of the item the expression is in, if available. diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index 1838fa5f8ffa..c14da6aacea0 100644 --- a/clippy_lints/src/utils/usage.rs +++ b/clippy_lints/src/utils/usage.rs @@ -19,7 +19,7 @@ pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &'a LateContext<'a, }; let def_id = expr.hir_id.owner.to_def_id(); cx.tcx.infer_ctxt().enter(|infcx| { - ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(expr); + ExprUseVisitor::new(&mut delegate, &infcx, def_id.expect_local(), cx.param_env, cx.tables).walk_expr(expr); }); if delegate.skip { diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 348d13ef41f1..f3038861cee2 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -85,7 +85,7 @@ impl LateLintPass<'_, '_> for WildcardImports { if let ItemKind::Use(use_path, UseKind::Glob) = &item.kind; // don't lint prelude glob imports if !use_path.segments.iter().last().map_or(false, |ps| ps.ident.as_str() == "prelude"); - let used_imports = cx.tcx.names_imported_by_glob_use(item.hir_id.owner.to_def_id()); + let used_imports = cx.tcx.names_imported_by_glob_use(item.hir_id.owner); if !used_imports.is_empty(); // Already handled by `unused_imports` then { let mut applicability = Applicability::MachineApplicable;