diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index a4f7b64cb6a7e..6675a1029bbc8 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -208,8 +208,9 @@ jobs: - name: Extract Binaries run: | DIR=$CARGO_TARGET_DIR/debug + rm $DIR/deps/integration-*.d + mv $DIR/deps/integration-* $DIR/integration find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf - mv $DIR/integration-* $DIR/integration rm -rf $CARGO_TARGET_DIR/release - name: Upload Binaries diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 01ced205af485..697486c1af093 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -486,7 +486,7 @@ fn is_mutable_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>, tys: &mut FxHash if let hir::PatKind::Wild = pat.kind { return false; // ignore `_` patterns } - let def_id = pat.hir_id.owner_def_id(); + 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) } else { @@ -601,7 +601,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> { Call(_, args) | MethodCall(_, _, args) => { let mut tys = FxHashSet::default(); for arg in args { - let def_id = arg.hir_id.owner_def_id(); + let def_id = arg.hir_id.owner.to_def_id(); if self.cx.tcx.has_typeck_tables(def_id) && is_mutable_ty( self.cx, diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index 355e75d0d5597..cd034f916cef4 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl { // but filter out implementations that have generic params (type or lifetime) // or are derived from a macro if !in_macro(item.span) && generics.params.is_empty() { - self.impls.insert(item.hir_id.owner_def_id(), item.span); + self.impls.insert(item.hir_id.owner.to_def_id(), item.span); } } } @@ -69,7 +69,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl { // Retrieve all inherent implementations from the crate, grouped by type for impls in cx .tcx - .crate_inherent_impls(item.hir_id.owner_def_id().krate) + .crate_inherent_impls(item.hir_id.owner.to_def_id().krate) .inherent_impls .values() { diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index fb79ad271e0ac..1c81d78a2b952 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -56,9 +56,9 @@ extern crate rustc_trait_selection; #[allow(unused_extern_crates)] extern crate rustc_typeck; -use rustc::session::Session; use rustc_data_structures::fx::FxHashSet; use rustc_lint::LintId; +use rustc_session::Session; /// Macro used to declare a Clippy lint. /// diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 211d9034ffb70..475e60736e07f 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1679,7 +1679,7 @@ fn check_for_mutation( span_low: None, span_high: None, }; - let def_id = def_id::DefId::local(body.hir_id.owner); + 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); }); diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 96750cb3b4667..e03f9e36095b3 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { hir::ItemKind::Fn(..) => { // ignore main() if it.ident.name == sym!(main) { - let def_id = cx.tcx.hir().local_def_id(it.hir_id); + let def_id = it.hir_id.owner; let def_key = cx.tcx.hir().def_key(def_id); if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) { return; diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 0f871d29c2f3b..22b56c28b6bc1 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -69,7 +69,7 @@ fn check_missing_inline_attrs(cx: &LateContext<'_, '_>, attrs: &[ast::Attribute] } fn is_executable(cx: &LateContext<'_, '_>) -> bool { - use rustc::session::config::CrateType; + use rustc_session::config::CrateType; cx.tcx.sess.crate_types.get().iter().any(|t: &CrateType| match t { CrateType::Executable => true, diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index adc93909677da..f69b145fa39fb 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -149,9 +149,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { if_chain! { if let Some(ref impling_types) = self.impling_types; if let Some(self_def) = cx.tcx.type_of(self_did).ty_adt_def(); - if self_def.did.is_local(); + if let Some(self_def_id) = self_def.did.as_local(); then { - let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_def.did.to_local()); + let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_def_id); if impling_types.contains(&self_id) { return; } diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 05428f1a31fb0..d532efbec7492 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -99,7 +99,7 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block<'_>) { then { if let ExprKind::Field(ref lhs1, _) = lhs1.kind { if let ExprKind::Field(ref lhs2, _) = lhs2.kind { - if lhs1.hir_id.owner_def_id() == lhs2.hir_id.owner_def_id() { + if lhs1.hir_id.owner == lhs2.hir_id.owner { return; } } diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index 7e9a94f14fef6..194e11ac9bdf9 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -3,13 +3,13 @@ use std::cmp; use crate::utils::{is_copy, is_self_ty, snippet, span_lint_and_sugg}; use if_chain::if_chain; use matches::matches; -use rustc::session::config::Config as SessionConfig; use rustc::ty; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl, HirId, ItemKind, MutTy, Mutability, Node}; use rustc_lint::{LateContext, LateLintPass}; +use rustc_session::config::Config as SessionConfig; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; use rustc_target::abi::LayoutOf; diff --git a/clippy_lints/src/utils/attrs.rs b/clippy_lints/src/utils/attrs.rs index 3721350959b98..e27e1b7f2e6cf 100644 --- a/clippy_lints/src/utils/attrs.rs +++ b/clippy_lints/src/utils/attrs.rs @@ -1,6 +1,6 @@ -use rustc::session::Session; use rustc_ast::ast; use rustc_errors::Applicability; +use rustc_session::Session; use std::str::FromStr; /// Deprecation status of attributes known by Clippy. diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index e95c45852ac2f..4fcaf4264d778 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -3,7 +3,6 @@ use crate::utils::{get_attr, higher}; use rustc::hir::map::Map; -use rustc::session::Session; use rustc_ast::ast::{Attribute, LitFloatType, LitKind}; use rustc_ast::walk_list; use rustc_data_structures::fx::FxHashMap; @@ -11,6 +10,7 @@ use rustc_hir as hir; use rustc_hir::intravisit::{NestedVisitorMap, Visitor}; use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, Pat, PatKind, QPath, Stmt, StmtKind, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_session::Session; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index d79f6d525fcf4..c6a47f05e2482 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -1,11 +1,11 @@ //! checks for attributes use crate::utils::get_attr; -use rustc::session::Session; use rustc_ast::ast::Attribute; use rustc_hir as hir; use rustc_hir::print; use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_session::Session; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 280e8e2f32e6b..c1c5bcc1dd1bb 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -297,8 +297,8 @@ pub fn qpath_res(cx: &LateContext<'_, '_>, qpath: &hir::QPath<'_>, id: hir::HirI match qpath { hir::QPath::Resolved(_, path) => path.res, hir::QPath::TypeRelative(..) => { - if cx.tcx.has_typeck_tables(id.owner_def_id()) { - cx.tcx.typeck_tables_of(id.owner_def_id()).qpath_res(qpath, id) + 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) } else { Res::Err } diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index 7cde18fdb3b49..a08251c1a4eb2 100644 --- a/clippy_lints/src/utils/usage.rs +++ b/clippy_lints/src/utils/usage.rs @@ -5,7 +5,7 @@ use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::Res; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; -use rustc_hir::{def_id, Expr, HirId, Path}; +use rustc_hir::{Expr, HirId, Path}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::LateContext; use rustc_span::symbol::Ident; @@ -17,7 +17,7 @@ pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &'a LateContext<'a, used_mutably: FxHashSet::default(), skip: false, }; - let def_id = def_id::DefId::local(expr.hir_id.owner); + 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); }); diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 6f8cec7c05672..348d13ef41f10 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_def_id()); + let used_imports = cx.tcx.names_imported_by_glob_use(item.hir_id.owner.to_def_id()); if !used_imports.is_empty(); // Already handled by `unused_imports` then { let mut applicability = Applicability::MachineApplicable; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index a63c6771bb539..5ad43ad55a36a 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -357,7 +357,7 @@ impl Write { }; let tts = tts.clone(); - let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, None, false, false, None); + let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, false, None); let mut expr: Option = None; if is_write { expr = match parser.parse_expr().map_err(|mut err| err.cancel()) { diff --git a/tests/ui/inefficient_to_string.stderr b/tests/ui/inefficient_to_string.stderr index 1c0490ffa44cc..4be46161e8b74 100644 --- a/tests/ui/inefficient_to_string.stderr +++ b/tests/ui/inefficient_to_string.stderr @@ -35,21 +35,21 @@ LL | let _: String = rrrstring.to_string(); | = help: `&&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString` -error: calling `to_string` on `&&std::borrow::Cow<'_, str>` +error: calling `to_string` on `&&std::borrow::Cow` --> $DIR/inefficient_to_string.rs:29:21 | LL | let _: String = rrcow.to_string(); | ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrcow).to_string()` | - = help: `&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString` + = help: `&std::borrow::Cow` implements `ToString` through a slower blanket impl, but `std::borrow::Cow` has a fast specialization of `ToString` -error: calling `to_string` on `&&&std::borrow::Cow<'_, str>` +error: calling `to_string` on `&&&std::borrow::Cow` --> $DIR/inefficient_to_string.rs:30:21 | LL | let _: String = rrrcow.to_string(); | ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrcow).to_string()` | - = help: `&&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString` + = help: `&&std::borrow::Cow` implements `ToString` through a slower blanket impl, but `std::borrow::Cow` has a fast specialization of `ToString` error: aborting due to 6 previous errors diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index 37162ecf4756f..8582080498f3e 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -1,4 +1,4 @@ -error: transmute from a type (`&'a T`) to itself +error: transmute from a type (`&T`) to itself --> $DIR/transmute.rs:19:20 | LL | let _: &'a T = core::intrinsics::transmute(t); diff --git a/tests/ui/transmute_ptr_to_ptr.stderr b/tests/ui/transmute_ptr_to_ptr.stderr index 4d1b8fcc199e8..61fbea1c164ea 100644 --- a/tests/ui/transmute_ptr_to_ptr.stderr +++ b/tests/ui/transmute_ptr_to_ptr.stderr @@ -1,3 +1,17 @@ +error: transmute from a type (`&T`) to itself + --> $DIR/transmute_ptr_to_ptr.rs:8:5 + | +LL | std::mem::transmute::<&'a T, &'static T>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::useless-transmute` implied by `-D warnings` + +error: transmute from a type (`&T`) to itself + --> $DIR/transmute_ptr_to_ptr.rs:13:5 + | +LL | std::mem::transmute::<&'a T, &'b T>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: transmute from a pointer to a pointer --> $DIR/transmute_ptr_to_ptr.rs:29:29 | @@ -36,5 +50,17 @@ error: transmute from a reference to a reference LL | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` -error: aborting due to 6 previous errors +error: transmute from a type (`&LifetimeParam`) to itself + --> $DIR/transmute_ptr_to_ptr.rs:50:47 + | +LL | let _: &LifetimeParam<'static> = unsafe { std::mem::transmute(&lp) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: transmute from a type (`&GenericParam<&LifetimeParam>`) to itself + --> $DIR/transmute_ptr_to_ptr.rs:51:62 + | +LL | let _: &GenericParam<&LifetimeParam<'static>> = unsafe { std::mem::transmute(&GenericParam { t: &lp }) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors diff --git a/tests/ui/transmute_ptr_to_ref.stderr b/tests/ui/transmute_ptr_to_ref.stderr index 2d52e421816ee..df0598a58cd36 100644 --- a/tests/ui/transmute_ptr_to_ref.stderr +++ b/tests/ui/transmute_ptr_to_ref.stderr @@ -42,13 +42,13 @@ error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) LL | let _: &T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)` -error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`) +error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo`) --> $DIR/transmute_ptr_to_ref.rs:32:32 | LL | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<_>)` -error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`) +error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<&u8>`) --> $DIR/transmute_ptr_to_ref.rs:34:33 | LL | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) };