From a0480025050cc70e116288be3a3d2790fc95f947 Mon Sep 17 00:00:00 2001 From: surechen Date: Fri, 10 Nov 2023 10:11:24 +0800 Subject: [PATCH] check redundant prelude imports detects unnecessary imports in std::prelude that can be eliminated. For example import: ```rust use std::{option::{Iter, IterMut, IntoIter, Option::{self, Some}}, convert::{TryFrom, TryInto}, mem::drop}; ``` delete : `Option::{self, Some}` and `mem::drop` --- compiler/rustc_ast/src/mut_visit.rs | 2 +- compiler/rustc_ast/src/token.rs | 2 +- compiler/rustc_ast/src/visit.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 1 - compiler/rustc_ast_lowering/src/format.rs | 2 +- compiler/rustc_ast_lowering/src/index.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 1 - .../rustc_ast_passes/src/ast_validation.rs | 4 +- compiler/rustc_borrowck/src/dataflow.rs | 2 +- .../src/region_infer/graphviz.rs | 1 - compiler/rustc_borrowck/src/type_check/mod.rs | 1 - .../rustc_builtin_macros/src/source_util.rs | 4 +- .../rustc_builtin_macros/src/test_harness.rs | 2 +- compiler/rustc_codegen_llvm/src/abi.rs | 1 - .../src/debuginfo/metadata.rs | 2 +- .../rustc_codegen_llvm/src/debuginfo/mod.rs | 2 +- .../rustc_codegen_ssa/src/mir/statement.rs | 1 - .../src/transform/check_consts/check.rs | 2 +- .../rustc_data_structures/src/owned_slice.rs | 1 + compiler/rustc_expand/src/base.rs | 2 +- .../rustc_hir_analysis/src/check/check.rs | 12 ++--- compiler/rustc_hir_pretty/src/lib.rs | 2 +- compiler/rustc_hir_typeck/src/coercion.rs | 2 +- compiler/rustc_hir_typeck/src/diverges.rs | 2 +- compiler/rustc_hir_typeck/src/expectation.rs | 2 +- .../src/fn_ctxt/adjust_fulfillment_errors.rs | 2 +- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 2 +- compiler/rustc_hir_typeck/src/inherited.rs | 2 +- compiler/rustc_hir_typeck/src/op.rs | 2 +- .../src/persist/dirty_clean.rs | 1 - .../src/errors/note_and_explain.rs | 2 +- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 1 - compiler/rustc_lint/src/lib.rs | 3 -- compiler/rustc_macros/src/hash_stable.rs | 4 +- compiler/rustc_macros/src/lift.rs | 2 +- compiler/rustc_metadata/src/rmeta/decoder.rs | 28 ++++-------- compiler/rustc_metadata/src/rmeta/encoder.rs | 30 ++++--------- compiler/rustc_metadata/src/rmeta/table.rs | 7 +-- compiler/rustc_middle/src/hir/map/mod.rs | 2 +- compiler/rustc_middle/src/middle/limits.rs | 1 - compiler/rustc_middle/src/mir/consts.rs | 1 - .../rustc_middle/src/mir/generic_graph.rs | 2 - compiler/rustc_middle/src/mir/graphviz.rs | 3 -- compiler/rustc_middle/src/mir/patch.rs | 3 -- compiler/rustc_middle/src/mir/pretty.rs | 11 ++--- compiler/rustc_middle/src/mir/spanview.rs | 4 +- compiler/rustc_middle/src/mir/tcx.rs | 2 - compiler/rustc_middle/src/mir/terminator.rs | 3 +- .../rustc_middle/src/mir/type_foldable.rs | 1 - compiler/rustc_middle/src/mir/visit.rs | 4 +- compiler/rustc_middle/src/ty/generic_args.rs | 2 +- compiler/rustc_middle/src/ty/layout.rs | 2 +- compiler/rustc_middle/src/ty/print/pretty.rs | 11 +++-- .../src/build/expr/as_rvalue.rs | 2 - .../rustc_mir_build/src/check_unsafety.rs | 2 +- .../src/thir/pattern/check_match.rs | 2 +- .../src/abort_unwinding_calls.rs | 1 - .../src/add_call_guards.rs | 1 - .../src/add_moves_for_packed_drops.rs | 1 - compiler/rustc_mir_transform/src/add_retag.rs | 1 - .../src/add_subtyping_projections.rs | 1 - .../src/check_alignment.rs | 1 - .../rustc_mir_transform/src/const_goto.rs | 1 - .../rustc_mir_transform/src/const_prop.rs | 1 - compiler/rustc_mir_transform/src/copy_prop.rs | 1 - compiler/rustc_mir_transform/src/coroutine.rs | 4 +- .../rustc_mir_transform/src/coverage/query.rs | 4 +- .../src/dataflow_const_prop.rs | 1 - .../src/deduplicate_blocks.rs | 2 - .../src/deref_separator.rs | 1 - .../src/elaborate_box_derefs.rs | 1 - .../src/elaborate_drops.rs | 1 - compiler/rustc_mir_transform/src/gvn.rs | 1 - compiler/rustc_mir_transform/src/inline.rs | 1 - .../rustc_mir_transform/src/instsimplify.rs | 2 - .../rustc_mir_transform/src/jump_threading.rs | 1 - .../rustc_mir_transform/src/large_enums.rs | 1 - .../src/lower_intrinsics.rs | 1 - .../src/lower_slice_len.rs | 1 - .../rustc_mir_transform/src/match_branches.rs | 1 - .../src/multiple_return_terminators.rs | 2 +- .../src/normalize_array_len.rs | 1 - compiler/rustc_mir_transform/src/prettify.rs | 1 - compiler/rustc_mir_transform/src/ref_prop.rs | 1 - .../src/remove_noop_landing_pads.rs | 1 - .../src/remove_place_mention.rs | 1 - .../src/remove_storage_markers.rs | 1 - .../src/remove_uninit_drops.rs | 4 +- .../src/remove_unneeded_drops.rs | 1 - .../rustc_mir_transform/src/remove_zsts.rs | 1 - .../rustc_mir_transform/src/reveal_all.rs | 1 - .../src/separate_const_switch.rs | 1 - compiler/rustc_mir_transform/src/simplify.rs | 1 - .../src/simplify_branches.rs | 1 - compiler/rustc_mir_transform/src/sroa.rs | 1 - .../src/unreachable_prop.rs | 1 - compiler/rustc_parse/src/parser/attr.rs | 1 - compiler/rustc_parse/src/parser/item.rs | 8 +--- .../rustc_query_system/src/dep_graph/edges.rs | 1 - compiler/rustc_query_system/src/query/job.rs | 1 + .../rustc_resolve/src/build_reduced_graph.rs | 14 +++--- compiler/rustc_resolve/src/check_unused.rs | 23 +++++++++- compiler/rustc_resolve/src/def_collector.rs | 2 +- compiler/rustc_resolve/src/diagnostics.rs | 4 +- compiler/rustc_resolve/src/ident.rs | 17 ++++--- compiler/rustc_resolve/src/imports.rs | 41 +++++++++-------- compiler/rustc_resolve/src/late.rs | 10 ++--- compiler/rustc_resolve/src/lib.rs | 40 ++++++++++++----- compiler/rustc_resolve/src/macros.rs | 4 +- compiler/rustc_smir/src/rustc_smir/context.rs | 2 +- compiler/rustc_smir/src/rustc_smir/mod.rs | 2 +- compiler/rustc_span/src/source_map.rs | 6 +-- .../src/traits/auto_trait.rs | 2 - compiler/rustc_ty_utils/src/layout.rs | 4 +- compiler/stable_mir/src/error.rs | 1 - library/core/src/array/iter.rs | 2 +- library/core/src/char/methods.rs | 1 - library/core/src/clone.rs | 2 - library/core/src/convert/num.rs | 2 +- library/core/src/future/future.rs | 1 - library/core/src/intrinsics.rs | 1 + .../core/src/iter/adapters/array_chunks.rs | 2 +- library/core/src/iter/adapters/chain.rs | 2 +- library/core/src/iter/adapters/flatten.rs | 4 +- library/core/src/iter/adapters/fuse.rs | 3 +- library/core/src/iter/adapters/map_windows.rs | 2 +- library/core/src/iter/adapters/mod.rs | 2 +- library/core/src/iter/adapters/zip.rs | 2 +- library/core/src/mem/mod.rs | 2 +- library/core/src/ops/coroutine.rs | 1 - library/core/src/pin.rs | 3 +- library/core/src/ptr/const_ptr.rs | 6 +-- library/core/src/ptr/mut_ptr.rs | 4 +- library/core/src/ptr/non_null.rs | 1 - library/core/src/ptr/unique.rs | 1 - library/core/src/slice/iter.rs | 2 +- library/core/src/slice/mod.rs | 7 +-- library/core/src/task/poll.rs | 1 - library/core/src/task/wake.rs | 2 +- library/std/src/backtrace.rs | 1 - library/std/src/io/error/repr_bitpacked.rs | 1 - .../rust-analyzer/crates/stdx/src/anymap.rs | 1 - tests/ui/bare-fn-implements-fn-mut.rs | 2 - tests/ui/box/alloc-unstable.rs | 3 -- tests/ui/box/into-boxed-slice.rs | 2 - tests/ui/box/new-box-syntax.rs | 2 - tests/ui/box/unit/unique-kinds.rs | 1 - tests/ui/cleanup-rvalue-for-scope.rs | 3 -- tests/ui/cleanup-rvalue-scopes.rs | 2 - .../coherence-negative-impls-safe-rpass.rs | 2 - tests/ui/coherence/coherence-where-clause.rs | 2 - tests/ui/consts/const-block.rs | 2 - tests/ui/coroutine/control-flow.rs | 1 - tests/ui/coroutine/discriminant.rs | 2 +- tests/ui/coroutine/iterator-count.rs | 1 - tests/ui/coroutine/non-static-is-unpin.rs | 2 +- tests/ui/coroutine/smoke-resume-args.rs | 1 - tests/ui/extern/issue-13655.rs | 2 - tests/ui/for-loop-while/while-prelude-drop.rs | 3 -- tests/ui/issues/issue-20847.rs | 2 - tests/ui/issues/issue-5554.rs | 1 - tests/ui/issues/issue-8783.rs | 2 - tests/ui/lint/unused/lint-unused-imports.rs | 2 - .../ui/lint/unused/lint-unused-imports.stderr | 26 +---------- .../use-redundant-prelude-rust-2015.rs | 19 ++++++++ .../use-redundant-prelude-rust-2015.stderr | 44 +++++++++++++++++++ .../use-redundant-prelude-rust-2021.rs | 11 +++++ .../use-redundant-prelude-rust-2021.stderr | 26 +++++++++++ tests/ui/moves/move-out-of-field.rs | 2 - .../overloaded-calls-param-vtables.rs | 1 - .../ui/overloaded/overloaded-calls-simple.rs | 2 - .../overloaded/overloaded-calls-zero-args.rs | 2 - tests/ui/overloaded/overloaded-deref-count.rs | 1 - tests/ui/overloaded/overloaded-deref.rs | 1 - ...-lifetime-static-items-enclosing-scopes.rs | 3 -- tests/ui/rust-2018/remove-extern-crate.fixed | 1 + tests/ui/rust-2018/remove-extern-crate.rs | 1 + tests/ui/rust-2018/remove-extern-crate.stderr | 6 +-- .../specialization-translate-projections.rs | 1 - tests/ui/stdlib-unit-tests/istr.rs | 2 - .../minmax-stability-issue-23687.rs | 2 +- .../class-cast-to-trait-cross-crate-2.rs | 1 - .../enum-nullable-const-null-with-fields.rs | 3 -- .../ui/suggestions/derive-clone-for-eq.fixed | 2 - tests/ui/suggestions/derive-clone-for-eq.rs | 2 - .../ui/suggestions/derive-clone-for-eq.stderr | 4 +- tests/ui/traits/inheritance/num0.rs | 2 - .../traits/inheritance/overloading-simple.rs | 1 - tests/ui/traits/inheritance/overloading.rs | 1 - tests/ui/traits/issue-22019.rs | 2 - tests/ui/traits/multidispatch2.rs | 1 - .../negated-auto-traits-rpass.rs | 2 - tests/ui/traits/wf-object/reverse-order.rs | 2 - tests/ui/ufcs/ufcs-polymorphic-paths.rs | 3 +- .../unboxed-closures-boxed.rs | 1 - .../unboxed-closures-call-sugar-autoderef.rs | 2 - ...ed-closures-call-sugar-object-autoderef.rs | 2 - .../unboxed-closures-call-sugar-object.rs | 2 - .../unboxed-closures-extern-fn.rs | 1 - ...unboxed-closures-fn-as-fnmut-and-fnonce.rs | 2 - .../unboxed-closures-generic.rs | 2 - .../zero-sized/zero-sized-binary-heap-push.rs | 1 - .../zero-sized/zero-sized-linkedlist-push.rs | 1 - 204 files changed, 314 insertions(+), 414 deletions(-) create mode 100644 tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs create mode 100644 tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr create mode 100644 tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs create mode 100644 tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 541b987292240..3f3949277a5ab 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -7,10 +7,10 @@ //! a `MutVisitor` renaming item names in a module will miss all of those //! that are created by the expansion of a macro. +use crate::ast::*; use crate::ptr::P; use crate::token::{self, Token}; use crate::tokenstream::*; -use crate::{ast::*, StaticItem}; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::stack::ensure_sufficient_stack; diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index a7c6f8c5d8c26..b0cd2ec981592 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -13,7 +13,7 @@ use rustc_macros::HashStable_Generic; use rustc_span::symbol::{kw, sym}; #[allow(hidden_glob_reexports)] use rustc_span::symbol::{Ident, Symbol}; -use rustc_span::{self, edition::Edition, Span, DUMMY_SP}; +use rustc_span::{edition::Edition, Span, DUMMY_SP}; use std::borrow::Cow; use std::fmt; diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 1caa39e2dd999..80e4b78c54c14 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -13,7 +13,7 @@ //! instance, a walker looking for item names in a module will miss all of //! those that are created by the expansion of a macro. -use crate::{ast::*, StaticItem}; +use crate::ast::*; use rustc_span::symbol::Ident; use rustc_span::Span; diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 180459efef920..d98679b3f4d5e 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -7,7 +7,6 @@ use super::errors::{ use super::ResolverAstLoweringExt; use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs}; use crate::{FnDeclKind, ImplTraitPosition}; -use rustc_ast::attr; use rustc_ast::ptr::P as AstP; use rustc_ast::*; use rustc_data_structures::stack::ensure_sufficient_stack; diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index b6202be4f52ae..1b4398bfcbf5a 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -1,6 +1,6 @@ use super::LoweringContext; use rustc_ast as ast; -use rustc_ast::visit::{self, Visitor}; +use rustc_ast::visit::Visitor; use rustc_ast::*; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs index e91b78720a86b..cb59c9787b844 100644 --- a/compiler/rustc_ast_lowering/src/index.rs +++ b/compiler/rustc_ast_lowering/src/index.rs @@ -2,7 +2,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sorted_map::SortedMap; use rustc_hir as hir; use rustc_hir::def_id::LocalDefId; -use rustc_hir::intravisit::{self, Visitor}; +use rustc_hir::intravisit::Visitor; use rustc_hir::*; use rustc_index::{Idx, IndexVec}; use rustc_middle::span_bug; diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 4c7b9b4155fdf..6dce8d2182cc6 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -46,7 +46,6 @@ extern crate tracing; use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait}; use rustc_ast::ptr::P; -use rustc_ast::visit; use rustc_ast::{self as ast, *}; use rustc_ast_pretty::pprust; use rustc_data_structures::captures::Captures; diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 45b5e63bd1b3b..43cb937649994 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -8,9 +8,9 @@ use itertools::{Either, Itertools}; use rustc_ast::ptr::P; -use rustc_ast::visit::{self, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; +use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; +use rustc_ast::walk_list; use rustc_ast::*; -use rustc_ast::{walk_list, StaticItem}; use rustc_ast_pretty::pprust::{self, State}; use rustc_data_structures::fx::FxIndexMap; use rustc_feature::Features; diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index b3d14c1beb565..6e72edf6307a4 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -10,7 +10,7 @@ use rustc_middle::ty::RegionVid; use rustc_middle::ty::TyCtxt; use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces}; use rustc_mir_dataflow::ResultsVisitable; -use rustc_mir_dataflow::{self, fmt::DebugWithContext, GenKill}; +use rustc_mir_dataflow::{fmt::DebugWithContext, GenKill}; use rustc_mir_dataflow::{Analysis, Direction, Results}; use std::fmt; diff --git a/compiler/rustc_borrowck/src/region_infer/graphviz.rs b/compiler/rustc_borrowck/src/region_infer/graphviz.rs index a0cf22e935a94..408c8390e763c 100644 --- a/compiler/rustc_borrowck/src/region_infer/graphviz.rs +++ b/compiler/rustc_borrowck/src/region_infer/graphviz.rs @@ -8,7 +8,6 @@ use std::borrow::Cow; use std::io::{self, Write}; use super::*; -use crate::constraints::OutlivesConstraint; use rustc_graphviz as dot; impl<'tcx> RegionInferenceContext<'tcx> { diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index d4fd1a3cf2ae5..d5ed7f22d2f2c 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -25,7 +25,6 @@ use rustc_infer::infer::{ }; use rustc_middle::mir::tcx::PlaceTy; use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor}; -use rustc_middle::mir::AssertKind; use rustc_middle::mir::*; use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::ObligationCause; diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index 7ae4b1b59dcde..37808854a56f8 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -5,11 +5,11 @@ use rustc_ast::tokenstream::TokenStream; use rustc_ast_pretty::pprust; use rustc_expand::base::{self, *}; use rustc_expand::module::DirOwnership; +use rustc_parse::new_parser_from_file; use rustc_parse::parser::{ForceCollect, Parser}; -use rustc_parse::{self, new_parser_from_file}; use rustc_session::lint::builtin::INCOMPLETE_INCLUDE; use rustc_span::symbol::Symbol; -use rustc_span::{self, Pos, Span}; +use rustc_span::{Pos, Span}; use smallvec::SmallVec; use std::rc::Rc; diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index 380556c3ca5f0..c5daf17abb99d 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -2,7 +2,7 @@ use rustc_ast as ast; use rustc_ast::entry::EntryPointType; -use rustc_ast::mut_visit::{ExpectOne, *}; +use rustc_ast::mut_visit::*; use rustc_ast::ptr::P; use rustc_ast::visit::{walk_item, Visitor}; use rustc_ast::{attr, ModKind}; diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index b5f53f5183835..97dc401251cf0 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -15,7 +15,6 @@ use rustc_middle::ty::layout::LayoutOf; pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; use rustc_middle::ty::Ty; use rustc_session::config; -use rustc_target::abi::call::ArgAbi; pub use rustc_target::abi::call::*; use rustc_target::abi::{self, HasDataLayout, Int}; pub use rustc_target::spec::abi::Abi; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index cf78fc56b498c..98563673c30fc 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -35,7 +35,7 @@ use rustc_middle::ty::{ use rustc_session::config::{self, DebugInfo, Lto}; use rustc_span::symbol::Symbol; use rustc_span::FileName; -use rustc_span::{self, FileNameDisplayPreference, SourceFile}; +use rustc_span::{FileNameDisplayPreference, SourceFile}; use rustc_symbol_mangling::typeid_for_trait_ref; use rustc_target::abi::{Align, Size}; use smallvec::smallvec; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index 4832b147a5444..a0ae1e9bf5d1b 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -32,7 +32,7 @@ use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TypeVisitableExt}; use rustc_session::config::{self, DebugInfo}; use rustc_session::Session; use rustc_span::symbol::Symbol; -use rustc_span::{self, BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span}; +use rustc_span::{BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span}; use rustc_target::abi::Size; use libc::c_uint; diff --git a/compiler/rustc_codegen_ssa/src/mir/statement.rs b/compiler/rustc_codegen_ssa/src/mir/statement.rs index 899e41265bba5..a158fc6e26074 100644 --- a/compiler/rustc_codegen_ssa/src/mir/statement.rs +++ b/compiler/rustc_codegen_ssa/src/mir/statement.rs @@ -3,7 +3,6 @@ use rustc_middle::mir::NonDivergingIntrinsic; use super::FunctionCx; use super::LocalRef; -use crate::traits::BuilderMethods; use crate::traits::*; impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 13742ad273b59..9a1197626f230 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -12,7 +12,7 @@ use rustc_middle::traits::BuiltinImplSource; use rustc_middle::ty::GenericArgs; use rustc_middle::ty::{self, adjustment::PointerCoercion, Instance, InstanceDef, Ty, TyCtxt}; use rustc_middle::ty::{TraitRef, TypeVisitableExt}; -use rustc_mir_dataflow::{self, Analysis}; +use rustc_mir_dataflow::Analysis; use rustc_span::{sym, Span, Symbol}; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _; use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt, SelectionContext}; diff --git a/compiler/rustc_data_structures/src/owned_slice.rs b/compiler/rustc_data_structures/src/owned_slice.rs index cbb3047d88412..246fd496a250a 100644 --- a/compiler/rustc_data_structures/src/owned_slice.rs +++ b/compiler/rustc_data_structures/src/owned_slice.rs @@ -4,6 +4,7 @@ use crate::sync::Lrc; // Use our fake Send/Sync traits when on not parallel compiler, // so that `OwnedSlice` only implements/requires Send/Sync // for parallel compiler builds. +#[allow(unused_imports)] use crate::sync::{Send, Sync}; /// An owned slice. diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 88e90a3b3d14c..6e2021f51280c 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -21,7 +21,7 @@ use rustc_errors::{ use rustc_feature::Features; use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT; use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics, RegisteredTools}; -use rustc_parse::{self, parser, MACRO_ARGUMENTS}; +use rustc_parse::{parser, MACRO_ARGUMENTS}; use rustc_session::errors::report_lit_error; use rustc_session::{parse::ParseSess, Limit, Session}; use rustc_span::def_id::{CrateNum, DefId, LocalDefId}; diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index fbed6f33e5928..ff94b7ec926ca 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1,5 +1,5 @@ use crate::check::intrinsicck::InlineAsmCtxt; -use crate::errors::{self, LinkageType}; +use crate::errors::LinkageType; use super::compare_impl_item::check_type_bounds; use super::compare_impl_item::{compare_impl_method, compare_impl_ty}; @@ -8,9 +8,8 @@ use rustc_attr as attr; use rustc_errors::{ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind}; -use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId}; +use rustc_hir::def_id::LocalModDefId; use rustc_hir::Node; -use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt}; use rustc_infer::traits::{Obligation, TraitEngineExt as _}; use rustc_lint_defs::builtin::REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS; @@ -21,18 +20,15 @@ use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES}; use rustc_middle::ty::util::{Discr, IntTypeExt}; use rustc_middle::ty::GenericArgKind; use rustc_middle::ty::{ - self, AdtDef, ParamEnv, RegionKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, - TypeVisitableExt, + AdtDef, ParamEnv, RegionKind, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, }; use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS}; use rustc_span::symbol::sym; -use rustc_span::{self, Span}; use rustc_target::abi::FieldIdx; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits::error_reporting::on_unimplemented::OnUnimplementedDirective; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _; use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _; -use rustc_trait_selection::traits::{self, ObligationCtxt, TraitEngine, TraitEngineExt as _}; +use rustc_trait_selection::traits::{self, TraitEngine, TraitEngineExt as _}; use rustc_type_ir::fold::TypeFoldable; use std::ops::ControlFlow; diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index e9e8c7fd4fc25..4966e9e5e5c4e 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -16,7 +16,7 @@ use rustc_hir::{BindingAnnotation, ByRef, GenericArg, GenericParam, GenericParam use rustc_hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier}; use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, Ident, Symbol}; -use rustc_span::{self, FileName}; +use rustc_span::FileName; use rustc_target::spec::abi::Abi; use std::cell::Cell; diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 587038d57bdfd..a99f74e5505a6 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -57,7 +57,7 @@ use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::{self, Ty, TypeAndMut}; use rustc_session::parse::feature_err; use rustc_span::symbol::sym; -use rustc_span::{self, DesugaringKind}; +use rustc_span::DesugaringKind; use rustc_target::spec::abi::Abi; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _; diff --git a/compiler/rustc_hir_typeck/src/diverges.rs b/compiler/rustc_hir_typeck/src/diverges.rs index 29fcc61cbb51d..0b559a0858e46 100644 --- a/compiler/rustc_hir_typeck/src/diverges.rs +++ b/compiler/rustc_hir_typeck/src/diverges.rs @@ -1,4 +1,4 @@ -use rustc_span::{self, Span, DUMMY_SP}; +use rustc_span::{Span, DUMMY_SP}; use std::{cmp, ops}; /// Tracks whether executing a node may exit normally (versus diff --git a/compiler/rustc_hir_typeck/src/expectation.rs b/compiler/rustc_hir_typeck/src/expectation.rs index 35e5fb769a58b..ff84e753d70df 100644 --- a/compiler/rustc_hir_typeck/src/expectation.rs +++ b/compiler/rustc_hir_typeck/src/expectation.rs @@ -1,6 +1,6 @@ use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_middle::ty::{self, Ty}; -use rustc_span::{self, Span}; +use rustc_span::Span; use super::Expectation::*; use super::FnCtxt; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs index e3aca11fd03aa..9b5459529ffb1 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs @@ -4,7 +4,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_infer::{infer::type_variable::TypeVariableOriginKind, traits::ObligationCauseCode}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; -use rustc_span::{self, symbol::kw, Span}; +use rustc_span::{symbol::kw, Span}; use rustc_trait_selection::traits; use std::ops::ControlFlow; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 87c93afe54024..3997d75c3ded1 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -33,7 +33,7 @@ use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt}; use rustc_session::Session; use rustc_span::symbol::{kw, Ident}; -use rustc_span::{self, sym, BytePos, Span}; +use rustc_span::{sym, BytePos, Span}; use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext}; use std::iter; diff --git a/compiler/rustc_hir_typeck/src/inherited.rs b/compiler/rustc_hir_typeck/src/inherited.rs index 281074a851926..7a6a2b2a01029 100644 --- a/compiler/rustc_hir_typeck/src/inherited.rs +++ b/compiler/rustc_hir_typeck/src/inherited.rs @@ -9,7 +9,7 @@ use rustc_middle::traits::DefiningAnchor; use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::LocalDefIdMap; -use rustc_span::{self, Span}; +use rustc_span::Span; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use rustc_trait_selection::traits::{self, PredicateObligation, TraitEngine, TraitEngineExt as _}; diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index fcb3f8f47bd60..7d4bb6da3154c 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -4,7 +4,7 @@ use super::method::MethodCallee; use super::{has_expected_num_generic_args, FnCtxt}; use crate::Expectation; use rustc_ast as ast; -use rustc_errors::{self, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder}; +use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder}; use rustc_hir as hir; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::traits::ObligationCauseCode; diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index eaf83b7ee5f4d..0f2194139dfcf 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -32,7 +32,6 @@ use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; -use std::iter::FromIterator; use thin_vec::ThinVec; const LOADED_FROM_DISK: Symbol = sym::loaded_from_disk; diff --git a/compiler/rustc_infer/src/errors/note_and_explain.rs b/compiler/rustc_infer/src/errors/note_and_explain.rs index 3ee4710bdef62..68bf36a1615dd 100644 --- a/compiler/rustc_infer/src/errors/note_and_explain.rs +++ b/compiler/rustc_infer/src/errors/note_and_explain.rs @@ -1,6 +1,6 @@ use crate::fluent_generated as fluent; use crate::infer::error_reporting::nice_region_error::find_anon_type; -use rustc_errors::{self, AddToDiagnostic, Diagnostic, IntoDiagnosticArg, SubdiagnosticMessage}; +use rustc_errors::{AddToDiagnostic, Diagnostic, IntoDiagnosticArg, SubdiagnosticMessage}; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::{symbol::kw, Span}; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 88212d164bc04..ee9afb679ac80 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -22,7 +22,7 @@ use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt}; use rustc_middle::util::Providers; use rustc_mir_build as mir_build; use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str, validate_attr}; -use rustc_passes::{self, abi_test, hir_stats, layout_test}; +use rustc_passes::{abi_test, hir_stats, layout_test}; use rustc_resolve::Resolver; use rustc_session::code_stats::VTableSizeInfo; use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType}; diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 8932200c5b7b1..14bd4845c6d71 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -40,7 +40,6 @@ use crate::{ }, EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext, }; -use rustc_ast::attr; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast::visit::{FnCtxt, FnKind}; use rustc_ast::{self as ast, *}; diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 8e95a71e11f1e..83414ee702feb 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -94,9 +94,6 @@ pub use array_into_iter::ARRAY_INTO_ITER; use rustc_hir::def_id::LocalModDefId; use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; -use rustc_session::lint::builtin::{ - BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, -}; use array_into_iter::ArrayIntoIter; use async_fn_in_trait::AsyncFnInTrait; diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index 2893937fc4a35..a6396ba687d11 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -1,6 +1,6 @@ -use proc_macro2::{self, Ident}; +use proc_macro2::Ident; use quote::quote; -use syn::{self, parse_quote}; +use syn::parse_quote; struct Attributes { ignore: bool, diff --git a/compiler/rustc_macros/src/lift.rs b/compiler/rustc_macros/src/lift.rs index ad7ac74041749..3dedd88fb19b6 100644 --- a/compiler/rustc_macros/src/lift.rs +++ b/compiler/rustc_macros/src/lift.rs @@ -1,5 +1,5 @@ use quote::quote; -use syn::{self, parse_quote}; +use syn::parse_quote; pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { s.add_bounds(synstructure::AddBounds::Generics); diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 5725a759fef80..89d10fea72970 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1,44 +1,34 @@ // Decoding metadata from a single crate's metadata -use crate::creader::{CStore, CrateMetadataRef}; +use crate::creader::CStore; use crate::rmeta::table::IsDefault; use crate::rmeta::*; use rustc_ast as ast; use rustc_data_structures::captures::Captures; -use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::owned_slice::OwnedSlice; -use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceLock}; use rustc_data_structures::unhash::UnhashMap; use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro}; -use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap, Res}; -use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE}; -use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash}; +use rustc_hir::def::Res; +use rustc_hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE}; +use rustc_hir::definitions::{DefPath, DefPathData}; use rustc_hir::diagnostic_items::DiagnosticItems; -use rustc_index::{Idx, IndexVec}; -use rustc_middle::metadata::ModChild; -use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; -use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo}; +use rustc_index::Idx; use rustc_middle::middle::lib_features::LibFeatures; use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState}; use rustc_middle::ty::codec::TyDecoder; -use rustc_middle::ty::fast_reject::SimplifiedType; -use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility}; +use rustc_middle::ty::Visibility; use rustc_serialize::opaque::MemDecoder; use rustc_serialize::{Decodable, Decoder}; -use rustc_session::cstore::{ - CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib, -}; +use rustc_session::cstore::{CrateSource, ExternCrate}; use rustc_session::Session; -use rustc_span::hygiene::ExpnIndex; -use rustc_span::symbol::{kw, Ident, Symbol}; -use rustc_span::{self, BytePos, ExpnId, Pos, Span, SpanData, SyntaxContext, DUMMY_SP}; +use rustc_span::symbol::kw; +use rustc_span::{BytePos, Pos, SpanData, SyntaxContext, DUMMY_SP}; use proc_macro::bridge::client::ProcMacro; use std::iter::TrustedLen; -use std::num::NonZeroUsize; use std::path::Path; use std::sync::atomic::Ordering; use std::{io, iter, mem}; diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 765bb7a362e5a..af6187b293381 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1,51 +1,37 @@ use crate::errors::{FailCreateFileEncoder, FailWriteFile}; -use crate::rmeta::def_path_hash_map::DefPathHashMapRef; -use crate::rmeta::table::TableBuilder; use crate::rmeta::*; -use rustc_ast::expand::StrippedCfgItem; use rustc_ast::Attribute; use rustc_data_structures::fingerprint::Fingerprint; -use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; +use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::memmap::{Mmap, MmapMut}; use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher}; use rustc_data_structures::sync::{join, par_for_each_in, Lrc}; use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_hir as hir; -use rustc_hir::def::DefKind; -use rustc_hir::def_id::{ - CrateNum, DefId, DefIndex, LocalDefId, LocalDefIdSet, CRATE_DEF_ID, CRATE_DEF_INDEX, - LOCAL_CRATE, -}; +use rustc_hir::def_id::{LocalDefId, LocalDefIdSet, CRATE_DEF_ID, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::DefPathData; -use rustc_hir::lang_items::LangItem; use rustc_hir_pretty::id_to_string; -use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::middle::dependency_format::Linkage; -use rustc_middle::middle::exported_symbols::{ - metadata_symbol_name, ExportedSymbol, SymbolExportInfo, -}; -use rustc_middle::middle::lib_features::FeatureStability; +use rustc_middle::middle::exported_symbols::metadata_symbol_name; use rustc_middle::mir::interpret; use rustc_middle::query::LocalCrate; use rustc_middle::query::Providers; use rustc_middle::traits::specialization_graph; use rustc_middle::ty::codec::TyEncoder; -use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams}; -use rustc_middle::ty::{self, AssocItemContainer, SymbolName, Ty, TyCtxt}; +use rustc_middle::ty::fast_reject::{self, TreatParams}; +use rustc_middle::ty::{AssocItemContainer, SymbolName}; use rustc_middle::util::common::to_readable_str; use rustc_serialize::{opaque, Decodable, Decoder, Encodable, Encoder}; use rustc_session::config::{CrateType, OptLevel}; -use rustc_session::cstore::{ForeignModule, LinkagePreference, NativeLib}; -use rustc_span::hygiene::{ExpnIndex, HygieneEncodeContext, MacroKind}; -use rustc_span::symbol::{sym, Symbol}; -use rustc_span::{self, ExternalSource, FileName, SourceFile, Span, SpanData, SyntaxContext}; +use rustc_span::hygiene::HygieneEncodeContext; +use rustc_span::symbol::sym; +use rustc_span::{ExternalSource, FileName, SourceFile, SpanData, SyntaxContext}; use std::borrow::Borrow; use std::collections::hash_map::Entry; use std::fs::File; use std::hash::Hash; use std::io::{Read, Seek, Write}; -use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; pub(super) struct EncodeContext<'a, 'tcx> { diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 7cdbcd9193cf7..3fc6d9db331ac 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -1,13 +1,8 @@ use crate::rmeta::*; use rustc_data_structures::fingerprint::Fingerprint; -use rustc_hir::def::{CtorKind, CtorOf}; +use rustc_hir::def::CtorOf; use rustc_index::Idx; -use rustc_middle::ty::{ParameterizedOverTcx, UnusedGenericParams}; -use rustc_serialize::opaque::FileEncoder; -use rustc_span::hygiene::MacroKind; -use std::marker::PhantomData; -use std::num::NonZeroUsize; pub(super) trait IsDefault: Default { fn is_default(&self) -> bool; diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index f407d30ac82a3..d376036d83221 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -10,7 +10,7 @@ use rustc_data_structures::sync::{par_for_each_in, try_par_for_each_in, DynSend, use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, DefPathHash}; -use rustc_hir::intravisit::{self, Visitor}; +use rustc_hir::intravisit::Visitor; use rustc_hir::*; use rustc_index::Idx; use rustc_middle::hir::nested_filter; diff --git a/compiler/rustc_middle/src/middle/limits.rs b/compiler/rustc_middle/src/middle/limits.rs index d4f023958d6fd..b29be92ae2663 100644 --- a/compiler/rustc_middle/src/middle/limits.rs +++ b/compiler/rustc_middle/src/middle/limits.rs @@ -8,7 +8,6 @@ //! this via an attribute on the crate like `#![recursion_limit="22"]`. This pass //! just peeks and looks for that attribute. -use crate::bug; use crate::error::LimitInvalid; use crate::query::Providers; use rustc_ast::Attribute; diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index d38df1b720104..678939114d8c2 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -1,6 +1,5 @@ use std::fmt::{self, Debug, Display, Formatter}; -use rustc_hir; use rustc_hir::def_id::DefId; use rustc_session::RemapFileNameExt; use rustc_span::Span; diff --git a/compiler/rustc_middle/src/mir/generic_graph.rs b/compiler/rustc_middle/src/mir/generic_graph.rs index d1753427e740b..51e26ab7984cf 100644 --- a/compiler/rustc_middle/src/mir/generic_graph.rs +++ b/compiler/rustc_middle/src/mir/generic_graph.rs @@ -1,7 +1,5 @@ use gsgdt::{Edge, Graph, Node, NodeStyle}; -use rustc_hir::def_id::DefId; use rustc_middle::mir::*; -use rustc_middle::ty::TyCtxt; /// Convert an MIR function into a gsgdt Graph pub fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Graph { diff --git a/compiler/rustc_middle/src/mir/graphviz.rs b/compiler/rustc_middle/src/mir/graphviz.rs index 5c7de86443008..96bef40dac51a 100644 --- a/compiler/rustc_middle/src/mir/graphviz.rs +++ b/compiler/rustc_middle/src/mir/graphviz.rs @@ -1,9 +1,6 @@ use gsgdt::GraphvizSettings; use rustc_graphviz as dot; -use rustc_hir::def_id::DefId; use rustc_middle::mir::*; -use rustc_middle::ty::{self, TyCtxt}; -use std::fmt::Debug; use std::io::{self, Write}; use super::generic_graph::mir_fn_to_generic_graph; diff --git a/compiler/rustc_middle/src/mir/patch.rs b/compiler/rustc_middle/src/mir/patch.rs index eb4aa9eb95c28..b81e9fa1aab64 100644 --- a/compiler/rustc_middle/src/mir/patch.rs +++ b/compiler/rustc_middle/src/mir/patch.rs @@ -1,7 +1,4 @@ -use rustc_index::{Idx, IndexVec}; use rustc_middle::mir::*; -use rustc_middle::ty::Ty; -use rustc_span::Span; /// This struct represents a patch to MIR, which can add /// new statements and basic blocks and patch over block diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 1974a35cb85c6..9fccdfd771301 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1,23 +1,18 @@ use std::collections::BTreeSet; -use std::fmt::{self, Debug, Display, Write as _}; +use std::fmt::{Display, Write as _}; use std::fs; use std::io::{self, Write as _}; use std::path::{Path, PathBuf}; use super::graphviz::write_mir_fn_graphviz; use super::spanview::write_mir_fn_spanview; -use either::Either; use rustc_ast::InlineAsmTemplatePiece; -use rustc_data_structures::fx::FxHashMap; -use rustc_hir::def_id::DefId; -use rustc_index::Idx; use rustc_middle::mir::interpret::{ - alloc_range, read_target_uint, AllocBytes, AllocId, Allocation, ConstAllocation, GlobalAlloc, - Pointer, Provenance, + alloc_range, read_target_uint, AllocBytes, AllocId, Allocation, GlobalAlloc, Pointer, + Provenance, }; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::{self, *}; -use rustc_middle::ty::{self, TyCtxt}; use rustc_target::abi::Size; const INDENT: &str = " "; diff --git a/compiler/rustc_middle/src/mir/spanview.rs b/compiler/rustc_middle/src/mir/spanview.rs index 46e5c74c73c94..cb9fc0d37f2e0 100644 --- a/compiler/rustc_middle/src/mir/spanview.rs +++ b/compiler/rustc_middle/src/mir/spanview.rs @@ -1,9 +1,7 @@ -use rustc_hir::def_id::DefId; use rustc_middle::hir; use rustc_middle::mir::*; -use rustc_middle::ty::TyCtxt; use rustc_session::config::MirSpanview; -use rustc_span::{BytePos, Pos, Span}; +use rustc_span::{BytePos, Pos}; use std::cmp; use std::io::{self, Write}; diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 0fc12586948d8..f9b2a6ee8aacb 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -4,9 +4,7 @@ */ use crate::mir::*; -use crate::ty::{self, Ty, TyCtxt}; use rustc_hir as hir; -use rustc_target::abi::{FieldIdx, VariantIdx}; #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)] pub struct PlaceTy<'tcx> { diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index 9a6ac6ff57a4e..1270840e75e61 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -2,9 +2,8 @@ use rustc_hir::LangItem; use smallvec::SmallVec; -use super::{BasicBlock, InlineAsmOperand, Operand, SourceInfo, TerminatorKind, UnwindAction}; +use super::TerminatorKind; use rustc_macros::HashStable; -use std::iter; use std::slice; use super::*; diff --git a/compiler/rustc_middle/src/mir/type_foldable.rs b/compiler/rustc_middle/src/mir/type_foldable.rs index d5c81b6cd7930..ea6b44d62b0fe 100644 --- a/compiler/rustc_middle/src/mir/type_foldable.rs +++ b/compiler/rustc_middle/src/mir/type_foldable.rs @@ -3,7 +3,6 @@ use rustc_ast::InlineAsmTemplatePiece; use super::*; -use crate::ty; TrivialTypeTraversalImpls! { BlockTailInfo, diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index d47cfd5712f8b..9059936f49554 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -63,9 +63,7 @@ //! `is_cleanup` above. use crate::mir::*; -use crate::ty::GenericArgsRef; -use crate::ty::{self, CanonicalUserTypeAnnotation, Ty}; -use rustc_span::Span; +use crate::ty::CanonicalUserTypeAnnotation; macro_rules! make_mir_visitor { ($visitor_trait_name:ident, $($mutability:ident)?) => { diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index fa68923b2c126..63f4bab7914ed 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -10,7 +10,7 @@ use rustc_data_structures::intern::Interned; use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; use rustc_hir::def_id::DefId; use rustc_macros::HashStable; -use rustc_serialize::{self, Decodable, Encodable}; +use rustc_serialize::{Decodable, Encodable}; use rustc_type_ir::WithCachedTypeInfo; use smallvec::SmallVec; diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 4d8ac19dbe21d..dd46785ec77a3 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -2,7 +2,7 @@ use crate::error::UnsupportedFnAbi; use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::query::TyCtxtAt; use crate::ty::normalize_erasing_regions::NormalizationError; -use crate::ty::{self, ConstKind, ReprOptions, Ty, TyCtxt, TypeVisitableExt}; +use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_error_messages::DiagnosticMessage; use rustc_errors::{ DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg, diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index d50743bc2075f..c71f274b2b53a 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2,19 +2,18 @@ use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar use crate::query::IntoQueryParam; use crate::query::Providers; use crate::traits::util::supertraits_for_pretty_printing; +use crate::ty::GenericArgKind; use crate::ty::{ - self, ConstInt, ParamConst, ScalarInt, Term, TermKind, Ty, TyCtxt, TypeFoldable, - TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, + ConstInt, ParamConst, ScalarInt, Term, TermKind, TypeFoldable, TypeSuperFoldable, + TypeSuperVisitable, TypeVisitable, TypeVisitableExt, }; -use crate::ty::{GenericArg, GenericArgKind}; use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; -use rustc_data_structures::sso::SsoHashSet; use rustc_hir as hir; use rustc_hir::def::{self, CtorKind, DefKind, Namespace}; -use rustc_hir::def_id::{DefId, DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE}; -use rustc_hir::definitions::{DefKey, DefPathData, DefPathDataName, DisambiguatedDefPathData}; +use rustc_hir::def_id::{DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE}; +use rustc_hir::definitions::{DefKey, DefPathDataName}; use rustc_hir::LangItem; use rustc_session::config::TrimmedDefPaths; use rustc_session::cstore::{ExternCrate, ExternCrateSource}; diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 2130dbdc033ed..a5f6bb12ee457 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -10,8 +10,6 @@ use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; use rustc_hir::lang_items::LangItem; use rustc_middle::middle::region; use rustc_middle::mir::interpret::Scalar; -use rustc_middle::mir::AssertKind; -use rustc_middle::mir::Place; use rustc_middle::mir::*; use rustc_middle::thir::*; use rustc_middle::ty::cast::{mir_cast_kind, CastTy}; diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index bbaa02233e571..9da1a5b45c2d1 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -1,6 +1,6 @@ use crate::build::ExprCategory; use crate::errors::*; -use rustc_middle::thir::visit::{self, Visitor}; +use rustc_middle::thir::visit::Visitor; use rustc_hir as hir; use rustc_middle::mir::BorrowKind; diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 8060271390568..0e88dd80e24a3 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -14,7 +14,7 @@ use rustc_hir as hir; use rustc_hir::def::*; use rustc_hir::def_id::LocalDefId; use rustc_hir::HirId; -use rustc_middle::thir::visit::{self, Visitor}; +use rustc_middle::thir::visit::Visitor; use rustc_middle::thir::*; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt}; diff --git a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs index 2b3d423ea61ae..dfc7a9891f921 100644 --- a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs +++ b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_ast::InlineAsmOptions; use rustc_middle::mir::*; use rustc_middle::ty::layout; diff --git a/compiler/rustc_mir_transform/src/add_call_guards.rs b/compiler/rustc_mir_transform/src/add_call_guards.rs index b814fbf32b141..a47c8d94bba22 100644 --- a/compiler/rustc_mir_transform/src/add_call_guards.rs +++ b/compiler/rustc_mir_transform/src/add_call_guards.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_index::{Idx, IndexVec}; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs b/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs index ef2a0c790e945..de6d20ae3e807 100644 --- a/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs +++ b/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs @@ -2,7 +2,6 @@ use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; use crate::util; -use crate::MirPass; use rustc_middle::mir::patch::MirPatch; /// This pass moves values being dropped that are within a packed diff --git a/compiler/rustc_mir_transform/src/add_retag.rs b/compiler/rustc_mir_transform/src/add_retag.rs index 75473ca53fb3d..94077c63057c8 100644 --- a/compiler/rustc_mir_transform/src/add_retag.rs +++ b/compiler/rustc_mir_transform/src/add_retag.rs @@ -4,7 +4,6 @@ //! of MIR building, and only after this pass we think of the program has having the //! normal MIR semantics. -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; diff --git a/compiler/rustc_mir_transform/src/add_subtyping_projections.rs b/compiler/rustc_mir_transform/src/add_subtyping_projections.rs index e5be7c0ca76e2..04204c68f7b76 100644 --- a/compiler/rustc_mir_transform/src/add_subtyping_projections.rs +++ b/compiler/rustc_mir_transform/src/add_subtyping_projections.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_index::IndexVec; use rustc_middle::mir::patch::MirPatch; use rustc_middle::mir::visit::MutVisitor; diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs index 42b2f18869c22..9eec724ef21b9 100644 --- a/compiler/rustc_mir_transform/src/check_alignment.rs +++ b/compiler/rustc_mir_transform/src/check_alignment.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_hir::lang_items::LangItem; use rustc_index::IndexVec; use rustc_middle::mir::*; diff --git a/compiler/rustc_mir_transform/src/const_goto.rs b/compiler/rustc_mir_transform/src/const_goto.rs index fd2d37dbea518..3884346076eea 100644 --- a/compiler/rustc_mir_transform/src/const_goto.rs +++ b/compiler/rustc_mir_transform/src/const_goto.rs @@ -17,7 +17,6 @@ //! } //! ``` -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; use rustc_middle::{mir::visit::Visitor, ty::ParamEnv}; diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index 9a16003bdc9ae..9c3257387d235 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -18,7 +18,6 @@ use rustc_target::abi::{self, HasDataLayout, Size, TargetDataLayout}; use rustc_target::spec::abi::Abi as CallAbi; use crate::dataflow_const_prop::Patch; -use crate::MirPass; use rustc_const_eval::interpret::{ self, compile_time_machine, AllocId, ConstAllocation, FnArg, Frame, ImmTy, Immediate, InterpCx, InterpResult, MemoryKind, OpTy, PlaceTy, Pointer, Scalar, StackPopCleanup, diff --git a/compiler/rustc_mir_transform/src/copy_prop.rs b/compiler/rustc_mir_transform/src/copy_prop.rs index 74009496e75d4..0119b95cced97 100644 --- a/compiler/rustc_mir_transform/src/copy_prop.rs +++ b/compiler/rustc_mir_transform/src/copy_prop.rs @@ -6,7 +6,6 @@ use rustc_middle::ty::TyCtxt; use rustc_mir_dataflow::impls::borrowed_locals; use crate::ssa::SsaLocals; -use crate::MirPass; /// Unify locals that copy each other. /// diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 1cb1a9886a09d..230bb651c63f5 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -56,7 +56,6 @@ use crate::deref_separator::deref_finder; use crate::errors; use crate::pass_manager as pm; use crate::simplify; -use crate::MirPass; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::pluralize; use rustc_hir as hir; @@ -64,7 +63,6 @@ use rustc_hir::lang_items::LangItem; use rustc_hir::CoroutineKind; use rustc_index::bit_set::{BitMatrix, BitSet, GrowableBitSet}; use rustc_index::{Idx, IndexVec}; -use rustc_middle::mir::dump_mir; use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::InstanceDef; @@ -74,7 +72,7 @@ use rustc_mir_dataflow::impls::{ MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive, }; use rustc_mir_dataflow::storage::always_storage_live_locals; -use rustc_mir_dataflow::{self, Analysis}; +use rustc_mir_dataflow::Analysis; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::symbol::sym; use rustc_span::Span; diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs index 809407f897db8..dfc7c3a713bc2 100644 --- a/compiler/rustc_mir_transform/src/coverage/query.rs +++ b/compiler/rustc_mir_transform/src/coverage/query.rs @@ -2,9 +2,9 @@ use super::*; use rustc_data_structures::captures::Captures; use rustc_middle::mir::coverage::*; -use rustc_middle::mir::{Body, Coverage, CoverageIdsInfo}; +use rustc_middle::mir::{Body, CoverageIdsInfo}; use rustc_middle::query::Providers; -use rustc_middle::ty::{self, TyCtxt}; +use rustc_middle::ty::{self}; /// A `query` provider for retrieving coverage information injected into MIR. pub(crate) fn provide(providers: &mut Providers) { diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index 21b92e6d77c89..d559936005803 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -19,7 +19,6 @@ use rustc_span::DUMMY_SP; use rustc_target::abi::{Abi, FieldIdx, Size, VariantIdx, FIRST_VARIANT}; use crate::const_prop::throw_machine_stop_str; -use crate::MirPass; // These constants are somewhat random guesses and have not been optimized. // If `tcx.sess.mir_opt_level() >= 4`, we ignore the limits (this can become very expensive). diff --git a/compiler/rustc_mir_transform/src/deduplicate_blocks.rs b/compiler/rustc_mir_transform/src/deduplicate_blocks.rs index 666293cbc3071..b40b2ec8bfdc4 100644 --- a/compiler/rustc_mir_transform/src/deduplicate_blocks.rs +++ b/compiler/rustc_mir_transform/src/deduplicate_blocks.rs @@ -3,8 +3,6 @@ use std::{collections::hash_map::Entry, hash::Hash, hash::Hasher, iter}; -use crate::MirPass; - use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::*; diff --git a/compiler/rustc_mir_transform/src/deref_separator.rs b/compiler/rustc_mir_transform/src/deref_separator.rs index 42be745701846..0e2fccc85dacd 100644 --- a/compiler/rustc_mir_transform/src/deref_separator.rs +++ b/compiler/rustc_mir_transform/src/deref_separator.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_index::IndexVec; use rustc_middle::mir::patch::MirPatch; use rustc_middle::mir::visit::NonUseContext::VarDebugInfo; diff --git a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs index 1c917a85c038e..96943435bab89 100644 --- a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs +++ b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs @@ -2,7 +2,6 @@ //! //! Box is not actually a pointer so it is incorrect to dereference it directly. -use crate::MirPass; use rustc_hir::def_id::DefId; use rustc_index::Idx; use rustc_middle::mir::patch::MirPatch; diff --git a/compiler/rustc_mir_transform/src/elaborate_drops.rs b/compiler/rustc_mir_transform/src/elaborate_drops.rs index 83517aef7e2f5..1091625c0940b 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drops.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drops.rs @@ -1,5 +1,4 @@ use crate::deref_separator::deref_finder; -use crate::MirPass; use rustc_index::bit_set::BitSet; use rustc_index::IndexVec; use rustc_middle::mir::patch::MirPatch; diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 735960f31b378..151ea0c8fca2f 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -103,7 +103,6 @@ use std::borrow::Cow; use crate::dataflow_const_prop::DummyMachine; use crate::ssa::{AssignedValue, SsaLocals}; -use crate::MirPass; use either::Either; pub struct GVN; diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 8fa2671318430..8ad804bf3e7aa 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -17,7 +17,6 @@ use rustc_target::spec::abi::Abi; use crate::cost_checker::CostChecker; use crate::simplify::{remove_dead_blocks, CfgSimplifier}; use crate::util; -use crate::MirPass; use std::iter; use std::ops::{Range, RangeFrom}; diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 7a844b01707d1..4f0f63d22a4d4 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -1,8 +1,6 @@ //! Performs various peephole optimizations. use crate::simplify::simplify_duplicate_switch_targets; -use crate::MirPass; -use rustc_hir::Mutability; use rustc_middle::mir::*; use rustc_middle::ty::layout::ValidityRequirement; use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt}; diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 5754dd08164e6..36a15f472761e 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -45,7 +45,6 @@ use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt}; use rustc_mir_dataflow::value_analysis::{Map, PlaceIndex, State, TrackElem}; use crate::cost_checker::CostChecker; -use crate::MirPass; pub struct JumpThreading; diff --git a/compiler/rustc_mir_transform/src/large_enums.rs b/compiler/rustc_mir_transform/src/large_enums.rs index 0a8b13d6677ad..1d788a55ff82f 100644 --- a/compiler/rustc_mir_transform/src/large_enums.rs +++ b/compiler/rustc_mir_transform/src/large_enums.rs @@ -1,5 +1,4 @@ use crate::rustc_middle::ty::util::IntTypeExt; -use crate::MirPass; use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::interpret::AllocId; use rustc_middle::mir::*; diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index 249e0fc633e88..18f588dccf62f 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -1,6 +1,5 @@ //! Lowers intrinsic calls -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::symbol::sym; diff --git a/compiler/rustc_mir_transform/src/lower_slice_len.rs b/compiler/rustc_mir_transform/src/lower_slice_len.rs index ae487841179a7..daeb56666f4d7 100644 --- a/compiler/rustc_mir_transform/src/lower_slice_len.rs +++ b/compiler/rustc_mir_transform/src/lower_slice_len.rs @@ -1,7 +1,6 @@ //! This pass lowers calls to core::slice::len to just Len op. //! It should run before inlining! -use crate::MirPass; use rustc_hir::def_id::DefId; use rustc_index::IndexSlice; use rustc_middle::mir::*; diff --git a/compiler/rustc_mir_transform/src/match_branches.rs b/compiler/rustc_mir_transform/src/match_branches.rs index 3dc627b614601..1c4aa37d57ff5 100644 --- a/compiler/rustc_mir_transform/src/match_branches.rs +++ b/compiler/rustc_mir_transform/src/match_branches.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; use std::iter; diff --git a/compiler/rustc_mir_transform/src/multiple_return_terminators.rs b/compiler/rustc_mir_transform/src/multiple_return_terminators.rs index c9b42e75cb254..64749a4b5b688 100644 --- a/compiler/rustc_mir_transform/src/multiple_return_terminators.rs +++ b/compiler/rustc_mir_transform/src/multiple_return_terminators.rs @@ -1,7 +1,7 @@ //! This pass removes jumps to basic blocks containing only a return, and replaces them with a //! return instead. -use crate::{simplify, MirPass}; +use crate::simplify; use rustc_index::bit_set::BitSet; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_mir_transform/src/normalize_array_len.rs b/compiler/rustc_mir_transform/src/normalize_array_len.rs index 206cdf9fe284d..128634bd7f254 100644 --- a/compiler/rustc_mir_transform/src/normalize_array_len.rs +++ b/compiler/rustc_mir_transform/src/normalize_array_len.rs @@ -2,7 +2,6 @@ //! is taken using `.len()` method. Handy to preserve information in MIR for const prop use crate::ssa::SsaLocals; -use crate::MirPass; use rustc_index::IndexVec; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; diff --git a/compiler/rustc_mir_transform/src/prettify.rs b/compiler/rustc_mir_transform/src/prettify.rs index 745fa30841c35..7b77d0323533e 100644 --- a/compiler/rustc_mir_transform/src/prettify.rs +++ b/compiler/rustc_mir_transform/src/prettify.rs @@ -4,7 +4,6 @@ //! (`-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals`) //! to make the MIR easier to read for humans. -use crate::MirPass; use rustc_index::{bit_set::BitSet, IndexSlice, IndexVec}; use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; use rustc_middle::mir::*; diff --git a/compiler/rustc_mir_transform/src/ref_prop.rs b/compiler/rustc_mir_transform/src/ref_prop.rs index df39c819ba9a1..f13ab5b0f1fe5 100644 --- a/compiler/rustc_mir_transform/src/ref_prop.rs +++ b/compiler/rustc_mir_transform/src/ref_prop.rs @@ -9,7 +9,6 @@ use rustc_mir_dataflow::storage::always_storage_live_locals; use rustc_mir_dataflow::Analysis; use crate::ssa::{SsaLocals, StorageLiveLocals}; -use crate::MirPass; /// Propagate references using SSA analysis. /// diff --git a/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs b/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs index 54892442c87b2..095119e2e3ff8 100644 --- a/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs +++ b/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_index::bit_set::BitSet; use rustc_middle::mir::patch::MirPatch; use rustc_middle::mir::*; diff --git a/compiler/rustc_mir_transform/src/remove_place_mention.rs b/compiler/rustc_mir_transform/src/remove_place_mention.rs index 8be1c37572d14..78335b3b5e063 100644 --- a/compiler/rustc_mir_transform/src/remove_place_mention.rs +++ b/compiler/rustc_mir_transform/src/remove_place_mention.rs @@ -1,6 +1,5 @@ //! This pass removes `PlaceMention` statement, which has no effect at codegen. -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_mir_transform/src/remove_storage_markers.rs b/compiler/rustc_mir_transform/src/remove_storage_markers.rs index dbe082e909371..795f5232ee302 100644 --- a/compiler/rustc_mir_transform/src/remove_storage_markers.rs +++ b/compiler/rustc_mir_transform/src/remove_storage_markers.rs @@ -1,6 +1,5 @@ //! This pass removes storage markers if they won't be emitted during codegen. -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_mir_transform/src/remove_uninit_drops.rs b/compiler/rustc_mir_transform/src/remove_uninit_drops.rs index 548879e2e39bf..7d12bcf2fa153 100644 --- a/compiler/rustc_mir_transform/src/remove_uninit_drops.rs +++ b/compiler/rustc_mir_transform/src/remove_uninit_drops.rs @@ -4,9 +4,7 @@ use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, VariantDef}; use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex}; -use rustc_mir_dataflow::{ - self, move_path_children_matching, Analysis, MaybeReachable, MoveDataParamEnv, -}; +use rustc_mir_dataflow::{move_path_children_matching, Analysis, MaybeReachable, MoveDataParamEnv}; use rustc_target::abi::FieldIdx; use crate::MirPass; diff --git a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs index 08b2a6537e93e..5d528bed35647 100644 --- a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs +++ b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs @@ -4,7 +4,6 @@ //! useful because (unlike MIR building) it runs after type checking, so it can make use of //! `Reveal::All` to provide more precise type information. -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_mir_transform/src/remove_zsts.rs b/compiler/rustc_mir_transform/src/remove_zsts.rs index 9f59f9d124520..34d57a45301d7 100644 --- a/compiler/rustc_mir_transform/src/remove_zsts.rs +++ b/compiler/rustc_mir_transform/src/remove_zsts.rs @@ -1,6 +1,5 @@ //! Removes operations on ZST places, and convert ZST operands to constants. -use crate::MirPass; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; diff --git a/compiler/rustc_mir_transform/src/reveal_all.rs b/compiler/rustc_mir_transform/src/reveal_all.rs index 1626cf3c035e6..4d2eca578404c 100644 --- a/compiler/rustc_mir_transform/src/reveal_all.rs +++ b/compiler/rustc_mir_transform/src/reveal_all.rs @@ -1,6 +1,5 @@ //! Normalizes MIR in RevealAll mode. -use crate::MirPass; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; diff --git a/compiler/rustc_mir_transform/src/separate_const_switch.rs b/compiler/rustc_mir_transform/src/separate_const_switch.rs index 907cfe7581a8d..6e22690d8dad5 100644 --- a/compiler/rustc_mir_transform/src/separate_const_switch.rs +++ b/compiler/rustc_mir_transform/src/separate_const_switch.rs @@ -37,7 +37,6 @@ //! simplicity rather than completeness (it notably //! sometimes duplicates abusively). -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; use smallvec::SmallVec; diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index 97d398fe5c910..856a0f227714d 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -27,7 +27,6 @@ //! naively generate still contains the `_a = ()` write in the unreachable block "after" the //! return. -use crate::MirPass; use rustc_data_structures::fx::FxIndexSet; use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor}; diff --git a/compiler/rustc_mir_transform/src/simplify_branches.rs b/compiler/rustc_mir_transform/src/simplify_branches.rs index 1f0e605c3b858..35a052166bd93 100644 --- a/compiler/rustc_mir_transform/src/simplify_branches.rs +++ b/compiler/rustc_mir_transform/src/simplify_branches.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index a4ca2b91e829b..06d5e17fdd6c6 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -1,4 +1,3 @@ -use crate::MirPass; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_index::bit_set::{BitSet, GrowableBitSet}; use rustc_index::IndexVec; diff --git a/compiler/rustc_mir_transform/src/unreachable_prop.rs b/compiler/rustc_mir_transform/src/unreachable_prop.rs index 919e8d6a2340f..f12a6aa2429c8 100644 --- a/compiler/rustc_mir_transform/src/unreachable_prop.rs +++ b/compiler/rustc_mir_transform/src/unreachable_prop.rs @@ -2,7 +2,6 @@ //! when all of their successors are unreachable. This is achieved through a //! post-order traversal of the blocks. -use crate::MirPass; use rustc_data_structures::fx::FxHashSet; use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::patch::MirPatch; diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index bad7c19cc278b..aafe42fd34931 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -7,7 +7,6 @@ use rustc_ast::attr; use rustc_ast::token::{self, Delimiter, Nonterminal}; use rustc_errors::{error_code, Diagnostic, IntoDiagnostic, PResult}; use rustc_span::{sym, BytePos, Span}; -use std::convert::TryInto; use thin_vec::ThinVec; use tracing::debug; diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 23886b1208bb4..981b33ede3eb5 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -3,18 +3,12 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken}; use crate::errors::{self, MacroExpandsToAdtField}; use crate::fluent_generated as fluent; -use ast::StaticItem; use rustc_ast::ast::*; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, TokenKind}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_ast::util::case::Case; -use rustc_ast::MacCall; -use rustc_ast::{self as ast, AttrVec, Attribute, DUMMY_NODE_ID}; -use rustc_ast::{Async, Const, Defaultness, IsAuto, Mutability, Unsafe, UseTree, UseTreeKind}; -use rustc_ast::{BindingAnnotation, Block, FnDecl, FnSig, Param, SelfKind}; -use rustc_ast::{EnumDef, FieldDef, Generics, TraitRef, Ty, TyKind, Variant, VariantData}; -use rustc_ast::{FnHeader, ForeignItem, Path, PathSegment, Visibility, VisibilityKind}; +use rustc_ast::{self as ast}; use rustc_ast_pretty::pprust; use rustc_errors::{ struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult, diff --git a/compiler/rustc_query_system/src/dep_graph/edges.rs b/compiler/rustc_query_system/src/dep_graph/edges.rs index 400f128d5833b..63d46f47f5ce6 100644 --- a/compiler/rustc_query_system/src/dep_graph/edges.rs +++ b/compiler/rustc_query_system/src/dep_graph/edges.rs @@ -1,7 +1,6 @@ use crate::dep_graph::DepNodeIndex; use smallvec::SmallVec; use std::hash::{Hash, Hasher}; -use std::iter::Extend; use std::ops::Deref; #[derive(Default, Debug)] diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 2a55ec72c5f70..7f32d02794803 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -15,6 +15,7 @@ use std::hash::Hash; use std::io::Write; use std::num::NonZeroU64; +#[allow(unused_imports)] #[cfg(parallel_compiler)] use { parking_lot::{Condvar, Mutex}, diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 65901eedb2148..e5cc321814692 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -8,11 +8,11 @@ use crate::def_collector::collect_definitions; use crate::imports::{ImportData, ImportKind}; use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; -use crate::Namespace::{self, MacroNS, TypeNS, ValueNS}; +use crate::Namespace::{MacroNS, TypeNS, ValueNS}; use crate::{errors, BindingKey, MacroData, NameBindingData}; use crate::{Determinacy, ExternPreludeEntry, Finalize, Module, ModuleKind, ModuleOrUniformRoot}; -use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PerNS, ResolutionError}; -use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, VisResolutionError}; +use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, ResolutionError}; +use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError}; use rustc_ast::visit::{self, AssocCtxt, Visitor}; use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind}; @@ -358,7 +358,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> { root_span, root_id, vis: Cell::new(Some(vis)), - used: Cell::new(false), + used: Default::default(), }); self.r.indeterminate_imports.push(import); @@ -852,7 +852,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> { span: item.span, module_path: Vec::new(), vis: Cell::new(Some(vis)), - used: Cell::new(used), + used: Cell::new(used.then_some(Used::Other)), }); self.r.potentially_unused_imports.push(import); let imported_binding = self.r.import(binding, import); @@ -1061,7 +1061,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> { span, module_path: Vec::new(), vis: Cell::new(Some(ty::Visibility::Restricted(CRATE_DEF_ID))), - used: Cell::new(false), + used: Default::default(), }) }; @@ -1225,7 +1225,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> { span, module_path: Vec::new(), vis: Cell::new(Some(vis)), - used: Cell::new(true), + used: Cell::new(Some(Used::Other)), }); let import_binding = self.r.import(binding, import); self.r.define(self.r.graph_root, ident, MacroNS, import_binding); diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 3b1f957c89099..246eb3eec9273 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -182,6 +182,27 @@ impl<'a, 'b, 'tcx> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b, 'tcx> { } } else { self.check_import(id); + let import = self.r.redundant_imports.remove(&id); + if let Some(import) = import { + if let ImportKind::Single { + source, + target, + ref source_bindings, + ref target_bindings, + .. + } = import.kind + && !self.unused_imports.contains_key(&self.base_id) + && source == target + { + self.r.check_for_redundant_imports( + source, + import, + source_bindings, + target_bindings, + target, + ); + } + } } visit::walk_use_tree(self, use_tree, id); @@ -286,7 +307,7 @@ impl Resolver<'_, '_> { for import in self.potentially_unused_imports.iter() { match import.kind { - _ if import.used.get() + _ if import.used.get().is_some() || import.expect_vis().is_public() || import.span.is_dummy() => { diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 224f3f36a3f56..82581cce59916 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -1,5 +1,5 @@ use crate::{ImplTraitContext, Resolver}; -use rustc_ast::visit::{self, FnKind}; +use rustc_ast::visit::FnKind; use rustc_ast::*; use rustc_expand::expand::AstFragment; use rustc_hir::def::{CtorKind, CtorOf, DefKind}; diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 6c387a385e640..c7cdeab070090 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -33,8 +33,8 @@ use crate::errors::{ }; use crate::imports::{Import, ImportKind}; use crate::late::{PatternSource, Rib}; -use crate::path_names_to_string; use crate::{errors as errs, BindingKey}; +use crate::{path_names_to_string, Used}; use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingError, Finalize}; use crate::{HasGenericParams, MacroRulesScope, Module, ModuleKind, ModuleOrUniformRoot}; use crate::{LexicalScopeBinding, NameBinding, NameBindingKind, PrivacyError, VisResolutionError}; @@ -1482,7 +1482,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ); // Silence the 'unused import' warning we might get, // since this diagnostic already covers that import. - self.record_use(ident, binding, false); + self.record_use(ident, binding, Some(Used::Other)); return; } } diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index a069c6f8e0436..c8ab79e4e524f 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -14,8 +14,8 @@ use crate::late::{ ConstantHasGenerics, HasGenericParams, NoConstantGenericsReason, PathSource, Rib, RibKind, }; use crate::macros::{sub_namespace_match, MacroRulesScope}; -use crate::BindingKey; use crate::{errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize}; +use crate::{BindingKey, Used}; use crate::{ImportKind, LexicalScopeBinding, Module, ModuleKind, ModuleOrUniformRoot}; use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PrivacyError, Res}; use crate::{ResolutionError, Resolver, Scope, ScopeSet, Segment, ToNameBinding, Weak}; @@ -335,7 +335,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ModuleKind::Block => {} // We can see through blocks _ => break, } - let item = self.resolve_ident_in_module_unadjusted( ModuleOrUniformRoot::Module(module), ident, @@ -343,6 +342,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { parent_scope, finalize, ignore_binding, + None, ); if let Ok(binding) = item { // The ident resolves to an item. @@ -509,6 +509,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { !matches!(scope_set, ScopeSet::Late(..)), finalize, ignore_binding, + Some(Used::Scope), ); match binding { Ok(binding) => { @@ -579,6 +580,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { parent_scope, None, ignore_binding, + Some(Used::Other), ) { if use_prelude || this.is_builtin_macro(binding.res()) { result = Ok((binding, Flags::MISC_FROM_PRELUDE)); @@ -754,6 +756,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { false, finalize, ignore_binding, + Some(Used::Other), ) } @@ -766,6 +769,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { parent_scope: &ParentScope<'a>, finalize: Option, ignore_binding: Option>, + used: Option, ) -> Result, Determinacy> { self.resolve_ident_in_module_unadjusted_ext( module, @@ -775,6 +779,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { false, finalize, ignore_binding, + used, ) .map_err(|(determinacy, _)| determinacy) } @@ -793,6 +798,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // This binding should be ignored during in-module resolution, so that we don't get // "self-confirming" import resolutions during import validation and checking. ignore_binding: Option>, + used: Option, ) -> Result, (Determinacy, Weak)> { let module = match module { ModuleOrUniformRoot::Module(module) => module, @@ -849,7 +855,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let key = BindingKey::new(ident, ns); let resolution = self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports. - // If the primary binding is unusable, search further and return the shadowed glob // binding if it exists. What we really want here is having two separate scopes in // a module - one for non-globs and one for globs, but until that's done use this @@ -857,7 +862,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let binding = [resolution.binding, resolution.shadowed_glob] .into_iter() .find_map(|binding| if binding == ignore_binding { None } else { binding }); - if let Some(Finalize { path_span, report_private, .. }) = finalize { let Some(binding) = binding else { return Err((Determined, Weak::No)); @@ -901,8 +905,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.macro_expanded_macro_export_errors.insert((path_span, binding.span)); } } - - self.record_use(ident, binding, restricted_shadowing); + self.record_use(ident, binding, used); return Ok(binding); } @@ -923,6 +926,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Check if one of single imports can still define the name, // if it can then our result is not determined and can be invalidated. for single_import in &resolution.single_imports { + debug!("single_import:{:?}", single_import); let Some(import_vis) = single_import.vis.get() else { continue; }; @@ -1029,6 +1033,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { adjusted_parent_scope, None, ignore_binding, + Some(Used::Other), ); match result { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 3774ae6642004..756b91c4506f4 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -10,9 +10,9 @@ use crate::errors::{ use crate::Determinacy::{self, *}; use crate::{fluent_generated as fluent, Namespace::*}; use crate::{module_to_string, names_to_string, ImportSuggestion}; -use crate::{AmbiguityKind, BindingKey, ModuleKind, ResolutionError, Resolver, Segment}; +use crate::{AmbiguityKind, BindingKey, ResolutionError, Resolver, Segment}; use crate::{Finalize, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet}; -use crate::{NameBinding, NameBindingData, NameBindingKind, PathResult}; +use crate::{NameBinding, NameBindingData, NameBindingKind, PathResult, Used}; use rustc_ast::NodeId; use rustc_data_structures::fx::FxHashSet; @@ -169,7 +169,7 @@ pub(crate) struct ImportData<'a> { /// The resolution of `module_path`. pub imported_module: Cell>>, pub vis: Cell>, - pub used: Cell, + pub used: Cell>, } /// All imports are unique and allocated on a same arena, @@ -282,7 +282,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } self.arenas.alloc_name_binding(NameBindingData { - kind: NameBindingKind::Import { binding, import, used: Cell::new(false) }, + kind: NameBindingKind::Import { binding, import }, ambiguity: None, warn_ambiguity: false, span: import.span, @@ -478,9 +478,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let key = BindingKey::new(target, ns); let _ = this.try_define(import.parent_scope.module, key, dummy_binding, false); }); - self.record_use(target, dummy_binding, false); + self.record_use(target, dummy_binding, Some(Used::Other)); } else if import.imported_module.get().is_none() { - import.used.set(true); + import.used.set(Some(Used::Other)); if let Some(id) = import.id() { self.used_imports.insert(id); } @@ -1040,11 +1040,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { && initial_binding.is_extern_crate() && !initial_binding.is_import() { - this.record_use( - ident, - target_binding, - import.module_path.is_empty(), - ); + let used = if import.module_path.is_empty() { + Used::Scope + } else { + Used::Other + }; + this.record_use(ident, target_binding, Some(used)); } } initial_binding.res() @@ -1291,14 +1292,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { this.import_res_map.entry(import_id).or_default()[ns] = Some(binding.res()); } }); - - self.check_for_redundant_imports(ident, import, source_bindings, target_bindings, target); + if let ImportKind::Single { id, .. } = import.kind { + debug!("redundant_imports insert id:{:?} import:{:?}", id, import); + self.redundant_imports.insert(id, import); + } debug!("(resolving single import) successfully resolved import"); None } - fn check_for_redundant_imports( + pub(crate) fn check_for_redundant_imports( &mut self, ident: Ident, import: Import<'a>, @@ -1313,13 +1316,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { if import.parent_scope.expansion != LocalExpnId::ROOT { return; } - // Skip if we are inside a named module (in contrast to an anonymous // module defined by a block). - if let ModuleKind::Def(..) = import.parent_scope.module.kind { + // Skip if the import is public or was used through non scope-based resolution, + // e.g. through a module-relative path. + if self.effective_visibilities.is_exported(self.local_def_id(import.root_id)) + || import.used.get() == Some(Used::Other) + { return; } - let mut is_redundant = PerNS { value_ns: None, type_ns: None, macro_ns: None }; let mut redundant_span = PerNS { value_ns: None, type_ns: None, macro_ns: None }; @@ -1348,7 +1353,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } }); - if !is_redundant.is_empty() && is_redundant.present_items().all(|is_redundant| is_redundant) { let mut redundant_spans: Vec<_> = redundant_span.present_items().collect(); @@ -1372,7 +1376,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.tcx.sess.create_err(CannotGlobImportAllCrates { span: import.span }).emit(); return; }; - if module.is_trait() { self.tcx.sess.create_err(ItemsInTraitsAreNotImportable { span: import.span }).emit(); return; diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 75a0541b89be4..37ba02b8b4ad2 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -7,20 +7,20 @@ //! `build_reduced_graph.rs`, `macros.rs` and `imports.rs`. use crate::errors::ImportsCannotReferTo; -use crate::BindingKey; use crate::{path_names_to_string, rustdoc, BindingError, Finalize, LexicalScopeBinding}; +use crate::{BindingKey, Used}; use crate::{Module, ModuleOrUniformRoot, NameBinding, ParentScope, PathResult}; use crate::{ResolutionError, Resolver, Segment, UseError}; use rustc_ast::ptr::P; -use rustc_ast::visit::{self, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; +use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; use rustc_ast::*; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_errors::{Applicability, DiagnosticArgValue, DiagnosticId, IntoDiagnosticArg}; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS}; use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE}; -use rustc_hir::{BindingAnnotation, PrimTy, TraitCandidate}; +use rustc_hir::{PrimTy, TraitCandidate}; use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::{bug, span_bug}; use rustc_session::config::{CrateType, ResolveDocLinks}; @@ -3482,7 +3482,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { // whether they can be shadowed by fresh bindings or not, so force an error. // issues/33118#issuecomment-233962221 (see below) still applies here, // but we have to ignore it for backward compatibility. - self.r.record_use(ident, binding, false); + self.r.record_use(ident, binding, Some(Used::Other)); return None; } LexicalScopeBinding::Item(binding) => (binding.res(), Some(binding)), @@ -3497,7 +3497,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { ) if is_syntactic_ambiguity => { // Disambiguate in favor of a unit struct/variant or constant pattern. if let Some(binding) = binding { - self.r.record_use(ident, binding, false); + self.r.record_use(ident, binding, Some(Used::Other)); } Some(res) } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 208391cc0199f..40c9847eb94cf 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -175,6 +175,12 @@ enum ImplTraitContext { Universal, } +#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)] +enum Used { + Scope, + Other, +} + #[derive(Debug)] struct BindingError { name: Symbol, @@ -684,7 +690,7 @@ impl<'a> ToNameBinding<'a> for NameBinding<'a> { enum NameBindingKind<'a> { Res(Res), Module(Module<'a>), - Import { binding: NameBinding<'a>, import: Import<'a>, used: Cell }, + Import { binding: NameBinding<'a>, import: Import<'a> }, } impl<'a> NameBindingKind<'a> { @@ -962,6 +968,9 @@ pub struct Resolver<'a, 'tcx> { /// All non-determined imports. indeterminate_imports: Vec>, + /// Imports for redundant check. + redundant_imports: FxHashMap>, + // Spans for local variables found during pattern resolution. // Used for suggestions during error reporting. pat_span_map: NodeMap, @@ -1346,6 +1355,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { determined_imports: Vec::new(), indeterminate_imports: Vec::new(), + redundant_imports: FxHashMap::default(), + pat_span_map: Default::default(), partial_res_map: Default::default(), import_res_map: Default::default(), @@ -1758,15 +1769,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { false } - fn record_use(&mut self, ident: Ident, used_binding: NameBinding<'a>, is_lexical_scope: bool) { - self.record_use_inner(ident, used_binding, is_lexical_scope, used_binding.warn_ambiguity); + fn record_use(&mut self, ident: Ident, used_binding: NameBinding<'a>, used: Option) { + self.record_use_inner(ident, used_binding, used, used_binding.warn_ambiguity); } fn record_use_inner( &mut self, ident: Ident, used_binding: NameBinding<'a>, - is_lexical_scope: bool, + used: Option, warn_ambiguity: bool, ) { if let Some((b2, kind)) = used_binding.ambiguity { @@ -1784,23 +1795,30 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.ambiguity_errors.push(ambiguity_error); } } - if let NameBindingKind::Import { import, binding, ref used } = used_binding.kind { + if let NameBindingKind::Import { import, binding } = used_binding.kind { // Avoid marking `extern crate` items that refer to a name from extern prelude, // but not introduce it, as used if they are accessed from lexical scope. - if is_lexical_scope { + if used == Some(Used::Scope) { if let Some(entry) = self.extern_prelude.get(&ident.normalize_to_macros_2_0()) { if !entry.introduced_by_item && entry.binding == Some(used_binding) { return; } } } - used.set(true); - import.used.set(true); + let old_used = import.used.get(); + if used > old_used { + import.used.set(used); + } if let Some(id) = import.id() { self.used_imports.insert(id); } self.add_to_glob_map(import, ident); - self.record_use_inner(ident, binding, false, warn_ambiguity || binding.warn_ambiguity); + self.record_use_inner( + ident, + binding, + Some(Used::Other), + warn_ambiguity || binding.warn_ambiguity, + ); } } @@ -1955,7 +1973,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { if !entry.is_import() { self.crate_loader(|c| c.process_path_extern(ident.name, ident.span)); } else if entry.introduced_by_item { - self.record_use(ident, binding, false); + self.record_use(ident, binding, Some(Used::Other)); } } binding @@ -2085,7 +2103,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let is_import = name_binding.is_import(); let span = name_binding.span; if let Res::Def(DefKind::Fn, _) = res { - self.record_use(ident, name_binding, false); + self.record_use(ident, name_binding, Some(Used::Other)); } self.main_def = Some(MainDefinition { res, is_import, span }); } diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 5f21741223bc0..a9c86941a1edb 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -6,7 +6,7 @@ use crate::errors::{ MacroExpectedFound, RemoveSurroundingDerive, }; use crate::Namespace::*; -use crate::{BuiltinMacroState, Determinacy, MacroData}; +use crate::{BuiltinMacroState, Determinacy, MacroData, Used}; use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet}; use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding}; use rustc_ast::expand::StrippedCfgItem; @@ -805,7 +805,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ) { Ok(binding) => { let initial_res = initial_binding.map(|initial_binding| { - self.record_use(ident, initial_binding, false); + self.record_use(ident, initial_binding, Some(Used::Other)); initial_binding.res() }); let res = binding.res(); diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs index 3449176f72937..8511679505f68 100644 --- a/compiler/rustc_smir/src/rustc_smir/context.rs +++ b/compiler/rustc_smir/src/rustc_smir/context.rs @@ -14,7 +14,7 @@ use stable_mir::ty::{ AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, Const, FnDef, GenericArgs, LineInfo, RigidTy, Span, TyKind, }; -use stable_mir::{self, Crate, CrateItem, Error, Filename, ItemKind, Symbol}; +use stable_mir::{Crate, CrateItem, Error, Filename, ItemKind, Symbol}; use std::cell::RefCell; use crate::rustc_internal::{internal, RustcInternal}; diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index eee587f3b2ab1..bc4dd3ee403d0 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -14,7 +14,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; use stable_mir::mir::mono::InstanceDef; use stable_mir::ty::{ConstId, Span}; -use stable_mir::{self, ItemKind}; +use stable_mir::ItemKind; use tracing::debug; use crate::rustc_internal::IndexMap; diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index dcf346acb334e..cb10e6bf2ba81 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -11,13 +11,11 @@ use crate::*; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::stable_hasher::{Hash128, Hash64, StableHasher}; -use rustc_data_structures::sync::{IntoDynSyncSend, Lrc, MappedReadGuard, ReadGuard, RwLock}; -use std::cmp; +use rustc_data_structures::sync::{IntoDynSyncSend, MappedReadGuard, ReadGuard, RwLock}; use std::fs; use std::hash::Hash; use std::io::{self, BorrowedBuf, Read}; -use std::path::{self, Path, PathBuf}; +use std::path::{self}; #[cfg(test)] mod tests; diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index d8bf97138cda4..2f239a289ba75 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -5,11 +5,9 @@ use super::*; use crate::errors::UnableToConstructConstantValue; use crate::infer::region_constraints::{Constraint, RegionConstraintData}; -use crate::infer::InferCtxt; use crate::traits::project::ProjectAndUnifyResult; use rustc_infer::infer::DefineOpaqueTypes; use rustc_middle::mir::interpret::ErrorHandled; -use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{ImplPolarity, Region, RegionVid}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 826c69ee7160b..999ba3d001909 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -8,9 +8,7 @@ use rustc_middle::ty::layout::{ IntegerExt, LayoutCx, LayoutError, LayoutOf, TyAndLayout, MAX_SIMD_LANES, }; use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::{ - self, AdtDef, EarlyBinder, GenericArgsRef, ReprOptions, Ty, TyCtxt, TypeVisitableExt, -}; +use rustc_middle::ty::{self, AdtDef, EarlyBinder, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt}; use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; use rustc_span::symbol::Symbol; use rustc_span::DUMMY_SP; diff --git a/compiler/stable_mir/src/error.rs b/compiler/stable_mir/src/error.rs index 1ff65717e87db..e9c06e69e3a95 100644 --- a/compiler/stable_mir/src/error.rs +++ b/compiler/stable_mir/src/error.rs @@ -4,7 +4,6 @@ //! - [CompilerError]: This represents errors that can be raised when invoking the compiler. //! - [Error]: Generic error that represents the reason why a request that could not be fulfilled. -use std::convert::From; use std::fmt::{Debug, Display, Formatter}; use std::{error, fmt}; diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index 321357a15bf04..2b22488b8ffc5 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -4,7 +4,7 @@ use crate::num::NonZeroUsize; use crate::{ fmt, intrinsics::transmute_unchecked, - iter::{self, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce}, + iter::{self, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce}, mem::MaybeUninit, ops::{IndexRange, Range}, ptr, diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 7ce33bdd41159..a93b94867ce4c 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -1,6 +1,5 @@ //! impl char {} -use crate::ascii; use crate::slice; use crate::str::from_utf8_unchecked_mut; use crate::unicode::printable::is_printable; diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index d7ca9c22dada8..ba86334f9505c 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -210,8 +210,6 @@ pub struct AssertParamIsCopy { /// are implemented in `traits::SelectionContext::copy_clone_conditions()` /// in `rustc_trait_selection`. mod impls { - use super::Clone; - macro_rules! impl_clone { ($($t:ty)*) => { $( diff --git a/library/core/src/convert/num.rs b/library/core/src/convert/num.rs index b048b51359208..08dc8f48dfedc 100644 --- a/library/core/src/convert/num.rs +++ b/library/core/src/convert/num.rs @@ -1,4 +1,4 @@ -use super::{From, TryFrom}; +use super::TryFrom; use crate::num::TryFromIntError; mod private { diff --git a/library/core/src/future/future.rs b/library/core/src/future/future.rs index 8c7111cb3ff0b..71b9464efd288 100644 --- a/library/core/src/future/future.rs +++ b/library/core/src/future/future.rs @@ -1,6 +1,5 @@ #![stable(feature = "futures_api", since = "1.36.0")] -use crate::marker::Unpin; use crate::ops; use crate::pin::Pin; use crate::task::{Context, Poll}; diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index f25ca9e2b1866..87052934c5c1d 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2537,6 +2537,7 @@ macro_rules! assert_unsafe_precondition { } }; } +#[allow(unused_imports)] pub(crate) use assert_unsafe_precondition; /// Checks whether `ptr` is properly aligned with respect to diff --git a/library/core/src/iter/adapters/array_chunks.rs b/library/core/src/iter/adapters/array_chunks.rs index 319af4408d76d..946d0051ccec3 100644 --- a/library/core/src/iter/adapters/array_chunks.rs +++ b/library/core/src/iter/adapters/array_chunks.rs @@ -1,7 +1,7 @@ use crate::array; use crate::iter::adapters::SourceIter; use crate::iter::{ - ByRefSized, FusedIterator, InPlaceIterable, Iterator, TrustedFused, TrustedRandomAccessNoCoerce, + ByRefSized, FusedIterator, InPlaceIterable, TrustedFused, TrustedRandomAccessNoCoerce, }; use crate::num::NonZeroUsize; use crate::ops::{ControlFlow, NeverShortCircuit, Try}; diff --git a/library/core/src/iter/adapters/chain.rs b/library/core/src/iter/adapters/chain.rs index 26aa959e6da3f..c748336cd7fa0 100644 --- a/library/core/src/iter/adapters/chain.rs +++ b/library/core/src/iter/adapters/chain.rs @@ -1,4 +1,4 @@ -use crate::iter::{DoubleEndedIterator, FusedIterator, Iterator, TrustedLen}; +use crate::iter::{FusedIterator, TrustedLen}; use crate::num::NonZeroUsize; use crate::ops::Try; diff --git a/library/core/src/iter/adapters/flatten.rs b/library/core/src/iter/adapters/flatten.rs index 09428350fd92a..6122332da0d24 100644 --- a/library/core/src/iter/adapters/flatten.rs +++ b/library/core/src/iter/adapters/flatten.rs @@ -1,7 +1,7 @@ use crate::iter::adapters::SourceIter; use crate::iter::{ - Cloned, Copied, DoubleEndedIterator, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, - Iterator, Map, TrustedFused, TrustedLen, + Cloned, Copied, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, Map, TrustedFused, + TrustedLen, }; use crate::iter::{Once, OnceWith}; use crate::num::NonZeroUsize; diff --git a/library/core/src/iter/adapters/fuse.rs b/library/core/src/iter/adapters/fuse.rs index 3234cade50dc5..462a7e8773320 100644 --- a/library/core/src/iter/adapters/fuse.rs +++ b/library/core/src/iter/adapters/fuse.rs @@ -2,8 +2,7 @@ use crate::intrinsics; use crate::iter::adapters::zip::try_get_unchecked; use crate::iter::adapters::SourceIter; use crate::iter::{ - DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedFused, TrustedLen, - TrustedRandomAccess, TrustedRandomAccessNoCoerce, + FusedIterator, TrustedFused, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, }; use crate::ops::Try; diff --git a/library/core/src/iter/adapters/map_windows.rs b/library/core/src/iter/adapters/map_windows.rs index 3c0e80b2559db..5f39b24583427 100644 --- a/library/core/src/iter/adapters/map_windows.rs +++ b/library/core/src/iter/adapters/map_windows.rs @@ -1,6 +1,6 @@ use crate::{ fmt, - iter::{ExactSizeIterator, FusedIterator}, + iter::FusedIterator, mem::{self, MaybeUninit}, ptr, }; diff --git a/library/core/src/iter/adapters/mod.rs b/library/core/src/iter/adapters/mod.rs index a691039c789c6..4037e2e2839c0 100644 --- a/library/core/src/iter/adapters/mod.rs +++ b/library/core/src/iter/adapters/mod.rs @@ -1,4 +1,4 @@ -use crate::iter::{InPlaceIterable, Iterator}; +use crate::iter::InPlaceIterable; use crate::num::NonZeroUsize; use crate::ops::{ChangeOutputType, ControlFlow, FromResidual, Residual, Try}; diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index e3041519be707..b33400fab476f 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -1,6 +1,6 @@ use crate::cmp; use crate::fmt::{self, Debug}; -use crate::iter::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterator, TrustedFused}; +use crate::iter::{FusedIterator, TrustedFused}; use crate::iter::{InPlaceIterable, SourceIter, TrustedLen, UncheckedIterator}; use crate::num::NonZeroUsize; diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index bf10ada0176c2..c1687abb7cb9c 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -10,7 +10,7 @@ use crate::cmp; use crate::fmt; use crate::hash; use crate::intrinsics; -use crate::marker::{Copy, DiscriminantKind, Sized}; +use crate::marker::DiscriminantKind; use crate::ptr; mod manually_drop; diff --git a/library/core/src/ops/coroutine.rs b/library/core/src/ops/coroutine.rs index 80e2903992ec3..e58c9068af85c 100644 --- a/library/core/src/ops/coroutine.rs +++ b/library/core/src/ops/coroutine.rs @@ -1,4 +1,3 @@ -use crate::marker::Unpin; use crate::pin::Pin; /// The result of a coroutine resumption. diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index c3e774e1dab15..7d8c881eab809 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -381,10 +381,9 @@ #![stable(feature = "pin", since = "1.33.0")] -use crate::cmp::{self, PartialEq, PartialOrd}; +use crate::cmp; use crate::fmt; use crate::hash::{Hash, Hasher}; -use crate::marker::{Sized, Unpin}; use crate::ops::{CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Receiver}; /// A pinned pointer. diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 36685f756d08e..5b09b697a05da 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1,7 +1,7 @@ use super::*; -use crate::cmp::Ordering::{self, Equal, Greater, Less}; -use crate::intrinsics::{self, const_eval_select}; -use crate::mem::{self, SizedTypeProperties}; +use crate::cmp::Ordering::{Equal, Greater, Less}; +use crate::intrinsics::const_eval_select; +use crate::mem::SizedTypeProperties; use crate::slice::{self, SliceIndex}; impl *const T { diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index bc362fb627f2b..19166a2d10973 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1,6 +1,6 @@ use super::*; -use crate::cmp::Ordering::{self, Equal, Greater, Less}; -use crate::intrinsics::{self, const_eval_select}; +use crate::cmp::Ordering::{Equal, Greater, Less}; +use crate::intrinsics::const_eval_select; use crate::mem::SizedTypeProperties; use crate::slice::{self, SliceIndex}; diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index c99fe36de6d82..97fd7593ee1f2 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -1,5 +1,4 @@ use crate::cmp::Ordering; -use crate::convert::From; use crate::fmt; use crate::hash; use crate::intrinsics; diff --git a/library/core/src/ptr/unique.rs b/library/core/src/ptr/unique.rs index bf8b86677d568..067f1541e31ae 100644 --- a/library/core/src/ptr/unique.rs +++ b/library/core/src/ptr/unique.rs @@ -1,4 +1,3 @@ -use crate::convert::From; use crate::fmt; use crate::marker::{PhantomData, Unsize}; use crate::ops::{CoerceUnsized, DispatchFromDyn}; diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 5e229bf524411..fc54ea2377096 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -10,7 +10,7 @@ use crate::intrinsics::assume; use crate::iter::{ FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, UncheckedIterator, }; -use crate::marker::{PhantomData, Send, Sized, Sync}; +use crate::marker::PhantomData; use crate::mem::{self, SizedTypeProperties}; use crate::num::NonZeroUsize; use crate::ptr::{self, invalid, invalid_mut, NonNull}; diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 65aae8499f3b7..b800a7cda0436 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -9,16 +9,11 @@ use crate::cmp::Ordering::{self, Equal, Greater, Less}; use crate::fmt; use crate::intrinsics::exact_div; -use crate::marker::Copy; use crate::mem::{self, SizedTypeProperties}; use crate::num::NonZeroUsize; -use crate::ops::{Bound, FnMut, OneSidedRange, Range, RangeBounds}; -use crate::option::Option; -use crate::option::Option::{None, Some}; +use crate::ops::{Bound, OneSidedRange, Range, RangeBounds}; use crate::panic::debug_assert_nounwind; use crate::ptr; -use crate::result::Result; -use crate::result::Result::{Err, Ok}; use crate::simd::{self, Simd}; use crate::slice; diff --git a/library/core/src/task/poll.rs b/library/core/src/task/poll.rs index 0a0f702f6fb75..bfa1cf096e237 100644 --- a/library/core/src/task/poll.rs +++ b/library/core/src/task/poll.rs @@ -2,7 +2,6 @@ use crate::convert; use crate::ops::{self, ControlFlow}; -use crate::result::Result; /// Indicates whether a value is available or if the current task has been /// scheduled to receive a wakeup instead. diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 817e39942c053..1a11291e86b9d 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -1,7 +1,7 @@ #![stable(feature = "futures_api", since = "1.36.0")] use crate::fmt; -use crate::marker::{PhantomData, Unpin}; +use crate::marker::PhantomData; use crate::ptr; /// A `RawWaker` allows the implementor of a task executor to create a [`Waker`] diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 7fcf2ee358c46..9638f49198716 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -96,7 +96,6 @@ use crate::panic::UnwindSafe; use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed}; use crate::sync::LazyLock; use crate::sys_common::backtrace::{lock, output_filename, set_image_base}; -use crate::vec::Vec; /// A captured OS thread stack backtrace. /// diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs index 6e7366b36355f..db175659770b5 100644 --- a/library/std/src/io/error/repr_bitpacked.rs +++ b/library/std/src/io/error/repr_bitpacked.rs @@ -103,7 +103,6 @@ //! the time. use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}; -use alloc::boxed::Box; use core::marker::PhantomData; use core::mem::{align_of, size_of}; use core::ptr::{self, NonNull}; diff --git a/src/tools/rust-analyzer/crates/stdx/src/anymap.rs b/src/tools/rust-analyzer/crates/stdx/src/anymap.rs index fd44e6c6d0f4c..7dba002c6ec6f 100644 --- a/src/tools/rust-analyzer/crates/stdx/src/anymap.rs +++ b/src/tools/rust-analyzer/crates/stdx/src/anymap.rs @@ -17,7 +17,6 @@ #![warn(missing_docs, unused_results)] -use core::convert::TryInto; use core::hash::Hasher; /// A hasher designed to eke a little more speed out, given `TypeId`’s known characteristics. diff --git a/tests/ui/bare-fn-implements-fn-mut.rs b/tests/ui/bare-fn-implements-fn-mut.rs index dfead48893e55..d6ecd6b654bf7 100644 --- a/tests/ui/bare-fn-implements-fn-mut.rs +++ b/tests/ui/bare-fn-implements-fn-mut.rs @@ -1,7 +1,5 @@ // run-pass -use std::ops::FnMut; - fn call_f(mut f: F) { f(); } diff --git a/tests/ui/box/alloc-unstable.rs b/tests/ui/box/alloc-unstable.rs index 66388d0d5126c..640cadcc8e3dc 100644 --- a/tests/ui/box/alloc-unstable.rs +++ b/tests/ui/box/alloc-unstable.rs @@ -1,8 +1,5 @@ // run-pass #![feature(allocator_api)] - -use std::boxed::Box; - fn main() { let _boxed: Box = Box::new(10); } diff --git a/tests/ui/box/into-boxed-slice.rs b/tests/ui/box/into-boxed-slice.rs index 61b3d91525347..86866ac2f7ecc 100644 --- a/tests/ui/box/into-boxed-slice.rs +++ b/tests/ui/box/into-boxed-slice.rs @@ -1,7 +1,5 @@ // run-pass #![feature(box_into_boxed_slice)] - -use std::boxed::Box; fn main() { assert_eq!(Box::into_boxed_slice(Box::new(5u8)), Box::new([5u8]) as Box<[u8]>); assert_eq!(Box::into_boxed_slice(Box::new([25u8])), Box::new([[25u8]]) as Box<[[u8; 1]]>); diff --git a/tests/ui/box/new-box-syntax.rs b/tests/ui/box/new-box-syntax.rs index c56e1dd46254f..e3b1550d60bc5 100644 --- a/tests/ui/box/new-box-syntax.rs +++ b/tests/ui/box/new-box-syntax.rs @@ -8,8 +8,6 @@ // Tests that the new `box` syntax works with unique pointers. -use std::boxed::Box; - struct Structure { x: isize, y: isize, diff --git a/tests/ui/box/unit/unique-kinds.rs b/tests/ui/box/unit/unique-kinds.rs index f02d0b50764ae..1ef09d7195a95 100644 --- a/tests/ui/box/unit/unique-kinds.rs +++ b/tests/ui/box/unit/unique-kinds.rs @@ -1,6 +1,5 @@ // run-pass -use std::cmp::PartialEq; use std::fmt::Debug; fn sendable() { diff --git a/tests/ui/cleanup-rvalue-for-scope.rs b/tests/ui/cleanup-rvalue-for-scope.rs index b6582c01fbada..38a41f3b8d739 100644 --- a/tests/ui/cleanup-rvalue-for-scope.rs +++ b/tests/ui/cleanup-rvalue-for-scope.rs @@ -5,9 +5,6 @@ #![allow(unused_variables)] // Test that the lifetime of rvalues in for loops is extended // to the for loop itself. - -use std::ops::Drop; - static mut FLAGS: u64 = 0; struct Box { f: T } diff --git a/tests/ui/cleanup-rvalue-scopes.rs b/tests/ui/cleanup-rvalue-scopes.rs index b80f95b79f91d..56340e515b973 100644 --- a/tests/ui/cleanup-rvalue-scopes.rs +++ b/tests/ui/cleanup-rvalue-scopes.rs @@ -8,8 +8,6 @@ #![feature(box_patterns)] -use std::ops::Drop; - static mut FLAGS: u64 = 0; struct Box { f: T } diff --git a/tests/ui/coherence/coherence-negative-impls-safe-rpass.rs b/tests/ui/coherence/coherence-negative-impls-safe-rpass.rs index b87e162aca096..d5306d59ed5f3 100644 --- a/tests/ui/coherence/coherence-negative-impls-safe-rpass.rs +++ b/tests/ui/coherence/coherence-negative-impls-safe-rpass.rs @@ -4,8 +4,6 @@ #![feature(negative_impls)] -use std::marker::Send; - struct TestType; impl !Send for TestType {} diff --git a/tests/ui/coherence/coherence-where-clause.rs b/tests/ui/coherence/coherence-where-clause.rs index 5c40def86bba0..cd9a423f4ecaf 100644 --- a/tests/ui/coherence/coherence-where-clause.rs +++ b/tests/ui/coherence/coherence-where-clause.rs @@ -1,8 +1,6 @@ // run-pass use std::fmt::Debug; -use std::default::Default; - trait MyTrait { fn get(&self) -> Self; } diff --git a/tests/ui/consts/const-block.rs b/tests/ui/consts/const-block.rs index ec99c70f6e0b9..40c7a7a1da978 100644 --- a/tests/ui/consts/const-block.rs +++ b/tests/ui/consts/const-block.rs @@ -3,8 +3,6 @@ #![allow(dead_code)] #![allow(unused_unsafe)] -use std::marker::Sync; - struct Foo { a: usize, b: *const () diff --git a/tests/ui/coroutine/control-flow.rs b/tests/ui/coroutine/control-flow.rs index 709b135b2ee5b..0cb37524a6c7e 100644 --- a/tests/ui/coroutine/control-flow.rs +++ b/tests/ui/coroutine/control-flow.rs @@ -5,7 +5,6 @@ #![feature(coroutines, coroutine_trait)] -use std::marker::Unpin; use std::ops::{CoroutineState, Coroutine}; use std::pin::Pin; diff --git a/tests/ui/coroutine/discriminant.rs b/tests/ui/coroutine/discriminant.rs index 73bdd9c8671fc..0cdeb6dd6787b 100644 --- a/tests/ui/coroutine/discriminant.rs +++ b/tests/ui/coroutine/discriminant.rs @@ -6,7 +6,7 @@ #![feature(coroutines, coroutine_trait, core_intrinsics, discriminant_kind)] use std::intrinsics::discriminant_value; -use std::marker::{DiscriminantKind, Unpin}; +use std::marker::DiscriminantKind; use std::mem::size_of_val; use std::{cmp, ops::*}; diff --git a/tests/ui/coroutine/iterator-count.rs b/tests/ui/coroutine/iterator-count.rs index 322e56f8a8b32..b7628c44ddcf8 100644 --- a/tests/ui/coroutine/iterator-count.rs +++ b/tests/ui/coroutine/iterator-count.rs @@ -2,7 +2,6 @@ #![feature(coroutines, coroutine_trait)] -use std::marker::Unpin; use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; diff --git a/tests/ui/coroutine/non-static-is-unpin.rs b/tests/ui/coroutine/non-static-is-unpin.rs index d6ded53ae5a29..d77fe659f083b 100644 --- a/tests/ui/coroutine/non-static-is-unpin.rs +++ b/tests/ui/coroutine/non-static-is-unpin.rs @@ -5,7 +5,7 @@ #![feature(coroutines, coroutine_trait)] #![allow(dropping_copy_types)] -use std::marker::{PhantomPinned, Unpin}; +use std::marker::PhantomPinned; fn assert_unpin(_: G) { } diff --git a/tests/ui/coroutine/smoke-resume-args.rs b/tests/ui/coroutine/smoke-resume-args.rs index a801989859e86..752b21ba087af 100644 --- a/tests/ui/coroutine/smoke-resume-args.rs +++ b/tests/ui/coroutine/smoke-resume-args.rs @@ -6,7 +6,6 @@ #![feature(coroutines, coroutine_trait)] use std::fmt::Debug; -use std::marker::Unpin; use std::ops::{ Coroutine, CoroutineState::{self, *}, diff --git a/tests/ui/extern/issue-13655.rs b/tests/ui/extern/issue-13655.rs index 6dd1847995f00..a47b5183f2ba6 100644 --- a/tests/ui/extern/issue-13655.rs +++ b/tests/ui/extern/issue-13655.rs @@ -1,7 +1,5 @@ // run-pass #![feature(fn_traits, unboxed_closures)] -use std::ops::Fn; - struct Foo(T); impl Fn<()> for Foo { diff --git a/tests/ui/for-loop-while/while-prelude-drop.rs b/tests/ui/for-loop-while/while-prelude-drop.rs index 196b9daf6ecc9..947a70e1dd20f 100644 --- a/tests/ui/for-loop-while/while-prelude-drop.rs +++ b/tests/ui/for-loop-while/while-prelude-drop.rs @@ -1,8 +1,5 @@ // run-pass #![allow(non_camel_case_types)] - -use std::string::String; - #[derive(PartialEq)] enum t { a, b(String), } diff --git a/tests/ui/issues/issue-20847.rs b/tests/ui/issues/issue-20847.rs index 0cd7edf89db01..03e632263e673 100644 --- a/tests/ui/issues/issue-20847.rs +++ b/tests/ui/issues/issue-20847.rs @@ -1,8 +1,6 @@ // run-pass #![feature(fn_traits)] -use std::ops::Fn; - fn say(x: u32, y: u32) { println!("{} {}", x, y); } diff --git a/tests/ui/issues/issue-5554.rs b/tests/ui/issues/issue-5554.rs index 7737536f43dfe..afe333ed709d6 100644 --- a/tests/ui/issues/issue-5554.rs +++ b/tests/ui/issues/issue-5554.rs @@ -2,7 +2,6 @@ #![allow(dead_code)] // pretty-expanded FIXME #23616 -use std::default::Default; pub struct X { a: T, diff --git a/tests/ui/issues/issue-8783.rs b/tests/ui/issues/issue-8783.rs index 4eb49c8216184..cfffd9eb0182d 100644 --- a/tests/ui/issues/issue-8783.rs +++ b/tests/ui/issues/issue-8783.rs @@ -2,8 +2,6 @@ #![allow(unused_variables)] // pretty-expanded FIXME #23616 -use std::default::Default; - struct X { pub x: usize } impl Default for X { fn default() -> X { diff --git a/tests/ui/lint/unused/lint-unused-imports.rs b/tests/ui/lint/unused/lint-unused-imports.rs index 4fa6511c97e1d..88f2baa5da9b3 100644 --- a/tests/ui/lint/unused/lint-unused-imports.rs +++ b/tests/ui/lint/unused/lint-unused-imports.rs @@ -66,7 +66,6 @@ pub mod bar { fn g() { use self::g; //~ ERROR unused import: `self::g` - //~^ ERROR the item `g` is imported redundantly fn f() { self::g(); } @@ -76,7 +75,6 @@ fn g() { #[allow(unused_variables)] fn h() { use test2::foo; //~ ERROR unused import: `test2::foo` - //~^ ERROR the item `foo` is imported redundantly let foo = 0; } diff --git a/tests/ui/lint/unused/lint-unused-imports.stderr b/tests/ui/lint/unused/lint-unused-imports.stderr index 0574ca4569fbf..07684a84a64ff 100644 --- a/tests/ui/lint/unused/lint-unused-imports.stderr +++ b/tests/ui/lint/unused/lint-unused-imports.stderr @@ -34,36 +34,14 @@ error: unused import: `foo::Square` LL | use foo::Square; | ^^^^^^^^^^^ -error: the item `g` is imported redundantly - --> $DIR/lint-unused-imports.rs:68:9 - | -LL | / fn g() { -LL | | use self::g; - | | ^^^^^^^ -LL | | -LL | | fn f() { -LL | | self::g(); -LL | | } -LL | | } - | |_- the item `g` is already defined here - error: unused import: `self::g` --> $DIR/lint-unused-imports.rs:68:9 | LL | use self::g; | ^^^^^^^ -error: the item `foo` is imported redundantly - --> $DIR/lint-unused-imports.rs:78:9 - | -LL | use test2::{foo, bar}; - | --- the item `foo` is already imported here -... -LL | use test2::foo; - | ^^^^^^^^^^ - error: unused import: `test2::foo` - --> $DIR/lint-unused-imports.rs:78:9 + --> $DIR/lint-unused-imports.rs:77:9 | LL | use test2::foo; | ^^^^^^^^^^ @@ -74,5 +52,5 @@ error: unused import: `test::B2` LL | use test::B2; | ^^^^^^^^ -error: aborting due to 10 previous errors +error: aborting due to 8 previous errors diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs new file mode 100644 index 0000000000000..32bdafd012189 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs @@ -0,0 +1,19 @@ +// check-pass +#![warn(unused_imports)] + + +use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly +use std::option::Option::None; //~ WARNING the item `None` is imported redundantly + +use std::result::Result::Ok;//~ WARNING the item `Ok` is imported redundantly +use std::result::Result::Err;//~ WARNING the item `Err` is imported redundantly +use std::convert::{TryFrom, TryInto}; + +fn main() { + let _a: Option = Some(1); + let _b: Option = None; + let _c: Result = Ok(1); + let _d: Result = Err("error"); + let _e: Result = 8u8.try_into(); + let _f: Result = i32::try_from(8u8); +} diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr new file mode 100644 index 0000000000000..1b09df911eb03 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr @@ -0,0 +1,44 @@ +warning: the item `Some` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:5:5 + | +LL | use std::option::Option::Some; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `Some` is already defined here + | +note: the lint level is defined here + --> $DIR/use-redundant-prelude-rust-2015.rs:2:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +warning: the item `None` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:6:5 + | +LL | use std::option::Option::None; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `None` is already defined here + +warning: the item `Ok` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:8:5 + | +LL | use std::result::Result::Ok; + | ^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `Ok` is already defined here + +warning: the item `Err` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:9:5 + | +LL | use std::result::Result::Err; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `Err` is already defined here + +warning: 4 warnings emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs new file mode 100644 index 0000000000000..c6f1856922385 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs @@ -0,0 +1,11 @@ +// check-pass +// edition:2021 +#![warn(unused_imports)] + +use std::convert::TryFrom;//~ WARNING the item `TryFrom` is imported redundantly +use std::convert::TryInto;//~ WARNING the item `TryInto` is imported redundantly + +fn main() { + let _e: Result = 8u8.try_into(); + let _f: Result = i32::try_from(8u8); +} diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr new file mode 100644 index 0000000000000..542356dc996df --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr @@ -0,0 +1,26 @@ +warning: the item `TryFrom` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2021.rs:5:5 + | +LL | use std::convert::TryFrom; + | ^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `TryFrom` is already defined here + | +note: the lint level is defined here + --> $DIR/use-redundant-prelude-rust-2021.rs:3:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +warning: the item `TryInto` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2021.rs:6:5 + | +LL | use std::convert::TryInto; + | ^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `TryInto` is already defined here + +warning: 2 warnings emitted + diff --git a/tests/ui/moves/move-out-of-field.rs b/tests/ui/moves/move-out-of-field.rs index 9f697db4f79b4..4166d8dc8e91b 100644 --- a/tests/ui/moves/move-out-of-field.rs +++ b/tests/ui/moves/move-out-of-field.rs @@ -1,7 +1,5 @@ // run-pass -use std::string::String; - struct StringBuffer { s: String, } diff --git a/tests/ui/overloaded/overloaded-calls-param-vtables.rs b/tests/ui/overloaded/overloaded-calls-param-vtables.rs index fde1ad20f7d9c..74ee1c17614e9 100644 --- a/tests/ui/overloaded/overloaded-calls-param-vtables.rs +++ b/tests/ui/overloaded/overloaded-calls-param-vtables.rs @@ -6,7 +6,6 @@ #![feature(unboxed_closures, fn_traits)] use std::marker::PhantomData; -use std::ops::Fn; use std::ops::Add; struct G(PhantomData); diff --git a/tests/ui/overloaded/overloaded-calls-simple.rs b/tests/ui/overloaded/overloaded-calls-simple.rs index 4131836079907..8fed18b8e29c3 100644 --- a/tests/ui/overloaded/overloaded-calls-simple.rs +++ b/tests/ui/overloaded/overloaded-calls-simple.rs @@ -2,8 +2,6 @@ #![feature(lang_items, unboxed_closures, fn_traits)] -use std::ops::{Fn, FnMut, FnOnce}; - struct S1 { x: i32, y: i32, diff --git a/tests/ui/overloaded/overloaded-calls-zero-args.rs b/tests/ui/overloaded/overloaded-calls-zero-args.rs index 69ca88619b8c0..b123730679008 100644 --- a/tests/ui/overloaded/overloaded-calls-zero-args.rs +++ b/tests/ui/overloaded/overloaded-calls-zero-args.rs @@ -2,8 +2,6 @@ #![feature(unboxed_closures, fn_traits)] -use std::ops::FnMut; - struct S { x: i32, y: i32, diff --git a/tests/ui/overloaded/overloaded-deref-count.rs b/tests/ui/overloaded/overloaded-deref-count.rs index e2f1e10b5c8ae..d2482b1250059 100644 --- a/tests/ui/overloaded/overloaded-deref-count.rs +++ b/tests/ui/overloaded/overloaded-deref-count.rs @@ -2,7 +2,6 @@ use std::cell::Cell; use std::ops::{Deref, DerefMut}; -use std::vec::Vec; struct DerefCounter { count_imm: Cell, diff --git a/tests/ui/overloaded/overloaded-deref.rs b/tests/ui/overloaded/overloaded-deref.rs index 73d8232a32291..b08d8f3f767fa 100644 --- a/tests/ui/overloaded/overloaded-deref.rs +++ b/tests/ui/overloaded/overloaded-deref.rs @@ -1,7 +1,6 @@ // run-pass use std::cell::RefCell; use std::rc::Rc; -use std::string::String; #[derive(PartialEq, Debug)] struct Point { diff --git a/tests/ui/regions/regions-lifetime-static-items-enclosing-scopes.rs b/tests/ui/regions/regions-lifetime-static-items-enclosing-scopes.rs index b6a89e29ecc42..2c455fc35634f 100644 --- a/tests/ui/regions/regions-lifetime-static-items-enclosing-scopes.rs +++ b/tests/ui/regions/regions-lifetime-static-items-enclosing-scopes.rs @@ -3,9 +3,6 @@ // This test verifies that temporary lifetime is correctly computed // for static objects in enclosing scopes. - -use std::cmp::PartialEq; - fn f(o: &mut Option) { assert_eq!(*o, None); } diff --git a/tests/ui/rust-2018/remove-extern-crate.fixed b/tests/ui/rust-2018/remove-extern-crate.fixed index 209b91af1ddfb..12f97e2f975d8 100644 --- a/tests/ui/rust-2018/remove-extern-crate.fixed +++ b/tests/ui/rust-2018/remove-extern-crate.fixed @@ -6,6 +6,7 @@ #![warn(rust_2018_idioms)] #![allow(dropping_copy_types)] +#![allow(unused_imports)] //~ WARNING unused extern crate // Shouldn't suggest changing to `use`, as `another_name` diff --git a/tests/ui/rust-2018/remove-extern-crate.rs b/tests/ui/rust-2018/remove-extern-crate.rs index ef3c2db696af2..f7cdc753ef76a 100644 --- a/tests/ui/rust-2018/remove-extern-crate.rs +++ b/tests/ui/rust-2018/remove-extern-crate.rs @@ -6,6 +6,7 @@ #![warn(rust_2018_idioms)] #![allow(dropping_copy_types)] +#![allow(unused_imports)] extern crate core; //~ WARNING unused extern crate // Shouldn't suggest changing to `use`, as `another_name` diff --git a/tests/ui/rust-2018/remove-extern-crate.stderr b/tests/ui/rust-2018/remove-extern-crate.stderr index f752cac8ed630..020db9975c092 100644 --- a/tests/ui/rust-2018/remove-extern-crate.stderr +++ b/tests/ui/rust-2018/remove-extern-crate.stderr @@ -1,5 +1,5 @@ warning: unused extern crate - --> $DIR/remove-extern-crate.rs:10:1 + --> $DIR/remove-extern-crate.rs:11:1 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ help: remove it @@ -12,7 +12,7 @@ LL | #![warn(rust_2018_idioms)] = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:34:5 + --> $DIR/remove-extern-crate.rs:35:5 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | use core; | ~~~ warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:44:5 + --> $DIR/remove-extern-crate.rs:45:5 | LL | pub extern crate core; | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/specialization/specialization-translate-projections.rs b/tests/ui/specialization/specialization-translate-projections.rs index 92ea9e2b85d32..a9753376135e7 100644 --- a/tests/ui/specialization/specialization-translate-projections.rs +++ b/tests/ui/specialization/specialization-translate-projections.rs @@ -5,7 +5,6 @@ #![feature(specialization)] //~ WARN the feature `specialization` is incomplete -use std::convert::Into; trait Trait { fn to_u8(&self) -> u8; diff --git a/tests/ui/stdlib-unit-tests/istr.rs b/tests/ui/stdlib-unit-tests/istr.rs index dca6d40d59adf..219b47789b899 100644 --- a/tests/ui/stdlib-unit-tests/istr.rs +++ b/tests/ui/stdlib-unit-tests/istr.rs @@ -1,7 +1,5 @@ // run-pass -use std::string::String; - fn test_stack_assign() { let s: String = "a".to_string(); println!("{}", s.clone()); diff --git a/tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs b/tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs index 9100bfbde95fa..7fbffb8fa98e6 100644 --- a/tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs +++ b/tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs @@ -1,7 +1,7 @@ // run-pass use std::fmt::Debug; -use std::cmp::{self, PartialOrd, Ordering}; +use std::cmp::{self, Ordering}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] struct Foo { diff --git a/tests/ui/structs-enums/class-cast-to-trait-cross-crate-2.rs b/tests/ui/structs-enums/class-cast-to-trait-cross-crate-2.rs index f870096fdd44a..989f0a275f7de 100644 --- a/tests/ui/structs-enums/class-cast-to-trait-cross-crate-2.rs +++ b/tests/ui/structs-enums/class-cast-to-trait-cross-crate-2.rs @@ -3,7 +3,6 @@ extern crate cci_class_cast; -use std::string::ToString; use cci_class_cast::kitty::cat; fn print_out(thing: Box, expected: String) { diff --git a/tests/ui/structs-enums/enum-nullable-const-null-with-fields.rs b/tests/ui/structs-enums/enum-nullable-const-null-with-fields.rs index ae267e7988e8c..1d52d44d1696b 100644 --- a/tests/ui/structs-enums/enum-nullable-const-null-with-fields.rs +++ b/tests/ui/structs-enums/enum-nullable-const-null-with-fields.rs @@ -1,8 +1,5 @@ // run-pass -use std::result::Result; -use std::result::Result::Ok; - static C: Result<(), Box> = Ok(()); // This is because of yet another bad assertion (ICE) about the null side of a nullable enum. diff --git a/tests/ui/suggestions/derive-clone-for-eq.fixed b/tests/ui/suggestions/derive-clone-for-eq.fixed index f07784d53b3a3..a74487019adf0 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.fixed +++ b/tests/ui/suggestions/derive-clone-for-eq.fixed @@ -1,8 +1,6 @@ // run-rustfix // /~https://github.com/rust-lang/rust/issues/79076 -use std::cmp::PartialEq; - #[derive(Clone, Eq)] //~ ERROR [E0277] pub struct Struct(T); diff --git a/tests/ui/suggestions/derive-clone-for-eq.rs b/tests/ui/suggestions/derive-clone-for-eq.rs index 15c0d4659fbbe..99956ed9879d5 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.rs +++ b/tests/ui/suggestions/derive-clone-for-eq.rs @@ -1,8 +1,6 @@ // run-rustfix // /~https://github.com/rust-lang/rust/issues/79076 -use std::cmp::PartialEq; - #[derive(Clone, Eq)] //~ ERROR [E0277] pub struct Struct(T); diff --git a/tests/ui/suggestions/derive-clone-for-eq.stderr b/tests/ui/suggestions/derive-clone-for-eq.stderr index eb95f729d1e7c..680890e880ca6 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.stderr +++ b/tests/ui/suggestions/derive-clone-for-eq.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/derive-clone-for-eq.rs:6:17 + --> $DIR/derive-clone-for-eq.rs:4:17 | LL | #[derive(Clone, Eq)] | ^^ the trait `Clone` is not implemented for `T` | note: required for `Struct` to implement `PartialEq` - --> $DIR/derive-clone-for-eq.rs:9:19 + --> $DIR/derive-clone-for-eq.rs:7:19 | LL | impl PartialEq for Struct | ----- ^^^^^^^^^^^^ ^^^^^^^^^ diff --git a/tests/ui/traits/inheritance/num0.rs b/tests/ui/traits/inheritance/num0.rs index cee52542d38d2..c9c73ee00e606 100644 --- a/tests/ui/traits/inheritance/num0.rs +++ b/tests/ui/traits/inheritance/num0.rs @@ -4,8 +4,6 @@ // pretty-expanded FIXME #23616 -use std::cmp::PartialOrd; - pub trait NumCast: Sized { fn from(i: i32) -> Option; } diff --git a/tests/ui/traits/inheritance/overloading-simple.rs b/tests/ui/traits/inheritance/overloading-simple.rs index c306aa2cda0a1..800d7bc6b1fe6 100644 --- a/tests/ui/traits/inheritance/overloading-simple.rs +++ b/tests/ui/traits/inheritance/overloading-simple.rs @@ -1,6 +1,5 @@ // run-pass #![allow(dead_code)] -use std::cmp::PartialEq; trait MyNum : PartialEq { } diff --git a/tests/ui/traits/inheritance/overloading.rs b/tests/ui/traits/inheritance/overloading.rs index 083643e821f4b..f126847da09c0 100644 --- a/tests/ui/traits/inheritance/overloading.rs +++ b/tests/ui/traits/inheritance/overloading.rs @@ -1,5 +1,4 @@ // run-pass -use std::cmp::PartialEq; use std::ops::{Add, Sub, Mul}; trait MyNum : Add + Sub + Mul + PartialEq + Clone { } diff --git a/tests/ui/traits/issue-22019.rs b/tests/ui/traits/issue-22019.rs index 1a887f0f39f6b..605fee510b103 100644 --- a/tests/ui/traits/issue-22019.rs +++ b/tests/ui/traits/issue-22019.rs @@ -8,8 +8,6 @@ #![allow(missing_copy_implementations)] #![allow(unused_variables)] -use std::borrow::ToOwned; - pub struct CFGNode; pub type Node<'a> = &'a CFGNode; diff --git a/tests/ui/traits/multidispatch2.rs b/tests/ui/traits/multidispatch2.rs index 20608aabb3be8..21aa13fd48752 100644 --- a/tests/ui/traits/multidispatch2.rs +++ b/tests/ui/traits/multidispatch2.rs @@ -1,7 +1,6 @@ // run-pass use std::fmt::Debug; -use std::default::Default; trait MyTrait { fn get(&self) -> T; diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs b/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs index a1042f8310a98..0bc611c26caa2 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs +++ b/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs @@ -2,8 +2,6 @@ #![allow(unused_variables)] #![feature(negative_impls)] -use std::marker::Send; - pub struct WaitToken; impl !Send for WaitToken {} diff --git a/tests/ui/traits/wf-object/reverse-order.rs b/tests/ui/traits/wf-object/reverse-order.rs index 4f676cbe33846..74b2ef48533d2 100644 --- a/tests/ui/traits/wf-object/reverse-order.rs +++ b/tests/ui/traits/wf-object/reverse-order.rs @@ -2,8 +2,6 @@ // Ensure that `dyn $($AutoTrait)+ ObjSafe` is well-formed. -use std::marker::Unpin; - // Some arbitrary object-safe trait: trait Obj {} diff --git a/tests/ui/ufcs/ufcs-polymorphic-paths.rs b/tests/ui/ufcs/ufcs-polymorphic-paths.rs index a14ebd6a41fc4..71b9de8184cd6 100644 --- a/tests/ui/ufcs/ufcs-polymorphic-paths.rs +++ b/tests/ui/ufcs/ufcs-polymorphic-paths.rs @@ -1,7 +1,6 @@ // run-pass -use std::borrow::{Cow, ToOwned}; -use std::default::Default; +use std::borrow::Cow; use std::iter::FromIterator; use std::ops::Add; use std::option::IntoIter as OptionIter; diff --git a/tests/ui/unboxed-closures/unboxed-closures-boxed.rs b/tests/ui/unboxed-closures/unboxed-closures-boxed.rs index 3f550fd04259f..53f0523da70cc 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-boxed.rs +++ b/tests/ui/unboxed-closures/unboxed-closures-boxed.rs @@ -1,6 +1,5 @@ // run-pass -use std::ops::FnMut; fn make_adder(x: i32) -> Boxi32+'static> { Box::new(move |y: i32| -> i32 { x + y }) as diff --git a/tests/ui/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs b/tests/ui/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs index 9b8a3f4098cdb..8a40c1d47855a 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs +++ b/tests/ui/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs @@ -1,8 +1,6 @@ // run-pass // Test that the call operator autoderefs when calling a bounded type parameter. -use std::ops::FnMut; - fn call_with_2(x: &mut F) -> isize where F : FnMut(isize) -> isize { diff --git a/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs b/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs index d47ceea0f4f4d..2433f0757aa08 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs +++ b/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs @@ -1,8 +1,6 @@ // run-pass // Test that the call operator autoderefs when calling to an object type. -use std::ops::FnMut; - fn make_adder(x: isize) -> Boxisize + 'static> { Box::new(move |y| { x + y }) } diff --git a/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object.rs b/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object.rs index f77733d106d4f..b27d610495940 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object.rs +++ b/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object.rs @@ -1,6 +1,4 @@ // run-pass -use std::ops::FnMut; - fn make_adder(x: isize) -> Boxisize + 'static> { Box::new(move |y| { x + y }) } diff --git a/tests/ui/unboxed-closures/unboxed-closures-extern-fn.rs b/tests/ui/unboxed-closures/unboxed-closures-extern-fn.rs index 677cd259a4e6e..d07e871b10d52 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-extern-fn.rs +++ b/tests/ui/unboxed-closures/unboxed-closures-extern-fn.rs @@ -1,7 +1,6 @@ // run-pass // Checks that extern fn pointers implement the full range of Fn traits. -use std::ops::{Fn,FnMut,FnOnce}; fn square(x: isize) -> isize { x * x } diff --git a/tests/ui/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs b/tests/ui/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs index 851f3d2fe9ba0..db1bea0e1159a 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs +++ b/tests/ui/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs @@ -4,8 +4,6 @@ #![feature(unboxed_closures, fn_traits)] -use std::ops::{Fn,FnMut,FnOnce}; - struct S; impl Fn<(i32,)> for S { diff --git a/tests/ui/unboxed-closures/unboxed-closures-generic.rs b/tests/ui/unboxed-closures/unboxed-closures-generic.rs index 740b8b2a72fae..524e756e69b0c 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-generic.rs +++ b/tests/ui/unboxed-closures/unboxed-closures-generic.rs @@ -1,6 +1,4 @@ // run-pass -use std::ops::FnMut; - fn call_iti32>(y: i32, mut f: F) -> i32 { f(2, y) } diff --git a/tests/ui/zero-sized/zero-sized-binary-heap-push.rs b/tests/ui/zero-sized/zero-sized-binary-heap-push.rs index 6553c5adbe7a2..14cf6c2036bdc 100644 --- a/tests/ui/zero-sized/zero-sized-binary-heap-push.rs +++ b/tests/ui/zero-sized/zero-sized-binary-heap-push.rs @@ -1,7 +1,6 @@ // run-pass #![allow(unused_variables)] use std::collections::BinaryHeap; -use std::iter::Iterator; fn main() { const N: usize = 8; diff --git a/tests/ui/zero-sized/zero-sized-linkedlist-push.rs b/tests/ui/zero-sized/zero-sized-linkedlist-push.rs index 03724085f5f4d..301f03110b74b 100644 --- a/tests/ui/zero-sized/zero-sized-linkedlist-push.rs +++ b/tests/ui/zero-sized/zero-sized-linkedlist-push.rs @@ -1,6 +1,5 @@ // run-pass use std::collections::LinkedList; -use std::iter::Iterator; fn main() { const N: usize = 8;