From 3f2a1c9c1726d4d93e3433303262e44faa5910e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Mon, 13 Dec 2021 00:00:00 +0000 Subject: [PATCH 01/18] Use `OutputFilenames` to generate output file for `-Zllvm-time-trace` The resulting profile will include the crate name and will be stored in the `--out-dir` directory. This implementation makes it convenient to use LLVM time trace together with cargo, in the contrast to the previous implementation which would overwrite profiles or store them in `.cargo/registry/..`. --- compiler/rustc_codegen_cranelift/src/lib.rs | 1 + compiler/rustc_codegen_gcc/src/lib.rs | 2 +- compiler/rustc_codegen_llvm/src/lib.rs | 4 +++- compiler/rustc_codegen_llvm/src/llvm_util.rs | 6 ++++-- compiler/rustc_codegen_ssa/src/traits/backend.rs | 1 + compiler/rustc_interface/src/queries.rs | 7 +++++-- .../hotplug_codegen_backend/the_backend.rs | 1 + 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index beb97edf09e8..fcdf6b50764e 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -205,6 +205,7 @@ impl CodegenBackend for CraneliftCodegenBackend { &self, ongoing_codegen: Box, _sess: &Session, + _outputs: &OutputFilenames, ) -> Result<(CodegenResults, FxHashMap), ErrorReported> { Ok(*ongoing_codegen .downcast::<(CodegenResults, FxHashMap)>() diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index a549bcbd9310..30a33b99e505 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -96,7 +96,7 @@ impl CodegenBackend for GccCodegenBackend { Box::new(res) } - fn join_codegen(&self, ongoing_codegen: Box, sess: &Session) -> Result<(CodegenResults, FxHashMap), ErrorReported> { + fn join_codegen(&self, ongoing_codegen: Box, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxHashMap), ErrorReported> { let (codegen_results, work_products) = ongoing_codegen .downcast::>() .expect("Expected GccCodegenBackend's OngoingCodegen, found Box") diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 62c17e6a10f1..b52e9a6ea83b 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -340,6 +340,7 @@ impl CodegenBackend for LlvmCodegenBackend { &self, ongoing_codegen: Box, sess: &Session, + outputs: &OutputFilenames, ) -> Result<(CodegenResults, FxHashMap), ErrorReported> { let (codegen_results, work_products) = ongoing_codegen .downcast::>() @@ -348,7 +349,8 @@ impl CodegenBackend for LlvmCodegenBackend { sess.time("llvm_dump_timing_file", || { if sess.opts.debugging_opts.llvm_time_trace { - llvm_util::time_trace_profiler_finish("llvm_timings.json"); + let file_name = outputs.with_extension("llvm_timings.json"); + llvm_util::time_trace_profiler_finish(&file_name); } }); diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 79a261244d3f..e4935ac431c8 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -4,6 +4,7 @@ use libc::c_int; use libloading::Library; use rustc_codegen_ssa::target_features::supported_target_features; use rustc_data_structures::fx::FxHashSet; +use rustc_fs_util::path_to_c_string; use rustc_middle::bug; use rustc_session::config::PrintRequest; use rustc_session::Session; @@ -13,6 +14,7 @@ use std::ffi::{CStr, CString}; use tracing::debug; use std::mem; +use std::path::Path; use std::ptr; use std::slice; use std::str; @@ -134,9 +136,9 @@ unsafe fn configure_llvm(sess: &Session) { llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr()); } -pub fn time_trace_profiler_finish(file_name: &str) { +pub fn time_trace_profiler_finish(file_name: &Path) { unsafe { - let file_name = CString::new(file_name).unwrap(); + let file_name = path_to_c_string(file_name); llvm::LLVMTimeTraceProfilerFinish(file_name.as_ptr()); } } diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 707561f5ebd0..c6abb3f6eb41 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -97,6 +97,7 @@ pub trait CodegenBackend { &self, ongoing_codegen: Box, sess: &Session, + outputs: &OutputFilenames, ) -> Result<(CodegenResults, FxHashMap), ErrorReported>; /// This is called on the returned `Box` from `join_codegen` diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index f188ad35605a..e635ee1e0ec8 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -335,8 +335,11 @@ pub struct Linker { impl Linker { pub fn link(self) -> Result<()> { - let (codegen_results, work_products) = - self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess)?; + let (codegen_results, work_products) = self.codegen_backend.join_codegen( + self.ongoing_codegen, + &self.sess, + &self.prepare_outputs, + )?; self.sess.compile_status()?; diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 7c16f7bdaf7c..8047a42c2b17 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -46,6 +46,7 @@ impl CodegenBackend for TheBackend { &self, ongoing_codegen: Box, _sess: &Session, + _outputs: &OutputFilenames, ) -> Result<(CodegenResults, FxHashMap), ErrorReported> { let codegen_results = ongoing_codegen .downcast::() From 7f2f9c60c27721dee52a3fce18911103416fb380 Mon Sep 17 00:00:00 2001 From: Jonas Berlin Date: Mon, 13 Dec 2021 13:23:33 +0200 Subject: [PATCH 02/18] =?UTF-8?q?Iterator::cycle()=20=E2=80=94=20document?= =?UTF-8?q?=20empty=20iterator=20special=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/core/src/iter/traits/iterator.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 267fa4067983..6a38600c956f 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -3028,7 +3028,8 @@ pub trait Iterator { /// /// Instead of stopping at [`None`], the iterator will instead start again, /// from the beginning. After iterating again, it will start at the - /// beginning again. And again. And again. Forever. + /// beginning again. And again. And again. Forever. Note that in case the + /// original iterator is empty the resulting iterator will also be empty. /// /// # Examples /// From 715c562d71f18ceb077482fc22339b3a73816b4e Mon Sep 17 00:00:00 2001 From: Jonas Berlin Date: Mon, 13 Dec 2021 13:52:17 +0200 Subject: [PATCH 03/18] [ReviewFix] Linguistics --- library/core/src/iter/traits/iterator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 6a38600c956f..9a9a844f41bb 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -3029,7 +3029,7 @@ pub trait Iterator { /// Instead of stopping at [`None`], the iterator will instead start again, /// from the beginning. After iterating again, it will start at the /// beginning again. And again. And again. Forever. Note that in case the - /// original iterator is empty the resulting iterator will also be empty. + /// original iterator is empty, the resulting iterator will also be empty. /// /// # Examples /// From 0c594f8c8633d30508d6b14d98562ef3dcfde58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 13 Dec 2021 23:31:14 +0100 Subject: [PATCH 04/18] Remove in_band_lifetimes from borrowck --- compiler/rustc_borrowck/src/borrow_set.rs | 2 +- .../rustc_borrowck/src/diagnostics/bound_region_errors.rs | 8 ++++---- .../rustc_borrowck/src/diagnostics/conflict_errors.rs | 4 ++-- compiler/rustc_borrowck/src/diagnostics/mod.rs | 4 ++-- .../rustc_borrowck/src/diagnostics/mutability_errors.rs | 4 ++-- compiler/rustc_borrowck/src/lib.rs | 1 - compiler/rustc_borrowck/src/member_constraints.rs | 6 +++--- compiler/rustc_borrowck/src/path_utils.rs | 2 +- .../src/type_check/free_region_relations.rs | 8 ++++---- .../src/type_check/liveness/local_use_map.rs | 2 +- compiler/rustc_borrowck/src/type_check/liveness/mod.rs | 4 ++-- .../rustc_borrowck/src/type_check/liveness/polonius.rs | 8 ++++---- compiler/rustc_borrowck/src/type_check/liveness/trace.rs | 6 +++--- compiler/rustc_borrowck/src/type_check/mod.rs | 2 +- compiler/rustc_borrowck/src/type_check/relate_tys.rs | 4 ++-- 15 files changed, 32 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index 952e18c1e570..4a9904891eca 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -84,7 +84,7 @@ pub enum LocalsStateAtExit { } impl LocalsStateAtExit { - fn build( + fn build<'tcx>( locals_are_invalidated_at_exit: bool, body: &Body<'tcx>, move_data: &MoveData<'tcx>, diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs index 1bc9f8cf3ccc..be4b3cdbaa0e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs @@ -31,7 +31,7 @@ enum UniverseInfoInner<'tcx> { Other, } -impl UniverseInfo<'tcx> { +impl<'tcx> UniverseInfo<'tcx> { crate fn other() -> UniverseInfo<'tcx> { UniverseInfo(UniverseInfoInner::Other) } @@ -191,7 +191,7 @@ struct PredicateQuery<'tcx> { base_universe: ty::UniverseIndex, } -impl TypeOpInfo<'tcx> for PredicateQuery<'tcx> { +impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> { fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error"); err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate)); @@ -231,7 +231,7 @@ struct NormalizeQuery<'tcx, T> { base_universe: ty::UniverseIndex, } -impl TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T> +impl<'tcx, T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T> where T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx, { @@ -291,7 +291,7 @@ struct AscribeUserTypeQuery<'tcx> { base_universe: ty::UniverseIndex, } -impl TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> { +impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> { fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { // FIXME: This error message isn't great, but it doesn't show up in the existing UI tests, // and is only the fallback when the nice error fails. Consider improving this some more. diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 8c4508ed1888..56854ebf02fa 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1513,8 +1513,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { location: Location, mpi: MovePathIndex, ) -> (Vec, Vec) { - fn predecessor_locations( - body: &'a mir::Body<'tcx>, + fn predecessor_locations<'a>( + body: &'a mir::Body<'_>, location: Location, ) -> impl Iterator + 'a { if location.statement_index == 0 { diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 42f5d5575420..7e5cb892c059 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -408,7 +408,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Add a note that a type does not implement `Copy` pub(super) fn note_type_does_not_implement_copy( &self, - err: &mut DiagnosticBuilder<'a>, + err: &mut DiagnosticBuilder<'_>, place_desc: &str, ty: Ty<'tcx>, span: Option, @@ -732,7 +732,7 @@ pub(super) enum BorrowedContentSource<'tcx> { OverloadedIndex(Ty<'tcx>), } -impl BorrowedContentSource<'tcx> { +impl<'tcx> BorrowedContentSource<'tcx> { pub(super) fn describe_for_unnamed_place(&self, tcx: TyCtxt<'_>) -> String { match *self { BorrowedContentSource::DerefRawPointer => "a raw pointer".to_string(), diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index b4821ee36e0a..0434c1ba59a1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -747,7 +747,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { HirId, ImplItem, ImplItemKind, Item, ItemKind, }; - fn maybe_body_id_of_fn(hir_map: &Map<'tcx>, id: HirId) -> Option { + fn maybe_body_id_of_fn(hir_map: &Map<'_>, id: HirId) -> Option { match hir_map.find(id) { Some(Node::Item(Item { kind: ItemKind::Fn(_, _, body_id), .. })) | Some(Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })) => { @@ -1066,7 +1066,7 @@ fn is_closure_or_generator(ty: Ty<'_>) -> bool { /// LL | s: &'a String /// | ---------- use `&'a mut String` here to make mutable /// ``` -fn annotate_struct_field( +fn annotate_struct_field<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, field: &mir::Field, diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 88fab269109f..054516f49617 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -3,7 +3,6 @@ #![feature(bool_to_option)] #![feature(box_patterns)] #![feature(crate_visibility_modifier)] -#![feature(in_band_lifetimes)] #![feature(iter_zip)] #![feature(let_else)] #![feature(min_specialization)] diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index f22d355e6134..0fe44328fd9f 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -53,7 +53,7 @@ rustc_index::newtype_index! { } } -impl Default for MemberConstraintSet<'tcx, ty::RegionVid> { +impl Default for MemberConstraintSet<'_, ty::RegionVid> { fn default() -> Self { Self { first_constraints: Default::default(), @@ -97,7 +97,7 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> { } } -impl MemberConstraintSet<'tcx, R1> +impl<'tcx, R1> MemberConstraintSet<'tcx, R1> where R1: Copy + Hash + Eq, { @@ -140,7 +140,7 @@ where } } -impl MemberConstraintSet<'tcx, R> +impl MemberConstraintSet<'_, R> where R: Copy + Hash + Eq, { diff --git a/compiler/rustc_borrowck/src/path_utils.rs b/compiler/rustc_borrowck/src/path_utils.rs index d5d00b467eee..b2c8dfc82c20 100644 --- a/compiler/rustc_borrowck/src/path_utils.rs +++ b/compiler/rustc_borrowck/src/path_utils.rs @@ -141,7 +141,7 @@ pub(super) fn borrow_of_local_data(place: Place<'_>) -> bool { /// then returns the index of the field being projected. Note that this closure will always /// be `self` in the current MIR, because that is the only time we directly access the fields /// of a closure type. -pub(crate) fn is_upvar_field_projection( +pub(crate) fn is_upvar_field_projection<'tcx>( tcx: TyCtxt<'tcx>, upvars: &[Upvar<'tcx>], place_ref: PlaceRef<'tcx>, 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 8d97c3cbb0b0..fec6bdf314b1 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -58,7 +58,7 @@ crate struct CreateResult<'tcx> { crate normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>, } -crate fn create( +crate fn create<'tcx>( infcx: &InferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, implicit_region_bound: Option>, @@ -81,7 +81,7 @@ crate fn create( .create() } -impl UniversalRegionRelations<'tcx> { +impl UniversalRegionRelations<'_> { /// Records in the `outlives_relation` (and /// `inverse_outlives_relation`) that `fr_a: fr_b`. Invoked by the /// builder below. @@ -110,7 +110,7 @@ impl UniversalRegionRelations<'tcx> { /// outlives `fr` and (b) is not local. /// /// (*) If there are multiple competing choices, we return all of them. - crate fn non_local_upper_bounds(&'a self, fr: &'a RegionVid) -> Vec<&'a RegionVid> { + crate fn non_local_upper_bounds<'a>(&'a self, fr: &'a RegionVid) -> Vec<&'a RegionVid> { 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!?"); @@ -232,7 +232,7 @@ struct UniversalRegionRelationsBuilder<'this, 'tcx> { region_bound_pairs: RegionBoundPairs<'tcx>, } -impl UniversalRegionRelationsBuilder<'cx, 'tcx> { +impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { crate fn create(mut self) -> CreateResult<'tcx> { let unnormalized_input_output_tys = self .universal_regions diff --git a/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs b/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs index 8b74abd94c07..dd23683fae8d 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs @@ -152,7 +152,7 @@ impl LocalUseMapBuild<'_> { } } -impl Visitor<'tcx> for LocalUseMapBuild<'_> { +impl Visitor<'_> for LocalUseMapBuild<'_> { fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) { if self.locals_with_use_data[local] { match def_use::categorize(context) { diff --git a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs index 1e712354d6a8..f18fe1f43d4d 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs @@ -74,7 +74,7 @@ pub(super) fn generate<'mir, 'tcx>( // to compute whether a variable `X` is live if that variable contains // some region `R` in its type where `R` is not known to outlive a free // region (i.e., where `R` may be valid for just a subset of the fn body). -fn compute_live_locals( +fn compute_live_locals<'tcx>( tcx: TyCtxt<'tcx>, free_regions: &FxHashSet, body: &Body<'tcx>, @@ -104,7 +104,7 @@ fn compute_live_locals( /// regions. For these regions, we do not need to compute /// liveness, since the outlives constraints will ensure that they /// are live over the whole fn body anyhow. -fn regions_that_outlive_free_regions( +fn regions_that_outlive_free_regions<'tcx>( num_region_vars: usize, universal_regions: &UniversalRegions<'tcx>, constraint_set: &OutlivesConstraintSet<'tcx>, diff --git a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs index 79ab8b713f95..ee067c4872f6 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs @@ -53,7 +53,7 @@ impl UseFactsExtractor<'_> { } } -impl Visitor<'tcx> for UseFactsExtractor<'_> { +impl Visitor<'_> for UseFactsExtractor<'_> { fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) { match def_use::categorize(context) { Some(DefUse::Def) => self.insert_def(local, location), @@ -63,7 +63,7 @@ impl Visitor<'tcx> for UseFactsExtractor<'_> { } } - fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { + fn visit_place(&mut self, place: &Place<'_>, context: PlaceContext, location: Location) { self.super_place(place, context, location); match context { PlaceContext::NonMutatingUse(_) => { @@ -82,7 +82,7 @@ impl Visitor<'tcx> for UseFactsExtractor<'_> { } } -pub(super) fn populate_access_facts( +pub(super) fn populate_access_facts<'tcx>( typeck: &mut TypeChecker<'_, 'tcx>, body: &Body<'tcx>, location_table: &LocationTable, @@ -123,7 +123,7 @@ pub(super) fn populate_access_facts( // For every potentially drop()-touched region `region` in `local`'s type // (`kind`), emit a Polonius `use_of_var_derefs_origin(local, origin)` fact. -pub(super) fn add_drop_of_var_derefs_origin( +pub(super) fn add_drop_of_var_derefs_origin<'tcx>( typeck: &mut TypeChecker<'_, 'tcx>, local: Local, kind: &GenericArg<'tcx>, diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index 73c284071d5c..0969b9a508f1 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -34,7 +34,7 @@ use crate::{ /// DROP-LIVE set are to the liveness sets for regions found in the /// `dropck_outlives` result of the variable's type (in particular, /// this respects `#[may_dangle]` annotations). -pub(super) fn trace( +pub(super) fn trace<'mir, 'tcx>( typeck: &mut TypeChecker<'_, 'tcx>, body: &Body<'tcx>, elements: &Rc, @@ -119,7 +119,7 @@ struct LivenessResults<'me, 'typeck, 'flow, 'tcx> { stack: Vec, } -impl LivenessResults<'me, 'typeck, 'flow, 'tcx> { +impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { fn new(cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>) -> Self { let num_points = cx.elements.num_points(); LivenessResults { @@ -418,7 +418,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> { } } -impl LivenessContext<'_, '_, '_, 'tcx> { +impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { /// Returns `true` if the local variable (or some part of it) is initialized at the current /// cursor position. Callers should call one of the `seek` methods immediately before to point /// the cursor to the desired location. diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 6a263bd63ada..0d515d713e84 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -945,7 +945,7 @@ crate struct MirTypeckRegionConstraints<'tcx> { crate type_tests: Vec>, } -impl MirTypeckRegionConstraints<'tcx> { +impl<'tcx> MirTypeckRegionConstraints<'tcx> { fn placeholder_region( &mut self, infcx: &InferCtxt<'_, 'tcx>, diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index 415d1abaa8b0..cc3fe0a123c5 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -51,7 +51,7 @@ struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { universe_info: UniverseInfo<'tcx>, } -impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { +impl<'me, 'bccx, 'tcx> NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { fn new( type_checker: &'me mut TypeChecker<'bccx, 'tcx>, locations: Locations, @@ -62,7 +62,7 @@ impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { } } -impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> { +impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> { fn param_env(&self) -> ty::ParamEnv<'tcx> { self.type_checker.param_env } From ae21dd00ace34974a8337195c885c250f402d8cf Mon Sep 17 00:00:00 2001 From: PFPoitras Date: Mon, 13 Dec 2021 21:45:08 -0400 Subject: [PATCH 05/18] Remove in_band_lifetimes --- compiler/rustc_typeck/src/astconv/errors.rs | 2 +- compiler/rustc_typeck/src/check/_match.rs | 2 +- compiler/rustc_typeck/src/check/check.rs | 8 ++++---- compiler/rustc_typeck/src/check/coercion.rs | 4 ++-- compiler/rustc_typeck/src/check/dropck.rs | 2 +- compiler/rustc_typeck/src/check/inherited.rs | 4 ++-- .../rustc_typeck/src/check/method/suggest.rs | 2 +- compiler/rustc_typeck/src/check/mod.rs | 4 ++-- compiler/rustc_typeck/src/check/op.rs | 4 ++-- compiler/rustc_typeck/src/check/pat.rs | 4 ++-- compiler/rustc_typeck/src/check/regionck.rs | 4 ++-- compiler/rustc_typeck/src/check/upvar.rs | 20 +++++++++---------- compiler/rustc_typeck/src/check/wfcheck.rs | 12 +++++------ compiler/rustc_typeck/src/check_unused.rs | 4 ++-- .../rustc_typeck/src/coherence/builtin.rs | 4 ++-- .../src/coherence/inherent_impls.rs | 4 ++-- .../src/coherence/inherent_impls_overlap.rs | 4 ++-- compiler/rustc_typeck/src/coherence/orphan.rs | 2 +- .../rustc_typeck/src/coherence/unsafety.rs | 6 +++--- compiler/rustc_typeck/src/collect.rs | 18 ++++++++--------- compiler/rustc_typeck/src/collect/type_of.rs | 2 +- compiler/rustc_typeck/src/expr_use_visitor.rs | 6 +++--- compiler/rustc_typeck/src/impl_wf_check.rs | 2 +- compiler/rustc_typeck/src/lib.rs | 1 - compiler/rustc_typeck/src/outlives/test.rs | 2 +- compiler/rustc_typeck/src/variance/test.rs | 2 +- 26 files changed, 64 insertions(+), 65 deletions(-) diff --git a/compiler/rustc_typeck/src/astconv/errors.rs b/compiler/rustc_typeck/src/astconv/errors.rs index ec75e4a55d4e..ea54b85b2f20 100644 --- a/compiler/rustc_typeck/src/astconv/errors.rs +++ b/compiler/rustc_typeck/src/astconv/errors.rs @@ -92,7 +92,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { &self, span: Span, trait_def_id: DefId, - trait_segment: &'a hir::PathSegment<'a>, + trait_segment: &'_ hir::PathSegment<'_>, ) { let trait_def = self.tcx().trait_def(trait_def_id); diff --git a/compiler/rustc_typeck/src/check/_match.rs b/compiler/rustc_typeck/src/check/_match.rs index a8160313228b..405e4e8594a3 100644 --- a/compiler/rustc_typeck/src/check/_match.rs +++ b/compiler/rustc_typeck/src/check/_match.rs @@ -557,7 +557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } -fn arms_contain_ref_bindings(arms: &'tcx [hir::Arm<'tcx>]) -> Option { +fn arms_contain_ref_bindings<'tcx>(arms: &'tcx [hir::Arm<'tcx>]) -> Option { arms.iter().filter_map(|a| a.pat.contains_explicit_ref_binding()).max_by_key(|m| match *m { hir::Mutability::Mut => 1, hir::Mutability::Not => 0, diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 5a6bac9ec03d..fd7b3a55dfb9 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -453,7 +453,7 @@ pub(super) fn check_opaque<'tcx>( /// 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( +pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span, @@ -517,7 +517,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes( } } - impl Visitor<'tcx> for ProhibitOpaqueVisitor<'tcx> { + impl<'tcx> Visitor<'tcx> for ProhibitOpaqueVisitor<'tcx> { type Map = rustc_middle::hir::map::Map<'tcx>; fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap { @@ -1512,7 +1512,7 @@ pub(super) use wfcheck::check_trait_item as check_trait_item_well_formed; pub(super) use wfcheck::check_impl_item as check_impl_item_well_formed; -fn async_opaque_type_cycle_error(tcx: TyCtxt<'tcx>, span: Span) { +fn async_opaque_type_cycle_error(tcx: TyCtxt<'_>, span: Span) { struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing") .span_label(span, "recursive `async fn`") .note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`") @@ -1530,7 +1530,7 @@ fn async_opaque_type_cycle_error(tcx: TyCtxt<'tcx>, span: Span) { /// /// If all the return expressions evaluate to `!`, then we explain that the error will go away /// after changing it. This can happen when a user uses `panic!()` or similar as a placeholder. -fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) { +fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) { let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type"); let mut label = false; diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index b4810b4e22fe..ac18908e95bc 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -102,7 +102,7 @@ fn identity(_: Ty<'_>) -> Vec> { vec![] } -fn simple(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 }] } @@ -1694,7 +1694,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { err.help("you could instead create a new `enum` with a variant for each returned type"); } - fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool { + fn is_return_ty_unsized<'a>(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool { if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) { if let hir::FnRetTy::Return(ty) = fn_decl.output { let ty = >::ast_ty_to_ty(fcx, ty); diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs index 4b4d29307ff6..3cc66aaf0d79 100644 --- a/compiler/rustc_typeck/src/check/dropck.rs +++ b/compiler/rustc_typeck/src/check/dropck.rs @@ -302,7 +302,7 @@ impl<'tcx> SimpleEqRelation<'tcx> { } } -impl TypeRelation<'tcx> for SimpleEqRelation<'tcx> { +impl<'tcx> TypeRelation<'tcx> for SimpleEqRelation<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_typeck/src/check/inherited.rs b/compiler/rustc_typeck/src/check/inherited.rs index bf52e7750433..beb6b371b2bb 100644 --- a/compiler/rustc_typeck/src/check/inherited.rs +++ b/compiler/rustc_typeck/src/check/inherited.rs @@ -76,7 +76,7 @@ pub struct InheritedBuilder<'tcx> { def_id: LocalDefId, } -impl Inherited<'_, 'tcx> { +impl<'tcx> Inherited<'_, 'tcx> { pub fn build(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> InheritedBuilder<'tcx> { let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner; @@ -97,7 +97,7 @@ impl<'tcx> InheritedBuilder<'tcx> { } } -impl Inherited<'a, 'tcx> { +impl<'a, 'tcx> Inherited<'a, 'tcx> { pub(super) fn new(infcx: InferCtxt<'a, 'tcx>, def_id: LocalDefId) -> Self { let tcx = infcx.tcx; let item_id = tcx.hir().local_def_id_to_hir_id(def_id); diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 45b8e13d328c..8392731b28d6 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -1968,7 +1968,7 @@ fn find_use_placement<'tcx>(tcx: TyCtxt<'tcx>, target_module: LocalDefId) -> (Op (span, found_use) } -fn print_disambiguation_help( +fn print_disambiguation_help<'tcx>( item_name: Ident, args: Option<&'tcx [hir::Expr<'tcx>]>, err: &mut DiagnosticBuilder<'_>, diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 2e80f85972fa..a9e6b1caff07 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -508,7 +508,7 @@ struct GeneratorTypes<'tcx> { /// Given a `DefId` for an opaque type in return position, find its parent item's return /// expressions. -fn get_owner_return_paths( +fn get_owner_return_paths<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, ) -> Option<(hir::HirId, ReturnsVisitor<'tcx>)> { @@ -906,7 +906,7 @@ struct CheckItemTypesVisitor<'tcx> { tcx: TyCtxt<'tcx>, } -impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> { +impl<'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> { fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) { check_item_type(self.tcx, i); } diff --git a/compiler/rustc_typeck/src/check/op.rs b/compiler/rustc_typeck/src/check/op.rs index 4956321eb5cd..8ebfcdd539b6 100644 --- a/compiler/rustc_typeck/src/check/op.rs +++ b/compiler/rustc_typeck/src/check/op.rs @@ -893,7 +893,7 @@ enum Op { } /// Dereferences a single level of immutable referencing. -fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> { +fn deref_ty_if_possible<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> { match ty.kind() { ty::Ref(_, ty, hir::Mutability::Not) => ty, _ => ty, @@ -1007,7 +1007,7 @@ impl<'tcx> TypeVisitor<'tcx> for TypeParamVisitor<'tcx> { struct TypeParamEraser<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, Span); -impl TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> { +impl<'tcx> TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.0.tcx } diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index cbf33cf1b78a..ec06e0b11264 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -740,7 +740,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn check_pat_path( + fn check_pat_path<'b>( &self, pat: &Pat<'_>, path_resolution: (Res, Option>, &'b [hir::PathSegment<'b>]), @@ -816,7 +816,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { false } - fn emit_bad_pat_path( + fn emit_bad_pat_path<'b>( &self, mut e: DiagnosticBuilder<'_>, pat_span: Span, diff --git a/compiler/rustc_typeck/src/check/regionck.rs b/compiler/rustc_typeck/src/check/regionck.rs index d2d8b14dd969..1b42edc83be2 100644 --- a/compiler/rustc_typeck/src/check/regionck.rs +++ b/compiler/rustc_typeck/src/check/regionck.rs @@ -106,7 +106,7 @@ macro_rules! ignore_err { pub(crate) trait OutlivesEnvironmentExt<'tcx> { fn add_implied_bounds( &mut self, - infcx: &InferCtxt<'a, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, fn_sig_tys: FxHashSet>, body_id: hir::HirId, span: Span, @@ -130,7 +130,7 @@ impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironment<'tcx> { /// add those assumptions into the outlives-environment. /// /// Tests: `src/test/ui/regions/regions-free-region-ordering-*.rs` - fn add_implied_bounds( + fn add_implied_bounds<'a>( &mut self, infcx: &InferCtxt<'a, 'tcx>, fn_sig_tys: FxHashSet>, diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index a98afd1e3e1d..ffd7d29bbbbe 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -1672,7 +1672,7 @@ fn restrict_repr_packed_field_ref_capture<'tcx>( } /// Returns a Ty that applies the specified capture kind on the provided capture Ty -fn apply_capture_kind_on_capture_ty( +fn apply_capture_kind_on_capture_ty<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, capture_kind: UpvarCapture<'tcx>, @@ -1685,7 +1685,7 @@ fn apply_capture_kind_on_capture_ty( } /// Returns the Span of where the value with the provided HirId would be dropped -fn drop_location_span(tcx: TyCtxt<'tcx>, hir_id: &hir::HirId) -> Span { +fn drop_location_span<'tcx>(tcx: TyCtxt<'tcx>, hir_id: &hir::HirId) -> Span { let owner_id = tcx.hir().get_enclosing_scope(*hir_id).unwrap(); let owner_node = tcx.hir().get(owner_id); @@ -1999,7 +1999,7 @@ 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( +fn restrict_precision_for_unsafe<'tcx>( mut place: Place<'tcx>, mut curr_mode: ty::UpvarCapture<'tcx>, ) -> (Place<'tcx>, ty::UpvarCapture<'tcx>) { @@ -2097,7 +2097,7 @@ fn adjust_for_non_move_closure<'tcx>( (place, kind) } -fn construct_place_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String { +fn construct_place_string<'tcx>(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String { let variable_name = match place.base { PlaceBase::Upvar(upvar_id) => var_name(tcx, upvar_id.var_path.hir_id).to_string(), _ => bug!("Capture_information should only contain upvars"), @@ -2120,7 +2120,7 @@ fn construct_place_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String { format!("{}[{}]", variable_name, projections_str) } -fn construct_capture_kind_reason_string( +fn construct_capture_kind_reason_string<'tcx>( tcx: TyCtxt<'_>, place: &Place<'tcx>, capture_info: &ty::CaptureInfo<'tcx>, @@ -2135,13 +2135,13 @@ fn construct_capture_kind_reason_string( format!("{} captured as {} here", place_str, capture_kind_str) } -fn construct_path_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String { +fn construct_path_string<'tcx>(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String { let place_str = construct_place_string(tcx, place); format!("{} used here", place_str) } -fn construct_capture_info_string( +fn construct_capture_info_string<'tcx>( tcx: TyCtxt<'_>, place: &Place<'tcx>, capture_info: &ty::CaptureInfo<'tcx>, @@ -2233,7 +2233,7 @@ fn migration_suggestion_for_2229( /// would've already handled `E1`, and have an existing capture_information for it. /// Calling `determine_capture_info(existing_info_e1, current_info_e2)` will return /// `existing_info_e1` in this case, allowing us to point to `E1` in case of diagnostics. -fn determine_capture_info( +fn determine_capture_info<'tcx>( capture_info_a: ty::CaptureInfo<'tcx>, capture_info_b: ty::CaptureInfo<'tcx>, ) -> ty::CaptureInfo<'tcx> { @@ -2292,7 +2292,7 @@ fn determine_capture_info( /// /// Note: Capture kind changes from `MutBorrow` to `UniqueImmBorrow` if the truncated part of the `place` /// contained `Deref` of `&mut`. -fn truncate_place_to_len_and_update_capture_kind( +fn truncate_place_to_len_and_update_capture_kind<'tcx>( place: &mut Place<'tcx>, curr_mode: &mut ty::UpvarCapture<'tcx>, len: usize, @@ -2330,7 +2330,7 @@ fn truncate_place_to_len_and_update_capture_kind( /// `PlaceAncestryRelation::Ancestor` implies Place A is ancestor of Place B /// `PlaceAncestryRelation::Descendant` implies Place A is descendant of Place B /// `PlaceAncestryRelation::Divergent` implies neither of them is the ancestor of the other. -fn determine_place_ancestry_relation( +fn determine_place_ancestry_relation<'tcx>( place_a: &Place<'tcx>, place_b: &Place<'tcx>, ) -> PlaceAncestryRelation { diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 3fd3284d8b10..5c599d70d5c4 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -1450,7 +1450,7 @@ fn check_method_receiver<'fcx, 'tcx>( } } -fn e0307(fcx: &FnCtxt<'fcx, 'tcx>, span: Span, receiver_ty: Ty<'_>) { +fn e0307<'fcx, 'tcx> (fcx: &FnCtxt<'fcx, 'tcx>, span: Span, receiver_ty: Ty<'_>) { struct_span_err!( fcx.tcx.sess.diagnostic(), span, @@ -1553,7 +1553,7 @@ fn receiver_is_valid<'fcx, 'tcx>( true } -fn receiver_is_implemented( +fn receiver_is_implemented<'tcx>( fcx: &FnCtxt<'_, 'tcx>, receiver_trait_def_id: DefId, cause: ObligationCause<'tcx>, @@ -1696,13 +1696,13 @@ pub struct CheckTypeWellFormedVisitor<'tcx> { tcx: TyCtxt<'tcx>, } -impl CheckTypeWellFormedVisitor<'tcx> { - pub fn new(tcx: TyCtxt<'tcx>) -> CheckTypeWellFormedVisitor<'tcx> { +impl CheckTypeWellFormedVisitor<'_> { + pub fn new(tcx: TyCtxt<'_>) -> CheckTypeWellFormedVisitor<'_> { CheckTypeWellFormedVisitor { tcx } } } -impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { +impl<'tcx> ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { fn visit_item(&self, i: &'tcx hir::Item<'tcx>) { Visitor::visit_item(&mut self.clone(), i); } @@ -1720,7 +1720,7 @@ impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { } } -impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { +impl<'tcx> Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { type Map = hir_map::Map<'tcx>; fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap { diff --git a/compiler/rustc_typeck/src/check_unused.rs b/compiler/rustc_typeck/src/check_unused.rs index 79ed83d59ed9..f63561f0582a 100644 --- a/compiler/rustc_typeck/src/check_unused.rs +++ b/compiler/rustc_typeck/src/check_unused.rs @@ -21,7 +21,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) { unused_crates_lint(tcx); } -impl ItemLikeVisitor<'v> for CheckVisitor<'tcx> { +impl <'v, 'tcx> ItemLikeVisitor<'v> for CheckVisitor<'tcx> { fn visit_item(&mut self, item: &hir::Item<'_>) { if item.vis.node.is_pub() || item.span.is_dummy() { return; @@ -43,7 +43,7 @@ struct CheckVisitor<'tcx> { used_trait_imports: FxHashSet, } -impl CheckVisitor<'tcx> { +impl<'tcx> CheckVisitor<'tcx> { fn check_import(&self, item_id: hir::ItemId, span: Span) { if !self.tcx.maybe_unused_trait_import(item_id.def_id) { return; diff --git a/compiler/rustc_typeck/src/coherence/builtin.rs b/compiler/rustc_typeck/src/coherence/builtin.rs index dfb4304ab02c..5b277589a3ad 100644 --- a/compiler/rustc_typeck/src/coherence/builtin.rs +++ b/compiler/rustc_typeck/src/coherence/builtin.rs @@ -108,7 +108,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) { } } -fn visit_implementation_of_coerce_unsized(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 @@ -287,7 +287,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef }) } -pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { +pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did); // this provider should only get invoked for local def-ids diff --git a/compiler/rustc_typeck/src/coherence/inherent_impls.rs b/compiler/rustc_typeck/src/coherence/inherent_impls.rs index 6a9ba9d49134..0c38dc5b4bde 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls.rs @@ -38,7 +38,7 @@ struct InherentCollect<'tcx> { impls_map: CrateInherentImpls, } -impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { +impl<'v, 'tcx> ItemLikeVisitor<'v> for InherentCollect<'tcx> { fn visit_item(&mut self, item: &hir::Item<'_>) { let (ty, assoc_items) = match item.kind { hir::ItemKind::Impl(hir::Impl { of_trait: None, ref self_ty, items, .. }) => { @@ -370,7 +370,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { fn visit_foreign_item(&mut self, _foreign_item: &hir::ForeignItem<'_>) {} } -impl InherentCollect<'tcx> { +impl<'tcx> InherentCollect<'tcx> { fn check_def_id(&mut self, item: &hir::Item<'_>, def_id: DefId) { if let Some(def_id) = def_id.as_local() { // Add the implementation to the mapping from implementation to base diff --git a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs index beacf301cae2..18892db4b3ae 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs @@ -18,7 +18,7 @@ struct InherentOverlapChecker<'tcx> { tcx: TyCtxt<'tcx>, } -impl InherentOverlapChecker<'tcx> { +impl<'tcx> InherentOverlapChecker<'tcx> { /// Checks whether any associated items in impls 1 and 2 share the same identifier and /// namespace. fn impls_have_common_items( @@ -115,7 +115,7 @@ impl InherentOverlapChecker<'tcx> { } } -impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> { +impl<'v, 'tcx> ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> { fn visit_item(&mut self, item: &'v hir::Item<'v>) { match item.kind { hir::ItemKind::Enum(..) diff --git a/compiler/rustc_typeck/src/coherence/orphan.rs b/compiler/rustc_typeck/src/coherence/orphan.rs index b450d3f6c08a..e954b4cf512c 100644 --- a/compiler/rustc_typeck/src/coherence/orphan.rs +++ b/compiler/rustc_typeck/src/coherence/orphan.rs @@ -143,7 +143,7 @@ fn orphan_check_impl(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorRep Ok(()) } -fn emit_orphan_check_error( +fn emit_orphan_check_error<'tcx>( tcx: TyCtxt<'tcx>, sp: Span, trait_span: Span, diff --git a/compiler/rustc_typeck/src/coherence/unsafety.rs b/compiler/rustc_typeck/src/coherence/unsafety.rs index e7b03fa3ac68..5a0a84a4aa61 100644 --- a/compiler/rustc_typeck/src/coherence/unsafety.rs +++ b/compiler/rustc_typeck/src/coherence/unsafety.rs @@ -16,8 +16,8 @@ struct UnsafetyChecker<'tcx> { tcx: TyCtxt<'tcx>, } -impl UnsafetyChecker<'tcx> { - fn check_unsafety_coherence( +impl<'tcx> UnsafetyChecker<'tcx> { + fn check_unsafety_coherence<'v>( &mut self, item: &'v hir::Item<'v>, impl_generics: Option<&hir::Generics<'_>>, @@ -83,7 +83,7 @@ impl UnsafetyChecker<'tcx> { } } -impl ItemLikeVisitor<'v> for UnsafetyChecker<'tcx> { +impl<'v, 'tcx> ItemLikeVisitor<'v> for UnsafetyChecker<'tcx> { fn visit_item(&mut self, item: &'v hir::Item<'v>) { if let hir::ItemKind::Impl(ref impl_) = item.kind { self.check_unsafety_coherence( diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index ea86bafffb39..8057dc2effa7 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -147,7 +147,7 @@ struct CollectItemTypesVisitor<'tcx> { /// If there are any placeholder types (`_`), emit an error explaining that this is not allowed /// and suggest adding type parameters in the appropriate place, taking into consideration any and /// all already existing generic type parameters to avoid suggesting a name that is already in use. -crate fn placeholder_type_error( +crate fn placeholder_type_error<'tcx>( tcx: TyCtxt<'tcx>, span: Option, generics: &[hir::GenericParam<'_>], @@ -223,7 +223,7 @@ crate fn placeholder_type_error( err.emit(); } -fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) { +fn reject_placeholder_type_signatures_in_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) { let (generics, suggest) = match &item.kind { hir::ItemKind::Union(_, generics) | hir::ItemKind::Enum(_, generics) @@ -251,7 +251,7 @@ fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir ); } -impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { +impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { type Map = Map<'tcx>; fn nested_visit_map(&mut self) -> NestedVisitorMap { @@ -311,7 +311,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { /////////////////////////////////////////////////////////////////////////// // Utility types and common code for the above passes. -fn bad_placeholder_type( +fn bad_placeholder_type<'tcx>( tcx: TyCtxt<'tcx>, mut spans: Vec, kind: &'static str, @@ -332,7 +332,7 @@ fn bad_placeholder_type( err } -impl ItemCtxt<'tcx> { +impl<'tcx> ItemCtxt<'tcx> { pub fn new(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> ItemCtxt<'tcx> { ItemCtxt { tcx, item_def_id } } @@ -350,7 +350,7 @@ impl ItemCtxt<'tcx> { } } -impl AstConv<'tcx> for ItemCtxt<'tcx> { +impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -643,7 +643,7 @@ fn type_param_predicates( result } -impl ItemCtxt<'tcx> { +impl<'tcx> ItemCtxt<'tcx> { /// Finds bounds from `hir::Generics`. This requires scanning through the /// AST. We do this to avoid having to convert *all* the bounds, which /// would create artificial cycles. Instead, we can only convert the @@ -1239,7 +1239,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option, } - impl Visitor<'tcx> for LateBoundRegionsDetector<'tcx> { + impl<'tcx> Visitor<'tcx> for LateBoundRegionsDetector<'tcx> { type Map = intravisit::ErasedMap<'tcx>; fn nested_visit_map(&mut self) -> NestedVisitorMap { @@ -1746,7 +1746,7 @@ fn is_suggestable_infer_ty(ty: &hir::Ty<'_>) -> bool { } } -pub fn get_infer_ret_ty(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir hir::Ty<'hir>> { +pub fn get_infer_ret_ty<'hir>(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir hir::Ty<'hir>> { if let hir::FnRetTy::Return(ty) = output { if is_suggestable_infer_ty(ty) { return Some(&*ty); diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index af199ca99460..99fddcb00cec 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -731,7 +731,7 @@ fn infer_placeholder_type<'a>( } } - impl TypeFolder<'tcx> for MakeNameable<'tcx> { + impl<'tcx> TypeFolder<'tcx> for MakeNameable<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_typeck/src/expr_use_visitor.rs b/compiler/rustc_typeck/src/expr_use_visitor.rs index 7d0600b99e36..0896daf48b78 100644 --- a/compiler/rustc_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_typeck/src/expr_use_visitor.rs @@ -482,7 +482,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } } - fn walk_struct_expr( + fn walk_struct_expr<'hir>( &mut self, fields: &[hir::ExprField<'_>], opt_with: &Option<&'hir hir::Expr<'_>>, @@ -705,7 +705,7 @@ 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::Expr<'_>) { - fn upvar_is_local_variable( + fn upvar_is_local_variable<'tcx>( upvars: Option<&'tcx FxIndexMap>, upvar_id: &hir::HirId, body_owner_is_closure: bool, @@ -846,7 +846,7 @@ fn delegate_consume<'a, 'tcx>( } } -fn is_multivariant_adt(ty: Ty<'tcx>) -> bool { +fn is_multivariant_adt(ty: Ty<'_>) -> bool { if let ty::Adt(def, _) = ty.kind() { // Note that if a non-exhaustive SingleVariant is defined in another crate, we need // to assume that more cases will be added to the variant in the future. This mean diff --git a/compiler/rustc_typeck/src/impl_wf_check.rs b/compiler/rustc_typeck/src/impl_wf_check.rs index 5d2f8fc42427..ae6321de7f2d 100644 --- a/compiler/rustc_typeck/src/impl_wf_check.rs +++ b/compiler/rustc_typeck/src/impl_wf_check.rs @@ -76,7 +76,7 @@ struct ImplWfCheck<'tcx> { min_specialization: bool, } -impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> { +impl<'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { if let hir::ItemKind::Impl(ref impl_) = item.kind { enforce_impl_params_are_constrained(self.tcx, item.def_id, impl_.items); diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index 41e06f43c461..ea777d90a9c5 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -59,7 +59,6 @@ This API is completely unstable and subject to change. #![feature(bool_to_option)] #![feature(crate_visibility_modifier)] #![feature(if_let_guard)] -#![feature(in_band_lifetimes)] #![feature(is_sorted)] #![feature(iter_zip)] #![feature(let_else)] diff --git a/compiler/rustc_typeck/src/outlives/test.rs b/compiler/rustc_typeck/src/outlives/test.rs index ec4fa9cd4b57..b3efd9f9ec36 100644 --- a/compiler/rustc_typeck/src/outlives/test.rs +++ b/compiler/rustc_typeck/src/outlives/test.rs @@ -12,7 +12,7 @@ struct OutlivesTest<'tcx> { tcx: TyCtxt<'tcx>, } -impl ItemLikeVisitor<'tcx> for OutlivesTest<'tcx> { +impl<'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { // For unit testing: check for a special "rustc_outlives" // attribute and report an error with various results if found. diff --git a/compiler/rustc_typeck/src/variance/test.rs b/compiler/rustc_typeck/src/variance/test.rs index 7be3c68e8f61..d6959075d888 100644 --- a/compiler/rustc_typeck/src/variance/test.rs +++ b/compiler/rustc_typeck/src/variance/test.rs @@ -12,7 +12,7 @@ struct VarianceTest<'tcx> { tcx: TyCtxt<'tcx>, } -impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> { +impl<'tcx> ItemLikeVisitor<'tcx> for VarianceTest<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { // For unit testing: check for a special "rustc_variance" // attribute and report an error with various results if found. From 4e38807166dcf2bd1e76a93c0eb4b4eea1511385 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Mon, 13 Dec 2021 22:23:55 -0500 Subject: [PATCH 06/18] core: minor `Option` doc correction --- library/core/src/option.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 381e2d6eed3f..015366ed490c 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -512,11 +512,11 @@ use crate::{ #[rustc_diagnostic_item = "Option"] #[stable(feature = "rust1", since = "1.0.0")] pub enum Option { - /// No value + /// No value. #[lang = "None"] #[stable(feature = "rust1", since = "1.0.0")] None, - /// Some value `T` + /// Some value of type `T`. #[lang = "Some"] #[stable(feature = "rust1", since = "1.0.0")] Some(#[stable(feature = "rust1", since = "1.0.0")] T), From 7175980ff51636f03824d67869e9a237c7d76ad5 Mon Sep 17 00:00:00 2001 From: Ellen Date: Mon, 13 Dec 2021 19:14:35 +0000 Subject: [PATCH 07/18] awdawdawd --- compiler/rustc_ast_lowering/src/lib.rs | 3 +-- compiler/rustc_hir/src/hir.rs | 14 -------------- compiler/rustc_resolve/src/late/lifetimes.rs | 9 ++++----- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index c04b0471cb72..4f571cd87a2f 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -53,7 +53,7 @@ use rustc_hir::def::{DefKind, Namespace, PartialRes, PerNS, Res}; use rustc_hir::def_id::{DefId, DefPathHash, LocalDefId, CRATE_DEF_ID}; use rustc_hir::definitions::{DefKey, DefPathData, Definitions}; use rustc_hir::intravisit; -use rustc_hir::{ConstArg, GenericArg, InferKind, ParamName}; +use rustc_hir::{ConstArg, GenericArg, ParamName}; use rustc_index::vec::{Idx, IndexVec}; use rustc_query_system::ich::StableHashingContext; use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS; @@ -1114,7 +1114,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { return GenericArg::Infer(hir::InferArg { hir_id: self.lower_node_id(ty.id), span: self.lower_span(ty.span), - kind: InferKind::Type, }); } // We parse const arguments as path types as we cannot distinguish them during diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index fdf7a8102a02..b8fe43ae10d9 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -255,23 +255,9 @@ pub struct ConstArg { pub span: Span, } -#[derive(Copy, Clone, Encodable, Debug, HashStable_Generic)] -pub enum InferKind { - Const, - Type, -} - -impl InferKind { - #[inline] - pub fn is_type(self) -> bool { - matches!(self, InferKind::Type) - } -} - #[derive(Encodable, Debug, HashStable_Generic)] pub struct InferArg { pub hir_id: HirId, - pub kind: InferKind, pub span: Span, } diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index c94c56df75b7..05098defead3 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -2541,8 +2541,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { GenericParamDefKind::Type { object_lifetime_default, .. } => { Some(object_lifetime_default) } - GenericParamDefKind::Lifetime - | GenericParamDefKind::Const { .. } => None, + GenericParamDefKind::Const { .. } => Some(Set1::Empty), + GenericParamDefKind::Lifetime => None, }) .collect() }) @@ -2569,12 +2569,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } GenericArg::Const(ct) => { self.visit_anon_const(&ct.value); + i += 1; } GenericArg::Infer(inf) => { self.visit_id(inf.hir_id); - if inf.kind.is_type() { - i += 1; - } + i += 1; } } } From 0a0f01410d378fc9d1ca27fe5a42f01092e0cf3e Mon Sep 17 00:00:00 2001 From: Ellen Date: Mon, 13 Dec 2021 19:47:10 +0000 Subject: [PATCH 08/18] test --- .../auxiliary/trait_object_lt_defaults_lib.rs | 1 + .../defaults/trait_object_lt_defaults.rs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs create mode 100644 src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs diff --git a/src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs b/src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs new file mode 100644 index 000000000000..26a2c47ffb26 --- /dev/null +++ b/src/test/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs @@ -0,0 +1 @@ +pub struct Foo<'a, const N: usize, T: 'a + ?Sized>(pub &'a T, [(); N]); diff --git a/src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs b/src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs new file mode 100644 index 000000000000..a1828727ecdb --- /dev/null +++ b/src/test/ui/const-generics/defaults/trait_object_lt_defaults.rs @@ -0,0 +1,24 @@ +// aux-build:trait_object_lt_defaults_lib.rs +// run-pass +#![allow(dead_code)] +extern crate trait_object_lt_defaults_lib; + +// Tests that `A<'a, 3, dyn Test>` is short for `A<'a, 3, dyn Test + 'a>` +// and `Foo<'a, 3, dyn Test>` is short for `Foo<'a, 3, dyn Test + 'a>` +// Test is in `const-generics/defaults` because it relies on param ordering + +trait Test {} + +struct A<'a, const N: usize, T: ?Sized + 'a>(&'a T, [(); N]); +fn blah<'a>(mut a: A<'a, 3, dyn Test>, arg: &'a (dyn Test + 'a)) { + a.0 = arg; +} + +fn other_blah<'a>( + mut a: trait_object_lt_defaults_lib::Foo<'a, 3, dyn Test>, + arg: &'a (dyn Test + 'a), +) { + a.0 = arg; +} + +fn main() {} From b682deca7e32c10876bd18c1344a0e4f4113d42d Mon Sep 17 00:00:00 2001 From: Sylvan Bowdler Date: Tue, 14 Dec 2021 08:01:32 +0000 Subject: [PATCH 09/18] Remove `in_band_lifetimes` from `rustc_symbol_mangling` --- compiler/rustc_symbol_mangling/src/legacy.rs | 6 +++--- compiler/rustc_symbol_mangling/src/lib.rs | 9 ++++----- compiler/rustc_symbol_mangling/src/test.rs | 4 ++-- compiler/rustc_symbol_mangling/src/v0.rs | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index de18614360ef..cdea84a8d60f 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -13,7 +13,7 @@ use tracing::debug; use std::fmt::{self, Write}; use std::mem::{self, discriminant}; -pub(super) fn mangle( +pub(super) fn mangle<'tcx>( tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, instantiating_crate: Option, @@ -199,7 +199,7 @@ struct SymbolPrinter<'tcx> { // `PrettyPrinter` aka pretty printing of e.g. types in paths, // symbol names should have their own printing machinery. -impl Printer<'tcx> for &mut SymbolPrinter<'tcx> { +impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> { type Error = fmt::Error; type Path = Self; @@ -345,7 +345,7 @@ impl Printer<'tcx> for &mut SymbolPrinter<'tcx> { } } -impl PrettyPrinter<'tcx> for &mut SymbolPrinter<'tcx> { +impl<'tcx> PrettyPrinter<'tcx> for &mut SymbolPrinter<'tcx> { fn region_should_not_be_omitted(&self, _region: ty::Region<'_>) -> bool { false } diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index bb7b45295560..d91f6d53409d 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -90,7 +90,6 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(never_type)] #![feature(nll)] -#![feature(in_band_lifetimes)] #![feature(iter_zip)] #![recursion_limit = "256"] @@ -117,7 +116,7 @@ pub mod test; /// This function computes the symbol name for the given `instance` and the /// given instantiating crate. That is, if you know that instance X is /// instantiated in crate Y, this is the symbol name this instance would have. -pub fn symbol_name_for_instance_in_crate( +pub fn symbol_name_for_instance_in_crate<'tcx>( tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, instantiating_crate: CrateNum, @@ -132,7 +131,7 @@ pub fn provide(providers: &mut Providers) { // The `symbol_name` query provides the symbol name for calling a given // instance from the local crate. In particular, it will also look up the // correct symbol name of instances from upstream crates. -fn symbol_name_provider(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::SymbolName<'tcx> { +fn symbol_name_provider<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::SymbolName<'tcx> { let symbol_name = compute_symbol_name(tcx, instance, || { // This closure determines the instantiating crate for instances that // need an instantiating-crate-suffix for their symbol name, in order @@ -152,14 +151,14 @@ fn symbol_name_provider(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::Symb } /// This function computes the typeid for the given function ABI. -pub fn typeid_for_fnabi(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> String { +pub fn typeid_for_fnabi<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> String { v0::mangle_typeid_for_fnabi(tcx, fn_abi) } /// Computes the symbol name for the given instance. This function will call /// `compute_instantiating_crate` if it needs to factor the instantiating crate /// into the symbol name. -fn compute_symbol_name( +fn compute_symbol_name<'tcx>( tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, compute_instantiating_crate: impl FnOnce() -> CrateNum, diff --git a/compiler/rustc_symbol_mangling/src/test.rs b/compiler/rustc_symbol_mangling/src/test.rs index f7d68b5cc706..700765a351ce 100644 --- a/compiler/rustc_symbol_mangling/src/test.rs +++ b/compiler/rustc_symbol_mangling/src/test.rs @@ -31,7 +31,7 @@ struct SymbolNamesTest<'tcx> { tcx: TyCtxt<'tcx>, } -impl SymbolNamesTest<'tcx> { +impl SymbolNamesTest<'_> { fn process_attrs(&mut self, def_id: LocalDefId) { let tcx = self.tcx; for attr in tcx.get_attrs(def_id.to_def_id()).iter() { @@ -59,7 +59,7 @@ impl SymbolNamesTest<'tcx> { } } -impl hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'tcx> { +impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { self.process_attrs(item.def_id); } diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 0363ddb0e6ee..167ff758f348 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -17,7 +17,7 @@ use std::fmt::Write; use std::iter; use std::ops::Range; -pub(super) fn mangle( +pub(super) fn mangle<'tcx>( tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, instantiating_crate: Option, @@ -56,7 +56,7 @@ pub(super) fn mangle( std::mem::take(&mut cx.out) } -pub(super) fn mangle_typeid_for_fnabi( +pub(super) fn mangle_typeid_for_fnabi<'tcx>( _tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, ) -> String { @@ -118,7 +118,7 @@ struct SymbolMangler<'tcx> { consts: FxHashMap<&'tcx ty::Const<'tcx>, usize>, } -impl SymbolMangler<'tcx> { +impl<'tcx> SymbolMangler<'tcx> { fn push(&mut self, s: &str) { self.out.push_str(s); } @@ -250,7 +250,7 @@ impl SymbolMangler<'tcx> { } } -impl Printer<'tcx> for &mut SymbolMangler<'tcx> { +impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { type Error = !; type Path = Self; From 1ea756bb8835309aac0c5f817f87f409bf1255b4 Mon Sep 17 00:00:00 2001 From: Sylvan Bowdler Date: Tue, 14 Dec 2021 09:44:49 +0000 Subject: [PATCH 10/18] Remove `in_band_lifetimes` from `rustc_trait_selection` --- compiler/rustc_trait_selection/src/lib.rs | 1 - .../rustc_trait_selection/src/opaque_types.rs | 6 +++--- .../src/traits/auto_trait.rs | 2 +- .../src/traits/chalk_fulfill.rs | 4 ++-- .../src/traits/codegen.rs | 2 +- .../src/traits/coherence.rs | 20 ++++++++++++++----- .../src/traits/error_reporting/mod.rs | 10 +++++----- .../src/traits/error_reporting/suggestions.rs | 2 +- .../src/traits/fulfill.rs | 2 +- .../rustc_trait_selection/src/traits/misc.rs | 2 +- .../rustc_trait_selection/src/traits/mod.rs | 2 +- .../src/traits/object_safety.rs | 7 ++----- .../src/traits/project.rs | 8 ++++---- .../src/traits/query/type_op/normalize.rs | 8 ++++---- .../src/traits/query/type_op/outlives.rs | 2 +- .../traits/specialize/specialization_graph.rs | 18 ++++++++--------- .../src/traits/structural_match.rs | 4 ++-- .../rustc_trait_selection/src/traits/util.rs | 17 +++++++++------- 18 files changed, 63 insertions(+), 54 deletions(-) diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 1820e33b19bf..6a2b4963c7d3 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -16,7 +16,6 @@ #![feature(drain_filter)] #![feature(derive_default_enum)] #![feature(hash_drain_filter)] -#![feature(in_band_lifetimes)] #![feature(iter_zip)] #![feature(let_else)] #![feature(never_type)] diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 75d57d78e3b0..ea0ac6318bc9 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -97,7 +97,7 @@ struct ReverseMapper<'tcx> { span: Span, } -impl ReverseMapper<'tcx> { +impl<'tcx> ReverseMapper<'tcx> { fn new( tcx: TyCtxt<'tcx>, tainted_by_errors: bool, @@ -134,7 +134,7 @@ impl ReverseMapper<'tcx> { } } -impl TypeFolder<'tcx> for ReverseMapper<'tcx> { +impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -338,7 +338,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { /// Requires that trait definitions have been processed so that we can /// elaborate predicates and walk supertraits. #[instrument(skip(tcx, predicates), level = "debug")] -crate fn required_region_bounds( +crate fn required_region_bounds<'tcx>( tcx: TyCtxt<'tcx>, erased_self_ty: Ty<'tcx>, predicates: impl Iterator>, diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 3642aebaec2f..53ff911ea0cd 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -219,7 +219,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { } } -impl AutoTraitFinder<'tcx> { +impl<'tcx> AutoTraitFinder<'tcx> { /// The core logic responsible for computing the bounds for our synthesized impl. /// /// To calculate the bounds, we call `SelectionContext.select` in a loop. Like diff --git a/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs b/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs index 2ccb25349173..34fc4ca8fead 100644 --- a/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs @@ -16,7 +16,7 @@ pub struct FulfillmentContext<'tcx> { relationships: FxHashMap, } -impl FulfillmentContext<'tcx> { +impl FulfillmentContext<'_> { crate fn new() -> Self { FulfillmentContext { obligations: FxIndexSet::default(), @@ -25,7 +25,7 @@ impl FulfillmentContext<'tcx> { } } -impl TraitEngine<'tcx> for FulfillmentContext<'tcx> { +impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { fn normalize_projection_type( &mut self, infcx: &InferCtxt<'_, 'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/codegen.rs b/compiler/rustc_trait_selection/src/traits/codegen.rs index bdd4fdd40438..848aba7c9128 100644 --- a/compiler/rustc_trait_selection/src/traits/codegen.rs +++ b/compiler/rustc_trait_selection/src/traits/codegen.rs @@ -107,7 +107,7 @@ pub fn codegen_fulfill_obligation<'tcx>( /// type inference variables that appear in `result` to be /// unified, and hence we need to process those obligations to get /// the complete picture of the type. -fn drain_fulfillment_cx_or_panic( +fn drain_fulfillment_cx_or_panic<'tcx, T>( infcx: &InferCtxt<'_, 'tcx>, fulfill_cx: &mut FulfillmentContext<'tcx>, result: T, diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index aec9da9f8d4f..20c734f32ff9 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -154,18 +154,24 @@ fn overlap<'cx, 'tcx>( }) } -fn overlap_within_probe( +fn overlap_within_probe<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, skip_leak_check: SkipLeakCheck, a_def_id: DefId, b_def_id: DefId, snapshot: &CombinedSnapshot<'_, 'tcx>, ) -> Option> { - fn loose_check(selcx: &mut SelectionContext<'cx, 'tcx>, o: &PredicateObligation<'tcx>) -> bool { + fn loose_check<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, + o: &PredicateObligation<'tcx>, + ) -> bool { !selcx.predicate_may_hold_fatal(o) } - fn strict_check(selcx: &SelectionContext<'cx, 'tcx>, o: &PredicateObligation<'tcx>) -> bool { + fn strict_check<'cx, 'tcx>( + selcx: &SelectionContext<'cx, 'tcx>, + o: &PredicateObligation<'tcx>, + ) -> bool { let infcx = selcx.infcx(); let tcx = infcx.tcx; o.flip_polarity(tcx) @@ -518,7 +524,11 @@ fn orphan_check_trait_ref<'tcx>( /// - for `Foo`, where `Foo` is a local type, this returns `[]`. /// - `&mut u32` returns `[u32]`, as `&mut` is a fundamental type, similar to `Box`. /// - `Box>` returns `[]`, as `Box` is a fundamental type and `Foo` is local. -fn contained_non_local_types(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec> { +fn contained_non_local_types<'tcx>( + tcx: TyCtxt<'tcx>, + ty: Ty<'tcx>, + in_crate: InCrate, +) -> Vec> { if ty_is_local_constructor(ty, in_crate) { Vec::new() } else { @@ -534,7 +544,7 @@ fn contained_non_local_types(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, in_crate: InCrate) /// For `#[fundamental]` ADTs and `&T` / `&mut T`, returns `Some` with the /// type parameters of the ADT, or `T`, respectively. For non-fundamental /// types, returns `None`. -fn fundamental_ty_inner_tys( +fn fundamental_ty_inner_tys<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ) -> Option>> { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 310eecc6e85f..16eb3afb22f1 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1062,7 +1062,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } } -trait InferCtxtPrivExt<'tcx> { +trait InferCtxtPrivExt<'hir, 'tcx> { // returns if `cond` not occurring implies that `error` does not occur - i.e., that // `error` occurring implies that `cond` occurs. fn error_implies(&self, cond: ty::Predicate<'tcx>, error: ty::Predicate<'tcx>) -> bool; @@ -1173,7 +1173,7 @@ trait InferCtxtPrivExt<'tcx> { ) -> bool; } -impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { +impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { // returns if `cond` not occurring implies that `error` does not occur - i.e., that // `error` occurring implies that `cond` occurs. fn error_implies(&self, cond: ty::Predicate<'tcx>, error: ty::Predicate<'tcx>) -> bool { @@ -2023,7 +2023,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { self.maybe_suggest_unsized_generics(err, span, node); } - fn maybe_suggest_unsized_generics( + fn maybe_suggest_unsized_generics<'hir>( &self, err: &mut DiagnosticBuilder<'tcx>, span: Span, @@ -2090,7 +2090,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { ); } - fn maybe_indirection_for_unsized( + fn maybe_indirection_for_unsized<'hir>( &self, err: &mut DiagnosticBuilder<'tcx>, item: &'hir Item<'hir>, @@ -2204,7 +2204,7 @@ impl<'v> Visitor<'v> for FindTypeParam { } pub fn recursive_type_with_infinite_size_error( - tcx: TyCtxt<'tcx>, + tcx: TyCtxt<'_>, type_def_id: DefId, spans: Vec, ) { 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 286c9c9900b9..e8d7a34505a5 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -192,7 +192,7 @@ fn predicate_constraint(generics: &hir::Generics<'_>, pred: String) -> (Span, St /// Type parameter needs more bounds. The trivial case is `T` `where T: Bound`, but /// it can also be an `impl Trait` param that needs to be decomposed to a type /// param for cleaner code. -fn suggest_restriction( +fn suggest_restriction<'tcx>( tcx: TyCtxt<'tcx>, generics: &hir::Generics<'tcx>, msg: &str, diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 8a60f9b8602f..2b5dae1d751f 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -252,7 +252,7 @@ struct FulfillProcessor<'a, 'b, 'tcx> { register_region_obligations: bool, } -fn mk_pending(os: Vec>) -> Vec> { +fn mk_pending(os: Vec>) -> Vec> { os.into_iter() .map(|o| PendingPredicateObligation { obligation: o, stalled_on: vec![] }) .collect() diff --git a/compiler/rustc_trait_selection/src/traits/misc.rs b/compiler/rustc_trait_selection/src/traits/misc.rs index fa8890fc3529..b23dce8a5813 100644 --- a/compiler/rustc_trait_selection/src/traits/misc.rs +++ b/compiler/rustc_trait_selection/src/traits/misc.rs @@ -16,7 +16,7 @@ pub enum CopyImplementationError<'tcx> { HasDestructor, } -pub fn can_type_implement_copy( +pub fn can_type_implement_copy<'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, self_type: Ty<'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index d81b6949cae6..a8f26982d2e4 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -801,7 +801,7 @@ fn vtable_trait_first_method_offset<'tcx>( } /// Find slot offset for trait vptr within vtable entries of another trait -pub fn vtable_trait_upcasting_coercion_new_vptr_slot( +pub fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>( tcx: TyCtxt<'tcx>, key: ( Ty<'tcx>, // trait object type whose trait owning vtable diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index c9afd93af710..4e84849bc1e2 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -50,10 +50,7 @@ pub fn astconv_object_safety_violations( violations } -fn object_safety_violations( - tcx: TyCtxt<'tcx>, - trait_def_id: DefId, -) -> &'tcx [ObjectSafetyViolation] { +fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &'_ [ObjectSafetyViolation] { debug_assert!(tcx.generics_of(trait_def_id).has_self); debug!("object_safety_violations: {:?}", trait_def_id); @@ -272,7 +269,7 @@ fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span .collect() } -fn predicate_references_self( +fn predicate_references_self<'tcx>( tcx: TyCtxt<'tcx>, (predicate, sp): (ty::Predicate<'tcx>, Span), ) -> Option { diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 2ebbfa5aa11d..b32fb616e12b 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -570,7 +570,7 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> { } } -impl TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> { +impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -678,7 +678,7 @@ impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> { } } -impl TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> { +impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -1937,14 +1937,14 @@ fn assoc_ty_def( } } -crate trait ProjectionCacheKeyExt<'tcx>: Sized { +crate trait ProjectionCacheKeyExt<'cx, 'tcx>: Sized { fn from_poly_projection_predicate( selcx: &mut SelectionContext<'cx, 'tcx>, predicate: ty::PolyProjectionPredicate<'tcx>, ) -> Option; } -impl<'tcx> ProjectionCacheKeyExt<'tcx> for ProjectionCacheKey<'tcx> { +impl<'cx, 'tcx> ProjectionCacheKeyExt<'cx, 'tcx> for ProjectionCacheKey<'tcx> { fn from_poly_projection_predicate( selcx: &mut SelectionContext<'cx, 'tcx>, predicate: ty::PolyProjectionPredicate<'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs index 729b66ac21c2..e92ca7325d34 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs @@ -31,7 +31,7 @@ pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Cop ) -> Fallible>; } -impl Normalizable<'tcx> for Ty<'tcx> { +impl<'tcx> Normalizable<'tcx> for Ty<'tcx> { fn type_op_method( tcx: TyCtxt<'tcx>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, @@ -40,7 +40,7 @@ impl Normalizable<'tcx> for Ty<'tcx> { } } -impl Normalizable<'tcx> for ty::Predicate<'tcx> { +impl<'tcx> Normalizable<'tcx> for ty::Predicate<'tcx> { fn type_op_method( tcx: TyCtxt<'tcx>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, @@ -49,7 +49,7 @@ impl Normalizable<'tcx> for ty::Predicate<'tcx> { } } -impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> { +impl<'tcx> Normalizable<'tcx> for ty::PolyFnSig<'tcx> { fn type_op_method( tcx: TyCtxt<'tcx>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, @@ -58,7 +58,7 @@ impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> { } } -impl Normalizable<'tcx> for ty::FnSig<'tcx> { +impl<'tcx> Normalizable<'tcx> for ty::FnSig<'tcx> { fn type_op_method( tcx: TyCtxt<'tcx>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs index 5a27e57860ec..82f147f8143d 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs @@ -14,7 +14,7 @@ impl<'tcx> DropckOutlives<'tcx> { } } -impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> { +impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> { type QueryResponse = DropckOutlivesResult<'tcx>; fn try_fast_path( diff --git a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs index ec7dcd4a419b..5e7dc5754bda 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs @@ -32,7 +32,7 @@ enum Inserted { ShouldRecurseOn(DefId), } -trait ChildrenExt { +trait ChildrenExt<'tcx> { fn insert_blindly(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId); fn remove_existing(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId); @@ -44,9 +44,9 @@ trait ChildrenExt { ) -> Result; } -impl ChildrenExt for Children { +impl ChildrenExt<'_> for Children { /// Insert an impl into this set of children without comparing to any existing impls. - fn insert_blindly(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) { + fn insert_blindly(&mut self, tcx: TyCtxt<'_>, impl_def_id: DefId) { let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); if let Some(st) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) { debug!("insert_blindly: impl_def_id={:?} st={:?}", impl_def_id, st); @@ -60,7 +60,7 @@ impl ChildrenExt for Children { /// Removes an impl from this set of children. Used when replacing /// an impl with a parent. The impl must be present in the list of /// children already. - fn remove_existing(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) { + fn remove_existing(&mut self, tcx: TyCtxt<'_>, impl_def_id: DefId) { let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); let vec: &mut Vec; if let Some(st) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) { @@ -79,7 +79,7 @@ impl ChildrenExt for Children { /// specialization relationships. fn insert( &mut self, - tcx: TyCtxt<'tcx>, + tcx: TyCtxt<'_>, impl_def_id: DefId, simplified_self: Option, ) -> Result { @@ -261,12 +261,12 @@ pub trait GraphExt { /// information about the area of overlap is returned in the `Err`. fn insert( &mut self, - tcx: TyCtxt<'tcx>, + tcx: TyCtxt<'_>, impl_def_id: DefId, ) -> Result, OverlapError>; /// Insert cached metadata mapping from a child impl back to its parent. - fn record_impl_from_cstore(&mut self, tcx: TyCtxt<'tcx>, parent: DefId, child: DefId); + fn record_impl_from_cstore(&mut self, tcx: TyCtxt<'_>, parent: DefId, child: DefId); } impl GraphExt for Graph { @@ -275,7 +275,7 @@ impl GraphExt for Graph { /// information about the area of overlap is returned in the `Err`. fn insert( &mut self, - tcx: TyCtxt<'tcx>, + tcx: TyCtxt<'_>, impl_def_id: DefId, ) -> Result, OverlapError> { assert!(impl_def_id.is_local()); @@ -370,7 +370,7 @@ impl GraphExt for Graph { } /// Insert cached metadata mapping from a child impl back to its parent. - fn record_impl_from_cstore(&mut self, tcx: TyCtxt<'tcx>, parent: DefId, child: DefId) { + fn record_impl_from_cstore(&mut self, tcx: TyCtxt<'_>, parent: DefId, child: DefId) { if self.parent.insert(child, parent).is_some() { bug!( "When recording an impl from the crate store, information about its parent \ diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index 3d7138222786..55feb3c1de17 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -66,7 +66,7 @@ pub fn search_for_structural_match_violation<'tcx>( /// /// Note that this does *not* recursively check if the substructure of `adt_ty` /// implements the traits. -fn type_marked_structural( +fn type_marked_structural<'tcx>( infcx: &InferCtxt<'_, 'tcx>, adt_ty: Ty<'tcx>, cause: ObligationCause<'tcx>, @@ -119,7 +119,7 @@ struct Search<'a, 'tcx> { seen: FxHashSet, } -impl Search<'a, 'tcx> { +impl<'a, 'tcx> Search<'a, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 5577e98e8932..3090e8a04285 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -172,7 +172,7 @@ pub fn supertrait_def_ids(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SupertraitDef } } -impl Iterator for SupertraitDefIds<'tcx> { +impl Iterator for SupertraitDefIds<'_> { type Item = DefId; fn next(&mut self) -> Option { @@ -259,7 +259,7 @@ pub fn predicate_for_trait_ref<'tcx>( } } -pub fn predicate_for_trait_def( +pub fn predicate_for_trait_def<'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, @@ -276,7 +276,7 @@ pub fn predicate_for_trait_def( /// Casts a trait reference into a reference to one of its super /// traits; returns `None` if `target_trait_def_id` is not a /// supertrait. -pub fn upcast_choices( +pub fn upcast_choices<'tcx>( tcx: TyCtxt<'tcx>, source_trait_ref: ty::PolyTraitRef<'tcx>, target_trait_def_id: DefId, @@ -291,7 +291,10 @@ pub fn upcast_choices( /// Given a trait `trait_ref`, returns the number of vtable entries /// that come from `trait_ref`, excluding its supertraits. Used in /// computing the vtable base for an upcast trait of a trait object. -pub fn count_own_vtable_entries(tcx: TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>) -> usize { +pub fn count_own_vtable_entries<'tcx>( + tcx: TyCtxt<'tcx>, + trait_ref: ty::PolyTraitRef<'tcx>, +) -> usize { let existential_trait_ref = trait_ref.map_bound(|trait_ref| ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)); let existential_trait_ref = tcx.erase_regions(existential_trait_ref); @@ -301,7 +304,7 @@ pub fn count_own_vtable_entries(tcx: TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<' /// Given an upcast trait object described by `object`, returns the /// index of the method `method_def_id` (which should be part of /// `object.upcast_trait_ref`) within the vtable for `object`. -pub fn get_vtable_index_of_object_method( +pub fn get_vtable_index_of_object_method<'tcx, N>( tcx: TyCtxt<'tcx>, object: &super::ImplSourceObjectData<'tcx, N>, method_def_id: DefId, @@ -323,7 +326,7 @@ pub fn get_vtable_index_of_object_method( object.vtable_base + index } -pub fn closure_trait_ref_and_return_type( +pub fn closure_trait_ref_and_return_type<'tcx>( tcx: TyCtxt<'tcx>, fn_trait_def_id: DefId, self_ty: Ty<'tcx>, @@ -342,7 +345,7 @@ pub fn closure_trait_ref_and_return_type( sig.map_bound(|sig| (trait_ref, sig.output())) } -pub fn generator_trait_ref_and_outputs( +pub fn generator_trait_ref_and_outputs<'tcx>( tcx: TyCtxt<'tcx>, fn_trait_def_id: DefId, self_ty: Ty<'tcx>, From 90aa8fb3d51093ac3d9ea5dbdf3cccfa236ff05a Mon Sep 17 00:00:00 2001 From: Anuvrat Date: Tue, 14 Dec 2021 16:42:16 +0530 Subject: [PATCH 11/18] made compiler happy --- library/proc_macro/src/bridge/client.rs | 4 ++-- library/proc_macro/src/bridge/mod.rs | 8 ++++---- library/proc_macro/src/bridge/rpc.rs | 8 ++++---- library/proc_macro/src/lib.rs | 1 - 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs index 8ae7b6de1a63..83a2ac6f0d4f 100644 --- a/library/proc_macro/src/bridge/client.rs +++ b/library/proc_macro/src/bridge/client.rs @@ -78,7 +78,7 @@ macro_rules! define_handles { } } - impl Decode<'_, 's, HandleStore>> + impl<'s, S: server::Types> Decode<'_, 's, HandleStore>> for &'s Marked { fn decode(r: &mut Reader<'_>, s: &'s HandleStore>) -> Self { @@ -92,7 +92,7 @@ macro_rules! define_handles { } } - impl DecodeMut<'_, 's, HandleStore>> + impl<'s, S: server::Types> DecodeMut<'_, 's, HandleStore>> for &'s mut Marked { fn decode( diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs index 2df287f7d930..fbeb585095bb 100644 --- a/library/proc_macro/src/bridge/mod.rs +++ b/library/proc_macro/src/bridge/mod.rs @@ -295,13 +295,13 @@ impl Unmark for Marked { self.value } } -impl Unmark for &'a Marked { +impl<'a, T, M> Unmark for &'a Marked { type Unmarked = &'a T; fn unmark(self) -> Self::Unmarked { &self.value } } -impl Unmark for &'a mut Marked { +impl<'a, T, M> Unmark for &'a mut Marked { type Unmarked = &'a mut T; fn unmark(self) -> Self::Unmarked { &mut self.value @@ -356,8 +356,8 @@ mark_noop! { (), bool, char, - &'a [u8], - &'a str, + &'_ [u8], + &'_ str, String, usize, Delimiter, diff --git a/library/proc_macro/src/bridge/rpc.rs b/library/proc_macro/src/bridge/rpc.rs index 42432563faf3..d50564d01a5d 100644 --- a/library/proc_macro/src/bridge/rpc.rs +++ b/library/proc_macro/src/bridge/rpc.rs @@ -79,7 +79,7 @@ macro_rules! rpc_encode_decode { } } - impl DecodeMut<'a, 's, S>),+)?> DecodeMut<'a, '_, S> + impl<'a, S, $($($T: for<'s> DecodeMut<'a, 's, S>),+)?> DecodeMut<'a, '_, S> for $name $(<$($T),+>)? { fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { @@ -176,7 +176,7 @@ impl, B: Encode> Encode for (A, B) { } } -impl DecodeMut<'a, 's, S>, B: for<'s> DecodeMut<'a, 's, S>> DecodeMut<'a, '_, S> +impl<'a, S, A: for<'s> DecodeMut<'a, 's, S>, B: for<'s> DecodeMut<'a, 's, S>> DecodeMut<'a, '_, S> for (A, B) { fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { @@ -213,7 +213,7 @@ impl Encode for &[u8] { } } -impl DecodeMut<'a, '_, S> for &'a [u8] { +impl<'a, S> DecodeMut<'a, '_, S> for &'a [u8] { fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { let len = usize::decode(r, s); let xs = &r[..len]; @@ -228,7 +228,7 @@ impl Encode for &str { } } -impl DecodeMut<'a, '_, S> for &'a str { +impl<'a, S> DecodeMut<'a, '_, S> for &'a str { fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { str::from_utf8(<&[u8]>::decode(r, s)).unwrap() } diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index ef96d72a38b5..69af598f91e1 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -25,7 +25,6 @@ #![feature(allow_internal_unstable)] #![feature(decl_macro)] #![feature(extern_types)] -#![feature(in_band_lifetimes)] #![feature(negative_impls)] #![feature(auto_traits)] #![feature(restricted_std)] From a586e7d857e9f2acee86cb25d42fb3ca3fbc1813 Mon Sep 17 00:00:00 2001 From: PFPoitras Date: Tue, 14 Dec 2021 09:26:57 -0400 Subject: [PATCH 12/18] Make suggestions from @jackh726; run fmt --- compiler/rustc_typeck/src/check/wfcheck.rs | 6 +++--- compiler/rustc_typeck/src/check_unused.rs | 2 +- compiler/rustc_typeck/src/coherence/builtin.rs | 4 ++-- compiler/rustc_typeck/src/coherence/inherent_impls.rs | 2 +- .../src/coherence/inherent_impls_overlap.rs | 10 +++++----- compiler/rustc_typeck/src/coherence/unsafety.rs | 8 ++++---- compiler/rustc_typeck/src/collect.rs | 5 ++++- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 5c599d70d5c4..b6ffef8d1b3d 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -1450,7 +1450,7 @@ fn check_method_receiver<'fcx, 'tcx>( } } -fn e0307<'fcx, 'tcx> (fcx: &FnCtxt<'fcx, 'tcx>, span: Span, receiver_ty: Ty<'_>) { +fn e0307<'tcx>(fcx: &FnCtxt<'_, 'tcx>, span: Span, receiver_ty: Ty<'_>) { struct_span_err!( fcx.tcx.sess.diagnostic(), span, @@ -1696,8 +1696,8 @@ pub struct CheckTypeWellFormedVisitor<'tcx> { tcx: TyCtxt<'tcx>, } -impl CheckTypeWellFormedVisitor<'_> { - pub fn new(tcx: TyCtxt<'_>) -> CheckTypeWellFormedVisitor<'_> { +impl<'tcx> CheckTypeWellFormedVisitor<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>) -> CheckTypeWellFormedVisitor<'tcx> { CheckTypeWellFormedVisitor { tcx } } } diff --git a/compiler/rustc_typeck/src/check_unused.rs b/compiler/rustc_typeck/src/check_unused.rs index f63561f0582a..f45cd3ed6894 100644 --- a/compiler/rustc_typeck/src/check_unused.rs +++ b/compiler/rustc_typeck/src/check_unused.rs @@ -21,7 +21,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) { unused_crates_lint(tcx); } -impl <'v, 'tcx> ItemLikeVisitor<'v> for CheckVisitor<'tcx> { +impl<'tcx> ItemLikeVisitor<'_> for CheckVisitor<'tcx> { fn visit_item(&mut self, item: &hir::Item<'_>) { if item.vis.node.is_pub() || item.span.is_dummy() { return; diff --git a/compiler/rustc_typeck/src/coherence/builtin.rs b/compiler/rustc_typeck/src/coherence/builtin.rs index 5b277589a3ad..d5494c5a6854 100644 --- a/compiler/rustc_typeck/src/coherence/builtin.rs +++ b/compiler/rustc_typeck/src/coherence/builtin.rs @@ -108,7 +108,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) { } } -fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'_>, impl_did: LocalDefId) { +fn visit_implementation_of_coerce_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) { debug!("visit_implementation_of_coerce_unsized: impl_did={:?}", impl_did); // Just compute this for the side-effects, in particular reporting @@ -118,7 +118,7 @@ fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'_>, impl_did: LocalDefId) tcx.at(span).coerce_unsized_info(impl_did); } -fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDefId) { +fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, 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_typeck/src/coherence/inherent_impls.rs b/compiler/rustc_typeck/src/coherence/inherent_impls.rs index 0c38dc5b4bde..f4e5cce0129c 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls.rs @@ -38,7 +38,7 @@ struct InherentCollect<'tcx> { impls_map: CrateInherentImpls, } -impl<'v, 'tcx> ItemLikeVisitor<'v> for InherentCollect<'tcx> { +impl<'tcx> ItemLikeVisitor<'_> for InherentCollect<'tcx> { fn visit_item(&mut self, item: &hir::Item<'_>) { let (ty, assoc_items) = match item.kind { hir::ItemKind::Impl(hir::Impl { of_trait: None, ref self_ty, items, .. }) => { diff --git a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs index 18892db4b3ae..59f211bd2c36 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs @@ -115,8 +115,8 @@ impl<'tcx> InherentOverlapChecker<'tcx> { } } -impl<'v, 'tcx> ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> { - fn visit_item(&mut self, item: &'v hir::Item<'v>) { +impl<'tcx> ItemLikeVisitor<'_> for InherentOverlapChecker<'tcx> { + fn visit_item(&mut self, item: &hir::Item<'_>) { match item.kind { hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) @@ -300,9 +300,9 @@ impl<'v, 'tcx> ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> { } } - fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem<'v>) {} + fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem<'_>) {} - fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'v>) {} + fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'_>) {} - fn visit_foreign_item(&mut self, _foreign_item: &hir::ForeignItem<'v>) {} + fn visit_foreign_item(&mut self, _foreign_item: &hir::ForeignItem<'_>) {} } diff --git a/compiler/rustc_typeck/src/coherence/unsafety.rs b/compiler/rustc_typeck/src/coherence/unsafety.rs index 5a0a84a4aa61..f7aabf2406f3 100644 --- a/compiler/rustc_typeck/src/coherence/unsafety.rs +++ b/compiler/rustc_typeck/src/coherence/unsafety.rs @@ -17,9 +17,9 @@ struct UnsafetyChecker<'tcx> { } impl<'tcx> UnsafetyChecker<'tcx> { - fn check_unsafety_coherence<'v>( + fn check_unsafety_coherence( &mut self, - item: &'v hir::Item<'v>, + item: &hir::Item<'_>, impl_generics: Option<&hir::Generics<'_>>, unsafety: hir::Unsafety, polarity: hir::ImplPolarity, @@ -83,8 +83,8 @@ impl<'tcx> UnsafetyChecker<'tcx> { } } -impl<'v, 'tcx> ItemLikeVisitor<'v> for UnsafetyChecker<'tcx> { - fn visit_item(&mut self, item: &'v hir::Item<'v>) { +impl<'tcx> ItemLikeVisitor<'_> for UnsafetyChecker<'tcx> { + fn visit_item(&mut self, item: &hir::Item<'_>) { if let hir::ItemKind::Impl(ref impl_) = item.kind { self.check_unsafety_coherence( item, diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 8057dc2effa7..b96a5b158a26 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -223,7 +223,10 @@ crate fn placeholder_type_error<'tcx>( err.emit(); } -fn reject_placeholder_type_signatures_in_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) { +fn reject_placeholder_type_signatures_in_item<'tcx>( + tcx: TyCtxt<'tcx>, + item: &'tcx hir::Item<'tcx>, +) { let (generics, suggest) = match &item.kind { hir::ItemKind::Union(_, generics) | hir::ItemKind::Enum(_, generics) From f0c0732a36f798876b855df909b98f100e541a16 Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Tue, 14 Dec 2021 10:35:31 -0500 Subject: [PATCH 13/18] Add another regression test for unnormalized fn args with Self --- ...implied-bounds-unnorm-associated-type-3.rs | 25 +++++++++++++++++++ ...ied-bounds-unnorm-associated-type-3.stderr | 12 +++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs create mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-3.stderr diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs new file mode 100644 index 000000000000..dc25ac086137 --- /dev/null +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs @@ -0,0 +1,25 @@ +// check-fail +// See issue #91899. If we treat unnormalized args as WF, `Self` can also be a +// source of unsoundness. + +pub trait Yokeable<'a>: 'static { + type Output: 'a; +} + +impl<'a, T: 'static + ?Sized> Yokeable<'a> for &'static T { + type Output = &'a T; +} + +pub trait ZeroCopyFrom: for<'a> Yokeable<'a> { + /// Clone the cart `C` into a [`Yokeable`] struct, which may retain references into `C`. + fn zero_copy_from<'b>(cart: &'b C) -> >::Output; +} + +impl ZeroCopyFrom<[T]> for &'static [T] { + fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] { + //~^ the parameter + cart + } +} + +fn main() {} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.stderr new file mode 100644 index 000000000000..26eecf6a21d3 --- /dev/null +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.stderr @@ -0,0 +1,12 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/implied-bounds-unnorm-associated-type-3.rs:19:5 + | +LL | fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + = note: ...so that the type `[T]` will meet its required lifetime bounds + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. From a957cefda63c76c7a91a705f683be45c684d4303 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Tue, 14 Dec 2021 15:23:34 +0100 Subject: [PATCH 14/18] Fix a bunch of typos --- library/alloc/tests/boxed.rs | 2 +- library/alloc/tests/str.rs | 2 +- library/core/src/alloc/layout.rs | 4 ++-- library/core/src/cell.rs | 6 +++--- library/core/src/iter/adapters/zip.rs | 2 +- library/core/src/iter/range.rs | 4 ++-- library/core/src/num/dec2flt/number.rs | 2 +- library/core/src/num/fmt.rs | 2 +- library/core/src/slice/iter.rs | 2 +- library/core/src/slice/rotate.rs | 6 +++--- library/core/src/str/iter.rs | 18 +++++++++--------- library/core/tests/array.rs | 2 +- library/panic_unwind/src/emcc.rs | 2 +- library/std/src/fs/tests.rs | 2 +- library/std/src/io/mod.rs | 4 ++-- library/std/src/io/stdio.rs | 2 +- library/std/src/net/ip/tests.rs | 2 +- library/std/src/panicking.rs | 6 +++--- library/std/src/sys/itron/thread.rs | 4 ++-- library/std/src/sys/unix/kernel_copy.rs | 2 +- .../src/sys/unix/process/process_fuchsia.rs | 2 +- library/std/src/sys/unix/weak.rs | 2 +- library/std/src/sys/wasm/alloc.rs | 8 ++++---- library/std/src/sys/wasm/atomics/mutex.rs | 6 +++--- library/std/src/sys/windows/stdio.rs | 2 +- library/std/src/sys/windows/thread_parker.rs | 2 +- .../src/sys_common/thread_parker/generic.rs | 6 +++--- library/std/src/thread/local.rs | 4 ++-- library/std/src/time.rs | 2 +- 29 files changed, 55 insertions(+), 55 deletions(-) diff --git a/library/alloc/tests/boxed.rs b/library/alloc/tests/boxed.rs index a38b5c471bf0..bfe66b2687ef 100644 --- a/library/alloc/tests/boxed.rs +++ b/library/alloc/tests/boxed.rs @@ -3,7 +3,7 @@ use std::mem::MaybeUninit; use std::ptr::NonNull; #[test] -fn unitialized_zero_size_box() { +fn uninitialized_zero_size_box() { assert_eq!( &*Box::<()>::new_uninit() as *const _, NonNull::>::dangling().as_ptr(), diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs index 1b741f174fb1..7bd0abbad019 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -162,7 +162,7 @@ fn test_join_for_different_lengths_with_long_separator() { } #[test] -fn test_join_isue_80335() { +fn test_join_issue_80335() { use core::{borrow::Borrow, cell::Cell}; struct WeirdBorrow { diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index 9df0b5c55191..ea639268652c 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -157,11 +157,11 @@ impl Layout { /// /// - If `T` is `Sized`, this function is always safe to call. /// - If the unsized tail of `T` is: - /// - a [slice], then the length of the slice tail must be an intialized + /// - a [slice], then the length of the slice tail must be an initialized /// integer, and the size of the *entire value* /// (dynamic tail length + statically sized prefix) must fit in `isize`. /// - a [trait object], then the vtable part of the pointer must point - /// to a valid vtable for the type `T` acquired by an unsizing coersion, + /// to a valid vtable for the type `T` acquired by an unsizing coercion, /// and the size of the *entire value* /// (dynamic tail length + statically sized prefix) must fit in `isize`. /// - an (unstable) [extern type], then this function is always safe to diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 06dc5ecf2ffa..bc3f7167fac3 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -898,7 +898,7 @@ impl RefCell { Ok(Ref { value: unsafe { &*self.value.get() }, borrow: b }) } None => Err(BorrowError { - // If a borrow occured, then we must already have an outstanding borrow, + // If a borrow occurred, then we must already have an outstanding borrow, // so `borrowed_at` will be `Some` #[cfg(feature = "debug_refcell")] location: self.borrowed_at.get().unwrap(), @@ -983,7 +983,7 @@ impl RefCell { Ok(RefMut { value: unsafe { &mut *self.value.get() }, borrow: b }) } None => Err(BorrowMutError { - // If a borrow occured, then we must already have an outstanding borrow, + // If a borrow occurred, then we must already have an outstanding borrow, // so `borrowed_at` will be `Some` #[cfg(feature = "debug_refcell")] location: self.borrowed_at.get().unwrap(), @@ -1104,7 +1104,7 @@ impl RefCell { Ok(unsafe { &*self.value.get() }) } else { Err(BorrowError { - // If a borrow occured, then we must already have an outstanding borrow, + // If a borrow occurred, then we must already have an outstanding borrow, // so `borrowed_at` will be `Some` #[cfg(feature = "debug_refcell")] location: self.borrowed_at.get().unwrap(), diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index 920fa59c8ad6..b8c3cd847e45 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -517,7 +517,7 @@ impl IterMut<'a, T> { // the length, to also allows for the fast `ptr == end` check. // // See the `next_unchecked!` and `is_empty!` macros as well as the - // `post_inc_start` method for more informations. + // `post_inc_start` method for more information. unsafe { assume(!ptr.is_null()); diff --git a/library/core/src/slice/rotate.rs b/library/core/src/slice/rotate.rs index 7528927ef33b..4589c6c0f04a 100644 --- a/library/core/src/slice/rotate.rs +++ b/library/core/src/slice/rotate.rs @@ -104,7 +104,7 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) // - overflows cannot happen for `i` since the function's safety contract ask for // `mid+right-1 = x+left+right` to be valid for writing // - underflows cannot happen because `i` must be bigger or equal to `left` for - // a substraction of `left` to happen. + // a subtraction of `left` to happen. // // So `x+i` is valid for reading and writing if the caller respected the contract tmp = unsafe { x.add(i).replace(tmp) }; @@ -202,7 +202,7 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) loop { // SAFETY: // `left >= right` so `[mid-right, mid+right)` is valid for reading and writing - // Substracting `right` from `mid` each turn is counterbalanced by the addition and + // Subtracting `right` from `mid` each turn is counterbalanced by the addition and // check after it. unsafe { ptr::swap_nonoverlapping(mid.sub(right), mid, right); @@ -218,7 +218,7 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) loop { // SAFETY: `[mid-left, mid+left)` is valid for reading and writing because // `left < right` so `mid+left < mid+right`. - // Adding `left` to `mid` each turn is counterbalanced by the substraction and check + // Adding `left` to `mid` each turn is counterbalanced by the subtraction and check // after it. unsafe { ptr::swap_nonoverlapping(mid.sub(left), mid, left); diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 484104467165..de6e6d52b362 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -748,7 +748,7 @@ generate_pattern_iterators! { } impl<'a, P: Pattern<'a>> Split<'a, P> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -769,7 +769,7 @@ impl<'a, P: Pattern<'a>> Split<'a, P> { } impl<'a, P: Pattern<'a>> RSplit<'a, P> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -808,7 +808,7 @@ generate_pattern_iterators! { } impl<'a, P: Pattern<'a>> SplitTerminator<'a, P> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -829,7 +829,7 @@ impl<'a, P: Pattern<'a>> SplitTerminator<'a, P> { } impl<'a, P: Pattern<'a>> RSplitTerminator<'a, P> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -931,7 +931,7 @@ generate_pattern_iterators! { } impl<'a, P: Pattern<'a>> SplitN<'a, P> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -952,7 +952,7 @@ impl<'a, P: Pattern<'a>> SplitN<'a, P> { } impl<'a, P: Pattern<'a>> RSplitN<'a, P> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -1236,7 +1236,7 @@ impl<'a> DoubleEndedIterator for SplitWhitespace<'a> { impl FusedIterator for SplitWhitespace<'_> {} impl<'a> SplitWhitespace<'a> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -1292,7 +1292,7 @@ impl<'a> DoubleEndedIterator for SplitAsciiWhitespace<'a> { impl FusedIterator for SplitAsciiWhitespace<'_> {} impl<'a> SplitAsciiWhitespace<'a> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// @@ -1360,7 +1360,7 @@ impl<'a, P: Pattern<'a, Searcher: ReverseSearcher<'a>>> DoubleEndedIterator impl<'a, P: Pattern<'a>> FusedIterator for SplitInclusive<'a, P> {} impl<'a, P: Pattern<'a>> SplitInclusive<'a, P> { - /// Returns remainder of the splitted string + /// Returns remainder of the split string /// /// # Examples /// diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs index ceb672007966..fe4fef749904 100644 --- a/library/core/tests/array.rs +++ b/library/core/tests/array.rs @@ -259,7 +259,7 @@ fn iterator_drops() { // This test does not work on targets without panic=unwind support. // To work around this problem, test is marked is should_panic, so it will // be automagically skipped on unsuitable targets, such as -// wasm32-unknown-unkown. +// wasm32-unknown-unknown. // // It means that we use panic for indicating success. #[test] diff --git a/library/panic_unwind/src/emcc.rs b/library/panic_unwind/src/emcc.rs index e428f2fdaaa3..12f0fe9c3c3a 100644 --- a/library/panic_unwind/src/emcc.rs +++ b/library/panic_unwind/src/emcc.rs @@ -49,7 +49,7 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo { }; struct Exception { - // This is necessary because C++ code can capture our execption with + // This is necessary because C++ code can capture our exception with // std::exception_ptr and rethrow it multiple times, possibly even in // another thread. caught: AtomicBool, diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 9a8f1e44f1f1..2293fb6b5581 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1369,7 +1369,7 @@ fn symlink_hard_link() { // "hard_link" should appear as a symlink. assert!(check!(fs::symlink_metadata(tmpdir.join("hard_link"))).file_type().is_symlink()); - // We sould be able to open "file" via any of the above names. + // We should be able to open "file" via any of the above names. let _ = check!(fs::File::open(tmpdir.join("file"))); assert!(fs::File::open(tmpdir.join("file.renamed")).is_err()); let _ = check!(fs::File::open(tmpdir.join("symlink"))); diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index dd182c059b9c..ecc9e91b6bdb 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -362,7 +362,7 @@ pub(crate) fn default_read_to_end(r: &mut R, buf: &mut Vec let start_len = buf.len(); let start_cap = buf.capacity(); - let mut initialized = 0; // Extra initalized bytes from previous loop iteration + let mut initialized = 0; // Extra initialized bytes from previous loop iteration loop { if buf.len() == buf.capacity() { buf.reserve(32); // buf is full, need more space @@ -370,7 +370,7 @@ pub(crate) fn default_read_to_end(r: &mut R, buf: &mut Vec let mut read_buf = ReadBuf::uninit(buf.spare_capacity_mut()); - // SAFETY: These bytes were initalized but not filled in the previous loop + // SAFETY: These bytes were initialized but not filled in the previous loop unsafe { read_buf.assume_init(initialized); } diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 9888d3a09c48..c072f0cafe47 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -1179,7 +1179,7 @@ where }) }) == Ok(Some(())) { - // Succesfully wrote to capture buffer. + // Successfully wrote to capture buffer. return; } diff --git a/library/std/src/net/ip/tests.rs b/library/std/src/net/ip/tests.rs index 17581f330266..632d4683b415 100644 --- a/library/std/src/net/ip/tests.rs +++ b/library/std/src/net/ip/tests.rs @@ -749,7 +749,7 @@ fn ipv4_from_constructors() { } #[test] -fn ipv6_from_contructors() { +fn ipv6_from_constructors() { assert_eq!(Ipv6Addr::LOCALHOST, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)); assert!(Ipv6Addr::LOCALHOST.is_loopback()); assert_eq!(Ipv6Addr::UNSPECIFIED, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)); diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 6fc6b8daec0a..87854fe4f297 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -365,7 +365,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // The call to `intrinsics::r#try` is made safe by: // - `do_call`, the first argument, can be called with the initial `data_ptr`. // - `do_catch`, the second argument, can be called with the `data_ptr` as well. - // See their safety preconditions for more informations + // See their safety preconditions for more information unsafe { return if intrinsics::r#try(do_call::, data_ptr, do_catch::) == 0 { Ok(ManuallyDrop::into_inner(data.r)) @@ -398,7 +398,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // expects normal function pointers. #[inline] fn do_call R, R>(data: *mut u8) { - // SAFETY: this is the responsibilty of the caller, see above. + // SAFETY: this is the responsibility of the caller, see above. unsafe { let data = data as *mut Data; let data = &mut (*data); @@ -420,7 +420,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // expects normal function pointers. #[inline] fn do_catch R, R>(data: *mut u8, payload: *mut u8) { - // SAFETY: this is the responsibilty of the caller, see above. + // SAFETY: this is the responsibility of the caller, see above. // // When `__rustc_panic_cleaner` is correctly implemented we can rely // on `obj` being the correct thing to pass to `data.p` (after wrapping diff --git a/library/std/src/sys/itron/thread.rs b/library/std/src/sys/itron/thread.rs index bb9fa54d02ea..ebcc9ab26e08 100644 --- a/library/std/src/sys/itron/thread.rs +++ b/library/std/src/sys/itron/thread.rs @@ -126,7 +126,7 @@ impl Thread { // In this case, `inner`'s ownership has been moved to us, // And we are responsible for dropping it. The acquire // ordering is not necessary because the parent thread made - // no memory acccess needing synchronization since the call + // no memory access needing synchronization since the call // to `acre_tsk`. // Safety: See above. let _ = unsafe { Box::from_raw(inner as *const _ as *mut ThreadInner) }; @@ -264,7 +264,7 @@ impl Drop for Thread { // one will ever join it. // The ownership of `self.inner` is moved to the child thread. // However, the release ordering is not necessary because we - // made no memory acccess needing synchronization since the call + // made no memory access needing synchronization since the call // to `acre_tsk`. } LIFECYCLE_FINISHED => { diff --git a/library/std/src/sys/unix/kernel_copy.rs b/library/std/src/sys/unix/kernel_copy.rs index 241cf89d3145..e85e4c5d618c 100644 --- a/library/std/src/sys/unix/kernel_copy.rs +++ b/library/std/src/sys/unix/kernel_copy.rs @@ -104,7 +104,7 @@ impl FdMeta { fn potential_sendfile_source(&self) -> bool { match self { - // procfs erronously shows 0 length on non-empty readable files. + // procfs erroneously shows 0 length on non-empty readable files. // and if a file is truly empty then a `read` syscall will determine that and skip the write syscall // thus there would be benefit from attempting sendfile FdMeta::Metadata(meta) diff --git a/library/std/src/sys/unix/process/process_fuchsia.rs b/library/std/src/sys/unix/process/process_fuchsia.rs index 507abb27871b..ce77c210a622 100644 --- a/library/std/src/sys/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/unix/process/process_fuchsia.rs @@ -284,7 +284,7 @@ impl ExitStatus { // // The other view would be to say that the caller on Fuchsia ought to know that `into_raw` // will give a raw Fuchsia status (whatever that is - I don't know, personally). That is - // not possible here becaause we must return a c_int because that's what Unix (including + // not possible here because we must return a c_int because that's what Unix (including // SuS and POSIX) say a wait status is, but Fuchsia apparently uses a u64, so it won't // necessarily fit. // diff --git a/library/std/src/sys/unix/weak.rs b/library/std/src/sys/unix/weak.rs index 32072affe8af..55719b87c7e0 100644 --- a/library/std/src/sys/unix/weak.rs +++ b/library/std/src/sys/unix/weak.rs @@ -124,7 +124,7 @@ impl DlsymWeak { } } - // Cold because it should only happen during first-time initalization. + // Cold because it should only happen during first-time initialization. #[cold] unsafe fn initialize(&self) -> Option { assert_eq!(mem::size_of::(), mem::size_of::()); diff --git a/library/std/src/sys/wasm/alloc.rs b/library/std/src/sys/wasm/alloc.rs index 3223e8941024..6dceb1689a8b 100644 --- a/library/std/src/sys/wasm/alloc.rs +++ b/library/std/src/sys/wasm/alloc.rs @@ -24,7 +24,7 @@ static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new(); unsafe impl GlobalAlloc for System { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. + // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. // Calling malloc() is safe because preconditions on this function match the trait method preconditions. let _lock = lock::lock(); unsafe { DLMALLOC.malloc(layout.size(), layout.align()) } @@ -32,7 +32,7 @@ unsafe impl GlobalAlloc for System { #[inline] unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { - // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. + // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. // Calling calloc() is safe because preconditions on this function match the trait method preconditions. let _lock = lock::lock(); unsafe { DLMALLOC.calloc(layout.size(), layout.align()) } @@ -40,7 +40,7 @@ unsafe impl GlobalAlloc for System { #[inline] unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. + // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. // Calling free() is safe because preconditions on this function match the trait method preconditions. let _lock = lock::lock(); unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) } @@ -48,7 +48,7 @@ unsafe impl GlobalAlloc for System { #[inline] unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { - // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access. + // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. // Calling realloc() is safe because preconditions on this function match the trait method preconditions. let _lock = lock::lock(); unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) } diff --git a/library/std/src/sys/wasm/atomics/mutex.rs b/library/std/src/sys/wasm/atomics/mutex.rs index 5ff0ec052b6f..3a09f0bf9bb4 100644 --- a/library/std/src/sys/wasm/atomics/mutex.rs +++ b/library/std/src/sys/wasm/atomics/mutex.rs @@ -73,7 +73,7 @@ pub struct ReentrantMutex { unsafe impl Send for ReentrantMutex {} unsafe impl Sync for ReentrantMutex {} -// Reentrant mutexes are similarly implemented to mutexs above except that +// Reentrant mutexes are similarly implemented to mutexes above except that // instead of "1" meaning unlocked we use the id of a thread to represent // whether it has locked a mutex. That way we have an atomic counter which // always holds the id of the thread that currently holds the lock (or 0 if the @@ -96,7 +96,7 @@ impl ReentrantMutex { pub unsafe fn lock(&self) { let me = thread::my_id(); while let Err(owner) = self._try_lock(me) { - // SAFETY: the caller must gurantee that `self.ptr()` and `owner` are valid i32. + // SAFETY: the caller must guarantee that `self.ptr()` and `owner` are valid i32. let val = unsafe { wasm32::memory_atomic_wait32(self.ptr(), owner as i32, -1) }; debug_assert!(val == 0 || val == 1); } @@ -136,7 +136,7 @@ impl ReentrantMutex { match *self.recursions.get() { 0 => { self.owner.swap(0, SeqCst); - // SAFETY: the caller must gurantee that `self.ptr()` is valid i32. + // SAFETY: the caller must guarantee that `self.ptr()` is valid i32. unsafe { wasm32::memory_atomic_notify(self.ptr() as *mut i32, 1); } // wake up one waiter, if any diff --git a/library/std/src/sys/windows/stdio.rs b/library/std/src/sys/windows/stdio.rs index a4fe5f67f699..eb0925b3fda7 100644 --- a/library/std/src/sys/windows/stdio.rs +++ b/library/std/src/sys/windows/stdio.rs @@ -124,7 +124,7 @@ fn write( // // If the data is not valid UTF-8 we write out as many bytes as are valid. // If the first byte is invalid it is either first byte of a multi-byte sequence but the - // provided byte slice is too short or it is the first byte of an invalide multi-byte sequence. + // provided byte slice is too short or it is the first byte of an invalid multi-byte sequence. let len = cmp::min(data.len(), MAX_BUFFER_SIZE / 2); let utf8 = match str::from_utf8(&data[..len]) { Ok(s) => s, diff --git a/library/std/src/sys/windows/thread_parker.rs b/library/std/src/sys/windows/thread_parker.rs index 4f59d4dd452b..5a8011a95880 100644 --- a/library/std/src/sys/windows/thread_parker.rs +++ b/library/std/src/sys/windows/thread_parker.rs @@ -22,7 +22,7 @@ // // Unlike WaitOnAddress, NtWaitForKeyedEvent/NtReleaseKeyedEvent operate on a // HANDLE (created with NtCreateKeyedEvent). This means that we can be sure -// a succesfully awoken park() was awoken by unpark() and not a +// a successfully awoken park() was awoken by unpark() and not a // NtReleaseKeyedEvent call from some other code, as these events are not only // matched by the key (address of the parker (state)), but also by this HANDLE. // We lazily allocate this handle the first time it is needed. diff --git a/library/std/src/sys_common/thread_parker/generic.rs b/library/std/src/sys_common/thread_parker/generic.rs index 14cfa958e5e5..d99e901bb5f8 100644 --- a/library/std/src/sys_common/thread_parker/generic.rs +++ b/library/std/src/sys_common/thread_parker/generic.rs @@ -1,4 +1,4 @@ -//! Parker implementaiton based on a Mutex and Condvar. +//! Parker implementation based on a Mutex and Condvar. use crate::sync::atomic::AtomicUsize; use crate::sync::atomic::Ordering::SeqCst; @@ -20,7 +20,7 @@ impl Parker { Parker { state: AtomicUsize::new(EMPTY), lock: Mutex::new(()), cvar: Condvar::new() } } - // This implementaiton doesn't require `unsafe`, but other implementations + // This implementation doesn't require `unsafe`, but other implementations // may assume this is only called by the thread that owns the Parker. pub unsafe fn park(&self) { // If we were previously notified then we consume this notification and @@ -55,7 +55,7 @@ impl Parker { } } - // This implementaiton doesn't require `unsafe`, but other implementations + // This implementation doesn't require `unsafe`, but other implementations // may assume this is only called by the thread that owns the Parker. pub unsafe fn park_timeout(&self, dur: Duration) { // Like `park` above we have a fast path for an already-notified thread, and diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index c03fe116320a..1d2f6e976800 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -582,7 +582,7 @@ pub mod fast { Key { inner: LazyKeyInner::new(), dtor_state: Cell::new(DtorState::Unregistered) } } - // note that this is just a publically-callable function only for the + // note that this is just a publicly-callable function only for the // const-initialized form of thread locals, basically a way to call the // free `register_dtor` function defined elsewhere in libstd. pub unsafe fn register_dtor(a: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { @@ -593,7 +593,7 @@ pub mod fast { pub unsafe fn get T>(&self, init: F) -> Option<&'static T> { // SAFETY: See the definitions of `LazyKeyInner::get` and - // `try_initialize` for more informations. + // `try_initialize` for more information. // // The caller must ensure no mutable references are ever active to // the inner cell or the inner T when this is called. diff --git a/library/std/src/time.rs b/library/std/src/time.rs index a5e3bd0c2903..86cc93c44537 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -273,7 +273,7 @@ impl Instant { // While issues have been seen on arm64 platforms the Arm architecture // requires that the counter monotonically increases and that it must // provide a uniform view of system time (e.g. it must not be possible - // for a core to recieve a message from another core with a time stamp + // for a core to receive a message from another core with a time stamp // and observe time going backwards (ARM DDI 0487G.b D11.1.2). While // there have been a few 64bit SoCs that have bugs which cause time to // not monoticially increase, these have been fixed in the Linux kernel From 4f4b2c7271d3090b6b63bf1ce8373a47b5b30d86 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 15 Dec 2021 00:11:23 +0800 Subject: [PATCH 15/18] Constify `bool::then{,_some}` --- library/core/src/bool.rs | 13 +++++++++++-- library/core/tests/bool.rs | 14 ++++++++++++++ library/core/tests/lib.rs | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/library/core/src/bool.rs b/library/core/src/bool.rs index f14c2a464162..d5119d0b7c32 100644 --- a/library/core/src/bool.rs +++ b/library/core/src/bool.rs @@ -14,8 +14,12 @@ impl bool { /// assert_eq!(true.then_some(0), Some(0)); /// ``` #[unstable(feature = "bool_to_option", issue = "80967")] + #[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")] #[inline] - pub fn then_some(self, t: T) -> Option { + pub const fn then_some(self, t: T) -> Option + where + T: ~const Drop, + { if self { Some(t) } else { None } } @@ -29,8 +33,13 @@ impl bool { /// assert_eq!(true.then(|| 0), Some(0)); /// ``` #[stable(feature = "lazy_bool_to_option", since = "1.50.0")] + #[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")] #[inline] - pub fn then T>(self, f: F) -> Option { + pub const fn then(self, f: F) -> Option + where + F: ~const FnOnce() -> T, + F: ~const Drop, + { if self { Some(f()) } else { None } } } diff --git a/library/core/tests/bool.rs b/library/core/tests/bool.rs index e40f0482aee3..4819ce911d61 100644 --- a/library/core/tests/bool.rs +++ b/library/core/tests/bool.rs @@ -88,4 +88,18 @@ fn test_bool_to_option() { assert_eq!(true.then_some(0), Some(0)); assert_eq!(false.then(|| 0), None); assert_eq!(true.then(|| 0), Some(0)); + + const fn zero() -> i32 { + 0 + } + + const A: Option = false.then_some(0); + const B: Option = true.then_some(0); + const C: Option = false.then(zero); + const D: Option = true.then(zero); + + assert_eq!(A, None); + assert_eq!(B, Some(0)); + assert_eq!(C, None); + assert_eq!(D, Some(0)); } diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index b41d3e09df87..dacb33619f8c 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -8,6 +8,7 @@ #![feature(cfg_panic)] #![feature(cfg_target_has_atomic)] #![feature(const_assume)] +#![feature(const_bool_to_option)] #![feature(const_cell_into_inner)] #![feature(const_convert)] #![feature(const_maybe_uninit_as_mut_ptr)] From 4d1d66b812efe27cc460921fcc6b24622444800d Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 14 Dec 2021 11:27:41 -0500 Subject: [PATCH 16/18] Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp` This avoids a needless query invocation --- compiler/rustc_middle/src/ty/sty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index a80fe6a3362b..1c525fb55e1b 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -787,7 +787,7 @@ impl<'tcx> ExistentialPredicate<'tcx> { tcx.def_path_hash(a.item_def_id).cmp(&tcx.def_path_hash(b.item_def_id)) } (AutoTrait(ref a), AutoTrait(ref b)) => { - tcx.trait_def(*a).def_path_hash.cmp(&tcx.trait_def(*b).def_path_hash) + tcx.def_path_hash(*a).cmp(&tcx.def_path_hash(*b)) } (Trait(_), _) => Ordering::Less, (Projection(_), Trait(_)) => Ordering::Greater, From f194c9b26af5d280ab2d0e01fd85e23b3c303771 Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Mon, 6 Dec 2021 18:55:58 +0100 Subject: [PATCH 17/18] Recover on invalid operators <> and <=> --- compiler/rustc_parse/src/parser/expr.rs | 34 ++++++++++++++++++- .../less-than-greater-than.rs | 4 +++ .../less-than-greater-than.stderr | 8 +++++ src/test/ui/operator-recovery/spaceship.rs | 4 +++ .../ui/operator-recovery/spaceship.stderr | 8 +++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/operator-recovery/less-than-greater-than.rs create mode 100644 src/test/ui/operator-recovery/less-than-greater-than.stderr create mode 100644 src/test/ui/operator-recovery/spaceship.rs create mode 100644 src/test/ui/operator-recovery/spaceship.stderr diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 1dbd7bad0f02..1c31c84b8bfe 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -213,11 +213,11 @@ impl<'a> Parser<'a> { } } + // Look for JS' `===` and `!==` and recover if (op.node == AssocOp::Equal || op.node == AssocOp::NotEqual) && self.token.kind == token::Eq && self.prev_token.span.hi() == self.token.span.lo() { - // Look for JS' `===` and `!==` and recover 😇 let sp = op.span.to(self.token.span); let sugg = match op.node { AssocOp::Equal => "==", @@ -235,6 +235,38 @@ impl<'a> Parser<'a> { self.bump(); } + // Look for PHP's `<>` and recover + if op.node == AssocOp::Less + && self.token.kind == token::Gt + && self.prev_token.span.hi() == self.token.span.lo() + { + let sp = op.span.to(self.token.span); + self.struct_span_err(sp, "invalid comparison operator `<>`") + .span_suggestion_short( + sp, + "`<>` is not a valid comparison operator, use `!=`", + "!=".to_string(), + Applicability::MachineApplicable, + ) + .emit(); + self.bump(); + } + + // Look for C++'s `<=>` and recover + if op.node == AssocOp::LessEqual + && self.token.kind == token::Gt + && self.prev_token.span.hi() == self.token.span.lo() + { + let sp = op.span.to(self.token.span); + self.struct_span_err(sp, "invalid comparison operator `<=>`") + .span_label( + sp, + "`<=>` is not a valid comparison operator, use `std::cmp::Ordering`", + ) + .emit(); + self.bump(); + } + let op = op.node; // Special cases: if op == AssocOp::As { diff --git a/src/test/ui/operator-recovery/less-than-greater-than.rs b/src/test/ui/operator-recovery/less-than-greater-than.rs new file mode 100644 index 000000000000..2beed528ff1c --- /dev/null +++ b/src/test/ui/operator-recovery/less-than-greater-than.rs @@ -0,0 +1,4 @@ +fn main() { + println!("{}", 1 <> 2); + //~^ERROR invalid comparison operator `<>` +} diff --git a/src/test/ui/operator-recovery/less-than-greater-than.stderr b/src/test/ui/operator-recovery/less-than-greater-than.stderr new file mode 100644 index 000000000000..80c921535bd0 --- /dev/null +++ b/src/test/ui/operator-recovery/less-than-greater-than.stderr @@ -0,0 +1,8 @@ +error: invalid comparison operator `<>` + --> $DIR/less-than-greater-than.rs:2:22 + | +LL | println!("{}", 1 <> 2); + | ^^ help: `<>` is not a valid comparison operator, use `!=` + +error: aborting due to previous error + diff --git a/src/test/ui/operator-recovery/spaceship.rs b/src/test/ui/operator-recovery/spaceship.rs new file mode 100644 index 000000000000..a65f9389625f --- /dev/null +++ b/src/test/ui/operator-recovery/spaceship.rs @@ -0,0 +1,4 @@ +fn main() { + println!("{}", 1 <=> 2); + //~^ERROR invalid comparison operator `<=>` +} diff --git a/src/test/ui/operator-recovery/spaceship.stderr b/src/test/ui/operator-recovery/spaceship.stderr new file mode 100644 index 000000000000..ed6bd74c9b92 --- /dev/null +++ b/src/test/ui/operator-recovery/spaceship.stderr @@ -0,0 +1,8 @@ +error: invalid comparison operator `<=>` + --> $DIR/spaceship.rs:2:22 + | +LL | println!("{}", 1 <=> 2); + | ^^^ `<=>` is not a valid comparison operator, use `std::cmp::Ordering` + +error: aborting due to previous error + From 462bb57e8092a895941a4f7cb2e4ee8fd0f1f6aa Mon Sep 17 00:00:00 2001 From: LegionMammal978 Date: Tue, 14 Dec 2021 13:49:49 -0500 Subject: [PATCH 18/18] Remove `in_band_lifetimes` from `rustc_codegen_llvm` See #91867 for more information. --- compiler/rustc_codegen_llvm/src/abi.rs | 22 +- compiler/rustc_codegen_llvm/src/asm.rs | 24 +- compiler/rustc_codegen_llvm/src/attributes.rs | 30 +- compiler/rustc_codegen_llvm/src/back/lto.rs | 4 +- compiler/rustc_codegen_llvm/src/back/write.rs | 2 +- compiler/rustc_codegen_llvm/src/base.rs | 9 +- compiler/rustc_codegen_llvm/src/builder.rs | 24 +- compiler/rustc_codegen_llvm/src/callee.rs | 2 +- compiler/rustc_codegen_llvm/src/common.rs | 16 +- compiler/rustc_codegen_llvm/src/consts.rs | 14 +- compiler/rustc_codegen_llvm/src/context.rs | 32 +- .../src/coverageinfo/mapgen.rs | 8 +- .../src/coverageinfo/mod.rs | 14 +- .../src/debuginfo/create_scope_map.rs | 4 +- .../rustc_codegen_llvm/src/debuginfo/gdb.rs | 2 +- .../src/debuginfo/metadata.rs | 104 +++-- .../rustc_codegen_llvm/src/debuginfo/mod.rs | 8 +- .../src/debuginfo/namespace.rs | 2 +- .../rustc_codegen_llvm/src/debuginfo/utils.rs | 13 +- compiler/rustc_codegen_llvm/src/declare.rs | 4 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 35 +- compiler/rustc_codegen_llvm/src/lib.rs | 1 - .../rustc_codegen_llvm/src/llvm/diagnostic.rs | 8 +- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 389 +++++++++--------- compiler/rustc_codegen_llvm/src/llvm/mod.rs | 20 +- compiler/rustc_codegen_llvm/src/mono_item.rs | 4 +- compiler/rustc_codegen_llvm/src/type_.rs | 6 +- compiler/rustc_codegen_llvm/src/va_arg.rs | 20 +- 28 files changed, 429 insertions(+), 392 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index d38ff588317a..e9b66b54c58b 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -136,11 +136,11 @@ impl ArgAttributesExt for ArgAttributes { } pub trait LlvmType { - fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type; + fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type; } impl LlvmType for Reg { - fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type { + fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type { match self.kind { RegKind::Integer => cx.type_ix(self.size.bits()), RegKind::Float => match self.size.bits() { @@ -154,7 +154,7 @@ impl LlvmType for Reg { } impl LlvmType for CastTarget { - fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type { + fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type { let rest_ll_unit = self.rest.unit.llvm_type(cx); let (rest_count, rem_bytes) = if self.rest.unit.size.bytes() == 0 { (0, 0) @@ -212,7 +212,7 @@ pub trait ArgAbiExt<'ll, 'tcx> { ); } -impl ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { +impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { /// Gets the LLVM type for a place of the original Rust type of /// this argument/return, i.e., the result of `type_of::type_of`. fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type { @@ -287,7 +287,7 @@ impl ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { fn store_fn_arg( &self, - bx: &mut Builder<'a, 'll, 'tcx>, + bx: &mut Builder<'_, 'll, 'tcx>, idx: &mut usize, dst: PlaceRef<'tcx, &'ll Value>, ) { @@ -314,7 +314,7 @@ impl ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { } } -impl ArgAbiMethods<'tcx> for Builder<'a, 'll, 'tcx> { +impl<'ll, 'tcx> ArgAbiMethods<'tcx> for Builder<'_, 'll, 'tcx> { fn store_fn_arg( &mut self, arg_abi: &ArgAbi<'tcx, Ty<'tcx>>, @@ -336,15 +336,15 @@ impl ArgAbiMethods<'tcx> for Builder<'a, 'll, 'tcx> { } } -pub trait FnAbiLlvmExt<'tcx> { +pub trait FnAbiLlvmExt<'ll, 'tcx> { fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type; fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type; fn llvm_cconv(&self) -> llvm::CallConv; fn apply_attrs_llfn(&self, cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value); - fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value); + fn apply_attrs_callsite(&self, bx: &mut Builder<'_, 'll, 'tcx>, callsite: &'ll Value); } -impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> { +impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type { // Ignore "extra" args from the call site for C variadic functions. // Only the "fixed" args are part of the LLVM function signature. @@ -505,7 +505,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> { } } - fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value) { + fn apply_attrs_callsite(&self, bx: &mut Builder<'_, 'll, 'tcx>, callsite: &'ll Value) { if self.ret.layout.abi.is_uninhabited() { llvm::Attribute::NoReturn.apply_callsite(llvm::AttributePlace::Function, callsite); } @@ -610,7 +610,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> { } } -impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { +impl<'tcx> AbiBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> { fn apply_attrs_callsite(&mut self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, callsite: Self::Value) { fn_abi.apply_attrs_callsite(self, callsite) } diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index ee31f2e60a97..caf16c1939df 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -23,7 +23,7 @@ use rustc_target::asm::*; use libc::{c_char, c_uint}; use tracing::debug; -impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { +impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { fn codegen_llvm_inline_asm( &mut self, ia: &hir::LlvmInlineAsmInner, @@ -399,7 +399,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { } } -impl AsmMethods for CodegenCx<'ll, 'tcx> { +impl AsmMethods for CodegenCx<'_, '_> { fn codegen_global_asm( &self, template: &[InlineAsmTemplatePiece], @@ -447,8 +447,8 @@ impl AsmMethods for CodegenCx<'ll, 'tcx> { } } -pub(crate) fn inline_asm_call( - bx: &mut Builder<'a, 'll, 'tcx>, +pub(crate) fn inline_asm_call<'ll>( + bx: &mut Builder<'_, 'll, '_>, asm: &str, cons: &str, inputs: &[&'ll Value], @@ -583,7 +583,7 @@ fn a64_vreg_index(reg: InlineAsmReg) -> Option { } /// Converts a register class to an LLVM constraint code. -fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>) -> String { +fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) -> String { match reg { // For vector registers LLVM wants the register name to match the type size. InlineAsmRegOrRegClass::Reg(reg) => { @@ -773,7 +773,7 @@ fn modifier_to_llvm( /// Type to use for outputs that are discarded. It doesn't really matter what /// the type is, as long as it is valid for the constraint code. -fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll Type { +fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'ll Type { match reg { InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => cx.type_i32(), InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg) @@ -841,7 +841,7 @@ fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll /// Helper function to get the LLVM type for a Scalar. Pointers are returned as /// the equivalent integer type. -fn llvm_asm_scalar_type(cx: &CodegenCx<'ll, 'tcx>, scalar: Scalar) -> &'ll Type { +fn llvm_asm_scalar_type<'ll>(cx: &CodegenCx<'ll, '_>, scalar: Scalar) -> &'ll Type { match scalar.value { Primitive::Int(Integer::I8, _) => cx.type_i8(), Primitive::Int(Integer::I16, _) => cx.type_i16(), @@ -855,8 +855,8 @@ fn llvm_asm_scalar_type(cx: &CodegenCx<'ll, 'tcx>, scalar: Scalar) -> &'ll Type } /// Fix up an input value to work around LLVM bugs. -fn llvm_fixup_input( - bx: &mut Builder<'a, 'll, 'tcx>, +fn llvm_fixup_input<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, mut value: &'ll Value, reg: InlineAsmRegClass, layout: &TyAndLayout<'tcx>, @@ -933,8 +933,8 @@ fn llvm_fixup_input( } /// Fix up an output value to work around LLVM bugs. -fn llvm_fixup_output( - bx: &mut Builder<'a, 'll, 'tcx>, +fn llvm_fixup_output<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, mut value: &'ll Value, reg: InlineAsmRegClass, layout: &TyAndLayout<'tcx>, @@ -1009,7 +1009,7 @@ fn llvm_fixup_output( } /// Output type to use for llvm_fixup_output. -fn llvm_fixup_output_type( +fn llvm_fixup_output_type<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass, layout: &TyAndLayout<'tcx>, diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 8e6329a997f1..bd25087c08e8 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -25,7 +25,7 @@ use crate::value::Value; /// Mark LLVM function to use provided inline heuristic. #[inline] -fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) { +fn inline<'ll>(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) { use self::InlineAttr::*; match inline { Hint => Attribute::InlineHint.apply_llfn(Function, val), @@ -41,7 +41,7 @@ fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) { /// Apply LLVM sanitize attributes. #[inline] -pub fn sanitize(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &'ll Value) { +pub fn sanitize<'ll>(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &'ll Value) { let enabled = cx.tcx.sess.opts.debugging_opts.sanitizer - no_sanitize; if enabled.contains(SanitizerSet::ADDRESS) { llvm::Attribute::SanitizeAddress.apply_llfn(Function, llfn); @@ -59,17 +59,17 @@ pub fn sanitize(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &'ll V /// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function. #[inline] -pub fn emit_uwtable(val: &'ll Value, emit: bool) { +pub fn emit_uwtable(val: &Value, emit: bool) { Attribute::UWTable.toggle_llfn(Function, val, emit); } /// Tell LLVM if this function should be 'naked', i.e., skip the epilogue and prologue. #[inline] -fn naked(val: &'ll Value, is_naked: bool) { +fn naked(val: &Value, is_naked: bool) { Attribute::Naked.toggle_llfn(Function, val, is_naked); } -pub fn set_frame_pointer_type(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { +pub fn set_frame_pointer_type<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { let mut fp = cx.sess().target.frame_pointer; // "mcount" function relies on stack pointer. // See . @@ -92,7 +92,7 @@ pub fn set_frame_pointer_type(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { /// Tell LLVM what instrument function to insert. #[inline] -fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { +fn set_instrument_function<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { if cx.sess().instrument_mcount() { // Similar to `clang -pg` behavior. Handled by the // `post-inline-ee-instrument` LLVM pass. @@ -110,7 +110,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { } } -fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { +fn set_probestack<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { // Currently stack probes seem somewhat incompatible with the address // sanitizer and thread sanitizer. With asan we're already protected from // stack overflow anyway so we don't really need stack probes regardless. @@ -161,7 +161,7 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { } } -fn set_stackprotector(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { +fn set_stackprotector<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { let sspattr = match cx.sess().stack_protector() { StackProtector::None => return, StackProtector::All => Attribute::StackProtectReq, @@ -172,7 +172,7 @@ fn set_stackprotector(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { sspattr.apply_llfn(Function, llfn) } -pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { +pub fn apply_target_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { let target_cpu = SmallCStr::new(llvm_util::target_cpu(cx.tcx.sess)); llvm::AddFunctionAttrStringValue( llfn, @@ -182,7 +182,7 @@ pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { ); } -pub fn apply_tune_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { +pub fn apply_tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { if let Some(tune) = llvm_util::tune_cpu(cx.tcx.sess) { let tune_cpu = SmallCStr::new(tune); llvm::AddFunctionAttrStringValue( @@ -196,14 +196,14 @@ pub fn apply_tune_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { /// Sets the `NonLazyBind` LLVM attribute on a given function, /// assuming the codegen options allow skipping the PLT. -pub fn non_lazy_bind(sess: &Session, llfn: &'ll Value) { +pub fn non_lazy_bind<'ll>(sess: &Session, llfn: &'ll Value) { // Don't generate calls through PLT if it's not necessary if !sess.needs_plt() { Attribute::NonLazyBind.apply_llfn(Function, llfn); } } -pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) { +pub(crate) fn default_optimisation_attrs<'ll>(sess: &Session, llfn: &'ll Value) { match sess.opts.optimize { OptLevel::Size => { llvm::Attribute::MinSize.unapply_llfn(Function, llfn); @@ -226,7 +226,11 @@ pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) { /// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`) /// attributes. -pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::Instance<'tcx>) { +pub fn from_fn_attrs<'ll, 'tcx>( + cx: &CodegenCx<'ll, 'tcx>, + llfn: &'ll Value, + instance: ty::Instance<'tcx>, +) { let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id()); match codegen_fn_attrs.optimize { diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index f6c40f1689e9..4bb1fed2d510 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -363,7 +363,7 @@ fn fat_lto( crate struct Linker<'a>(&'a mut llvm::Linker<'a>); -impl Linker<'a> { +impl<'a> Linker<'a> { crate fn new(llmod: &'a llvm::Module) -> Self { unsafe { Linker(llvm::LLVMRustLinkerNew(llmod)) } } @@ -383,7 +383,7 @@ impl Linker<'a> { } } -impl Drop for Linker<'a> { +impl Drop for Linker<'_> { fn drop(&mut self) { unsafe { llvm::LLVMRustLinkerFree(&mut *(self.0 as *mut _)); diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 3fceb2ac4ed8..0533e80a5c94 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -46,7 +46,7 @@ pub fn llvm_err(handler: &rustc_errors::Handler, msg: &str) -> FatalError { } } -pub fn write_output_file( +pub fn write_output_file<'ll>( handler: &rustc_errors::Handler, target: &'ll llvm::TargetMachine, pm: &llvm::PassManager<'ll>, diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 7a3e11e32bc1..483b81d23bc2 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -39,7 +39,7 @@ pub struct ValueIter<'ll> { step: unsafe extern "C" fn(&'ll Value) -> Option<&'ll Value>, } -impl Iterator for ValueIter<'ll> { +impl<'ll> Iterator for ValueIter<'ll> { type Item = &'ll Value; fn next(&mut self) -> Option<&'ll Value> { @@ -51,14 +51,11 @@ impl Iterator for ValueIter<'ll> { } } -pub fn iter_globals(llmod: &'ll llvm::Module) -> ValueIter<'ll> { +pub fn iter_globals(llmod: &llvm::Module) -> ValueIter<'_> { unsafe { ValueIter { cur: llvm::LLVMGetFirstGlobal(llmod), step: llvm::LLVMGetNextGlobal } } } -pub fn compile_codegen_unit( - tcx: TyCtxt<'tcx>, - cgu_name: Symbol, -) -> (ModuleCodegen, u64) { +pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen, u64) { let start_time = Instant::now(); let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx); diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index ff88302bf7aa..8c3054b23ff4 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -36,7 +36,7 @@ pub struct Builder<'a, 'll, 'tcx> { pub cx: &'a CodegenCx<'ll, 'tcx>, } -impl Drop for Builder<'a, 'll, 'tcx> { +impl Drop for Builder<'_, '_, '_> { fn drop(&mut self) { unsafe { llvm::LLVMDisposeBuilder(&mut *(self.llbuilder as *mut _)); @@ -52,7 +52,7 @@ const EMPTY_C_STR: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") } // FIXME(eddyb) pass `&CStr` directly to FFI once it's a thin pointer. const UNNAMED: *const c_char = EMPTY_C_STR.as_ptr(); -impl BackendTypes for Builder<'_, 'll, 'tcx> { +impl<'ll, 'tcx> BackendTypes for Builder<'_, 'll, 'tcx> { type Value = as BackendTypes>::Value; type Function = as BackendTypes>::Function; type BasicBlock = as BackendTypes>::BasicBlock; @@ -70,27 +70,27 @@ impl abi::HasDataLayout for Builder<'_, '_, '_> { } } -impl ty::layout::HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> { +impl<'tcx> ty::layout::HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> { #[inline] fn tcx(&self) -> TyCtxt<'tcx> { self.cx.tcx } } -impl ty::layout::HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> { +impl<'tcx> ty::layout::HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> { fn param_env(&self) -> ty::ParamEnv<'tcx> { self.cx.param_env() } } -impl HasTargetSpec for Builder<'_, '_, 'tcx> { +impl HasTargetSpec for Builder<'_, '_, '_> { #[inline] fn target_spec(&self) -> &Target { self.cx.target_spec() } } -impl LayoutOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { +impl<'tcx> LayoutOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { type LayoutOfResult = TyAndLayout<'tcx>; #[inline] @@ -99,7 +99,7 @@ impl LayoutOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { } } -impl FnAbiOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { +impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { type FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>; #[inline] @@ -113,7 +113,7 @@ impl FnAbiOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { } } -impl Deref for Builder<'_, 'll, 'tcx> { +impl<'ll, 'tcx> Deref for Builder<'_, 'll, 'tcx> { type Target = CodegenCx<'ll, 'tcx>; #[inline] @@ -122,7 +122,7 @@ impl Deref for Builder<'_, 'll, 'tcx> { } } -impl HasCodegen<'tcx> for Builder<'_, 'll, 'tcx> { +impl<'ll, 'tcx> HasCodegen<'tcx> for Builder<'_, 'll, 'tcx> { type CodegenCx = CodegenCx<'ll, 'tcx>; } @@ -136,7 +136,7 @@ macro_rules! builder_methods_for_value_instructions { } } -impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { +impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn build(cx: &'a CodegenCx<'ll, 'tcx>, llbb: &'ll BasicBlock) -> Self { let bx = Builder::with_cx(cx); unsafe { @@ -1206,14 +1206,14 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } } -impl StaticBuilderMethods for Builder<'a, 'll, 'tcx> { +impl<'ll> StaticBuilderMethods for Builder<'_, 'll, '_> { fn get_static(&mut self, def_id: DefId) -> &'ll Value { // Forward to the `get_static` method of `CodegenCx` self.cx().get_static(def_id) } } -impl Builder<'a, 'll, 'tcx> { +impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> { fn with_cx(cx: &'a CodegenCx<'ll, 'tcx>) -> Self { // Create a fresh builder from the crate context. let llbuilder = unsafe { llvm::LLVMCreateBuilderInContext(cx.llcx) }; diff --git a/compiler/rustc_codegen_llvm/src/callee.rs b/compiler/rustc_codegen_llvm/src/callee.rs index 1bc924d3b90b..ac423a227032 100644 --- a/compiler/rustc_codegen_llvm/src/callee.rs +++ b/compiler/rustc_codegen_llvm/src/callee.rs @@ -22,7 +22,7 @@ use rustc_middle::ty::{self, Instance, TypeFoldable}; /// /// - `cx`: the crate context /// - `instance`: the instance to be instantiated -pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value { +pub fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value { let tcx = cx.tcx(); debug!("get_fn(instance={:?})", instance); diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index d0ed97812431..9d34734f4e59 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -65,7 +65,7 @@ pub struct Funclet<'ll> { operand: OperandBundleDef<'ll>, } -impl Funclet<'ll> { +impl<'ll> Funclet<'ll> { pub fn new(cleanuppad: &'ll Value) -> Self { Funclet { cleanuppad, operand: OperandBundleDef::new("funclet", &[cleanuppad]) } } @@ -79,7 +79,7 @@ impl Funclet<'ll> { } } -impl BackendTypes for CodegenCx<'ll, 'tcx> { +impl<'ll> BackendTypes for CodegenCx<'ll, '_> { type Value = &'ll Value; // FIXME(eddyb) replace this with a `Function` "subclass" of `Value`. type Function = &'ll Value; @@ -93,7 +93,7 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> { type DIVariable = &'ll llvm::debuginfo::DIVariable; } -impl CodegenCx<'ll, 'tcx> { +impl<'ll> CodegenCx<'ll, '_> { pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value { unsafe { llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint) } } @@ -145,7 +145,7 @@ impl CodegenCx<'ll, 'tcx> { } } -impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn const_null(&self, t: &'ll Type) -> &'ll Value { unsafe { llvm::LLVMConstNull(t) } } @@ -327,14 +327,18 @@ pub fn val_ty(v: &Value) -> &Type { unsafe { llvm::LLVMTypeOf(v) } } -pub fn bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value { +pub fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value { unsafe { let ptr = bytes.as_ptr() as *const c_char; llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True) } } -pub fn struct_in_context(llcx: &'a llvm::Context, elts: &[&'a Value], packed: bool) -> &'a Value { +pub fn struct_in_context<'ll>( + llcx: &'ll llvm::Context, + elts: &[&'ll Value], + packed: bool, +) -> &'ll Value { unsafe { llvm::LLVMConstStructInContext(llcx, elts.as_ptr(), elts.len() as c_uint, packed as Bool) } diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 50a68ae49d50..d43c7c606517 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -24,7 +24,7 @@ use rustc_target::abi::{ use std::ops::Range; use tracing::debug; -pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll Value { +pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll Value { let mut llvals = Vec::with_capacity(alloc.relocations().len() + 1); let dl = cx.data_layout(); let pointer_size = dl.pointer_size.bytes() as usize; @@ -127,7 +127,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll cx.const_struct(&llvals, true) } -pub fn codegen_static_initializer( +pub fn codegen_static_initializer<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, def_id: DefId, ) -> Result<(&'ll Value, &'tcx Allocation), ErrorHandled> { @@ -135,7 +135,7 @@ pub fn codegen_static_initializer( Ok((const_alloc_to_llvm(cx, alloc), alloc)) } -fn set_global_alignment(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: Align) { +fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: Align) { // The target may require greater alignment for globals than the type does. // Note: GCC and Clang also allow `__attribute__((aligned))` on variables, // which can force it to be smaller. Rust doesn't support this yet. @@ -152,7 +152,7 @@ fn set_global_alignment(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: Alig } } -fn check_and_apply_linkage( +fn check_and_apply_linkage<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, attrs: &CodegenFnAttrs, ty: Ty<'tcx>, @@ -206,11 +206,11 @@ fn check_and_apply_linkage( } } -pub fn ptrcast(val: &'ll Value, ty: &'ll Type) -> &'ll Value { +pub fn ptrcast<'ll>(val: &'ll Value, ty: &'ll Type) -> &'ll Value { unsafe { llvm::LLVMConstPointerCast(val, ty) } } -impl CodegenCx<'ll, 'tcx> { +impl<'ll> CodegenCx<'ll, '_> { crate fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value { unsafe { llvm::LLVMConstBitCast(val, ty) } } @@ -344,7 +344,7 @@ impl CodegenCx<'ll, 'tcx> { } } -impl StaticMethods for CodegenCx<'ll, 'tcx> { +impl<'ll> StaticMethods for CodegenCx<'ll, '_> { fn static_addr_of(&self, cv: &'ll Value, align: Align, kind: Option<&str>) -> &'ll Value { if let Some(&gv) = self.const_globals.borrow().get(&cv) { unsafe { diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 613a8df891ce..fe55bf8686e2 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -124,7 +124,7 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode { } } -pub unsafe fn create_module( +pub unsafe fn create_module<'ll>( tcx: TyCtxt<'_>, llcx: &'ll llvm::Context, mod_name: &str, @@ -363,7 +363,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { } #[inline] - pub fn coverage_context(&'a self) -> Option<&'a coverageinfo::CrateCoverageContext<'ll, 'tcx>> { + pub fn coverage_context(&self) -> Option<&coverageinfo::CrateCoverageContext<'ll, 'tcx>> { self.coverage_cx.as_ref() } @@ -380,7 +380,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { } } -impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn vtables( &self, ) -> &RefCell, Option>), &'ll Value>> @@ -504,8 +504,8 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { } } -impl CodegenCx<'b, 'tcx> { - crate fn get_intrinsic(&self, key: &str) -> (&'b Type, &'b Value) { +impl<'ll> CodegenCx<'ll, '_> { + crate fn get_intrinsic(&self, key: &str) -> (&'ll Type, &'ll Value) { if let Some(v) = self.intrinsics.borrow().get(key).cloned() { return v; } @@ -516,9 +516,9 @@ impl CodegenCx<'b, 'tcx> { fn insert_intrinsic( &self, name: &'static str, - args: Option<&[&'b llvm::Type]>, - ret: &'b llvm::Type, - ) -> (&'b llvm::Type, &'b llvm::Value) { + args: Option<&[&'ll llvm::Type]>, + ret: &'ll llvm::Type, + ) -> (&'ll llvm::Type, &'ll llvm::Value) { let fn_ty = if let Some(args) = args { self.type_func(args, ret) } else { @@ -529,7 +529,7 @@ impl CodegenCx<'b, 'tcx> { (fn_ty, f) } - fn declare_intrinsic(&self, key: &str) -> Option<(&'b Type, &'b Value)> { + fn declare_intrinsic(&self, key: &str) -> Option<(&'ll Type, &'ll Value)> { macro_rules! ifn { ($name:expr, fn() -> $ret:expr) => ( if key == $name { @@ -793,7 +793,7 @@ impl CodegenCx<'b, 'tcx> { None } - crate fn eh_catch_typeinfo(&self) -> &'b Value { + crate fn eh_catch_typeinfo(&self) -> &'ll Value { if let Some(eh_catch_typeinfo) = self.eh_catch_typeinfo.get() { return eh_catch_typeinfo; } @@ -813,7 +813,7 @@ impl CodegenCx<'b, 'tcx> { } } -impl<'b, 'tcx> CodegenCx<'b, 'tcx> { +impl CodegenCx<'_, '_> { /// Generates a new symbol name with the given prefix. This symbol name must /// only be used for definitions with `internal` or `private` linkage. pub fn generate_local_symbol_name(&self, prefix: &str) -> String { @@ -829,21 +829,21 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> { } } -impl HasDataLayout for CodegenCx<'ll, 'tcx> { +impl HasDataLayout for CodegenCx<'_, '_> { #[inline] fn data_layout(&self) -> &TargetDataLayout { &self.tcx.data_layout } } -impl HasTargetSpec for CodegenCx<'ll, 'tcx> { +impl HasTargetSpec for CodegenCx<'_, '_> { #[inline] fn target_spec(&self) -> &Target { &self.tcx.sess.target } } -impl ty::layout::HasTyCtxt<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'tcx> ty::layout::HasTyCtxt<'tcx> for CodegenCx<'_, 'tcx> { #[inline] fn tcx(&self) -> TyCtxt<'tcx> { self.tcx @@ -856,7 +856,7 @@ impl<'tcx, 'll> HasParamEnv<'tcx> for CodegenCx<'ll, 'tcx> { } } -impl LayoutOfHelpers<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> { type LayoutOfResult = TyAndLayout<'tcx>; #[inline] @@ -869,7 +869,7 @@ impl LayoutOfHelpers<'tcx> for CodegenCx<'ll, 'tcx> { } } -impl FnAbiOfHelpers<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> { type FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>; #[inline] diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index d2af1b247e86..e0af5653753b 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -141,7 +141,7 @@ impl CoverageMapGenerator { /// the `mapping_regions` and `virtual_file_mapping`, and capture any new filenames. Then use /// LLVM APIs to encode the `virtual_file_mapping`, `expressions`, and `mapping_regions` into /// the given `coverage_mapping` byte buffer, compliant with the LLVM Coverage Mapping format. - fn write_coverage_mapping( + fn write_coverage_mapping<'a>( &mut self, expressions: Vec, counter_regions: impl Iterator, @@ -200,9 +200,9 @@ impl CoverageMapGenerator { /// Construct coverage map header and the array of function records, and combine them into the /// coverage map. Save the coverage map data into the LLVM IR as a static global using a /// specific, well-known section and name. - fn generate_coverage_map( + fn generate_coverage_map<'ll>( self, - cx: &CodegenCx<'ll, 'tcx>, + cx: &CodegenCx<'ll, '_>, version: u32, filenames_size: usize, filenames_val: &'ll llvm::Value, @@ -229,7 +229,7 @@ impl CoverageMapGenerator { /// Save the function record into the LLVM IR as a static global using a /// specific, well-known section and name. fn save_function_record( - cx: &CodegenCx<'ll, 'tcx>, + cx: &CodegenCx<'_, '_>, mangled_function_name: String, source_hash: u64, filenames_ref: u64, diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs index 96b278dbe326..b2879ef4aea1 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs @@ -56,7 +56,7 @@ impl<'ll, 'tcx> CrateCoverageContext<'ll, 'tcx> { } } -impl CoverageInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'ll, 'tcx> CoverageInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn coverageinfo_finalize(&self) { mapgen::finalize(self) } @@ -96,7 +96,7 @@ impl CoverageInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { } } -impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { +impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> { fn set_function_source_hash( &mut self, instance: Instance<'tcx>, @@ -184,7 +184,7 @@ impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { } } -fn declare_unused_fn(cx: &CodegenCx<'ll, 'tcx>, def_id: &DefId) -> Instance<'tcx> { +fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: &DefId) -> Instance<'tcx> { let tcx = cx.tcx; let instance = Instance::new( @@ -220,7 +220,7 @@ fn declare_unused_fn(cx: &CodegenCx<'ll, 'tcx>, def_id: &DefId) -> Instance<'tcx instance } -fn codegen_unused_fn_and_counter(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) { +fn codegen_unused_fn_and_counter<'tcx>(cx: &CodegenCx<'_, 'tcx>, instance: Instance<'tcx>) { let llfn = cx.get_fn(instance); let llbb = Builder::append_block(cx, llfn, "unused_function"); let mut bx = Builder::build(cx, llbb); @@ -237,8 +237,8 @@ fn codegen_unused_fn_and_counter(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<' bx.ret_void(); } -fn add_unused_function_coverage( - cx: &CodegenCx<'ll, 'tcx>, +fn add_unused_function_coverage<'tcx>( + cx: &CodegenCx<'_, 'tcx>, instance: Instance<'tcx>, def_id: DefId, ) { @@ -268,7 +268,7 @@ fn add_unused_function_coverage( /// required by LLVM InstrProf source-based coverage instrumentation. Use /// `bx.get_pgo_func_name_var()` to ensure the variable is only created once per /// `Instance`. -fn create_pgo_func_name_var( +fn create_pgo_func_name_var<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>, ) -> &'ll llvm::Value { diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs index 58f8573a2acb..39f53235e2c5 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs @@ -16,7 +16,7 @@ use rustc_index::vec::Idx; /// Produces DIScope DIEs for each MIR Scope which has variables defined in it. // FIXME(eddyb) almost all of this should be in `rustc_codegen_ssa::mir::debuginfo`. -pub fn compute_mir_scopes( +pub fn compute_mir_scopes<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>, mir: &Body<'tcx>, @@ -45,7 +45,7 @@ pub fn compute_mir_scopes( } } -fn make_mir_scope( +fn make_mir_scope<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>, mir: &Body<'tcx>, diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs index ae1f83d944f5..31a09242c5ad 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs @@ -28,7 +28,7 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, /// Allocates the global variable responsible for the .debug_gdb_scripts binary /// section. -pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>) -> &'ll Value { +pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll Value { let c_section_var_name = "__rustc_debug_gdb_scripts_section__\0"; let section_var_name = &c_section_var_name[..c_section_var_name.len() - 1]; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index cc39332d198f..9160f00363d1 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -155,7 +155,7 @@ pub struct TypeMap<'ll, 'tcx> { type_to_unique_id: FxHashMap, UniqueTypeId>, } -impl TypeMap<'ll, 'tcx> { +impl<'ll, 'tcx> TypeMap<'ll, 'tcx> { /// Adds a Ty to metadata mapping to the TypeMap. The method will fail if /// the mapping already exists. fn register_type_with_metadata(&mut self, type_: Ty<'tcx>, metadata: &'ll DIType) { @@ -291,7 +291,7 @@ enum RecursiveTypeDescription<'ll, 'tcx> { FinalMetadata(&'ll DICompositeType), } -fn create_and_register_recursive_type_forward_declaration( +fn create_and_register_recursive_type_forward_declaration<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, unfinished_type: Ty<'tcx>, unique_type_id: UniqueTypeId, @@ -313,7 +313,7 @@ fn create_and_register_recursive_type_forward_declaration( } } -impl RecursiveTypeDescription<'ll, 'tcx> { +impl<'ll, 'tcx> RecursiveTypeDescription<'ll, 'tcx> { /// Finishes up the description of the type in question (mostly by providing /// descriptions of the fields of the given type) and returns the final type /// metadata. @@ -375,7 +375,7 @@ macro_rules! return_if_metadata_created_in_meantime { }; } -fn fixed_vec_metadata( +fn fixed_vec_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, unique_type_id: UniqueTypeId, array_or_slice_type: Ty<'tcx>, @@ -410,7 +410,7 @@ fn fixed_vec_metadata( MetadataCreationResult::new(metadata, false) } -fn vec_slice_metadata( +fn vec_slice_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, slice_ptr_type: Ty<'tcx>, element_type: Ty<'tcx>, @@ -466,7 +466,7 @@ fn vec_slice_metadata( MetadataCreationResult::new(metadata, false) } -fn subroutine_type_metadata( +fn subroutine_type_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, unique_type_id: UniqueTypeId, signature: ty::PolyFnSig<'tcx>, @@ -507,7 +507,7 @@ fn subroutine_type_metadata( // `trait_type` should be the actual trait (e.g., `Trait`). Where the trait is part // of a DST struct, there is no `trait_object_type` and the results of this // function will be a little bit weird. -fn trait_pointer_metadata( +fn trait_pointer_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, trait_type: Ty<'tcx>, trait_object_type: Option>, @@ -588,7 +588,11 @@ fn trait_pointer_metadata( ) } -pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Span) -> &'ll DIType { +pub fn type_metadata<'ll, 'tcx>( + cx: &CodegenCx<'ll, 'tcx>, + t: Ty<'tcx>, + usage_site_span: Span, +) -> &'ll DIType { // Get the unique type ID of this type. let unique_type_id = { let mut type_map = debug_context(cx).type_map.borrow_mut(); @@ -812,7 +816,7 @@ fn hex_encode(data: &[u8]) -> String { hex_string } -pub fn file_metadata(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll DIFile { +pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll DIFile { debug!("file_metadata: file_name: {:?}", source_file.name); let hash = Some(&source_file.src_hash); @@ -833,11 +837,11 @@ pub fn file_metadata(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll file_metadata_raw(cx, file_name, directory, hash) } -pub fn unknown_file_metadata(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile { +pub fn unknown_file_metadata<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile { file_metadata_raw(cx, None, None, None) } -fn file_metadata_raw( +fn file_metadata_raw<'ll>( cx: &CodegenCx<'ll, '_>, file_name: Option, directory: Option, @@ -924,7 +928,7 @@ impl MsvcBasicName for ty::FloatTy { } } -fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { +fn basic_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { debug!("basic_type_metadata: {:?}", t); // When targeting MSVC, emit MSVC style type names for compatibility with @@ -981,7 +985,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { typedef_metadata } -fn foreign_type_metadata( +fn foreign_type_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, unique_type_id: UniqueTypeId, @@ -992,7 +996,7 @@ fn foreign_type_metadata( create_struct_stub(cx, t, &name, unique_type_id, NO_SCOPE_METADATA, DIFlags::FlagZero) } -fn pointer_type_metadata( +fn pointer_type_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, pointer_type: Ty<'tcx>, pointee_type_metadata: &'ll DIType, @@ -1012,7 +1016,7 @@ fn pointer_type_metadata( } } -fn param_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { +fn param_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { debug!("param_type_metadata: {:?}", t); let name = format!("{:?}", t); unsafe { @@ -1026,10 +1030,10 @@ fn param_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { } } -pub fn compile_unit_metadata( - tcx: TyCtxt<'_>, +pub fn compile_unit_metadata<'ll, 'tcx>( + tcx: TyCtxt<'tcx>, codegen_unit_name: &str, - debug_context: &CrateDebugContext<'ll, '_>, + debug_context: &CrateDebugContext<'ll, 'tcx>, ) -> &'ll DIDescriptor { let mut name_in_debuginfo = match tcx.sess.local_crate_source_file { Some(ref path) => path.clone(), @@ -1159,7 +1163,7 @@ pub fn compile_unit_metadata( return unit_metadata; }; - fn path_to_mdstring(llcx: &'ll llvm::Context, path: &Path) -> &'ll Value { + fn path_to_mdstring<'ll>(llcx: &'ll llvm::Context, path: &Path) -> &'ll Value { let path_str = path_to_c_string(path); unsafe { llvm::LLVMMDStringInContext( @@ -1176,7 +1180,7 @@ struct MetadataCreationResult<'ll> { already_stored_in_typemap: bool, } -impl MetadataCreationResult<'ll> { +impl<'ll> MetadataCreationResult<'ll> { fn new(metadata: &'ll DIType, already_stored_in_typemap: bool) -> Self { MetadataCreationResult { metadata, already_stored_in_typemap } } @@ -1243,7 +1247,7 @@ enum MemberDescriptionFactory<'ll, 'tcx> { VariantMDF(VariantMemberDescriptionFactory<'tcx>), } -impl MemberDescriptionFactory<'ll, 'tcx> { +impl<'ll, 'tcx> MemberDescriptionFactory<'ll, 'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec> { match *self { StructMDF(ref this) => this.create_member_descriptions(cx), @@ -1267,7 +1271,10 @@ struct StructMemberDescriptionFactory<'tcx> { } impl<'tcx> StructMemberDescriptionFactory<'tcx> { - fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec> { + fn create_member_descriptions<'ll>( + &self, + cx: &CodegenCx<'ll, 'tcx>, + ) -> Vec> { let layout = cx.layout_of(self.ty); self.variant .fields @@ -1295,7 +1302,7 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> { } } -fn prepare_struct_metadata( +fn prepare_struct_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, struct_type: Ty<'tcx>, unique_type_id: UniqueTypeId, @@ -1338,7 +1345,7 @@ fn prepare_struct_metadata( /// Here are some examples: /// - `name__field1__field2` when the upvar is captured by value. /// - `_ref__name__field` when the upvar is captured by reference. -fn closure_saved_names_of_captured_variables(tcx: TyCtxt<'tcx>, def_id: DefId) -> Vec { +fn closure_saved_names_of_captured_variables(tcx: TyCtxt<'_>, def_id: DefId) -> Vec { let body = tcx.optimized_mir(def_id); body.var_debug_info @@ -1366,7 +1373,10 @@ struct TupleMemberDescriptionFactory<'tcx> { } impl<'tcx> TupleMemberDescriptionFactory<'tcx> { - fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec> { + fn create_member_descriptions<'ll>( + &self, + cx: &CodegenCx<'ll, 'tcx>, + ) -> Vec> { let mut capture_names = match *self.ty.kind() { ty::Generator(def_id, ..) | ty::Closure(def_id, ..) => { Some(closure_saved_names_of_captured_variables(cx.tcx, def_id).into_iter()) @@ -1399,7 +1409,7 @@ impl<'tcx> TupleMemberDescriptionFactory<'tcx> { } } -fn prepare_tuple_metadata( +fn prepare_tuple_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, tuple_type: Ty<'tcx>, component_types: &[Ty<'tcx>], @@ -1443,7 +1453,10 @@ struct UnionMemberDescriptionFactory<'tcx> { } impl<'tcx> UnionMemberDescriptionFactory<'tcx> { - fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec> { + fn create_member_descriptions<'ll>( + &self, + cx: &CodegenCx<'ll, 'tcx>, + ) -> Vec> { self.variant .fields .iter() @@ -1465,7 +1478,7 @@ impl<'tcx> UnionMemberDescriptionFactory<'tcx> { } } -fn prepare_union_metadata( +fn prepare_union_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, union_type: Ty<'tcx>, unique_type_id: UniqueTypeId, @@ -1506,7 +1519,7 @@ fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool { // FIXME(eddyb) maybe precompute this? Right now it's computed once // per generator monomorphization, but it doesn't depend on substs. -fn generator_layout_and_saved_local_names( +fn generator_layout_and_saved_local_names<'tcx>( tcx: TyCtxt<'tcx>, def_id: DefId, ) -> (&'tcx GeneratorLayout<'tcx>, IndexVec>) { @@ -1554,7 +1567,7 @@ struct EnumMemberDescriptionFactory<'ll, 'tcx> { span: Span, } -impl EnumMemberDescriptionFactory<'ll, 'tcx> { +impl<'ll, 'tcx> EnumMemberDescriptionFactory<'ll, 'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec> { let generator_variant_info_data = match *self.enum_type.kind() { ty::Generator(def_id, ..) => { @@ -1886,8 +1899,11 @@ struct VariantMemberDescriptionFactory<'tcx> { span: Span, } -impl VariantMemberDescriptionFactory<'tcx> { - fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec> { +impl<'tcx> VariantMemberDescriptionFactory<'tcx> { + fn create_member_descriptions<'ll>( + &self, + cx: &CodegenCx<'ll, 'tcx>, + ) -> Vec> { self.args .iter() .enumerate() @@ -1961,7 +1977,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> { field_name.map(|name| name.to_string()).unwrap_or_else(|| format!("__{}", i)) } - fn source_info(&self, cx: &CodegenCx<'ll, 'tcx>) -> Option> { + fn source_info<'ll>(&self, cx: &CodegenCx<'ll, 'tcx>) -> Option> { if let VariantInfo::Generator { def_id, variant_index, .. } = self { let span = cx.tcx.generator_layout(*def_id).unwrap().variant_source_info[*variant_index].span; @@ -1978,7 +1994,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> { /// `MemberDescriptionFactory` for producing the descriptions of the /// fields of the variant. This is a rudimentary version of a full /// `RecursiveTypeDescription`. -fn describe_enum_variant( +fn describe_enum_variant<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, layout: layout::TyAndLayout<'tcx>, variant: VariantInfo<'_, 'tcx>, @@ -2011,7 +2027,7 @@ fn describe_enum_variant( (metadata_stub, member_description_factory) } -fn prepare_enum_metadata( +fn prepare_enum_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, enum_type: Ty<'tcx>, enum_def_id: DefId, @@ -2330,7 +2346,7 @@ fn prepare_enum_metadata( /// results in a LLVM struct. /// /// Examples of Rust types to use this are: structs, tuples, boxes, vecs, and enums. -fn composite_type_metadata( +fn composite_type_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, composite_type: Ty<'tcx>, composite_type_name: &str, @@ -2364,7 +2380,7 @@ fn composite_type_metadata( composite_type_metadata } -fn set_members_of_composite_type( +fn set_members_of_composite_type<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, composite_type: Ty<'tcx>, composite_type_metadata: &'ll DICompositeType, @@ -2409,7 +2425,7 @@ fn set_members_of_composite_type( } /// Computes the type parameters for a type, if any, for the given metadata. -fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIArray { +fn compute_type_parameters<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIArray { if let ty::Adt(def, substs) = *ty.kind() { if substs.types().next().is_some() { let generics = cx.tcx.generics_of(def.did); @@ -2454,7 +2470,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIAr /// A convenience wrapper around `LLVMRustDIBuilderCreateStructType()`. Does not do /// any caching, does not add any fields to the struct. This can be done later /// with `set_members_of_composite_type()`. -fn create_struct_stub( +fn create_struct_stub<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, struct_type: Ty<'tcx>, struct_type_name: &str, @@ -2495,7 +2511,7 @@ fn create_struct_stub( metadata_stub } -fn create_union_stub( +fn create_union_stub<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, union_type: Ty<'tcx>, union_type_name: &str, @@ -2536,7 +2552,7 @@ fn create_union_stub( /// Creates debug information for the given global variable. /// /// Adds the created metadata nodes directly to the crate's IR. -pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global: &'ll Value) { +pub fn create_global_var_metadata<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId, global: &'ll Value) { if cx.dbg_cx.is_none() { return; } @@ -2591,7 +2607,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global } /// Generates LLVM debuginfo for a vtable. -fn vtable_type_metadata( +fn vtable_type_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, poly_trait_ref: Option>, @@ -2623,7 +2639,7 @@ fn vtable_type_metadata( /// given type. /// /// Adds the created metadata nodes directly to the crate's IR. -pub fn create_vtable_metadata( +pub fn create_vtable_metadata<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, poly_trait_ref: Option>, @@ -2662,7 +2678,7 @@ pub fn create_vtable_metadata( } /// Creates an "extension" of an existing `DIScope` into another file. -pub fn extend_scope_to_file( +pub fn extend_scope_to_file<'ll>( cx: &CodegenCx<'ll, '_>, scope_metadata: &'ll DIScope, file: &SourceFile, diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index b801a7c13144..3e7371179cc7 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -71,7 +71,7 @@ pub struct CrateDebugContext<'a, 'tcx> { composite_types_completed: RefCell>, } -impl Drop for CrateDebugContext<'a, 'tcx> { +impl Drop for CrateDebugContext<'_, '_> { fn drop(&mut self) { unsafe { llvm::LLVMRustDIBuilderDispose(&mut *(self.builder as *mut _)); @@ -144,7 +144,7 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) { } } -impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> { +impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> { // FIXME(eddyb) find a common convention for all of the debuginfo-related // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.). fn dbg_var_addr( @@ -236,7 +236,7 @@ pub struct DebugLoc { pub col: u32, } -impl CodegenCx<'ll, '_> { +impl CodegenCx<'_, '_> { /// Looks up debug source information about a `BytePos`. // FIXME(eddyb) rename this to better indicate it's a duplicate of // `lookup_char_pos` rather than `dbg_loc`, perhaps by making @@ -266,7 +266,7 @@ impl CodegenCx<'ll, '_> { } } -impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn create_function_debug_context( &self, instance: Instance<'tcx>, diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs b/compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs index 1cbf53869960..d5ea48c311b9 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs @@ -17,7 +17,7 @@ pub fn mangled_name_of_instance<'a, 'tcx>( tcx.symbol_name(instance) } -pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope { +pub fn item_namespace<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope { if let Some(&scope) = debug_context(cx).namespace_map.borrow().get(&def_id) { return scope; } diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs index ee188e69be11..953b6765a489 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs @@ -23,21 +23,26 @@ pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool { } #[allow(non_snake_case)] -pub fn create_DIArray(builder: &DIBuilder<'ll>, arr: &[Option<&'ll DIDescriptor>]) -> &'ll DIArray { +pub fn create_DIArray<'ll>( + builder: &DIBuilder<'ll>, + arr: &[Option<&'ll DIDescriptor>], +) -> &'ll DIArray { unsafe { llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) } } #[inline] -pub fn debug_context(cx: &'a CodegenCx<'ll, 'tcx>) -> &'a CrateDebugContext<'ll, 'tcx> { +pub fn debug_context<'a, 'll, 'tcx>( + cx: &'a CodegenCx<'ll, 'tcx>, +) -> &'a CrateDebugContext<'ll, 'tcx> { cx.dbg_cx.as_ref().unwrap() } #[inline] #[allow(non_snake_case)] -pub fn DIB(cx: &'a CodegenCx<'ll, '_>) -> &'a DIBuilder<'ll> { +pub fn DIB<'a, 'll>(cx: &'a CodegenCx<'ll, '_>) -> &'a DIBuilder<'ll> { cx.dbg_cx.as_ref().unwrap().builder } -pub fn get_namespace_for_item(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope { +pub fn get_namespace_for_item<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope { item_namespace(cx, cx.tcx.parent(def_id).expect("get_namespace_for_item: missing parent?")) } diff --git a/compiler/rustc_codegen_llvm/src/declare.rs b/compiler/rustc_codegen_llvm/src/declare.rs index 8977fa085b9b..90d0d5caba1d 100644 --- a/compiler/rustc_codegen_llvm/src/declare.rs +++ b/compiler/rustc_codegen_llvm/src/declare.rs @@ -26,7 +26,7 @@ use tracing::debug; /// /// If there’s a value with the same name already declared, the function will /// update the declaration and return existing Value instead. -fn declare_raw_fn( +fn declare_raw_fn<'ll>( cx: &CodegenCx<'ll, '_>, name: &str, callconv: llvm::CallConv, @@ -50,7 +50,7 @@ fn declare_raw_fn( llfn } -impl CodegenCx<'ll, 'tcx> { +impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { /// Declare a global value. /// /// If there’s a value with the same name already declared, the function will diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 5e7d7552daf1..07d49b6e7299 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -25,7 +25,10 @@ use rustc_target::spec::{HasTargetSpec, PanicStrategy}; use std::cmp::Ordering; use std::iter; -fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: Symbol) -> Option<(&'ll Type, &'ll Value)> { +fn get_simple_intrinsic<'ll>( + cx: &CodegenCx<'ll, '_>, + name: Symbol, +) -> Option<(&'ll Type, &'ll Value)> { let llvm_name = match name { sym::sqrtf32 => "llvm.sqrt.f32", sym::sqrtf64 => "llvm.sqrt.f64", @@ -74,7 +77,7 @@ fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: Symbol) -> Option<(&'ll T Some(cx.get_intrinsic(llvm_name)) } -impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { +impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { fn codegen_intrinsic_call( &mut self, instance: ty::Instance<'tcx>, @@ -411,8 +414,8 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { } } -fn try_intrinsic( - bx: &mut Builder<'a, 'll, 'tcx>, +fn try_intrinsic<'ll>( + bx: &mut Builder<'_, 'll, '_>, try_func: &'ll Value, data: &'ll Value, catch_func: &'ll Value, @@ -441,8 +444,8 @@ fn try_intrinsic( // instructions are meant to work for all targets, as of the time of this // writing, however, LLVM does not recommend the usage of these new instructions // as the old ones are still more optimized. -fn codegen_msvc_try( - bx: &mut Builder<'a, 'll, 'tcx>, +fn codegen_msvc_try<'ll>( + bx: &mut Builder<'_, 'll, '_>, try_func: &'ll Value, data: &'ll Value, catch_func: &'ll Value, @@ -593,8 +596,8 @@ fn codegen_msvc_try( // function calling it, and that function may already have other personality // functions in play. By calling a shim we're guaranteed that our shim will have // the right personality function. -fn codegen_gnu_try( - bx: &mut Builder<'a, 'll, 'tcx>, +fn codegen_gnu_try<'ll>( + bx: &mut Builder<'_, 'll, '_>, try_func: &'ll Value, data: &'ll Value, catch_func: &'ll Value, @@ -649,8 +652,8 @@ fn codegen_gnu_try( // Variant of codegen_gnu_try used for emscripten where Rust panics are // implemented using C++ exceptions. Here we use exceptions of a specific type // (`struct rust_panic`) to represent Rust panics. -fn codegen_emcc_try( - bx: &mut Builder<'a, 'll, 'tcx>, +fn codegen_emcc_try<'ll>( + bx: &mut Builder<'_, 'll, '_>, try_func: &'ll Value, data: &'ll Value, catch_func: &'ll Value, @@ -799,8 +802,8 @@ fn get_rust_try_fn<'ll, 'tcx>( rust_try } -fn generic_simd_intrinsic( - bx: &mut Builder<'a, 'll, 'tcx>, +fn generic_simd_intrinsic<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, name: Symbol, callee_ty: Ty<'tcx>, args: &[OperandRef<'tcx, &'ll Value>], @@ -1129,12 +1132,12 @@ fn generic_simd_intrinsic( } } - fn simd_simple_float_intrinsic( + fn simd_simple_float_intrinsic<'ll, 'tcx>( name: Symbol, in_elem: &::rustc_middle::ty::TyS<'_>, in_ty: &::rustc_middle::ty::TyS<'_>, in_len: u64, - bx: &mut Builder<'a, 'll, 'tcx>, + bx: &mut Builder<'_, 'll, 'tcx>, span: Span, args: &[OperandRef<'tcx, &'ll Value>], ) -> Result<&'ll Value, ()> { @@ -1232,7 +1235,7 @@ fn generic_simd_intrinsic( elem_ty: Ty<'_>, vec_len: u64, no_pointers: usize, - bx: &Builder<'a, 'll, 'tcx>, + bx: &Builder<'_, '_, '_>, ) -> String { let p0s: String = "p0".repeat(no_pointers); match *elem_ty.kind() { @@ -1255,7 +1258,7 @@ fn generic_simd_intrinsic( } } - fn llvm_vector_ty( + fn llvm_vector_ty<'ll>( cx: &CodegenCx<'ll, '_>, elem_ty: Ty<'_>, vec_len: u64, diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 1dfaae7a1504..79be79db56aa 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -8,7 +8,6 @@ #![feature(bool_to_option)] #![feature(crate_visibility_modifier)] #![feature(extern_types)] -#![feature(in_band_lifetimes)] #![feature(iter_zip)] #![feature(nll)] #![recursion_limit = "256"] diff --git a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs index 36aa022d7465..e2fa5e488edd 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs @@ -43,7 +43,7 @@ pub struct OptimizationDiagnostic<'ll> { pub message: String, } -impl OptimizationDiagnostic<'ll> { +impl<'ll> OptimizationDiagnostic<'ll> { unsafe fn unpack(kind: OptimizationDiagnosticKind, di: &'ll DiagnosticInfo) -> Self { let mut function = None; let mut line = 0; @@ -142,7 +142,7 @@ pub struct InlineAsmDiagnostic { } impl InlineAsmDiagnostic { - unsafe fn unpackInlineAsm(di: &'ll DiagnosticInfo) -> Self { + unsafe fn unpackInlineAsm(di: &DiagnosticInfo) -> Self { let mut cookie = 0; let mut message = None; let mut level = super::DiagnosticLevel::Error; @@ -157,7 +157,7 @@ impl InlineAsmDiagnostic { } } - unsafe fn unpackSrcMgr(di: &'ll DiagnosticInfo) -> Self { + unsafe fn unpackSrcMgr(di: &DiagnosticInfo) -> Self { let mut cookie = 0; let smdiag = SrcMgrDiagnostic::unpack(super::LLVMRustGetSMDiagnostic(di, &mut cookie)); InlineAsmDiagnostic { @@ -180,7 +180,7 @@ pub enum Diagnostic<'ll> { UnknownDiagnostic(&'ll DiagnosticInfo), } -impl Diagnostic<'ll> { +impl<'ll> Diagnostic<'ll> { pub unsafe fn unpack(di: &'ll DiagnosticInfo) -> Self { use super::DiagnosticKind as Dk; let kind = super::LLVMRustGetDiagInfoKind(di); diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index d9a6723fe27f..6c911938ccc0 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1013,17 +1013,17 @@ extern "C" { pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type; // Operations on function types - pub fn LLVMFunctionType( + pub fn LLVMFunctionType<'a>( ReturnType: &'a Type, ParamTypes: *const &'a Type, ParamCount: c_uint, IsVarArg: Bool, ) -> &'a Type; pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint; - pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type); + pub fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type); // Operations on struct types - pub fn LLVMStructTypeInContext( + pub fn LLVMStructTypeInContext<'a>( C: &'a Context, ElementTypes: *const &'a Type, ElementCount: c_uint, @@ -1046,10 +1046,10 @@ extern "C" { pub fn LLVMTypeOf(Val: &Value) -> &Type; pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char; pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t); - pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value); - pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value); - pub fn LLVMGlobalSetMetadata(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata); - pub fn LLVMValueAsMetadata(Node: &'a Value) -> &Metadata; + pub fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value); + pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value); + pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata); + pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata; // Operations on constants of any type pub fn LLVMConstNull(Ty: &Type) -> &Value; @@ -1057,8 +1057,12 @@ extern "C" { // Operations on metadata pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value; - pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value; - pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value); + pub fn LLVMMDNodeInContext<'a>( + C: &'a Context, + Vals: *const &'a Value, + Count: c_uint, + ) -> &'a Value; + pub fn LLVMAddNamedMetadataOperand<'a>(M: &'a Module, Name: *const c_char, Val: &'a Value); // Operations on scalar constants pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value; @@ -1079,14 +1083,14 @@ extern "C" { Length: c_uint, DontNullTerminate: Bool, ) -> &Value; - pub fn LLVMConstStructInContext( + pub fn LLVMConstStructInContext<'a>( C: &'a Context, ConstantVals: *const &'a Value, Count: c_uint, Packed: Bool, ) -> &'a Value; - pub fn LLVMConstArray( + pub fn LLVMConstArray<'a>( ElementTy: &'a Type, ConstantVals: *const &'a Value, Length: c_uint, @@ -1094,17 +1098,17 @@ extern "C" { pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value; // Constant expressions - pub fn LLVMRustConstInBoundsGEP2( + pub fn LLVMRustConstInBoundsGEP2<'a>( ty: &'a Type, ConstantVal: &'a Value, ConstantIndices: *const &'a Value, NumIndices: c_uint, ) -> &'a Value; - pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstZExt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; pub fn LLVMConstExtractValue( AggConstant: &Value, IdxList: *const c_uint, @@ -1125,20 +1129,20 @@ extern "C" { // Operations on global variables pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>; - pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value; + pub fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value; pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>; - pub fn LLVMRustGetOrInsertGlobal( + pub fn LLVMRustGetOrInsertGlobal<'a>( M: &'a Module, Name: *const c_char, NameLen: size_t, T: &'a Type, ) -> &'a Value; - pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value; + pub fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value; pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>; pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>; pub fn LLVMDeleteGlobal(GlobalVar: &Value); pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>; - pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value); + pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value); pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool; pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool); pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode); @@ -1152,7 +1156,7 @@ extern "C" { pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool); // Operations on functions - pub fn LLVMRustGetOrInsertFunction( + pub fn LLVMRustGetOrInsertFunction<'a>( M: &'a Module, Name: *const c_char, NameLen: size_t, @@ -1180,7 +1184,7 @@ extern "C" { // Operations on basic blocks pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value; - pub fn LLVMAppendBasicBlockInContext( + pub fn LLVMAppendBasicBlockInContext<'a>( C: &'a Context, Fn: &'a Value, Name: *const c_char, @@ -1204,7 +1208,7 @@ extern "C" { pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool); // Operations on phi nodes - pub fn LLVMAddIncoming( + pub fn LLVMAddIncoming<'a>( PhiNode: &'a Value, IncomingValues: *const &'a Value, IncomingBlocks: *const &'a BasicBlock, @@ -1212,31 +1216,31 @@ extern "C" { ); // Instruction builders - pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>; - pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock); - pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock; - pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>); + pub fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>; + pub fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock); + pub fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock; + pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>); // Metadata - pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value); + pub fn LLVMSetCurrentDebugLocation<'a>(Builder: &Builder<'a>, L: &'a Value); // Terminators - pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value; - pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value; - pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value; - pub fn LLVMBuildCondBr( + pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value; + pub fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value; + pub fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value; + pub fn LLVMBuildCondBr<'a>( B: &Builder<'a>, If: &'a Value, Then: &'a BasicBlock, Else: &'a BasicBlock, ) -> &'a Value; - pub fn LLVMBuildSwitch( + pub fn LLVMBuildSwitch<'a>( B: &Builder<'a>, V: &'a Value, Else: &'a BasicBlock, NumCases: c_uint, ) -> &'a Value; - pub fn LLVMRustBuildInvoke( + pub fn LLVMRustBuildInvoke<'a>( B: &Builder<'a>, Ty: &'a Type, Fn: &'a Value, @@ -1247,239 +1251,239 @@ extern "C" { Bundle: Option<&OperandBundleDef<'a>>, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildLandingPad( + pub fn LLVMBuildLandingPad<'a>( B: &Builder<'a>, Ty: &'a Type, PersFn: Option<&'a Value>, NumClauses: c_uint, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value; - pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value; + pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value; + pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value; - pub fn LLVMRustBuildCleanupPad( + pub fn LLVMRustBuildCleanupPad<'a>( B: &Builder<'a>, ParentPad: Option<&'a Value>, ArgCnt: c_uint, Args: *const &'a Value, Name: *const c_char, ) -> Option<&'a Value>; - pub fn LLVMRustBuildCleanupRet( + pub fn LLVMRustBuildCleanupRet<'a>( B: &Builder<'a>, CleanupPad: &'a Value, UnwindBB: Option<&'a BasicBlock>, ) -> Option<&'a Value>; - pub fn LLVMRustBuildCatchPad( + pub fn LLVMRustBuildCatchPad<'a>( B: &Builder<'a>, ParentPad: &'a Value, ArgCnt: c_uint, Args: *const &'a Value, Name: *const c_char, ) -> Option<&'a Value>; - pub fn LLVMRustBuildCatchRet( + pub fn LLVMRustBuildCatchRet<'a>( B: &Builder<'a>, Pad: &'a Value, BB: &'a BasicBlock, ) -> Option<&'a Value>; - pub fn LLVMRustBuildCatchSwitch( + pub fn LLVMRustBuildCatchSwitch<'a>( Builder: &Builder<'a>, ParentPad: Option<&'a Value>, BB: Option<&'a BasicBlock>, NumHandlers: c_uint, Name: *const c_char, ) -> Option<&'a Value>; - pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock); - pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value); + pub fn LLVMRustAddHandler<'a>(CatchSwitch: &'a Value, Handler: &'a BasicBlock); + pub fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value); // Add a case to the switch instruction - pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock); + pub fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock); // Add a clause to the landing pad instruction - pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value); + pub fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value); // Set the cleanup on a landing pad instruction pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool); // Arithmetic - pub fn LLVMBuildAdd( + pub fn LLVMBuildAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFAdd( + pub fn LLVMBuildFAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildSub( + pub fn LLVMBuildSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFSub( + pub fn LLVMBuildFSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildMul( + pub fn LLVMBuildMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFMul( + pub fn LLVMBuildFMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildUDiv( + pub fn LLVMBuildUDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildExactUDiv( + pub fn LLVMBuildExactUDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildSDiv( + pub fn LLVMBuildSDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildExactSDiv( + pub fn LLVMBuildExactSDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFDiv( + pub fn LLVMBuildFDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildURem( + pub fn LLVMBuildURem<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildSRem( + pub fn LLVMBuildSRem<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFRem( + pub fn LLVMBuildFRem<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildShl( + pub fn LLVMBuildShl<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildLShr( + pub fn LLVMBuildLShr<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildAShr( + pub fn LLVMBuildAShr<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildNSWAdd( + pub fn LLVMBuildNSWAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildNUWAdd( + pub fn LLVMBuildNUWAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildNSWSub( + pub fn LLVMBuildNSWSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildNUWSub( + pub fn LLVMBuildNUWSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildNSWMul( + pub fn LLVMBuildNSWMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildNUWMul( + pub fn LLVMBuildNUWMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildAnd( + pub fn LLVMBuildAnd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildOr( + pub fn LLVMBuildOr<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildXor( + pub fn LLVMBuildXor<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; - pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; - pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildFNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; pub fn LLVMRustSetFastMath(Instr: &Value); // Memory - pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; - pub fn LLVMBuildArrayAlloca( + pub fn LLVMBuildAlloca<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildArrayAlloca<'a>( B: &Builder<'a>, Ty: &'a Type, Val: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildLoad2( + pub fn LLVMBuildLoad2<'a>( B: &Builder<'a>, Ty: &'a Type, PointerVal: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value; + pub fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value; - pub fn LLVMBuildGEP2( + pub fn LLVMBuildGEP2<'a>( B: &Builder<'a>, Ty: &'a Type, Pointer: &'a Value, @@ -1487,7 +1491,7 @@ extern "C" { NumIndices: c_uint, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildInBoundsGEP2( + pub fn LLVMBuildInBoundsGEP2<'a>( B: &Builder<'a>, Ty: &'a Type, Pointer: &'a Value, @@ -1495,7 +1499,7 @@ extern "C" { NumIndices: c_uint, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildStructGEP2( + pub fn LLVMBuildStructGEP2<'a>( B: &Builder<'a>, Ty: &'a Type, Pointer: &'a Value, @@ -1504,85 +1508,85 @@ extern "C" { ) -> &'a Value; // Casts - pub fn LLVMBuildTrunc( + pub fn LLVMBuildTrunc<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildZExt( + pub fn LLVMBuildZExt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildSExt( + pub fn LLVMBuildSExt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFPToUI( + pub fn LLVMBuildFPToUI<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFPToSI( + pub fn LLVMBuildFPToSI<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildUIToFP( + pub fn LLVMBuildUIToFP<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildSIToFP( + pub fn LLVMBuildSIToFP<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFPTrunc( + pub fn LLVMBuildFPTrunc<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFPExt( + pub fn LLVMBuildFPExt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildPtrToInt( + pub fn LLVMBuildPtrToInt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildIntToPtr( + pub fn LLVMBuildIntToPtr<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildBitCast( + pub fn LLVMBuildBitCast<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildPointerCast( + pub fn LLVMBuildPointerCast<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMRustBuildIntCast( + pub fn LLVMRustBuildIntCast<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, @@ -1590,14 +1594,14 @@ extern "C" { ) -> &'a Value; // Comparisons - pub fn LLVMBuildICmp( + pub fn LLVMBuildICmp<'a>( B: &Builder<'a>, Op: c_uint, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildFCmp( + pub fn LLVMBuildFCmp<'a>( B: &Builder<'a>, Op: c_uint, LHS: &'a Value, @@ -1606,9 +1610,9 @@ extern "C" { ) -> &'a Value; // Miscellaneous instructions - pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; - pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value; - pub fn LLVMRustBuildCall( + pub fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; + pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value; + pub fn LLVMRustBuildCall<'a>( B: &Builder<'a>, Ty: &'a Type, Fn: &'a Value, @@ -1616,7 +1620,7 @@ extern "C" { NumArgs: c_uint, Bundle: Option<&OperandBundleDef<'a>>, ) -> &'a Value; - pub fn LLVMRustBuildMemCpy( + pub fn LLVMRustBuildMemCpy<'a>( B: &Builder<'a>, Dst: &'a Value, DstAlign: c_uint, @@ -1625,7 +1629,7 @@ extern "C" { Size: &'a Value, IsVolatile: bool, ) -> &'a Value; - pub fn LLVMRustBuildMemMove( + pub fn LLVMRustBuildMemMove<'a>( B: &Builder<'a>, Dst: &'a Value, DstAlign: c_uint, @@ -1634,7 +1638,7 @@ extern "C" { Size: &'a Value, IsVolatile: bool, ) -> &'a Value; - pub fn LLVMRustBuildMemSet( + pub fn LLVMRustBuildMemSet<'a>( B: &Builder<'a>, Dst: &'a Value, DstAlign: c_uint, @@ -1642,46 +1646,46 @@ extern "C" { Size: &'a Value, IsVolatile: bool, ) -> &'a Value; - pub fn LLVMBuildSelect( + pub fn LLVMBuildSelect<'a>( B: &Builder<'a>, If: &'a Value, Then: &'a Value, Else: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildVAArg( + pub fn LLVMBuildVAArg<'a>( B: &Builder<'a>, list: &'a Value, Ty: &'a Type, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildExtractElement( + pub fn LLVMBuildExtractElement<'a>( B: &Builder<'a>, VecVal: &'a Value, Index: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildInsertElement( + pub fn LLVMBuildInsertElement<'a>( B: &Builder<'a>, VecVal: &'a Value, EltVal: &'a Value, Index: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildShuffleVector( + pub fn LLVMBuildShuffleVector<'a>( B: &Builder<'a>, V1: &'a Value, V2: &'a Value, Mask: &'a Value, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildExtractValue( + pub fn LLVMBuildExtractValue<'a>( B: &Builder<'a>, AggVal: &'a Value, Index: c_uint, Name: *const c_char, ) -> &'a Value; - pub fn LLVMBuildInsertValue( + pub fn LLVMBuildInsertValue<'a>( B: &Builder<'a>, AggVal: &'a Value, EltVal: &'a Value, @@ -1689,41 +1693,47 @@ extern "C" { Name: *const c_char, ) -> &'a Value; - pub fn LLVMRustBuildVectorReduceFAdd( + pub fn LLVMRustBuildVectorReduceFAdd<'a>( B: &Builder<'a>, Acc: &'a Value, Src: &'a Value, ) -> &'a Value; - pub fn LLVMRustBuildVectorReduceFMul( + pub fn LLVMRustBuildVectorReduceFMul<'a>( B: &Builder<'a>, Acc: &'a Value, Src: &'a Value, ) -> &'a Value; - pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub fn LLVMRustBuildVectorReduceMin( + pub fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceMin<'a>( B: &Builder<'a>, Src: &'a Value, IsSigned: bool, ) -> &'a Value; - pub fn LLVMRustBuildVectorReduceMax( + pub fn LLVMRustBuildVectorReduceMax<'a>( B: &Builder<'a>, Src: &'a Value, IsSigned: bool, ) -> &'a Value; - pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool) - -> &'a Value; - pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool) - -> &'a Value; + pub fn LLVMRustBuildVectorReduceFMin<'a>( + B: &Builder<'a>, + Src: &'a Value, + IsNaN: bool, + ) -> &'a Value; + pub fn LLVMRustBuildVectorReduceFMax<'a>( + B: &Builder<'a>, + Src: &'a Value, + IsNaN: bool, + ) -> &'a Value; - pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; - pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; + pub fn LLVMRustBuildMinNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; + pub fn LLVMRustBuildMaxNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; // Atomic Operations - pub fn LLVMRustBuildAtomicLoad( + pub fn LLVMRustBuildAtomicLoad<'a>( B: &Builder<'a>, ElementType: &'a Type, PointerVal: &'a Value, @@ -1731,14 +1741,14 @@ extern "C" { Order: AtomicOrdering, ) -> &'a Value; - pub fn LLVMRustBuildAtomicStore( + pub fn LLVMRustBuildAtomicStore<'a>( B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value, Order: AtomicOrdering, ) -> &'a Value; - pub fn LLVMRustBuildAtomicCmpXchg( + pub fn LLVMRustBuildAtomicCmpXchg<'a>( B: &Builder<'a>, LHS: &'a Value, CMP: &'a Value, @@ -1748,7 +1758,7 @@ extern "C" { Weak: Bool, ) -> &'a Value; - pub fn LLVMBuildAtomicRMW( + pub fn LLVMBuildAtomicRMW<'a>( B: &Builder<'a>, Op: AtomicRmwBinOp, LHS: &'a Value, @@ -1767,16 +1777,16 @@ extern "C" { pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int; /// Creates a pass manager. - pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>; + pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>; /// Creates a function-by-function pass manager - pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>; + pub fn LLVMCreateFunctionPassManagerForModule(M: &Module) -> &mut PassManager<'_>; /// Disposes a pass manager. - pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>); + pub fn LLVMDisposePassManager<'a>(PM: &'a mut PassManager<'a>); /// Runs a pass manager on a module. - pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool; + pub fn LLVMRunPassManager<'a>(PM: &PassManager<'a>, M: &'a Module) -> Bool; pub fn LLVMInitializePasses(); @@ -1786,7 +1796,7 @@ extern "C" { pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char); - pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>); + pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>); pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder; pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder); @@ -1830,7 +1840,7 @@ extern "C" { pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type; - pub fn LLVMStructSetBody( + pub fn LLVMStructSetBody<'a>( StructTy: &'a Type, ElementTypes: *const &'a Type, ElementCount: c_uint, @@ -1873,8 +1883,7 @@ extern "C" { BufferOut: &RustString, ); - pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char) - -> &'a Value; + pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &Value, FuncName: *const c_char) -> &Value; pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64; pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64; @@ -1895,15 +1904,15 @@ extern "C" { pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32); - pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value; + pub fn LLVMRustMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value; - pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>; + pub fn LLVMRustDIBuilderCreate(M: &Module) -> &mut DIBuilder<'_>; - pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>); + pub fn LLVMRustDIBuilderDispose<'a>(Builder: &'a mut DIBuilder<'a>); pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>); - pub fn LLVMRustDIBuilderCreateCompileUnit( + pub fn LLVMRustDIBuilderCreateCompileUnit<'a>( Builder: &DIBuilder<'a>, Lang: c_uint, File: &'a DIFile, @@ -1919,7 +1928,7 @@ extern "C" { SplitDebugInlining: bool, ) -> &'a DIDescriptor; - pub fn LLVMRustDIBuilderCreateFile( + pub fn LLVMRustDIBuilderCreateFile<'a>( Builder: &DIBuilder<'a>, Filename: *const c_char, FilenameLen: size_t, @@ -1930,12 +1939,12 @@ extern "C" { ChecksumLen: size_t, ) -> &'a DIFile; - pub fn LLVMRustDIBuilderCreateSubroutineType( + pub fn LLVMRustDIBuilderCreateSubroutineType<'a>( Builder: &DIBuilder<'a>, ParameterTypes: &'a DIArray, ) -> &'a DICompositeType; - pub fn LLVMRustDIBuilderCreateFunction( + pub fn LLVMRustDIBuilderCreateFunction<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIDescriptor, Name: *const c_char, @@ -1953,7 +1962,7 @@ extern "C" { Decl: Option<&'a DIDescriptor>, ) -> &'a DISubprogram; - pub fn LLVMRustDIBuilderCreateBasicType( + pub fn LLVMRustDIBuilderCreateBasicType<'a>( Builder: &DIBuilder<'a>, Name: *const c_char, NameLen: size_t, @@ -1961,7 +1970,7 @@ extern "C" { Encoding: c_uint, ) -> &'a DIBasicType; - pub fn LLVMRustDIBuilderCreateTypedef( + pub fn LLVMRustDIBuilderCreateTypedef<'a>( Builder: &DIBuilder<'a>, Type: &'a DIBasicType, Name: *const c_char, @@ -1971,7 +1980,7 @@ extern "C" { Scope: Option<&'a DIScope>, ) -> &'a DIDerivedType; - pub fn LLVMRustDIBuilderCreatePointerType( + pub fn LLVMRustDIBuilderCreatePointerType<'a>( Builder: &DIBuilder<'a>, PointeeTy: &'a DIType, SizeInBits: u64, @@ -1981,7 +1990,7 @@ extern "C" { NameLen: size_t, ) -> &'a DIDerivedType; - pub fn LLVMRustDIBuilderCreateStructType( + pub fn LLVMRustDIBuilderCreateStructType<'a>( Builder: &DIBuilder<'a>, Scope: Option<&'a DIDescriptor>, Name: *const c_char, @@ -1999,7 +2008,7 @@ extern "C" { UniqueIdLen: size_t, ) -> &'a DICompositeType; - pub fn LLVMRustDIBuilderCreateMemberType( + pub fn LLVMRustDIBuilderCreateMemberType<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIDescriptor, Name: *const c_char, @@ -2013,7 +2022,7 @@ extern "C" { Ty: &'a DIType, ) -> &'a DIDerivedType; - pub fn LLVMRustDIBuilderCreateVariantMemberType( + pub fn LLVMRustDIBuilderCreateVariantMemberType<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, Name: *const c_char, @@ -2028,7 +2037,7 @@ extern "C" { Ty: &'a DIType, ) -> &'a DIType; - pub fn LLVMRustDIBuilderCreateLexicalBlock( + pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, File: &'a DIFile, @@ -2036,13 +2045,13 @@ extern "C" { Col: c_uint, ) -> &'a DILexicalBlock; - pub fn LLVMRustDIBuilderCreateLexicalBlockFile( + pub fn LLVMRustDIBuilderCreateLexicalBlockFile<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, File: &'a DIFile, ) -> &'a DILexicalBlock; - pub fn LLVMRustDIBuilderCreateStaticVariable( + pub fn LLVMRustDIBuilderCreateStaticVariable<'a>( Builder: &DIBuilder<'a>, Context: Option<&'a DIScope>, Name: *const c_char, @@ -2058,7 +2067,7 @@ extern "C" { AlignInBits: u32, ) -> &'a DIGlobalVariableExpression; - pub fn LLVMRustDIBuilderCreateVariable( + pub fn LLVMRustDIBuilderCreateVariable<'a>( Builder: &DIBuilder<'a>, Tag: c_uint, Scope: &'a DIDescriptor, @@ -2073,7 +2082,7 @@ extern "C" { AlignInBits: u32, ) -> &'a DIVariable; - pub fn LLVMRustDIBuilderCreateArrayType( + pub fn LLVMRustDIBuilderCreateArrayType<'a>( Builder: &DIBuilder<'a>, Size: u64, AlignInBits: u32, @@ -2081,19 +2090,19 @@ extern "C" { Subscripts: &'a DIArray, ) -> &'a DIType; - pub fn LLVMRustDIBuilderGetOrCreateSubrange( + pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>( Builder: &DIBuilder<'a>, Lo: i64, Count: i64, ) -> &'a DISubrange; - pub fn LLVMRustDIBuilderGetOrCreateArray( + pub fn LLVMRustDIBuilderGetOrCreateArray<'a>( Builder: &DIBuilder<'a>, Ptr: *const Option<&'a DIDescriptor>, Count: c_uint, ) -> &'a DIArray; - pub fn LLVMRustDIBuilderInsertDeclareAtEnd( + pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>( Builder: &DIBuilder<'a>, Val: &'a Value, VarInfo: &'a DIVariable, @@ -2103,7 +2112,7 @@ extern "C" { InsertAtEnd: &'a BasicBlock, ) -> &'a Value; - pub fn LLVMRustDIBuilderCreateEnumerator( + pub fn LLVMRustDIBuilderCreateEnumerator<'a>( Builder: &DIBuilder<'a>, Name: *const c_char, NameLen: size_t, @@ -2111,7 +2120,7 @@ extern "C" { IsUnsigned: bool, ) -> &'a DIEnumerator; - pub fn LLVMRustDIBuilderCreateEnumerationType( + pub fn LLVMRustDIBuilderCreateEnumerationType<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, Name: *const c_char, @@ -2125,7 +2134,7 @@ extern "C" { IsScoped: bool, ) -> &'a DIType; - pub fn LLVMRustDIBuilderCreateUnionType( + pub fn LLVMRustDIBuilderCreateUnionType<'a>( Builder: &DIBuilder<'a>, Scope: Option<&'a DIScope>, Name: *const c_char, @@ -2141,7 +2150,7 @@ extern "C" { UniqueIdLen: size_t, ) -> &'a DIType; - pub fn LLVMRustDIBuilderCreateVariantPart( + pub fn LLVMRustDIBuilderCreateVariantPart<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, Name: *const c_char, @@ -2159,7 +2168,7 @@ extern "C" { pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr); - pub fn LLVMRustDIBuilderCreateTemplateTypeParameter( + pub fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>( Builder: &DIBuilder<'a>, Scope: Option<&'a DIScope>, Name: *const c_char, @@ -2167,7 +2176,7 @@ extern "C" { Ty: &'a DIType, ) -> &'a DITemplateTypeParameter; - pub fn LLVMRustDIBuilderCreateNameSpace( + pub fn LLVMRustDIBuilderCreateNameSpace<'a>( Builder: &DIBuilder<'a>, Scope: Option<&'a DIScope>, Name: *const c_char, @@ -2175,14 +2184,14 @@ extern "C" { ExportSymbols: bool, ) -> &'a DINameSpace; - pub fn LLVMRustDICompositeTypeReplaceArrays( + pub fn LLVMRustDICompositeTypeReplaceArrays<'a>( Builder: &DIBuilder<'a>, CompositeType: &'a DIType, Elements: Option<&'a DIArray>, Params: Option<&'a DIArray>, ); - pub fn LLVMRustDIBuilderCreateDebugLocation( + pub fn LLVMRustDIBuilderCreateDebugLocation<'a>( Line: c_uint, Column: c_uint, Scope: &'a DIScope, @@ -2248,7 +2257,7 @@ extern "C" { SplitDwarfFile: *const c_char, ) -> Option<&'static mut TargetMachine>; pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); - pub fn LLVMRustAddBuilderLibraryInfo( + pub fn LLVMRustAddBuilderLibraryInfo<'a>( PMB: &'a PassManagerBuilder, M: &'a Module, DisableSimplifyLibCalls: bool, @@ -2264,13 +2273,13 @@ extern "C" { PGOUsePath: *const c_char, PGOSampleUsePath: *const c_char, ); - pub fn LLVMRustAddLibraryInfo( + pub fn LLVMRustAddLibraryInfo<'a>( PM: &PassManager<'a>, M: &'a Module, DisableSimplifyLibCalls: bool, ); - pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module); - pub fn LLVMRustWriteOutputFile( + pub fn LLVMRustRunFunctionPassManager<'a>(PM: &PassManager<'a>, M: &'a Module); + pub fn LLVMRustWriteOutputFile<'a>( T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module, @@ -2278,7 +2287,7 @@ extern "C" { DwoOutput: *const c_char, FileType: FileType, ) -> LLVMRustResult; - pub fn LLVMRustOptimizeWithNewPassManager( + pub fn LLVMRustOptimizeWithNewPassManager<'a>( M: &'a Module, TM: &'a TargetMachine, OptLevel: PassBuilderOptLevel, @@ -2306,7 +2315,7 @@ extern "C" { ExtraPassesLen: size_t, ) -> LLVMRustResult; pub fn LLVMRustPrintModule( - M: &'a Module, + M: &Module, Output: *const c_char, Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t, ) -> LLVMRustResult; @@ -2319,21 +2328,21 @@ extern "C" { pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module); pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>; - pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>; - pub fn LLVMRustArchiveIteratorNext( + pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>; + pub fn LLVMRustArchiveIteratorNext<'a>( AIR: &ArchiveIterator<'a>, ) -> Option<&'a mut ArchiveChild<'a>>; pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char; pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char; - pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>); - pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>); + pub fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>); + pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>); pub fn LLVMRustDestroyArchive(AR: &'static mut Archive); #[allow(improper_ctypes)] pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString); #[allow(improper_ctypes)] - pub fn LLVMRustUnpackOptimizationDiagnostic( + pub fn LLVMRustUnpackOptimizationDiagnostic<'a>( DI: &'a DiagnosticInfo, pass_name_out: &RustString, function_out: &mut Option<&'a Value>, @@ -2343,7 +2352,7 @@ extern "C" { message_out: &RustString, ); - pub fn LLVMRustUnpackInlineAsmDiagnostic( + pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>( DI: &'a DiagnosticInfo, level_out: &mut DiagnosticLevel, cookie_out: &mut c_uint, @@ -2354,7 +2363,7 @@ extern "C" { pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString); pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind; - pub fn LLVMRustGetSMDiagnostic( + pub fn LLVMRustGetSMDiagnostic<'a>( DI: &'a DiagnosticInfo, cookie_out: &mut c_uint, ) -> &'a SMDiagnostic; @@ -2383,12 +2392,12 @@ extern "C" { WriteSymbtab: bool, Kind: ArchiveKind, ) -> LLVMRustResult; - pub fn LLVMRustArchiveMemberNew( + pub fn LLVMRustArchiveMemberNew<'a>( Filename: *const c_char, Name: *const c_char, Child: Option<&ArchiveChild<'a>>, ) -> &'a mut RustArchiveMember<'a>; - pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>); + pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>); pub fn LLVMRustWriteImportLibrary( ImportName: *const c_char, @@ -2399,18 +2408,18 @@ extern "C" { MinGW: bool, ) -> LLVMRustResult; - pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine); + pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine); - pub fn LLVMRustBuildOperandBundleDef( + pub fn LLVMRustBuildOperandBundleDef<'a>( Name: *const c_char, Inputs: *const &'a Value, NumInputs: c_uint, ) -> &'a mut OperandBundleDef<'a>; - pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>); + pub fn LLVMRustFreeOperandBundleDef<'a>(Bundle: &'a mut OperandBundleDef<'a>); - pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock); + pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock); - pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t); + pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t); pub fn LLVMRustUnsetComdat(V: &Value); pub fn LLVMRustSetModulePICLevel(M: &Module); pub fn LLVMRustSetModulePIELevel(M: &Module); @@ -2463,13 +2472,13 @@ extern "C" { pub fn LLVMRustLTOGetDICompileUnit(M: &Module, CU1: &mut *mut c_void, CU2: &mut *mut c_void); pub fn LLVMRustLTOPatchDICompileUnit(M: &Module, CU: *mut c_void); - pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>; + pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>; pub fn LLVMRustLinkerAdd( linker: &Linker<'_>, bytecode: *const c_char, bytecode_len: usize, ) -> bool; - pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>); + pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>); #[allow(improper_ctypes)] pub fn LLVMRustComputeLTOCacheKey( key_out: &RustString, diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index c1521a760b00..a1117a11fc7c 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -31,13 +31,13 @@ impl LLVMRustResult { } } -pub fn AddFunctionAttrStringValue(llfn: &'a Value, idx: AttributePlace, attr: &CStr, value: &CStr) { +pub fn AddFunctionAttrStringValue(llfn: &Value, idx: AttributePlace, attr: &CStr, value: &CStr) { unsafe { LLVMRustAddFunctionAttrStringValue(llfn, idx.as_uint(), attr.as_ptr(), value.as_ptr()) } } -pub fn AddFunctionAttrString(llfn: &'a Value, idx: AttributePlace, attr: &CStr) { +pub fn AddFunctionAttrString(llfn: &Value, idx: AttributePlace, attr: &CStr) { unsafe { LLVMRustAddFunctionAttrStringValue(llfn, idx.as_uint(), attr.as_ptr(), std::ptr::null()) } @@ -86,12 +86,12 @@ impl FromStr for ArchiveKind { } } -pub fn SetInstructionCallConv(instr: &'a Value, cc: CallConv) { +pub fn SetInstructionCallConv(instr: &Value, cc: CallConv) { unsafe { LLVMSetInstructionCallConv(instr, cc as c_uint); } } -pub fn SetFunctionCallConv(fn_: &'a Value, cc: CallConv) { +pub fn SetFunctionCallConv(fn_: &Value, cc: CallConv) { unsafe { LLVMSetFunctionCallConv(fn_, cc as c_uint); } @@ -103,26 +103,26 @@ pub fn SetFunctionCallConv(fn_: &'a Value, cc: CallConv) { // value's name as the comdat value to make sure that it is in a 1-to-1 relationship to the // function. // For more details on COMDAT sections see e.g., https://www.airs.com/blog/archives/52 -pub fn SetUniqueComdat(llmod: &Module, val: &'a Value) { +pub fn SetUniqueComdat(llmod: &Module, val: &Value) { unsafe { let name = get_value_name(val); LLVMRustSetComdat(llmod, val, name.as_ptr().cast(), name.len()); } } -pub fn UnsetComdat(val: &'a Value) { +pub fn UnsetComdat(val: &Value) { unsafe { LLVMRustUnsetComdat(val); } } -pub fn SetUnnamedAddress(global: &'a Value, unnamed: UnnamedAddr) { +pub fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) { unsafe { LLVMSetUnnamedAddress(global, unnamed); } } -pub fn set_thread_local_mode(global: &'a Value, mode: ThreadLocalMode) { +pub fn set_thread_local_mode(global: &Value, mode: ThreadLocalMode) { unsafe { LLVMSetThreadLocalMode(global, mode); } @@ -264,7 +264,7 @@ pub struct OperandBundleDef<'a> { pub raw: &'a mut ffi::OperandBundleDef<'a>, } -impl OperandBundleDef<'a> { +impl<'a> OperandBundleDef<'a> { pub fn new(name: &str, vals: &[&'a Value]) -> Self { let name = SmallCStr::new(name); let def = unsafe { @@ -274,7 +274,7 @@ impl OperandBundleDef<'a> { } } -impl Drop for OperandBundleDef<'a> { +impl Drop for OperandBundleDef<'_> { fn drop(&mut self) { unsafe { LLVMRustFreeOperandBundleDef(&mut *(self.raw as *mut _)); diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index 88498cf47d8b..a3053742aad9 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -13,7 +13,7 @@ use rustc_session::config::CrateType; use rustc_target::spec::RelocModel; use tracing::debug; -impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> { fn predefine_static( &self, def_id: DefId, @@ -92,7 +92,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> { } } -impl CodegenCx<'ll, 'tcx> { +impl CodegenCx<'_, '_> { /// Whether a definition or declaration can be assumed to be local to a group of /// libraries that form a single DSO or executable. pub(crate) unsafe fn should_assume_dso_local( diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index 2ae0a08f192d..21b77f7dea6f 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -38,7 +38,7 @@ impl fmt::Debug for Type { } } -impl CodegenCx<'ll, 'tcx> { +impl<'ll> CodegenCx<'ll, '_> { crate fn type_named_struct(&self, name: &str) -> &'ll Type { let name = SmallCStr::new(name); unsafe { llvm::LLVMStructCreateNamed(self.llcx, name.as_ptr()) } @@ -133,7 +133,7 @@ impl CodegenCx<'ll, 'tcx> { } } -impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn type_i1(&self) -> &'ll Type { unsafe { llvm::LLVMInt1TypeInContext(self.llcx) } } @@ -252,7 +252,7 @@ impl Type { } } -impl LayoutTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl<'ll, 'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn backend_type(&self, layout: TyAndLayout<'tcx>) -> &'ll Type { layout.llvm_type(self) } diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index 591f659f11bf..f090ae6ecb46 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -11,8 +11,8 @@ use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; use rustc_middle::ty::Ty; use rustc_target::abi::{Align, Endian, HasDataLayout, Size}; -fn round_pointer_up_to_alignment( - bx: &mut Builder<'a, 'll, 'tcx>, +fn round_pointer_up_to_alignment<'ll>( + bx: &mut Builder<'_, 'll, '_>, addr: &'ll Value, align: Align, ptr_ty: &'ll Type, @@ -23,8 +23,8 @@ fn round_pointer_up_to_alignment( bx.inttoptr(ptr_as_int, ptr_ty) } -fn emit_direct_ptr_va_arg( - bx: &mut Builder<'a, 'll, 'tcx>, +fn emit_direct_ptr_va_arg<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, llty: &'ll Type, size: Size, @@ -62,8 +62,8 @@ fn emit_direct_ptr_va_arg( } } -fn emit_ptr_va_arg( - bx: &mut Builder<'a, 'll, 'tcx>, +fn emit_ptr_va_arg<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, target_ty: Ty<'tcx>, indirect: bool, @@ -90,8 +90,8 @@ fn emit_ptr_va_arg( } } -fn emit_aapcs_va_arg( - bx: &mut Builder<'a, 'll, 'tcx>, +fn emit_aapcs_va_arg<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, target_ty: Ty<'tcx>, ) -> &'ll Value { @@ -175,8 +175,8 @@ fn emit_aapcs_va_arg( val } -pub(super) fn emit_va_arg( - bx: &mut Builder<'a, 'll, 'tcx>, +pub(super) fn emit_va_arg<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, addr: OperandRef<'tcx, &'ll Value>, target_ty: Ty<'tcx>, ) -> &'ll Value {