From 3dde32ca974721daa4dfd526226d6c9e707fd8af Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Tue, 20 Dec 2022 22:10:40 +0100 Subject: [PATCH 1/4] rustc: Remove needless lifetimes --- compiler/rustc_ast/src/util/comments.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 2 +- compiler/rustc_borrowck/src/consumers.rs | 6 +- .../src/diagnostics/find_all_local_uses.rs | 2 +- compiler/rustc_borrowck/src/lib.rs | 5 +- .../src/type_check/free_region_relations.rs | 6 +- compiler/rustc_builtin_macros/src/asm.rs | 2 +- compiler/rustc_codegen_gcc/src/base.rs | 2 +- compiler/rustc_codegen_gcc/src/common.rs | 2 +- compiler/rustc_codegen_gcc/src/lib.rs | 2 +- .../src/coverageinfo/mapgen.rs | 4 +- .../src/debuginfo/metadata.rs | 2 +- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 6 +- compiler/rustc_codegen_ssa/src/back/link.rs | 8 +-- .../src/back/symbol_export.rs | 6 +- .../rustc_codegen_ssa/src/debuginfo/mod.rs | 2 +- compiler/rustc_codegen_ssa/src/meth.rs | 2 +- .../rustc_codegen_ssa/src/target_features.rs | 2 +- .../rustc_data_structures/src/profiling.rs | 11 ++-- .../src/transitive_relation.rs | 2 +- compiler/rustc_data_structures/src/unord.rs | 6 +- compiler/rustc_error_messages/src/lib.rs | 4 +- compiler/rustc_expand/src/mbe/quoted.rs | 2 +- compiler/rustc_graphviz/src/lib.rs | 2 +- .../rustc_hir_analysis/src/check/check.rs | 14 ++-- .../src/check/compare_method.rs | 4 +- compiler/rustc_hir_analysis/src/check/mod.rs | 6 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 2 +- .../src/coherence/builtin.rs | 4 +- compiler/rustc_hir_analysis/src/collect.rs | 2 +- .../src/collect/lifetimes.rs | 4 +- .../src/collect/predicates_of.rs | 6 +- .../src/impl_wf_check/min_specialization.rs | 6 +- .../src/outlives/implicit_infer.rs | 6 +- compiler/rustc_hir_typeck/src/coercion.rs | 2 +- .../rustc_hir_typeck/src/expr_use_visitor.rs | 4 +- .../src/generator_interior/drop_ranges/mod.rs | 2 +- compiler/rustc_hir_typeck/src/lib.rs | 4 +- compiler/rustc_hir_typeck/src/op.rs | 2 +- compiler/rustc_hir_typeck/src/upvar.rs | 32 ++++----- .../rustc_incremental/src/assert_dep_graph.rs | 5 +- .../src/infer/error_reporting/mod.rs | 4 +- compiler/rustc_lint/src/non_fmt_panic.rs | 2 +- compiler/rustc_lint_defs/src/builtin.rs | 2 +- .../src/diagnostics/subdiagnostic.rs | 2 +- .../rustc_macros/src/diagnostics/utils.rs | 2 +- compiler/rustc_metadata/src/creader.rs | 4 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 2 +- .../rustc_middle/src/dep_graph/dep_node.rs | 2 +- compiler/rustc_middle/src/hir/map/mod.rs | 4 +- compiler/rustc_middle/src/middle/stability.rs | 4 +- compiler/rustc_middle/src/mir/mod.rs | 4 +- compiler/rustc_middle/src/mir/pretty.rs | 4 +- compiler/rustc_middle/src/mir/spanview.rs | 19 ++---- compiler/rustc_middle/src/mir/traversal.rs | 2 +- compiler/rustc_middle/src/traits/chalk.rs | 65 ++++++++----------- .../src/traits/specialization_graph.rs | 8 +-- compiler/rustc_middle/src/ty/closure.rs | 5 +- compiler/rustc_middle/src/ty/consts.rs | 2 +- compiler/rustc_middle/src/ty/consts/int.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 4 +- compiler/rustc_middle/src/ty/flags.rs | 2 +- compiler/rustc_middle/src/ty/layout.rs | 2 +- compiler/rustc_middle/src/ty/util.rs | 2 +- .../src/build/expr/as_place.rs | 4 +- compiler/rustc_mir_build/src/build/mod.rs | 12 ++-- .../rustc_mir_build/src/check_unsafety.rs | 8 +-- compiler/rustc_mir_build/src/thir/cx/mod.rs | 11 ++-- .../src/thir/pattern/const_to_pat.rs | 2 +- .../src/thir/pattern/deconstruct_pat.rs | 4 +- .../rustc_mir_dataflow/src/impls/liveness.rs | 4 +- .../rustc_mir_dataflow/src/value_analysis.rs | 2 +- .../rustc_mir_transform/src/check_unsafety.rs | 6 +- .../rustc_mir_transform/src/coverage/mod.rs | 6 +- .../rustc_mir_transform/src/coverage/query.rs | 4 +- .../rustc_mir_transform/src/coverage/tests.rs | 2 +- .../src/deduce_param_attrs.rs | 2 +- compiler/rustc_mir_transform/src/dest_prop.rs | 2 +- compiler/rustc_mir_transform/src/lib.rs | 32 ++++----- .../rustc_mir_transform/src/simplify_try.rs | 2 +- .../src/partitioning/mod.rs | 7 +- compiler/rustc_passes/src/dead.rs | 16 ++--- .../rustc_passes/src/debugger_visualizer.rs | 6 +- compiler/rustc_passes/src/diagnostic_items.rs | 10 +-- compiler/rustc_passes/src/layout_test.rs | 2 +- compiler/rustc_passes/src/reachable.rs | 4 +- compiler/rustc_passes/src/stability.rs | 2 +- compiler/rustc_passes/src/weak_lang_items.rs | 4 +- .../rustc_query_impl/src/on_disk_cache.rs | 2 +- .../rustc_query_impl/src/profiling_support.rs | 2 +- .../rustc_query_system/src/query/plumbing.rs | 4 +- compiler/rustc_save_analysis/src/lib.rs | 6 +- compiler/rustc_session/src/parse.rs | 12 ++-- compiler/rustc_session/src/utils.rs | 2 +- .../src/typeid/typeid_itanium_cxx_abi.rs | 2 +- .../rustc_target/src/abi/call/loongarch.rs | 4 +- compiler/rustc_target/src/abi/call/riscv.rs | 4 +- compiler/rustc_target/src/spec/mod.rs | 2 +- .../src/traits/coherence.rs | 8 +-- .../src/traits/error_reporting/suggestions.rs | 2 +- .../rustc_trait_selection/src/traits/mod.rs | 5 +- .../src/traits/outlives_bounds.rs | 2 +- .../src/traits/vtable.rs | 2 +- compiler/rustc_traits/src/chalk/db.rs | 2 +- .../src/normalize_erasing_regions.rs | 2 +- compiler/rustc_ty_utils/src/consts.rs | 14 ++-- compiler/rustc_ty_utils/src/implied_bounds.rs | 2 +- compiler/rustc_ty_utils/src/layout.rs | 4 +- compiler/rustc_ty_utils/src/ty.rs | 5 +- 109 files changed, 266 insertions(+), 320 deletions(-) diff --git a/compiler/rustc_ast/src/util/comments.rs b/compiler/rustc_ast/src/util/comments.rs index 35454c3a67092..275ed02c2b9f7 100644 --- a/compiler/rustc_ast/src/util/comments.rs +++ b/compiler/rustc_ast/src/util/comments.rs @@ -51,7 +51,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol { if i != 0 || j != lines.len() { Some((i, j)) } else { None } } - fn get_horizontal_trim<'a>(lines: &'a [&str], kind: CommentKind) -> Option { + fn get_horizontal_trim(lines: &[&str], kind: CommentKind) -> Option { let mut i = usize::MAX; let mut first = true; diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 0ef784a4453dc..db2527a200c32 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -414,7 +414,7 @@ fn compute_hir_hash( }) } -pub fn lower_to_hir<'hir>(tcx: TyCtxt<'hir>, (): ()) -> hir::Crate<'hir> { +pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> hir::Crate<'_> { let sess = tcx.sess; let krate = tcx.untracked_crate.steal(); let mut resolver = tcx.resolver_for_lowering(()).steal(); diff --git a/compiler/rustc_borrowck/src/consumers.rs b/compiler/rustc_borrowck/src/consumers.rs index 86da767f32273..becc04bbdab0d 100644 --- a/compiler/rustc_borrowck/src/consumers.rs +++ b/compiler/rustc_borrowck/src/consumers.rs @@ -28,10 +28,10 @@ pub use super::{ /// that shows how to do this at `src/test/run-make/obtain-borrowck/`. /// /// * Polonius is highly unstable, so expect regular changes in its signature or other details. -pub fn get_body_with_borrowck_facts<'tcx>( - tcx: TyCtxt<'tcx>, +pub fn get_body_with_borrowck_facts( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> BodyWithBorrowckFacts<'tcx> { +) -> BodyWithBorrowckFacts<'_> { let (input_body, promoted) = tcx.mir_promoted(def); let infcx = tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(def.did)).build(); let input_body: &Body<'_> = &input_body.borrow(); diff --git a/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs b/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs index 498e9834354b7..2c4d953f011fc 100644 --- a/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs +++ b/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs @@ -9,7 +9,7 @@ use rustc_middle::mir::{Body, Local, Location}; /// Find all uses of (including assignments to) a [`Local`]. /// /// Uses `BTreeSet` so output is deterministic. -pub(super) fn find<'tcx>(body: &Body<'tcx>, local: Local) -> BTreeSet { +pub(super) fn find(body: &Body<'_>, local: Local) -> BTreeSet { let mut visitor = AllLocalUsesVisitor { for_local: local, uses: BTreeSet::default() }; visitor.visit_body(body); visitor.uses diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index d8c22fbe59f01..168b798788b4c 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -124,10 +124,7 @@ pub fn provide(providers: &mut Providers) { }; } -fn mir_borrowck<'tcx>( - tcx: TyCtxt<'tcx>, - def: ty::WithOptConstParam, -) -> &'tcx BorrowCheckResult<'tcx> { +fn mir_borrowck(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> &BorrowCheckResult<'_> { let (input_body, promoted) = tcx.mir_promoted(def); debug!("run query mir_borrowck: {}", tcx.def_path_str(def.did.to_def_id())); diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index 14cfc3613bf0c..09cf870bcf35a 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -85,7 +85,7 @@ impl UniversalRegionRelations<'_> { /// outlives `fr` and (b) is not local. /// /// (*) If there are multiple competing choices, we return all of them. - pub(crate) fn non_local_upper_bounds<'a>(&'a self, fr: RegionVid) -> Vec { + pub(crate) fn non_local_upper_bounds(&self, fr: RegionVid) -> Vec { debug!("non_local_upper_bound(fr={:?})", fr); let res = self.non_local_bounds(&self.inverse_outlives, fr); assert!(!res.is_empty(), "can't find an upper bound!?"); @@ -148,9 +148,9 @@ impl UniversalRegionRelations<'_> { /// Helper for `non_local_upper_bounds` and `non_local_lower_bounds`. /// Repeatedly invokes `postdom_parent` until we find something that is not /// local. Returns `None` if we never do so. - fn non_local_bounds<'a>( + fn non_local_bounds( &self, - relation: &'a TransitiveRelation, + relation: &TransitiveRelation, fr0: RegionVid, ) -> Vec { // This method assumes that `fr0` is one of the universally diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 900c4427424ab..925392b500ad2 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -352,7 +352,7 @@ pub fn parse_asm_args<'a>( /// /// This function must be called immediately after the option token is parsed. /// Otherwise, the suggestion will be incorrect. -fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) { +fn err_duplicate_option(p: &mut Parser<'_>, symbol: Symbol, span: Span) { let mut err = p .sess .span_diagnostic diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs index 8f9f6f98faf81..d464bd3d12a07 100644 --- a/compiler/rustc_codegen_gcc/src/base.rs +++ b/compiler/rustc_codegen_gcc/src/base.rs @@ -52,7 +52,7 @@ pub fn linkage_to_gcc(linkage: Linkage) -> FunctionType { } } -pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_128bit_integers: bool) -> (ModuleCodegen, u64) { +pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_integers: bool) -> (ModuleCodegen, u64) { let prof_timer = tcx.prof.generic_activity("codegen_module"); let start_time = Instant::now(); diff --git a/compiler/rustc_codegen_gcc/src/common.rs b/compiler/rustc_codegen_gcc/src/common.rs index aa1c271c31cb4..d7df1347121ae 100644 --- a/compiler/rustc_codegen_gcc/src/common.rs +++ b/compiler/rustc_codegen_gcc/src/common.rs @@ -44,7 +44,7 @@ pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) -> context.new_array_constructor(None, typ, &elements) } -pub fn type_is_pointer<'gcc>(typ: Type<'gcc>) -> bool { +pub fn type_is_pointer(typ: Type) -> bool { typ.get_pointee().is_some() } diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index b9600da5c39df..bf1da38312f7d 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -161,7 +161,7 @@ impl ExtraBackendMethods for GccCodegenBackend { mods } - fn compile_codegen_unit<'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: Symbol) -> (ModuleCodegen, u64) { + fn compile_codegen_unit(&self, tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen, u64) { base::compile_codegen_unit(tcx, cgu_name, *self.supports_128bit_integers.lock().expect("lock")) } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 86580d05d4166..393bf30e9f834 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -30,7 +30,7 @@ use std::ffi::CString; /// implementing this Rust version, and though the format documentation is very explicit and /// detailed, some undocumented details in Clang's implementation (that may or may not be important) /// were also replicated for Rust's Coverage Map. -pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) { +pub fn finalize(cx: &CodegenCx<'_, '_>) { let tcx = cx.tcx; // Ensure the installed version of LLVM supports at least Coverage Map @@ -284,7 +284,7 @@ fn save_function_record( /// "code coverage dead code cgu" during the partitioning process. This prevents us from generating /// code regions for the same function more than once which can lead to linker errors regarding /// duplicate symbols. -fn add_unused_functions<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) { +fn add_unused_functions(cx: &CodegenCx<'_, '_>) { assert!(cx.codegen_unit.is_code_coverage_dead_code_cgu()); let tcx = cx.tcx; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index a9e3dcf4cb39a..48e3a812e4f20 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -111,7 +111,7 @@ macro_rules! return_if_di_node_created_in_meantime { /// Extract size and alignment from a TyAndLayout. #[inline] -fn size_and_align_of<'tcx>(ty_and_layout: TyAndLayout<'tcx>) -> (Size, Align) { +fn size_and_align_of(ty_and_layout: TyAndLayout<'_>) -> (Size, Align) { (ty_and_layout.size, ty_and_layout.align.abi) } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index e61dbe8b8fc50..0db45b6157ab1 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2389,11 +2389,11 @@ extern "C" { pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine); - pub fn LLVMRustBuildOperandBundleDef<'a>( + pub fn LLVMRustBuildOperandBundleDef( Name: *const c_char, - Inputs: *const &'a Value, + Inputs: *const &'_ Value, NumInputs: c_uint, - ) -> &'a mut OperandBundleDef<'a>; + ) -> &mut OperandBundleDef<'_>; pub fn LLVMRustFreeOperandBundleDef<'a>(Bundle: &'a mut OperandBundleDef<'a>); pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock); diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index a1c77ec0cfca7..edde1537b81e1 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -607,21 +607,21 @@ fn link_dwarf_object<'a>( } impl ThorinSession { - fn alloc_mmap<'arena>(&'arena self, data: Mmap) -> &'arena Mmap { + fn alloc_mmap(&self, data: Mmap) -> &Mmap { (*self.arena_mmap.alloc(data)).borrow() } } impl thorin::Session for ThorinSession { - fn alloc_data<'arena>(&'arena self, data: Vec) -> &'arena [u8] { + fn alloc_data(&self, data: Vec) -> &[u8] { (*self.arena_data.alloc(data)).borrow() } - fn alloc_relocation<'arena>(&'arena self, data: Relocations) -> &'arena Relocations { + fn alloc_relocation(&self, data: Relocations) -> &Relocations { (*self.arena_relocations.alloc(data)).borrow() } - fn read_input<'arena>(&'arena self, path: &Path) -> std::io::Result<&'arena [u8]> { + fn read_input(&self, path: &Path) -> std::io::Result<&[u8]> { let file = File::open(&path)?; let mmap = (unsafe { Mmap::map(file) })?; Ok(self.alloc_mmap(mmap)) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 22f534d909ab6..8cb7d74b90d4b 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -163,10 +163,10 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b tcx.reachable_non_generics(def_id.krate).contains_key(&def_id) } -fn exported_symbols_provider_local<'tcx>( - tcx: TyCtxt<'tcx>, +fn exported_symbols_provider_local( + tcx: TyCtxt<'_>, cnum: CrateNum, -) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] { +) -> &[(ExportedSymbol<'_>, SymbolExportInfo)] { assert_eq!(cnum, LOCAL_CRATE); if !tcx.sess.opts.output_types.should_codegen() { diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs b/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs index 6e3f4f0b8ef01..60e9b40e8fb40 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs @@ -10,7 +10,7 @@ pub mod type_names; /// NOTE: This is somewhat inconsistent right now: For empty enums and enums with a single /// fieldless variant, we generate DW_TAG_struct_type, although a /// DW_TAG_enumeration_type would be a better fit. -pub fn wants_c_like_enum_debuginfo<'tcx>(enum_type_and_layout: TyAndLayout<'tcx>) -> bool { +pub fn wants_c_like_enum_debuginfo(enum_type_and_layout: TyAndLayout<'_>) -> bool { match enum_type_and_layout.ty.kind() { ty::Adt(adt_def, _) => { if !adt_def.is_enum() { diff --git a/compiler/rustc_codegen_ssa/src/meth.rs b/compiler/rustc_codegen_ssa/src/meth.rs index d96ca921f1f4d..2421acab4715d 100644 --- a/compiler/rustc_codegen_ssa/src/meth.rs +++ b/compiler/rustc_codegen_ssa/src/meth.rs @@ -65,7 +65,7 @@ impl<'a, 'tcx> VirtualIndex { /// This takes a valid `self` receiver type and extracts the principal trait /// ref of the type. -fn expect_dyn_trait_in_self<'tcx>(ty: Ty<'tcx>) -> ty::PolyExistentialTraitRef<'tcx> { +fn expect_dyn_trait_in_self(ty: Ty<'_>) -> ty::PolyExistentialTraitRef<'_> { for arg in ty.peel_refs().walk() { if let GenericArgKind::Type(ty) = arg.unpack() { if let ty::Dynamic(data, _, _) = ty.kind() { diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index 0dabe96b60277..da69fc8ecf77e 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -419,7 +419,7 @@ pub fn from_target_feature( /// Computes the set of target features used in a function for the purposes of /// inline assembly. -fn asm_target_features<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> &'tcx FxHashSet { +fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxHashSet { let mut target_features = tcx.sess.unstable_target_features.clone(); if tcx.def_kind(did).has_codegen_attrs() { let attrs = tcx.codegen_fn_attrs(did); diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 1d4014f05acdc..16296b2248975 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -205,10 +205,7 @@ impl SelfProfilerRef { /// VerboseTimingGuard returned from this call is dropped. In addition to recording /// a measureme event, "verbose" generic activities also print a timing entry to /// stderr if the compiler is invoked with -Ztime-passes. - pub fn verbose_generic_activity<'a>( - &'a self, - event_label: &'static str, - ) -> VerboseTimingGuard<'a> { + pub fn verbose_generic_activity(&self, event_label: &'static str) -> VerboseTimingGuard<'_> { let message = if self.print_verbose_generic_activities { Some(event_label.to_owned()) } else { None }; @@ -216,11 +213,11 @@ impl SelfProfilerRef { } /// Like `verbose_generic_activity`, but with an extra arg. - pub fn verbose_generic_activity_with_arg<'a, A>( - &'a self, + pub fn verbose_generic_activity_with_arg( + &self, event_label: &'static str, event_arg: A, - ) -> VerboseTimingGuard<'a> + ) -> VerboseTimingGuard<'_> where A: Borrow + Into, { diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs index cf616203842a6..1ff0d58df1409 100644 --- a/compiler/rustc_data_structures/src/transitive_relation.rs +++ b/compiler/rustc_data_structures/src/transitive_relation.rs @@ -199,7 +199,7 @@ impl TransitiveRelation { /// Viewing the relation as a graph, computes the "mutual /// immediate postdominator" of a set of points (if one /// exists). See `postdom_upper_bound` for details. - pub fn mutual_immediate_postdominator<'a>(&'a self, mut mubs: Vec) -> Option { + pub fn mutual_immediate_postdominator(&self, mut mubs: Vec) -> Option { loop { match mubs.len() { 0 => return None, diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index c015f1232cd92..14257e4d5c60b 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -178,7 +178,7 @@ impl UnordSet { } #[inline] - pub fn items<'a>(&'a self) -> UnordItems<&'a V, impl Iterator> { + pub fn items(&self) -> UnordItems<&V, impl Iterator> { UnordItems(self.inner.iter()) } @@ -255,7 +255,7 @@ impl UnordMap { } #[inline] - pub fn items<'a>(&'a self) -> UnordItems<(&'a K, &'a V), impl Iterator> { + pub fn items(&self) -> UnordItems<(&K, &V), impl Iterator> { UnordItems(self.inner.iter()) } @@ -311,7 +311,7 @@ impl UnordBag { } #[inline] - pub fn items<'a>(&'a self) -> UnordItems<&'a V, impl Iterator> { + pub fn items(&self) -> UnordItems<&V, impl Iterator> { UnordItems(self.inner.iter()) } diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index 25d0e736e599f..f2f36a3541f04 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -549,9 +549,7 @@ fn icu_locale_from_unic_langid(lang: LanguageIdentifier) -> Option( - l: Vec>, -) -> FluentValue<'source> { +pub fn fluent_value_from_str_list_sep_by_and(l: Vec>) -> FluentValue<'_> { // Fluent requires 'static value here for its AnyEq usages. #[derive(Clone, PartialEq, Debug)] struct FluentStrListSepByAnd(Vec); diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index ee17d54f629d1..878284f5928de 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -356,7 +356,7 @@ fn parse_sep_and_kleene_op( // `$$` or a meta-variable is the lhs of a macro but shouldn't. // // For example, `macro_rules! foo { ( ${length()} ) => {} }` -fn span_dollar_dollar_or_metavar_in_the_lhs_err<'sess>(sess: &'sess ParseSess, token: &Token) { +fn span_dollar_dollar_or_metavar_in_the_lhs_err(sess: &ParseSess, token: &Token) { sess.span_diagnostic .span_err(token.span, &format!("unexpected token: {}", pprust::token_to_string(token))); sess.span_diagnostic.span_note_without_error( diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index 1f8268cc17c53..d7730935f2015 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -164,7 +164,7 @@ //! fn node_id(&'a self, n: &Nd) -> dot::Id<'a> { //! dot::Id::new(format!("N{}", n)).unwrap() //! } -//! fn node_label<'b>(&'b self, n: &Nd) -> dot::LabelText<'b> { +//! fn node_label(&self, n: &Nd) -> dot::LabelText { //! dot::LabelText::LabelStr(self.nodes[*n].into()) //! } //! fn edge_label<'b>(&'b self, _: &Ed) -> dot::LabelText<'b> { diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index eee0ba2e5ed27..a714663741be7 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -162,7 +162,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b } /// Check that a `static` is inhabited. -fn check_static_inhabited<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { +fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) { // Make sure statics are inhabited. // Other parts of the compiler assume that there are no uninhabited places. In principle it // would be enough to check this for `extern` statics, as statics with an initializer will @@ -212,7 +212,7 @@ fn check_static_inhabited<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { /// Checks that an opaque type does not contain cycles and does not use `Self` or `T::Foo` /// projections that would result in "inheriting lifetimes". -fn check_opaque<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) { +fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) { let item = tcx.hir().item(id); let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else { tcx.sess.delay_span_bug(tcx.hir().span(id.hir_id()), "expected opaque item"); @@ -245,8 +245,8 @@ fn check_opaque<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) { /// Checks that an opaque type does not use `Self` or `T::Foo` projections that would result /// in "inheriting lifetimes". #[instrument(level = "debug", skip(tcx, span))] -pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>( - tcx: TyCtxt<'tcx>, +pub(super) fn check_opaque_for_inheriting_lifetimes( + tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span, ) { @@ -496,7 +496,7 @@ fn is_enum_of_nonnullable_ptr<'tcx>( matches!(field.ty(tcx, substs).kind(), ty::FnPtr(..) | ty::Ref(..)) } -fn check_static_linkage<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { +fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) { if tcx.codegen_fn_attrs(def_id).import_linkage.is_some() { if match tcx.type_of(def_id).kind() { ty::RawPtr(_) => false, @@ -508,7 +508,7 @@ fn check_static_linkage<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { } } -fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) { +fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) { debug!( "check_item_type(it.def_id={:?}, it.name={})", id.owner_id, @@ -1160,7 +1160,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) } #[allow(trivial_numeric_casts)] -fn check_enum<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { +fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) { let def = tcx.adt_def(def_id); def.destructor(tcx); // force the destructor to be evaluated diff --git a/compiler/rustc_hir_analysis/src/check/compare_method.rs b/compiler/rustc_hir_analysis/src/check/compare_method.rs index cddd307c13dbb..c6bda9b46410e 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_method.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_method.rs @@ -1517,8 +1517,8 @@ fn compare_generic_param_kinds<'tcx>( } /// Use `tcx.compare_assoc_const_impl_item_with_trait_item` instead -pub(crate) fn raw_compare_const_impl<'tcx>( - tcx: TyCtxt<'tcx>, +pub(crate) fn raw_compare_const_impl( + tcx: TyCtxt<'_>, (impl_const_item_def, trait_const_item_def): (LocalDefId, DefId), ) -> Result<(), ErrorGuaranteed> { let impl_const_item = tcx.associated_item(impl_const_item_def); diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 57f0cae12bb31..ed2aed293a771 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -115,10 +115,10 @@ fn adt_destructor(tcx: TyCtxt<'_>, def_id: DefId) -> Option { /// Given a `DefId` for an opaque type in return position, find its parent item's return /// expressions. -fn get_owner_return_paths<'tcx>( - tcx: TyCtxt<'tcx>, +fn get_owner_return_paths( + tcx: TyCtxt<'_>, def_id: LocalDefId, -) -> Option<(LocalDefId, ReturnsVisitor<'tcx>)> { +) -> Option<(LocalDefId, ReturnsVisitor<'_>)> { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let parent_id = tcx.hir().get_parent_item(hir_id).def_id; tcx.hir().find_by_def_id(parent_id).and_then(|node| node.body_id()).map(|body_id| { diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 94d333c336ef3..aedc736b02393 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1673,7 +1673,7 @@ fn check_method_receiver<'tcx>( } } -fn e0307<'tcx>(tcx: TyCtxt<'tcx>, span: Span, receiver_ty: Ty<'_>) { +fn e0307(tcx: TyCtxt<'_>, span: Span, receiver_ty: Ty<'_>) { struct_span_err!( tcx.sess.diagnostic(), span, diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 193ecdb167880..2790d91572bec 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -171,7 +171,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) { } } -fn visit_implementation_of_coerce_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) { +fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'_>, impl_did: LocalDefId) { debug!("visit_implementation_of_coerce_unsized: impl_did={:?}", impl_did); // Just compute this for the side-effects, in particular reporting @@ -181,7 +181,7 @@ fn visit_implementation_of_coerce_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_did: Loc tcx.at(span).coerce_unsized_info(impl_did); } -fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) { +fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDefId) { debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did); let impl_hir_id = tcx.hir().local_def_id_to_hir_id(impl_did); diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 0c4649cea14ed..b7d599f57fd44 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -839,7 +839,7 @@ fn convert_variant( ) } -fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> { +fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AdtDef<'_> { use rustc_hir::*; let def_id = def_id.expect_local(); diff --git a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs index b4ad3467e7d87..b63a8ef698d18 100644 --- a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs +++ b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs @@ -276,7 +276,7 @@ fn resolve_lifetimes(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveLife rl } -fn late_region_as_bound_region<'tcx>(tcx: TyCtxt<'tcx>, region: &Region) -> ty::BoundVariableKind { +fn late_region_as_bound_region(tcx: TyCtxt<'_>, region: &Region) -> ty::BoundVariableKind { match region { Region::LateBound(_, _, def_id) => { let name = tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id.expect_local())); @@ -1018,7 +1018,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { } } -fn object_lifetime_default<'tcx>(tcx: TyCtxt<'tcx>, param_def_id: DefId) -> ObjectLifetimeDefault { +fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: DefId) -> ObjectLifetimeDefault { debug_assert_eq!(tcx.def_kind(param_def_id), DefKind::TyParam); let param_def_id = param_def_id.expect_local(); let parent_def_id = tcx.local_parent(param_def_id); diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 79d75231e5d76..0943350e2d47c 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -318,10 +318,10 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP } } -fn const_evaluatable_predicates_of<'tcx>( - tcx: TyCtxt<'tcx>, +fn const_evaluatable_predicates_of( + tcx: TyCtxt<'_>, def_id: LocalDefId, -) -> FxIndexSet<(ty::Predicate<'tcx>, Span)> { +) -> FxIndexSet<(ty::Predicate<'_>, Span)> { struct ConstCollector<'tcx> { tcx: TyCtxt<'tcx>, preds: FxIndexSet<(ty::Predicate<'tcx>, Span)>, diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index fd8e8ed7ba605..b60fc276178b3 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -157,11 +157,11 @@ fn check_constness(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node, /// ``` /// /// Would return `S1 = [C]` and `S2 = [Vec, C]`. -fn get_impl_substs<'tcx>( - tcx: TyCtxt<'tcx>, +fn get_impl_substs( + tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node, -) -> Option<(SubstsRef<'tcx>, SubstsRef<'tcx>)> { +) -> Option<(SubstsRef<'_>, SubstsRef<'_>)> { let infcx = &tcx.infer_ctxt().build(); let ocx = ObligationCtxt::new(infcx); let param_env = tcx.param_env(impl1_def_id); diff --git a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs index af8d7e8515865..a46f2a94cd281 100644 --- a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs +++ b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs @@ -13,9 +13,9 @@ use super::utils::*; /// `global_inferred_outlives`: this is initially the empty map that /// was generated by walking the items in the crate. This will /// now be filled with inferred predicates. -pub(super) fn infer_predicates<'tcx>( - tcx: TyCtxt<'tcx>, -) -> FxHashMap>> { +pub(super) fn infer_predicates( + tcx: TyCtxt<'_>, +) -> FxHashMap>> { debug!("infer_predicates"); let mut explicit_map = ExplicitPredicatesMap::new(); diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 8cdd12e4e347a..b0cd4a16e9869 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -118,7 +118,7 @@ fn identity(_: Ty<'_>) -> Vec> { vec![] } -fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec> { +fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec> { move |target| vec![Adjustment { kind, target }] } diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 03b174c77955f..7774ffc9b9793 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -756,8 +756,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { /// - When reporting the Place back to the Delegate, ensure that the UpvarId uses the enclosing /// closure as the DefId. fn walk_captures(&mut self, closure_expr: &hir::Closure<'_>) { - fn upvar_is_local_variable<'tcx>( - upvars: Option<&'tcx FxIndexMap>, + fn upvar_is_local_variable( + upvars: Option<&FxIndexMap>, upvar_id: hir::HirId, body_owner_is_closure: bool, ) -> bool { diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs index 2f55ea939fc0b..f7b493bc2242b 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs @@ -79,7 +79,7 @@ pub fn compute_drop_ranges<'a, 'tcx>( /// result of `foo`. On the other hand, if `place` points to `x` then `f` will /// be called both on the `ExprKind::Path` node that represents the expression /// as well as the HirId of the local `x` itself. -fn for_each_consumable<'tcx>(hir: Map<'tcx>, place: TrackedValue, mut f: impl FnMut(TrackedValue)) { +fn for_each_consumable(hir: Map<'_>, place: TrackedValue, mut f: impl FnMut(TrackedValue)) { f(place); let node = hir.find(place.hir_id()); if let Some(Node::Expr(expr)) = node { diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 5b2352cda34b3..b06927f9662be 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -462,8 +462,8 @@ fn fatally_break_rust(sess: &Session) { )); } -fn has_expected_num_generic_args<'tcx>( - tcx: TyCtxt<'tcx>, +fn has_expected_num_generic_args( + tcx: TyCtxt<'_>, trait_did: Option, expected: usize, ) -> bool { diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index b12d84af4adbc..9f0d175c4c669 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -904,7 +904,7 @@ enum Op { } /// Dereferences a single level of immutable referencing. -fn deref_ty_if_possible<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> { +fn deref_ty_if_possible(ty: Ty<'_>) -> Ty<'_> { match ty.kind() { ty::Ref(_, ty, hir::Mutability::Not) => *ty, _ => ty, diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 0f46972019e52..a9347991e7f98 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -1675,7 +1675,7 @@ fn apply_capture_kind_on_capture_ty<'tcx>( } /// Returns the Span of where the value with the provided HirId would be dropped -fn drop_location_span<'tcx>(tcx: TyCtxt<'tcx>, hir_id: hir::HirId) -> Span { +fn drop_location_span(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> Span { let owner_id = tcx.hir().get_enclosing_scope(hir_id).unwrap(); let owner_node = tcx.hir().get(owner_id); @@ -1843,10 +1843,10 @@ fn restrict_precision_for_drop_types<'a, 'tcx>( /// - No projections are applied to raw pointers, since these require unsafe blocks. We capture /// them completely. /// - No projections are applied on top of Union ADTs, since these require unsafe blocks. -fn restrict_precision_for_unsafe<'tcx>( - mut place: Place<'tcx>, +fn restrict_precision_for_unsafe( + mut place: Place<'_>, mut curr_mode: ty::UpvarCapture, -) -> (Place<'tcx>, ty::UpvarCapture) { +) -> (Place<'_>, ty::UpvarCapture) { if place.base_ty.is_unsafe_ptr() { truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, 0); } @@ -1876,10 +1876,10 @@ fn restrict_precision_for_unsafe<'tcx>( /// - No Index projections are captured, since arrays are captured completely. /// - No unsafe block is required to capture `place` /// Returns the truncated place and updated capture mode. -fn restrict_capture_precision<'tcx>( - place: Place<'tcx>, +fn restrict_capture_precision( + place: Place<'_>, curr_mode: ty::UpvarCapture, -) -> (Place<'tcx>, ty::UpvarCapture) { +) -> (Place<'_>, ty::UpvarCapture) { let (mut place, mut curr_mode) = restrict_precision_for_unsafe(place, curr_mode); if place.projections.is_empty() { @@ -1904,10 +1904,10 @@ fn restrict_capture_precision<'tcx>( } /// Truncate deref of any reference. -fn adjust_for_move_closure<'tcx>( - mut place: Place<'tcx>, +fn adjust_for_move_closure( + mut place: Place<'_>, mut kind: ty::UpvarCapture, -) -> (Place<'tcx>, ty::UpvarCapture) { +) -> (Place<'_>, ty::UpvarCapture) { let first_deref = place.projections.iter().position(|proj| proj.kind == ProjectionKind::Deref); if let Some(idx) = first_deref { @@ -1919,10 +1919,10 @@ fn adjust_for_move_closure<'tcx>( /// Adjust closure capture just that if taking ownership of data, only move data /// from enclosing stack frame. -fn adjust_for_non_move_closure<'tcx>( - mut place: Place<'tcx>, +fn adjust_for_non_move_closure( + mut place: Place<'_>, mut kind: ty::UpvarCapture, -) -> (Place<'tcx>, ty::UpvarCapture) { +) -> (Place<'_>, ty::UpvarCapture) { let contains_deref = place.projections.iter().position(|proj| proj.kind == ProjectionKind::Deref); @@ -2225,10 +2225,10 @@ fn determine_place_ancestry_relation<'tcx>( /// // it is constrained to `'a` /// } /// ``` -fn truncate_capture_for_optimization<'tcx>( - mut place: Place<'tcx>, +fn truncate_capture_for_optimization( + mut place: Place<'_>, mut curr_mode: ty::UpvarCapture, -) -> (Place<'tcx>, ty::UpvarCapture) { +) -> (Place<'_>, ty::UpvarCapture) { let is_shared_ref = |ty: Ty<'_>| matches!(ty.kind(), ty::Ref(.., hir::Mutability::Not)); // Find the right-most deref (if any). All the projections that come after this diff --git a/compiler/rustc_incremental/src/assert_dep_graph.rs b/compiler/rustc_incremental/src/assert_dep_graph.rs index b4bf9f4bcc767..67b4d6d6959f6 100644 --- a/compiler/rustc_incremental/src/assert_dep_graph.rs +++ b/compiler/rustc_incremental/src/assert_dep_graph.rs @@ -432,10 +432,7 @@ fn walk_between<'q>( } } -fn filter_edges<'q>( - query: &'q DepGraphQuery, - nodes: &FxHashSet, -) -> Vec<(DepKind, DepKind)> { +fn filter_edges(query: &DepGraphQuery, nodes: &FxHashSet) -> Vec<(DepKind, DepKind)> { let uniq: FxHashSet<_> = query .edges() .into_iter() diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 269fc95420ade..96a976fb89e0f 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2199,10 +2199,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ); } - fn binding_suggestion<'tcx, S: fmt::Display>( + fn binding_suggestion( err: &mut Diagnostic, type_param_span: Option<(Span, bool)>, - bound_kind: GenericKind<'tcx>, + bound_kind: GenericKind<'_>, sub: S, add_lt_sugg: Option<(Span, String)>, ) { diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index c1820ac4d1eab..8dccfe0046c45 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -304,7 +304,7 @@ fn check_panic_str<'tcx>( /// Given the span of `some_macro!(args);`, gives the span of `(` and `)`, /// and the type of (opening) delimiter used. -fn find_delimiters<'tcx>(cx: &LateContext<'tcx>, span: Span) -> Option<(Span, Span, char)> { +fn find_delimiters(cx: &LateContext<'_>, span: Span) -> Option<(Span, Span, char)> { let snippet = cx.sess().parse_sess.source_map().span_to_snippet(span).ok()?; let (open, open_ch) = snippet.char_indices().find(|&(_, c)| "([{".contains(c))?; let close = snippet.rfind(|c| ")]}".contains(c))?; diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index f7a4103f4d5c1..67868ded0b86b 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1405,7 +1405,7 @@ declare_lint! { /// struct S; /// /// impl S { - /// fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + /// fn late(self, _: &u8, _: &u8) {} /// } /// /// fn main() { diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index 446aebe4f83f5..767db36732259 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -29,7 +29,7 @@ impl SubdiagnosticDeriveBuilder { Self { diag, f } } - pub(crate) fn into_tokens<'a>(self, mut structure: Structure<'a>) -> TokenStream { + pub(crate) fn into_tokens(self, mut structure: Structure<'_>) -> TokenStream { let implementation = { let ast = structure.ast(); let span = ast.span().unwrap(); diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index da90233523ca3..4ff9c777ad858 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -385,7 +385,7 @@ impl quote::ToTokens for Applicability { /// Build the mapping of field names to fields. This allows attributes to peek values from /// other fields. -pub(super) fn build_field_mapping<'v>(variant: &VariantInfo<'v>) -> HashMap { +pub(super) fn build_field_mapping(variant: &VariantInfo<'_>) -> HashMap { let mut fields_map = FieldMap::new(); for binding in variant.bindings() { if let Some(ident) = &binding.ast().ident { diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 9ce3ff98ba985..b34dc0df1e280 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -520,8 +520,8 @@ impl<'a> CrateLoader<'a> { })) } - fn resolve_crate<'b>( - &'b mut self, + fn resolve_crate( + &mut self, name: Symbol, span: Span, dep_kind: CrateDepKind, diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 4af423f2a22e4..d5d31bc3edc97 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1093,7 +1093,7 @@ fn should_encode_const(def_kind: DefKind) -> bool { } } -fn should_encode_trait_impl_trait_tys<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { +fn should_encode_trait_impl_trait_tys(tcx: TyCtxt<'_>, def_id: DefId) -> bool { if tcx.def_kind(def_id) != DefKind::AssocFn { return false; } diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 6b55682691855..865bb70afb506 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -175,7 +175,7 @@ impl DepNodeExt for DepNode { /// DepNode. Condition (2) might not be fulfilled if a DepNode /// refers to something from the previous compilation session that /// has been removed. - fn extract_def_id<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option { + fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option { if tcx.fingerprint_style(self.kind) == FingerprintStyle::DefPathHash { Some(tcx.def_path_hash_to_def_id(DefPathHash(self.hash.into()), &mut || { panic!("Failed to extract DefId: {:?} {}", self.kind, self.hash) diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 0450abed51b06..cfdeb76ca2699 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -18,7 +18,7 @@ use rustc_span::Span; use rustc_target::spec::abi::Abi; #[inline] -pub fn associated_body<'hir>(node: Node<'hir>) -> Option { +pub fn associated_body(node: Node<'_>) -> Option { match node { Node::Item(Item { kind: ItemKind::Const(_, body) | ItemKind::Static(.., body) | ItemKind::Fn(.., body), @@ -41,7 +41,7 @@ pub fn associated_body<'hir>(node: Node<'hir>) -> Option { } } -fn is_body_owner<'hir>(node: Node<'hir>, hir_id: HirId) -> bool { +fn is_body_owner(node: Node<'_>, hir_id: HirId) -> bool { match associated_body(node) { Some(b) => b.hir_id == hir_id, None => false, diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 61bc089e431bb..0836f236e248f 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -223,8 +223,8 @@ pub fn deprecation_message_and_lint( ) } -pub fn early_report_deprecation<'a>( - lint_buffer: &'a mut LintBuffer, +pub fn early_report_deprecation( + lint_buffer: &mut LintBuffer, message: &str, suggestion: Option, lint: &'static Lint, diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index ffdf61d424422..50e41e3e00631 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -1767,9 +1767,9 @@ impl SourceScope { /// Finds the original HirId this MIR item came from. /// This is necessary after MIR optimizations, as otherwise we get a HirId /// from the function that was inlined instead of the function call site. - pub fn lint_root<'tcx>( + pub fn lint_root( self, - source_scopes: &IndexVec>, + source_scopes: &IndexVec>, ) -> Option { let mut data = &source_scopes[self]; // FIXME(oli-obk): we should be able to just walk the `inlined_parent_scope`, but it diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 1ebfdbbd6ef00..40289af257ff4 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -88,7 +88,7 @@ pub fn dump_mir<'tcx, F>( dump_matched_mir_node(tcx, pass_num, pass_name, disambiguator, body, extra_data); } -pub fn dump_enabled<'tcx>(tcx: TyCtxt<'tcx>, pass_name: &str, def_id: DefId) -> bool { +pub fn dump_enabled(tcx: TyCtxt<'_>, pass_name: &str, def_id: DefId) -> bool { let Some(ref filters) = tcx.sess.opts.unstable_opts.dump_mir else { return false; }; @@ -421,7 +421,7 @@ impl<'tcx> ExtraComments<'tcx> { } } -fn use_verbose<'tcx>(ty: Ty<'tcx>, fn_def: bool) -> bool { +fn use_verbose(ty: Ty<'_>, fn_def: bool) -> bool { match *ty.kind() { ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_) => false, // Unit type diff --git a/compiler/rustc_middle/src/mir/spanview.rs b/compiler/rustc_middle/src/mir/spanview.rs index 4e06d91012c0d..887ee57157540 100644 --- a/compiler/rustc_middle/src/mir/spanview.rs +++ b/compiler/rustc_middle/src/mir/spanview.rs @@ -230,7 +230,7 @@ where } /// Format a string showing the start line and column, and end line and column within a file. -pub fn source_range_no_file<'tcx>(tcx: TyCtxt<'tcx>, span: Span) -> String { +pub fn source_range_no_file(tcx: TyCtxt<'_>, span: Span) -> String { let source_map = tcx.sess.source_map(); let start = source_map.lookup_char_pos(span.lo()); let end = source_map.lookup_char_pos(span.hi()); @@ -322,7 +322,7 @@ fn block_span_viewable<'tcx>( Some(SpanViewable { bb, span, id, tooltip }) } -fn compute_block_span<'tcx>(data: &BasicBlockData<'tcx>, body_span: Span) -> Span { +fn compute_block_span(data: &BasicBlockData<'_>, body_span: Span) -> Span { let mut span = data.terminator().source_info.span; for statement_span in data.statements.iter().map(|statement| statement.source_info.span) { // Only combine Spans from the root context, and within the function's body_span. @@ -522,12 +522,7 @@ where } #[inline(always)] -fn write_coverage_gap<'tcx, W>( - tcx: TyCtxt<'tcx>, - lo: BytePos, - hi: BytePos, - w: &mut W, -) -> io::Result<()> +fn write_coverage_gap(tcx: TyCtxt<'_>, lo: BytePos, hi: BytePos, w: &mut W) -> io::Result<()> where W: Write, { @@ -582,8 +577,8 @@ where Ok(()) } -fn make_html_snippet<'tcx>( - tcx: TyCtxt<'tcx>, +fn make_html_snippet( + tcx: TyCtxt<'_>, span: Span, some_viewable: Option<&SpanViewable>, ) -> Option { @@ -664,7 +659,7 @@ fn trim_span_hi(span: Span, to_pos: BytePos) -> Span { if to_pos >= span.hi() { span } else { span.with_hi(cmp::max(span.lo(), to_pos)) } } -fn fn_span<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Span { +fn fn_span(tcx: TyCtxt<'_>, def_id: DefId) -> Span { let fn_decl_span = tcx.def_span(def_id); if let Some(body_span) = hir_body(tcx, def_id).map(|hir_body| hir_body.value.span) { if fn_decl_span.eq_ctxt(body_span) { fn_decl_span.to(body_span) } else { body_span } @@ -673,7 +668,7 @@ fn fn_span<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Span { } } -fn hir_body<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<&'tcx rustc_hir::Body<'tcx>> { +fn hir_body(tcx: TyCtxt<'_>, def_id: DefId) -> Option<&rustc_hir::Body<'_>> { let hir_node = tcx.hir().get_if_local(def_id).expect("expected DefId is local"); hir::map::associated_body(hir_node).map(|fn_body_id| tcx.hir().body(fn_body_id)) } diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index 55b2c592795bf..0b461d1ce41c5 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -302,7 +302,7 @@ pub fn reachable<'a, 'tcx>( } /// Returns a `BitSet` containing all basic blocks reachable from the `START_BLOCK`. -pub fn reachable_as_bitset<'tcx>(body: &Body<'tcx>) -> BitSet { +pub fn reachable_as_bitset(body: &Body<'_>) -> BitSet { let mut iter = preorder(body); (&mut iter).for_each(drop); iter.visited diff --git a/compiler/rustc_middle/src/traits/chalk.rs b/compiler/rustc_middle/src/traits/chalk.rs index 6d4af8bea6281..dd75b0d9ebc23 100644 --- a/compiler/rustc_middle/src/traits/chalk.rs +++ b/compiler/rustc_middle/src/traits/chalk.rs @@ -210,7 +210,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { Box::new(chalk_ir::TyData { kind: ty, flags: flags }) } - fn ty_data<'a>(self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData { + fn ty_data(self, ty: &Self::InternedType) -> &chalk_ir::TyData { ty } @@ -218,10 +218,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { Box::new(lifetime) } - fn lifetime_data<'a>( - self, - lifetime: &'a Self::InternedLifetime, - ) -> &'a chalk_ir::LifetimeData { + fn lifetime_data(self, lifetime: &Self::InternedLifetime) -> &chalk_ir::LifetimeData { &lifetime } @@ -229,7 +226,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { Box::new(constant) } - fn const_data<'a>(self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData { + fn const_data(self, constant: &Self::InternedConst) -> &chalk_ir::ConstData { &constant } @@ -246,10 +243,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { Box::new(data) } - fn generic_arg_data<'a>( - self, - data: &'a Self::InternedGenericArg, - ) -> &'a chalk_ir::GenericArgData { + fn generic_arg_data(self, data: &Self::InternedGenericArg) -> &chalk_ir::GenericArgData { &data } @@ -257,7 +251,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { Box::new(goal) } - fn goal_data<'a>(self, goal: &'a Self::InternedGoal) -> &'a chalk_ir::GoalData { + fn goal_data(self, goal: &Self::InternedGoal) -> &chalk_ir::GoalData { &goal } @@ -268,7 +262,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn goals_data<'a>(self, goals: &'a Self::InternedGoals) -> &'a [chalk_ir::Goal] { + fn goals_data(self, goals: &Self::InternedGoals) -> &[chalk_ir::Goal] { goals } @@ -279,10 +273,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn substitution_data<'a>( + fn substitution_data( self, - substitution: &'a Self::InternedSubstitution, - ) -> &'a [chalk_ir::GenericArg] { + substitution: &Self::InternedSubstitution, + ) -> &[chalk_ir::GenericArg] { substitution } @@ -293,10 +287,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { Box::new(data) } - fn program_clause_data<'a>( + fn program_clause_data( self, - clause: &'a Self::InternedProgramClause, - ) -> &'a chalk_ir::ProgramClauseData { + clause: &Self::InternedProgramClause, + ) -> &chalk_ir::ProgramClauseData { &clause } @@ -307,10 +301,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn program_clauses_data<'a>( + fn program_clauses_data( self, - clauses: &'a Self::InternedProgramClauses, - ) -> &'a [chalk_ir::ProgramClause] { + clauses: &Self::InternedProgramClauses, + ) -> &[chalk_ir::ProgramClause] { clauses } @@ -321,10 +315,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn quantified_where_clauses_data<'a>( + fn quantified_where_clauses_data( self, - clauses: &'a Self::InternedQuantifiedWhereClauses, - ) -> &'a [chalk_ir::QuantifiedWhereClause] { + clauses: &Self::InternedQuantifiedWhereClauses, + ) -> &[chalk_ir::QuantifiedWhereClause] { clauses } @@ -335,10 +329,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn variable_kinds_data<'a>( + fn variable_kinds_data( self, - parameter_kinds: &'a Self::InternedVariableKinds, - ) -> &'a [chalk_ir::VariableKind] { + parameter_kinds: &Self::InternedVariableKinds, + ) -> &[chalk_ir::VariableKind] { parameter_kinds } @@ -349,10 +343,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn canonical_var_kinds_data<'a>( + fn canonical_var_kinds_data( self, - canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, - ) -> &'a [chalk_ir::CanonicalVarKind] { + canonical_var_kinds: &Self::InternedCanonicalVarKinds, + ) -> &[chalk_ir::CanonicalVarKind] { canonical_var_kinds } @@ -363,10 +357,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn constraints_data<'a>( + fn constraints_data( self, - constraints: &'a Self::InternedConstraints, - ) -> &'a [chalk_ir::InEnvironment>] { + constraints: &Self::InternedConstraints, + ) -> &[chalk_ir::InEnvironment>] { constraints } @@ -377,10 +371,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { data.into_iter().collect::, _>>() } - fn variances_data<'a>( - self, - variances: &'a Self::InternedVariances, - ) -> &'a [chalk_ir::Variance] { + fn variances_data(self, variances: &Self::InternedVariances) -> &[chalk_ir::Variance] { variances } } diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs index cccedc9ec6ea9..7b0979acd5bbc 100644 --- a/compiler/rustc_middle/src/traits/specialization_graph.rs +++ b/compiler/rustc_middle/src/traits/specialization_graph.rs @@ -60,7 +60,7 @@ pub enum OverlapMode { } impl OverlapMode { - pub fn get<'tcx>(tcx: TyCtxt<'tcx>, trait_id: DefId) -> OverlapMode { + pub fn get(tcx: TyCtxt<'_>, trait_id: DefId) -> OverlapMode { let with_negative_coherence = tcx.features().with_negative_coherence; let strict_coherence = tcx.has_attr(trait_id, sym::rustc_strict_coherence); @@ -253,11 +253,11 @@ impl<'tcx> Ancestors<'tcx> { /// /// Returns `Err` if an error was reported while building the specialization /// graph. -pub fn ancestors<'tcx>( - tcx: TyCtxt<'tcx>, +pub fn ancestors( + tcx: TyCtxt<'_>, trait_def_id: DefId, start_from_impl: DefId, -) -> Result, ErrorGuaranteed> { +) -> Result, ErrorGuaranteed> { let specialization_graph = tcx.specialization_graph_of(trait_def_id); if let Some(reported) = specialization_graph.has_errored { diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index d00553cbad131..6ade8935fc84f 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -238,10 +238,7 @@ impl<'tcx> CapturedPlace<'tcx> { } } -fn symbols_for_closure_captures<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: (LocalDefId, LocalDefId), -) -> Vec { +fn symbols_for_closure_captures(tcx: TyCtxt<'_>, def_id: (LocalDefId, LocalDefId)) -> Vec { let typeck_results = tcx.typeck(def_id.0); let captures = typeck_results.closure_min_captures_flattened(def_id.1); captures.into_iter().map(|captured_place| captured_place.to_symbol(tcx)).collect() diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index e5abc38046ced..152a7e9d43fa4 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -239,7 +239,7 @@ impl<'tcx> Const<'tcx> { } } -pub fn const_param_default<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Const<'tcx> { +pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> Const<'_> { let default_def_id = match tcx.hir().get_by_def_id(def_id.expect_local()) { hir::Node::GenericParam(hir::GenericParam { kind: hir::GenericParamKind::Const { default: Some(ac), .. }, diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 2a8a4d598882d..48958e0d9e91c 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -232,7 +232,7 @@ impl ScalarInt { } #[inline] - pub fn try_to_machine_usize<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Result { + pub fn try_to_machine_usize(&self, tcx: TyCtxt<'_>) -> Result { Ok(self.to_bits(tcx.data_layout.pointer_size)? as u64) } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 8f4d56c65b985..5de414077a2b1 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1518,7 +1518,7 @@ impl<'tcx, T: 'tcx + ?Sized> IntoPointer for InternedInSet<'tcx, T> { #[allow(rustc::usage_of_ty_tykind)] impl<'tcx, T> Borrow for InternedInSet<'tcx, WithCachedTypeInfo> { - fn borrow<'a>(&'a self) -> &'a T { + fn borrow(&self) -> &T { &self.0.internee } } @@ -1541,7 +1541,7 @@ impl<'tcx, T: Hash> Hash for InternedInSet<'tcx, WithCachedTypeInfo> { } impl<'tcx, T> Borrow<[T]> for InternedInSet<'tcx, List> { - fn borrow<'a>(&'a self) -> &'a [T] { + fn borrow(&self) -> &[T] { &self.0[..] } } diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 042b89bc4b01f..8306d670a65de 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -22,7 +22,7 @@ impl FlagComputation { result } - pub fn for_predicate<'tcx>(binder: ty::Binder<'tcx, ty::PredicateKind<'_>>) -> FlagComputation { + pub fn for_predicate(binder: ty::Binder<'_, ty::PredicateKind<'_>>) -> FlagComputation { let mut result = FlagComputation::new(); result.add_predicate(binder); result diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 7f66b993646a3..9e0ca44d0981d 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -993,7 +993,7 @@ where /// might (from a foreign exception or similar). #[inline] #[tracing::instrument(level = "debug", skip(tcx))] -pub fn fn_can_unwind<'tcx>(tcx: TyCtxt<'tcx>, fn_def_id: Option, abi: SpecAbi) -> bool { +pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option, abi: SpecAbi) -> bool { if let Some(did) = fn_def_id { // Special attribute for functions which can't unwind. if tcx.codegen_fn_attrs(did).flags.contains(CodegenFnAttrFlags::NEVER_UNWIND) { diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 5d0af1d4eadc8..6d3b94c1fdbf8 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1248,7 +1248,7 @@ pub fn needs_drop_components<'tcx>( } } -pub fn is_trivially_const_drop<'tcx>(ty: Ty<'tcx>) -> bool { +pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool { match *ty.kind() { ty::Bool | ty::Char diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index edd527286264a..e22fa6365dcb4 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -81,8 +81,8 @@ pub(in crate::build) struct PlaceBuilder<'tcx> { /// ProjectionElems `Downcast`, `ConstantIndex`, `Index`, or `Subslice` because those will never be /// part of a path that is captured by a closure. We stop applying projections once we see the first /// projection that isn't captured by a closure. -fn convert_to_hir_projections_and_truncate_for_capture<'tcx>( - mir_projections: &[PlaceElem<'tcx>], +fn convert_to_hir_projections_and_truncate_for_capture( + mir_projections: &[PlaceElem<'_>], ) -> Vec { let mut hir_projections = Vec::new(); let mut variant = None; diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index c785dfb500fc9..9daf68a15f4b1 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -28,10 +28,10 @@ use rustc_target::spec::abi::Abi; use super::lints; -pub(crate) fn mir_built<'tcx>( - tcx: TyCtxt<'tcx>, +pub(crate) fn mir_built( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> &'tcx rustc_data_structures::steal::Steal> { +) -> &rustc_data_structures::steal::Steal> { if let Some(def) = def.try_upgrade(tcx) { return tcx.mir_built(def); } @@ -625,12 +625,12 @@ fn construct_const<'a, 'tcx>( /// /// This is required because we may still want to run MIR passes on an item /// with type errors, but normal MIR construction can't handle that in general. -fn construct_error<'tcx>( - tcx: TyCtxt<'tcx>, +fn construct_error( + tcx: TyCtxt<'_>, def: LocalDefId, body_owner_kind: hir::BodyOwnerKind, err: ErrorGuaranteed, -) -> Body<'tcx> { +) -> Body<'_> { let span = tcx.def_span(def); let hir_id = tcx.hir().local_def_id_to_hir_id(def); let generator_kind = tcx.generator_kind(def); diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 99e96ff77ced9..3c311729a52aa 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -703,7 +703,7 @@ impl UnsafeOpKind { } } -pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam) { +pub fn check_unsafety(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) { // THIR unsafeck is gated under `-Z thir-unsafeck` if !tcx.sess.opts.unstable_opts.thir_unsafeck { return; @@ -749,7 +749,7 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { +pub(crate) fn thir_check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) { if let Some(def) = ty::WithOptConstParam::try_lookup(def_id, tcx) { tcx.thir_check_unsafety_for_const_arg(def) } else { @@ -757,8 +757,8 @@ pub(crate) fn thir_check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { } } -pub(crate) fn thir_check_unsafety_for_const_arg<'tcx>( - tcx: TyCtxt<'tcx>, +pub(crate) fn thir_check_unsafety_for_const_arg( + tcx: TyCtxt<'_>, (did, param_did): (LocalDefId, DefId), ) { check_unsafety(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) }) diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index b5c4b7b137d4c..a355e1bdab5f5 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -18,10 +18,10 @@ use rustc_middle::thir::*; use rustc_middle::ty::{self, RvalueScopes, TyCtxt}; use rustc_span::Span; -pub(crate) fn thir_body<'tcx>( - tcx: TyCtxt<'tcx>, +pub(crate) fn thir_body( + tcx: TyCtxt<'_>, owner_def: ty::WithOptConstParam, -) -> Result<(&'tcx Steal>, ExprId), ErrorGuaranteed> { +) -> Result<(&Steal>, ExprId), ErrorGuaranteed> { let hir = tcx.hir(); let body = hir.body(hir.body_owned_by(owner_def.did)); let mut cx = Cx::new(tcx, owner_def); @@ -52,10 +52,7 @@ pub(crate) fn thir_body<'tcx>( Ok((tcx.alloc_steal_thir(cx.thir), expr)) } -pub(crate) fn thir_tree<'tcx>( - tcx: TyCtxt<'tcx>, - owner_def: ty::WithOptConstParam, -) -> String { +pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: ty::WithOptConstParam) -> String { match thir_body(tcx, owner_def) { Ok((thir, _)) => format!("{:#?}", thir.steal()), Err(_) => "error".into(), diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 7e1f708b0d6a1..6470efab2e93c 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -70,7 +70,7 @@ mod fallback_to_const_ref { /// hoops to get a reference to the value. pub(super) struct FallbackToConstRef(()); - pub(super) fn fallback_to_const_ref<'tcx>(c2p: &super::ConstToPat<'tcx>) -> FallbackToConstRef { + pub(super) fn fallback_to_const_ref(c2p: &super::ConstToPat<'_>) -> FallbackToConstRef { assert!(c2p.behind_reference.get()); FallbackToConstRef(()) } diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 18e9c69c4870e..a95349d767098 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -404,7 +404,7 @@ impl SplitIntRange { } /// Iterate over the contained ranges. - fn iter<'a>(&'a self) -> impl Iterator + Captures<'a> { + fn iter(&self) -> impl Iterator + Captures<'_> { use IntBorder::*; let self_range = Self::to_borders(self.range.clone()); @@ -612,7 +612,7 @@ impl SplitVarLenSlice { } /// Iterate over the partition of this slice. - fn iter<'a>(&'a self) -> impl Iterator + Captures<'a> { + fn iter(&self) -> impl Iterator + Captures<'_> { let smaller_lengths = match self.array_len { // The only admissible fixed-length slice is one of the array size. Whether `max_slice` // is fixed-length or variable-length, it will be the only relevant slice to output diff --git a/compiler/rustc_mir_dataflow/src/impls/liveness.rs b/compiler/rustc_mir_dataflow/src/impls/liveness.rs index 3e08a8799ef9a..923dc16c11b07 100644 --- a/compiler/rustc_mir_dataflow/src/impls/liveness.rs +++ b/compiler/rustc_mir_dataflow/src/impls/liveness.rs @@ -149,7 +149,7 @@ enum DefUse { } impl DefUse { - fn apply<'tcx>(trans: &mut impl GenKill, place: Place<'tcx>, context: PlaceContext) { + fn apply(trans: &mut impl GenKill, place: Place<'_>, context: PlaceContext) { match DefUse::for_place(place, context) { Some(DefUse::Def) => trans.kill(place.local), Some(DefUse::Use) => trans.gen(place.local), @@ -157,7 +157,7 @@ impl DefUse { } } - fn for_place<'tcx>(place: Place<'tcx>, context: PlaceContext) -> Option { + fn for_place(place: Place<'_>, context: PlaceContext) -> Option { match context { PlaceContext::NonUse(_) => None, diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 7df0114226418..fe5ee4011ab84 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -823,7 +823,7 @@ fn iter_fields<'tcx>( } /// Returns all locals with projections that have their reference or address taken. -fn excluded_locals<'tcx>(body: &Body<'tcx>) -> IndexVec { +fn excluded_locals(body: &Body<'_>) -> IndexVec { struct Collector { result: IndexVec, } diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs index 9c22b5df73ce8..adf6ae4c7270f 100644 --- a/compiler/rustc_mir_transform/src/check_unsafety.rs +++ b/compiler/rustc_mir_transform/src/check_unsafety.rs @@ -490,10 +490,10 @@ fn check_unused_unsafe( unused_unsafes } -fn unsafety_check_result<'tcx>( - tcx: TyCtxt<'tcx>, +fn unsafety_check_result( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> &'tcx UnsafetyCheckResult { +) -> &UnsafetyCheckResult { debug!("unsafety_violations({:?})", def); // N.B., this borrow is valid because all the consumers of diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs index 604810144887a..1468afc64563d 100644 --- a/compiler/rustc_mir_transform/src/coverage/mod.rs +++ b/compiler/rustc_mir_transform/src/coverage/mod.rs @@ -533,10 +533,10 @@ fn make_code_region( } } -fn fn_sig_and_body<'tcx>( - tcx: TyCtxt<'tcx>, +fn fn_sig_and_body( + tcx: TyCtxt<'_>, def_id: DefId, -) -> (Option<&'tcx rustc_hir::FnSig<'tcx>>, &'tcx rustc_hir::Body<'tcx>) { +) -> (Option<&rustc_hir::FnSig<'_>>, &rustc_hir::Body<'_>) { // FIXME(#79625): Consider improving MIR to provide the information needed, to avoid going back // to HIR for it. let hir_node = tcx.hir().get_if_local(def_id).expect("expected DefId is local"); diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs index dc1e68b253e72..3bd7f31b45dca 100644 --- a/compiler/rustc_mir_transform/src/coverage/query.rs +++ b/compiler/rustc_mir_transform/src/coverage/query.rs @@ -136,7 +136,7 @@ fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, instance_def: ty::InstanceDef<'tcx>) -> coverage_visitor.info } -fn covered_code_regions<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Vec<&'tcx CodeRegion> { +fn covered_code_regions(tcx: TyCtxt<'_>, def_id: DefId) -> Vec<&CodeRegion> { let body = mir_body(tcx, def_id); body.basic_blocks .iter() @@ -163,7 +163,7 @@ fn is_inlined(body: &Body<'_>, statement: &Statement<'_>) -> bool { /// This function ensures we obtain the correct MIR for the given item irrespective of /// whether that means const mir or runtime mir. For `const fn` this opts for runtime /// mir. -fn mir_body<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx mir::Body<'tcx> { +fn mir_body(tcx: TyCtxt<'_>, def_id: DefId) -> &mir::Body<'_> { let id = ty::WithOptConstParam::unknown(def_id); let def = ty::InstanceDef::Item(id); tcx.instance_mir(def) diff --git a/compiler/rustc_mir_transform/src/coverage/tests.rs b/compiler/rustc_mir_transform/src/coverage/tests.rs index eba6a2b34e47d..8f2bb11639f18 100644 --- a/compiler/rustc_mir_transform/src/coverage/tests.rs +++ b/compiler/rustc_mir_transform/src/coverage/tests.rs @@ -169,7 +169,7 @@ impl<'tcx> MockBlocks<'tcx> { } } -fn debug_basic_blocks<'tcx>(mir_body: &Body<'tcx>) -> String { +fn debug_basic_blocks(mir_body: &Body) -> String { format!( "{:?}", mir_body diff --git a/compiler/rustc_mir_transform/src/deduce_param_attrs.rs b/compiler/rustc_mir_transform/src/deduce_param_attrs.rs index 92f1fff6beb95..ddab7bbb2e301 100644 --- a/compiler/rustc_mir_transform/src/deduce_param_attrs.rs +++ b/compiler/rustc_mir_transform/src/deduce_param_attrs.rs @@ -129,7 +129,7 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly { } /// Returns true if values of a given type will never be passed indirectly, regardless of ABI. -fn type_will_always_be_passed_directly<'tcx>(ty: Ty<'tcx>) -> bool { +fn type_will_always_be_passed_directly(ty: Ty<'_>) -> bool { matches!( ty.kind(), ty::Bool diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index 74d8337653f03..08e296a837127 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -658,7 +658,7 @@ impl WriteInfo { } } - fn add_place<'tcx>(&mut self, place: Place<'tcx>) { + fn add_place(&mut self, place: Place<'_>) { self.writes.push(place.local); } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index aba5a8580f194..ae79c2290f6d3 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -266,10 +266,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> /// Make MIR ready for const evaluation. This is run on all MIR, not just on consts! /// FIXME(oli-obk): it's unclear whether we still need this phase (and its corresponding query). /// We used to have this for pre-miri MIR based const eval. -fn mir_const<'tcx>( - tcx: TyCtxt<'tcx>, - def: ty::WithOptConstParam, -) -> &'tcx Steal> { +fn mir_const(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> &Steal> { if let Some(def) = def.try_upgrade(tcx) { return tcx.mir_const(def); } @@ -308,10 +305,10 @@ fn mir_const<'tcx>( } /// Compute the main MIR body and the list of MIR bodies of the promoteds. -fn mir_promoted<'tcx>( - tcx: TyCtxt<'tcx>, +fn mir_promoted( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> (&'tcx Steal>, &'tcx Steal>>) { +) -> (&Steal>, &Steal>>) { if let Some(def) = def.try_upgrade(tcx) { return tcx.mir_promoted(def); } @@ -350,7 +347,7 @@ fn mir_promoted<'tcx>( } /// Compute the MIR that is used during CTFE (and thus has no optimizations run on it) -fn mir_for_ctfe<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Body<'tcx> { +fn mir_for_ctfe(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> { let did = def_id.expect_local(); if let Some(def) = ty::WithOptConstParam::try_lookup(did, tcx) { tcx.mir_for_ctfe_of_const_arg(def) @@ -364,10 +361,7 @@ fn mir_for_ctfe<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Body<'tcx> { /// we'd get cycle errors with `mir_for_ctfe`, because typeck would need to typeck /// the const parameter while type checking the main body, which in turn would try /// to type check the main body again. -fn mir_for_ctfe_of_const_arg<'tcx>( - tcx: TyCtxt<'tcx>, - (did, param_did): (LocalDefId, DefId), -) -> &'tcx Body<'tcx> { +fn mir_for_ctfe_of_const_arg(tcx: TyCtxt<'_>, (did, param_did): (LocalDefId, DefId)) -> &Body<'_> { tcx.arena.alloc(inner_mir_for_ctfe( tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) }, @@ -424,10 +418,10 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) - /// Obtain just the main MIR (no promoteds) and run some cleanups on it. This also runs /// mir borrowck *before* doing so in order to ensure that borrowck can be run and doesn't /// end up missing the source MIR due to stealing happening. -fn mir_drops_elaborated_and_const_checked<'tcx>( - tcx: TyCtxt<'tcx>, +fn mir_drops_elaborated_and_const_checked( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> &'tcx Steal> { +) -> &Steal> { if let Some(def) = def.try_upgrade(tcx) { return tcx.mir_drops_elaborated_and_const_checked(def); } @@ -597,7 +591,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { } /// Optimize the MIR and prepare it for codegen. -fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> &'tcx Body<'tcx> { +fn optimized_mir(tcx: TyCtxt<'_>, did: DefId) -> &Body<'_> { let did = did.expect_local(); assert_eq!(ty::WithOptConstParam::try_lookup(did, tcx), None); tcx.arena.alloc(inner_optimized_mir(tcx, did)) @@ -634,10 +628,10 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { /// Fetch all the promoteds of an item and prepare their MIR bodies to be ready for /// constant evaluation once all substitutions become known. -fn promoted_mir<'tcx>( - tcx: TyCtxt<'tcx>, +fn promoted_mir( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> &'tcx IndexVec> { +) -> &IndexVec> { if tcx.is_constructor(def.did.to_def_id()) { return tcx.arena.alloc(IndexVec::new()); } diff --git a/compiler/rustc_mir_transform/src/simplify_try.rs b/compiler/rustc_mir_transform/src/simplify_try.rs index baeb620ef2403..e4f3ace9a93da 100644 --- a/compiler/rustc_mir_transform/src/simplify_try.rs +++ b/compiler/rustc_mir_transform/src/simplify_try.rs @@ -532,7 +532,7 @@ struct VarField<'tcx> { } /// Match on `((_LOCAL as Variant).FIELD: TY)`. -fn match_variant_field_place<'tcx>(place: Place<'tcx>) -> Option<(Local, VarField<'tcx>)> { +fn match_variant_field_place(place: Place<'_>) -> Option<(Local, VarField<'_>)> { match place.as_ref() { PlaceRef { local, diff --git a/compiler/rustc_monomorphize/src/partitioning/mod.rs b/compiler/rustc_monomorphize/src/partitioning/mod.rs index 38e1d98e44e13..a55a3fe5ccaaa 100644 --- a/compiler/rustc_monomorphize/src/partitioning/mod.rs +++ b/compiler/rustc_monomorphize/src/partitioning/mod.rs @@ -345,10 +345,7 @@ where } } -fn collect_and_partition_mono_items<'tcx>( - tcx: TyCtxt<'tcx>, - (): (), -) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) { +fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[CodegenUnit<'_>]) { let collection_mode = match tcx.sess.opts.unstable_opts.print_mono_items { Some(ref s) => { let mode_string = s.to_lowercase(); @@ -541,7 +538,7 @@ fn dump_mono_items_stats<'tcx>( Ok(()) } -fn codegened_and_inlined_items<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> &'tcx DefIdSet { +fn codegened_and_inlined_items(tcx: TyCtxt<'_>, (): ()) -> &DefIdSet { let (items, cgus) = tcx.collect_and_partition_mono_items(()); let mut visited = DefIdSet::default(); let mut result = items.clone(); diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index f5556738bff91..edb0e4367f273 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -571,7 +571,7 @@ fn check_item<'tcx>( } } -fn check_trait_item<'tcx>(tcx: TyCtxt<'tcx>, worklist: &mut Vec, id: hir::TraitItemId) { +fn check_trait_item(tcx: TyCtxt<'_>, worklist: &mut Vec, id: hir::TraitItemId) { use hir::TraitItemKind::{Const, Fn}; if matches!(tcx.def_kind(id.owner_id), DefKind::AssocConst | DefKind::AssocFn) { let trait_item = tcx.hir().trait_item(id); @@ -583,11 +583,7 @@ fn check_trait_item<'tcx>(tcx: TyCtxt<'tcx>, worklist: &mut Vec, id: } } -fn check_foreign_item<'tcx>( - tcx: TyCtxt<'tcx>, - worklist: &mut Vec, - id: hir::ForeignItemId, -) { +fn check_foreign_item(tcx: TyCtxt<'_>, worklist: &mut Vec, id: hir::ForeignItemId) { if matches!(tcx.def_kind(id.owner_id), DefKind::Static(_) | DefKind::Fn) && has_allow_dead_code_or_lang_attr(tcx, id.hir_id()) { @@ -595,8 +591,8 @@ fn check_foreign_item<'tcx>( } } -fn create_and_seed_worklist<'tcx>( - tcx: TyCtxt<'tcx>, +fn create_and_seed_worklist( + tcx: TyCtxt<'_>, ) -> (Vec, FxHashMap) { let effective_visibilities = &tcx.effective_visibilities(()); // see `MarkSymbolVisitor::struct_constructors` @@ -626,8 +622,8 @@ fn create_and_seed_worklist<'tcx>( (worklist, struct_constructors) } -fn live_symbols_and_ignored_derived_traits<'tcx>( - tcx: TyCtxt<'tcx>, +fn live_symbols_and_ignored_derived_traits( + tcx: TyCtxt<'_>, (): (), ) -> (FxHashSet, FxHashMap>) { let (worklist, struct_constructors) = create_and_seed_worklist(tcx); diff --git a/compiler/rustc_passes/src/debugger_visualizer.rs b/compiler/rustc_passes/src/debugger_visualizer.rs index 253b0a88e48aa..aeacbaa67cb57 100644 --- a/compiler/rustc_passes/src/debugger_visualizer.rs +++ b/compiler/rustc_passes/src/debugger_visualizer.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use crate::errors::DebugVisualizerUnreadable; -fn check_for_debugger_visualizer<'tcx>( - tcx: TyCtxt<'tcx>, +fn check_for_debugger_visualizer( + tcx: TyCtxt<'_>, hir_id: HirId, debugger_visualizers: &mut FxHashSet, ) { @@ -69,7 +69,7 @@ fn check_for_debugger_visualizer<'tcx>( } /// Traverses and collects the debugger visualizers for a specific crate. -fn debugger_visualizers<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Vec { +fn debugger_visualizers(tcx: TyCtxt<'_>, cnum: CrateNum) -> Vec { assert_eq!(cnum, LOCAL_CRATE); // Initialize the collector. diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs index a72056e00b1e2..10ffa87efe35f 100644 --- a/compiler/rustc_passes/src/diagnostic_items.rs +++ b/compiler/rustc_passes/src/diagnostic_items.rs @@ -18,11 +18,7 @@ use rustc_span::symbol::{kw::Empty, sym, Symbol}; use crate::errors::{DuplicateDiagnosticItem, DuplicateDiagnosticItemInCrate}; -fn observe_item<'tcx>( - tcx: TyCtxt<'tcx>, - diagnostic_items: &mut DiagnosticItems, - def_id: LocalDefId, -) { +fn observe_item(tcx: TyCtxt<'_>, diagnostic_items: &mut DiagnosticItems, def_id: LocalDefId) { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let attrs = tcx.hir().attrs(hir_id); if let Some(name) = extract(attrs) { @@ -63,7 +59,7 @@ fn extract(attrs: &[ast::Attribute]) -> Option { } /// Traverse and collect the diagnostic items in the current -fn diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> DiagnosticItems { +fn diagnostic_items(tcx: TyCtxt<'_>, cnum: CrateNum) -> DiagnosticItems { assert_eq!(cnum, LOCAL_CRATE); // Initialize the collector. @@ -92,7 +88,7 @@ fn diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> DiagnosticItems } /// Traverse and collect all the diagnostic items in all crates. -fn all_diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> DiagnosticItems { +fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems { // Initialize the collector. let mut items = DiagnosticItems::default(); diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs index 5322baee7473a..827d86780aa8c 100644 --- a/compiler/rustc_passes/src/layout_test.rs +++ b/compiler/rustc_passes/src/layout_test.rs @@ -26,7 +26,7 @@ pub fn test_layout(tcx: TyCtxt<'_>) { } } -fn dump_layout_of<'tcx>(tcx: TyCtxt<'tcx>, item_def_id: LocalDefId, attr: &Attribute) { +fn dump_layout_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribute) { let tcx = tcx; let param_env = tcx.param_env(item_def_id); let ty = tcx.type_of(item_def_id); diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs index e7c3c712852dd..ad09522038678 100644 --- a/compiler/rustc_passes/src/reachable.rs +++ b/compiler/rustc_passes/src/reachable.rs @@ -347,7 +347,7 @@ fn check_item<'tcx>( } } -fn has_custom_linkage<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool { +fn has_custom_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { // Anything which has custom linkage gets thrown on the worklist no // matter where it is in the crate, along with "special std symbols" // which are currently akin to allocator symbols. @@ -364,7 +364,7 @@ fn has_custom_linkage<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool { || codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) } -fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> FxHashSet { +fn reachable_set(tcx: TyCtxt<'_>, (): ()) -> FxHashSet { let effective_visibilities = &tcx.effective_visibilities(()); let any_library = diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index da715523474f9..96f7236de5cb1 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -853,7 +853,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> { /// Check whether a path is a `use` item that has been marked as unstable. /// /// See issue #94972 for details on why this is a special case -fn is_unstable_reexport<'tcx>(tcx: TyCtxt<'tcx>, id: hir::HirId) -> bool { +fn is_unstable_reexport(tcx: TyCtxt<'_>, id: hir::HirId) -> bool { // Get the LocalDefId so we can lookup the item to check the kind. let Some(def_id) = tcx.hir().opt_local_def_id(id) else { return false; }; diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs index f0815fcd8db9a..fc6372cf99ee8 100644 --- a/compiler/rustc_passes/src/weak_lang_items.rs +++ b/compiler/rustc_passes/src/weak_lang_items.rs @@ -11,7 +11,7 @@ use crate::errors::{MissingLangItem, MissingPanicHandler, UnknownExternLangItem} /// Checks the crate for usage of weak lang items, returning a vector of all the /// language items required by this crate, but not defined yet. -pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItems) { +pub fn check_crate(tcx: TyCtxt<'_>, items: &mut lang_items::LanguageItems) { // These are never called by user code, they're generated by the compiler. // They will never implicitly be added to the `missing` array unless we do // so here. @@ -40,7 +40,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem verify(tcx, items); } -fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) { +fn verify(tcx: TyCtxt<'_>, items: &lang_items::LanguageItems) { // We only need to check for the presence of weak lang items if we're // emitting something that's not an rlib. let needs_check = tcx.sess.crate_types().iter().any(|kind| match *kind { diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs index c4e605c185217..2bcfdab03c817 100644 --- a/compiler/rustc_query_impl/src/on_disk_cache.rs +++ b/compiler/rustc_query_impl/src/on_disk_cache.rs @@ -227,7 +227,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> { *self.serialized_data.write() = None; } - fn serialize<'tcx>(&self, tcx: TyCtxt<'tcx>, encoder: FileEncoder) -> FileEncodeResult { + fn serialize(&self, tcx: TyCtxt<'_>, encoder: FileEncoder) -> FileEncodeResult { // Serializing the `DepGraph` should not modify it. tcx.dep_graph.with_ignore(|| { // Allocate `SourceFileIndex`es. diff --git a/compiler/rustc_query_impl/src/profiling_support.rs b/compiler/rustc_query_impl/src/profiling_support.rs index 81114f2cd82c3..5f54bab9c3147 100644 --- a/compiler/rustc_query_impl/src/profiling_support.rs +++ b/compiler/rustc_query_impl/src/profiling_support.rs @@ -278,7 +278,7 @@ pub(crate) fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>( /// If we are recording only summary data, the ids will point to /// just the query names. If we are recording query keys too, we /// allocate the corresponding strings here. -pub fn alloc_self_profile_query_strings<'tcx>(tcx: TyCtxt<'tcx>) { +pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) { if !tcx.prof.enabled() { return; } diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 848fa67e3df25..6110acd2c7507 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -337,9 +337,9 @@ where /// which will be used if the query is not in the cache and we need /// to compute it. #[inline] -pub fn try_get_cached<'a, Tcx, C, R, OnHit>( +pub fn try_get_cached( tcx: Tcx, - cache: &'a C, + cache: &C, key: &C::Key, // `on_hit` can be called while holding a lock to the query cache on_hit: OnHit, diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index 6c310abf10ac5..6afd5fe5a7f2a 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -957,10 +957,10 @@ impl SaveHandler for CallbackHandler<'_> { } } -pub fn process_crate<'l, 'tcx, H: SaveHandler>( - tcx: TyCtxt<'tcx>, +pub fn process_crate( + tcx: TyCtxt<'_>, cratename: Symbol, - input: &'l Input, + input: &Input, config: Option, mut handler: H, ) { diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index f9f4f2979c4ea..2aa8ca9e4a919 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -122,7 +122,7 @@ pub fn feature_err_issue<'a>( /// Construct a future incompatibility diagnostic for a feature gate. /// /// This diagnostic is only a warning and *does not cause compilation to fail*. -pub fn feature_warn<'a>(sess: &'a ParseSess, feature: Symbol, span: Span, explain: &str) { +pub fn feature_warn(sess: &ParseSess, feature: Symbol, span: Span, explain: &str) { feature_warn_issue(sess, feature, span, GateIssue::Language, explain); } @@ -134,8 +134,8 @@ pub fn feature_warn<'a>(sess: &'a ParseSess, feature: Symbol, span: Span, explai /// Almost always, you want to use this for a language feature. If so, prefer `feature_warn`. #[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::untranslatable_diagnostic)] -pub fn feature_warn_issue<'a>( - sess: &'a ParseSess, +pub fn feature_warn_issue( + sess: &ParseSess, feature: Symbol, span: Span, issue: GateIssue, @@ -160,7 +160,7 @@ pub fn feature_warn_issue<'a>( } /// Adds the diagnostics for a feature to an existing error. -pub fn add_feature_diagnostics<'a>(err: &mut Diagnostic, sess: &'a ParseSess, feature: Symbol) { +pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &ParseSess, feature: Symbol) { add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language); } @@ -169,9 +169,9 @@ pub fn add_feature_diagnostics<'a>(err: &mut Diagnostic, sess: &'a ParseSess, fe /// This variant allows you to control whether it is a library or language feature. /// Almost always, you want to use this for a language feature. If so, prefer /// `add_feature_diagnostics`. -pub fn add_feature_diagnostics_for_issue<'a>( +pub fn add_feature_diagnostics_for_issue( err: &mut Diagnostic, - sess: &'a ParseSess, + sess: &ParseSess, feature: Symbol, issue: GateIssue, ) { diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index e65b6891e3221..b996d36a318c5 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -3,7 +3,7 @@ use rustc_data_structures::profiling::VerboseTimingGuard; use std::path::{Path, PathBuf}; impl Session { - pub fn timer<'a>(&'a self, what: &'static str) -> VerboseTimingGuard<'a> { + pub fn timer(&self, what: &'static str) -> VerboseTimingGuard<'_> { self.prof.verbose_generic_activity(what) } pub fn time(&self, what: &'static str, f: impl FnOnce() -> R) -> R { diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index 0845b1b6b096c..493e31a688fcc 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -338,7 +338,7 @@ fn encode_substs<'tcx>( } /// Encodes a ty:Ty name, including its crate and path disambiguators and names. -fn encode_ty_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> String { +fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String { // Encode for use in u[IE], where // is , using v0's without v0's extended form of paths: // diff --git a/compiler/rustc_target/src/abi/call/loongarch.rs b/compiler/rustc_target/src/abi/call/loongarch.rs index d29b479de5da6..4a2d39cc70023 100644 --- a/compiler/rustc_target/src/abi/call/loongarch.rs +++ b/compiler/rustc_target/src/abi/call/loongarch.rs @@ -19,7 +19,7 @@ enum FloatConv { #[derive(Copy, Clone)] struct CannotUseFpConv; -fn is_loongarch_aggregate<'a, Ty>(arg: &ArgAbi<'a, Ty>) -> bool { +fn is_loongarch_aggregate(arg: &ArgAbi<'_, Ty>) -> bool { match arg.layout.abi { Abi::Vector { .. } => true, _ => arg.layout.is_aggregate(), @@ -290,7 +290,7 @@ fn classify_arg<'a, Ty, C>( } } -fn extend_integer_width<'a, Ty>(arg: &mut ArgAbi<'a, Ty>, xlen: u64) { +fn extend_integer_width(arg: &mut ArgAbi<'_, Ty>, xlen: u64) { if let Abi::Scalar(scalar) = arg.layout.abi { if let abi::Int(i, _) = scalar.primitive() { // 32-bit integers are always sign-extended diff --git a/compiler/rustc_target/src/abi/call/riscv.rs b/compiler/rustc_target/src/abi/call/riscv.rs index 1cb360f834e0e..34280d38e3406 100644 --- a/compiler/rustc_target/src/abi/call/riscv.rs +++ b/compiler/rustc_target/src/abi/call/riscv.rs @@ -25,7 +25,7 @@ enum FloatConv { #[derive(Copy, Clone)] struct CannotUseFpConv; -fn is_riscv_aggregate<'a, Ty>(arg: &ArgAbi<'a, Ty>) -> bool { +fn is_riscv_aggregate(arg: &ArgAbi<'_, Ty>) -> bool { match arg.layout.abi { Abi::Vector { .. } => true, _ => arg.layout.is_aggregate(), @@ -296,7 +296,7 @@ fn classify_arg<'a, Ty, C>( } } -fn extend_integer_width<'a, Ty>(arg: &mut ArgAbi<'a, Ty>, xlen: u64) { +fn extend_integer_width(arg: &mut ArgAbi<'_, Ty>, xlen: u64) { if let Abi::Scalar(scalar) = arg.layout.abi { if let abi::Int(i, _) = scalar.primitive() { // 32-bit integers are always sign-extended diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index be994eda14c00..988cd401f406b 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1319,7 +1319,7 @@ pub struct Target { } impl Target { - pub fn parse_data_layout<'a>(&'a self) -> Result> { + pub fn parse_data_layout(&self) -> Result> { let mut dl = TargetDataLayout::parse_from_llvm_datalayout_string(&self.data_layout)?; // Perform consistency checks against the Target information. diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 7c569621cfeb8..26757965c9583 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -66,13 +66,13 @@ pub fn add_placeholder_note(err: &mut Diagnostic) { /// with a suitably-freshened `ImplHeader` with those types /// substituted. Otherwise, returns `None`. #[instrument(skip(tcx, skip_leak_check), level = "debug")] -pub fn overlapping_impls<'tcx>( - tcx: TyCtxt<'tcx>, +pub fn overlapping_impls( + tcx: TyCtxt<'_>, impl1_def_id: DefId, impl2_def_id: DefId, skip_leak_check: SkipLeakCheck, overlap_mode: OverlapMode, -) -> Option> { +) -> Option> { // Before doing expensive operations like entering an inference context, do // a quick check via fast_reject to tell if the impl headers could possibly // unify. @@ -283,7 +283,7 @@ fn implicit_negative<'cx, 'tcx>( /// Given impl1 and impl2 check if both impls are never satisfied by a common type (including /// where-clauses) If so, return true, they are disjoint and false otherwise. -fn negative_impl<'tcx>(tcx: TyCtxt<'tcx>, impl1_def_id: DefId, impl2_def_id: DefId) -> bool { +fn negative_impl(tcx: TyCtxt<'_>, impl1_def_id: DefId, impl2_def_id: DefId) -> bool { debug!("negative_impl(impl1_def_id={:?}, impl2_def_id={:?})", impl1_def_id, impl2_def_id); // Create an infcx, taking the predicates of impl1 as assumptions: diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 036e8f6d47bba..d6c681ebb2d84 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -3483,7 +3483,7 @@ fn hint_missing_borrow<'tcx>( let arg_spans = fn_decl.inputs.iter().map(|ty| ty.span); - fn get_deref_type_and_refs<'tcx>(mut ty: Ty<'tcx>) -> (Ty<'tcx>, usize) { + fn get_deref_type_and_refs(mut ty: Ty<'_>) -> (Ty<'_>, usize) { let mut refs = 0; while let ty::Ref(_, new_ty, _) = ty.kind() { diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 2566d793d78da..c30531fa90664 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -484,10 +484,7 @@ fn subst_and_check_impossible_predicates<'tcx>( /// /// This only considers predicates that reference the impl's generics, and not /// those that reference the method's generics. -fn is_impossible_method<'tcx>( - tcx: TyCtxt<'tcx>, - (impl_def_id, trait_item_def_id): (DefId, DefId), -) -> bool { +fn is_impossible_method(tcx: TyCtxt<'_>, (impl_def_id, trait_item_def_id): (DefId, DefId)) -> bool { struct ReferencesOnlyParentGenerics<'tcx> { tcx: TyCtxt<'tcx>, generics: &'tcx ty::Generics, diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs index e1092a788e32b..f2c5f730b31b9 100644 --- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs +++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs @@ -34,7 +34,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> { /// argument types are well-formed. This may imply certain relationships /// between generic parameters. For example: /// ``` - /// fn foo<'a,T>(x: &'a T) {} + /// fn foo(x: &T) {} /// ``` /// can only be called with a `'a` and `T` such that `&'a T` is WF. /// For `&'a T` to be WF, `T: 'a` must hold. So we can assume `T: 'a`. diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index 41ce6cdf789da..5ec9c2a24cd44 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -191,7 +191,7 @@ fn dump_vtable_entries<'tcx>( }); } -fn own_existential_vtable_entries<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId) -> &'tcx [DefId] { +fn own_existential_vtable_entries(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &[DefId] { let trait_methods = tcx .associated_items(trait_def_id) .in_definition_order() diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index bc4a52c5040d1..f288eb112582d 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -719,7 +719,7 @@ impl<'tcx> chalk_ir::UnificationDatabase> for RustIrDatabase< /// var bound at index `0`. For types, we use a `BoundVar` index equal to /// the type parameter index. For regions, we use the `BoundRegionKind::BrNamed` /// variant (which has a `DefId`). -fn bound_vars_for_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx> { +fn bound_vars_for_item(tcx: TyCtxt<'_>, def_id: DefId) -> SubstsRef<'_> { InternalSubsts::for_item(tcx, def_id, |param, substs| match param.kind { ty::GenericParamDefKind::Type { .. } => tcx .mk_ty(ty::Bound( diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs index 44fd8bfb31f23..6e6bc62a040d1 100644 --- a/compiler/rustc_traits/src/normalize_erasing_regions.rs +++ b/compiler/rustc_traits/src/normalize_erasing_regions.rs @@ -54,7 +54,7 @@ fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable<'tcx> + PartialEq + } } -fn not_outlives_predicate<'tcx>(p: ty::Predicate<'tcx>) -> bool { +fn not_outlives_predicate(p: ty::Predicate<'_>) -> bool { match p.kind().skip_binder() { ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) => false, diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index f8ff31f971be6..a9b4e1420ea0d 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -267,8 +267,8 @@ struct IsThirPolymorphic<'a, 'tcx> { thir: &'a thir::Thir<'tcx>, } -fn error<'tcx>( - tcx: TyCtxt<'tcx>, +fn error( + tcx: TyCtxt<'_>, sub: GenericConstantTooComplexSub, root_span: Span, ) -> Result { @@ -281,8 +281,8 @@ fn error<'tcx>( Err(reported) } -fn maybe_supported_error<'tcx>( - tcx: TyCtxt<'tcx>, +fn maybe_supported_error( + tcx: TyCtxt<'_>, sub: GenericConstantTooComplexSub, root_span: Span, ) -> Result { @@ -349,10 +349,10 @@ impl<'a, 'tcx> visit::Visitor<'a, 'tcx> for IsThirPolymorphic<'a, 'tcx> { } /// Builds an abstract const, do not use this directly, but use `AbstractConst::new` instead. -pub fn thir_abstract_const<'tcx>( - tcx: TyCtxt<'tcx>, +pub fn thir_abstract_const( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> Result>, ErrorGuaranteed> { +) -> Result>, ErrorGuaranteed> { if tcx.features().generic_const_exprs { match tcx.def_kind(def.did) { // FIXME(generic_const_exprs): We currently only do this for anonymous constants, diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index f0d8c240ea588..b7a24a22c53e3 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -6,7 +6,7 @@ pub fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { assumed_wf_types, ..*providers }; } -fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::List> { +fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List> { match tcx.def_kind(def_id) { DefKind::Fn => { let sig = tcx.fn_sig(def_id); diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index c761a4dbe4500..c8c6acaa45397 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -489,8 +489,8 @@ enum SavedLocalEligibility { // of any variant. /// Compute the eligibility and assignment of each local. -fn generator_saved_local_eligibility<'tcx>( - info: &GeneratorLayout<'tcx>, +fn generator_saved_local_eligibility( + info: &GeneratorLayout<'_>, ) -> (BitSet, IndexVec) { use SavedLocalEligibility::*; diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 5279fc69a31b3..e2d10f550c326 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -225,10 +225,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { /// that are assumed to be well-formed (because they come from the environment). /// /// Used only in chalk mode. -fn well_formed_types_in_env<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: DefId, -) -> &'tcx ty::List> { +fn well_formed_types_in_env(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List> { use rustc_hir::{ForeignItemKind, ImplItemKind, ItemKind, Node, TraitItemKind}; use rustc_middle::ty::subst::GenericArgKind; From 42d100aad02031121ae2390c0dc5197131e93740 Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Tue, 20 Dec 2022 22:28:22 +0100 Subject: [PATCH 2/4] Add missing anonymous lifetime --- compiler/rustc_mir_transform/src/coverage/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_mir_transform/src/coverage/tests.rs b/compiler/rustc_mir_transform/src/coverage/tests.rs index 8f2bb11639f18..fa7f22303a8b5 100644 --- a/compiler/rustc_mir_transform/src/coverage/tests.rs +++ b/compiler/rustc_mir_transform/src/coverage/tests.rs @@ -169,7 +169,7 @@ impl<'tcx> MockBlocks<'tcx> { } } -fn debug_basic_blocks(mir_body: &Body) -> String { +fn debug_basic_blocks(mir_body: &Body<'_>) -> String { format!( "{:?}", mir_body From 2c9d9bf381e0643ccb0a777d19473ab939ebf6ae Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Tue, 20 Dec 2022 22:34:42 +0100 Subject: [PATCH 3/4] Add missing anonymous lifetime --- compiler/rustc_codegen_gcc/src/common.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_gcc/src/common.rs b/compiler/rustc_codegen_gcc/src/common.rs index d7df1347121ae..0afc56b4494d3 100644 --- a/compiler/rustc_codegen_gcc/src/common.rs +++ b/compiler/rustc_codegen_gcc/src/common.rs @@ -44,7 +44,7 @@ pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) -> context.new_array_constructor(None, typ, &elements) } -pub fn type_is_pointer(typ: Type) -> bool { +pub fn type_is_pointer(typ: Type<'_>) -> bool { typ.get_pointee().is_some() } From 1174aacf598d01b3e063668bb6ecd9c472688d02 Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Fri, 23 Dec 2022 15:59:53 +0100 Subject: [PATCH 4/4] Indicate anonymous lifetime --- compiler/rustc_graphviz/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index d7730935f2015..434f0a53b7866 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -164,7 +164,7 @@ //! fn node_id(&'a self, n: &Nd) -> dot::Id<'a> { //! dot::Id::new(format!("N{}", n)).unwrap() //! } -//! fn node_label(&self, n: &Nd) -> dot::LabelText { +//! fn node_label(&self, n: &Nd) -> dot::LabelText<'_> { //! dot::LabelText::LabelStr(self.nodes[*n].into()) //! } //! fn edge_label<'b>(&'b self, _: &Ed) -> dot::LabelText<'b> {