From 4cf21866e8f18449ea0c41ee1ba031c05419d94c Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 15 Feb 2025 15:18:19 -0500 Subject: Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer --- src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs | 3 ++- src/tools/rust-analyzer/crates/hir-def/src/lib.rs | 6 ++++++ src/tools/rust-analyzer/crates/hir-ty/src/layout.rs | 9 +++++---- src/tools/rust-analyzer/crates/hir-ty/src/lib.rs | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/tools/rust-analyzer') diff --git a/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs b/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs index 8fc19854033..5d1834a8642 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs @@ -9,6 +9,7 @@ use hir_expand::name::Name; use intern::sym; use la_arena::Arena; use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions}; +use rustc_hashes::Hash64; use triomphe::Arc; use tt::iter::TtElement; @@ -172,7 +173,7 @@ fn parse_repr_tt(tt: &TopSubtree) -> Option { } } - Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: 0 }) + Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: Hash64::ZERO }) } impl StructData { diff --git a/src/tools/rust-analyzer/crates/hir-def/src/lib.rs b/src/tools/rust-analyzer/crates/hir-def/src/lib.rs index c8efd904320..9c947df35e9 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/lib.rs @@ -18,9 +18,15 @@ extern crate ra_ap_rustc_parse_format as rustc_parse_format; #[cfg(feature = "in-rust-tree")] extern crate rustc_abi; +#[cfg(feature = "in-rust-tree")] +extern crate rustc_hashes; + #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_abi as rustc_abi; +#[cfg(not(feature = "in-rust-tree"))] +extern crate ra_ap_rustc_hashes as rustc_hashes; + pub mod db; pub mod attr; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index 108171586ea..b6f7c44c2ae 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -15,6 +15,7 @@ use hir_def::{ use la_arena::{Idx, RawIdx}; use rustc_abi::AddressSpace; use rustc_index::{IndexSlice, IndexVec}; +use rustc_hashes::Hash64; use triomphe::Arc; @@ -197,7 +198,7 @@ fn layout_of_simd_ty( align, max_repr_align: None, unadjusted_abi_align: align.abi, - randomization_seed: 0, + randomization_seed: Hash64::ZERO, })) } @@ -314,7 +315,7 @@ pub fn layout_of_ty_query( size, max_repr_align: None, unadjusted_abi_align: element.align.abi, - randomization_seed: 0, + randomization_seed: Hash64::ZERO, } } TyKind::Slice(element) => { @@ -328,7 +329,7 @@ pub fn layout_of_ty_query( size: Size::ZERO, max_repr_align: None, unadjusted_abi_align: element.align.abi, - randomization_seed: 0, + randomization_seed: Hash64::ZERO, } } TyKind::Str => Layout { @@ -340,7 +341,7 @@ pub fn layout_of_ty_query( size: Size::ZERO, max_repr_align: None, unadjusted_abi_align: dl.i8_align.abi, - randomization_seed: 0, + randomization_seed: Hash64::ZERO, }, // Potentially-wide pointers. TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs index 55d81875a2b..daddcf0b242 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs @@ -12,6 +12,9 @@ extern crate ra_ap_rustc_index as rustc_index; #[cfg(feature = "in-rust-tree")] extern crate rustc_abi; +#[cfg(feature = "in-rust-tree")] +extern crate rustc_hashes; + #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_abi as rustc_abi; @@ -21,6 +24,9 @@ extern crate rustc_pattern_analysis; #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_pattern_analysis as rustc_pattern_analysis; +#[cfg(not(feature = "in-rust-tree"))] +extern crate ra_ap_rustc_hashes as rustc_hashes; + mod builder; mod chalk_db; mod chalk_ext; -- cgit 1.4.1-3-g733a5 From 7ba3d7b54e7688f6f1a0fd22fe274ee7b06fea3e Mon Sep 17 00:00:00 2001 From: Zachary S Date: Sat, 25 Jan 2025 20:15:24 -0600 Subject: Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited. --- compiler/rustc_abi/src/callconv.rs | 2 -- compiler/rustc_abi/src/layout.rs | 23 +++++++------- compiler/rustc_abi/src/lib.rs | 35 ++++++++++------------ .../rustc_codegen_cranelift/src/value_and_place.rs | 4 +-- compiler/rustc_codegen_gcc/src/intrinsic/mod.rs | 2 +- compiler/rustc_codegen_gcc/src/type_of.rs | 13 ++++---- compiler/rustc_codegen_llvm/src/intrinsic.rs | 2 +- compiler/rustc_codegen_llvm/src/type_of.rs | 13 ++++---- compiler/rustc_codegen_ssa/src/mir/operand.rs | 4 +-- compiler/rustc_const_eval/src/interpret/operand.rs | 2 +- .../rustc_const_eval/src/interpret/validity.rs | 8 ++--- .../src/util/check_validity_requirement.rs | 16 +++++----- compiler/rustc_middle/src/ty/layout.rs | 3 +- compiler/rustc_mir_transform/src/gvn.rs | 5 +++- compiler/rustc_smir/src/rustc_smir/convert/abi.rs | 1 - compiler/rustc_target/src/callconv/loongarch.rs | 2 +- compiler/rustc_target/src/callconv/mod.rs | 3 +- compiler/rustc_target/src/callconv/riscv.rs | 2 +- compiler/rustc_target/src/callconv/x86.rs | 4 +-- compiler/rustc_target/src/callconv/x86_64.rs | 2 -- compiler/rustc_target/src/callconv/x86_win64.rs | 2 +- compiler/rustc_ty_utils/src/abi.rs | 4 +-- compiler/rustc_ty_utils/src/layout.rs | 21 ++++++------- compiler/rustc_ty_utils/src/layout/invariant.rs | 15 ++++++---- compiler/stable_mir/src/abi.rs | 6 +--- .../rust-analyzer/crates/hir-ty/src/layout.rs | 12 ++++---- 26 files changed, 93 insertions(+), 113 deletions(-) (limited to 'src/tools/rust-analyzer') diff --git a/compiler/rustc_abi/src/callconv.rs b/compiler/rustc_abi/src/callconv.rs index 9fb70b80c9e..4529ab8058e 100644 --- a/compiler/rustc_abi/src/callconv.rs +++ b/compiler/rustc_abi/src/callconv.rs @@ -65,8 +65,6 @@ impl<'a, Ty> TyAndLayout<'a, Ty> { Ty: TyAbiInterface<'a, C> + Copy, { match self.backend_repr { - BackendRepr::Uninhabited => Err(Heterogeneous), - // The primitive for this algorithm. BackendRepr::Scalar(scalar) => { let kind = match scalar.primitive() { diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index 45cd0b517f6..53243266f99 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -130,6 +130,7 @@ impl LayoutCalculator { }, backend_repr: BackendRepr::ScalarPair(a, b), largest_niche, + uninhabited: false, align, size, max_repr_align: None, @@ -221,8 +222,9 @@ impl LayoutCalculator { LayoutData { variants: Variants::Empty, fields: FieldsShape::Primitive, - backend_repr: BackendRepr::Uninhabited, + backend_repr: BackendRepr::Memory { sized: true }, largest_niche: None, + uninhabited: true, align: dl.i8_align, size: Size::ZERO, max_repr_align: None, @@ -400,6 +402,7 @@ impl LayoutCalculator { fields: FieldsShape::Union(union_field_count), backend_repr: abi, largest_niche: None, + uninhabited: false, align, size: size.align_to(align.abi), max_repr_align, @@ -447,7 +450,6 @@ impl LayoutCalculator { Scalar::Union { .. } => {} }; match &mut st.backend_repr { - BackendRepr::Uninhabited => {} BackendRepr::Scalar(scalar) => hide_niches(scalar), BackendRepr::ScalarPair(a, b) => { hide_niches(a); @@ -639,9 +641,8 @@ impl LayoutCalculator { let same_size = size == variant_layouts[largest_variant_index].size; let same_align = align == variant_layouts[largest_variant_index].align; - let abi = if variant_layouts.iter().all(|v| v.is_uninhabited()) { - BackendRepr::Uninhabited - } else if same_size && same_align && others_zst { + let uninhabited = variant_layouts.iter().all(|v| v.is_uninhabited()); + let abi = if same_size && same_align && others_zst { match variant_layouts[largest_variant_index].backend_repr { // When the total alignment and size match, we can use the // same ABI as the scalar variant with the reserved niche. @@ -683,6 +684,7 @@ impl LayoutCalculator { }, backend_repr: abi, largest_niche, + uninhabited, size, align, max_repr_align, @@ -853,9 +855,8 @@ impl LayoutCalculator { }; let mut abi = BackendRepr::Memory { sized: true }; - if layout_variants.iter().all(|v| v.is_uninhabited()) { - abi = BackendRepr::Uninhabited; - } else if tag.size(dl) == size { + let uninhabited = layout_variants.iter().all(|v| v.is_uninhabited()); + if tag.size(dl) == size { // Make sure we only use scalar layout when the enum is entirely its // own tag (i.e. it has no padding nor any non-ZST variant fields). abi = BackendRepr::Scalar(tag); @@ -995,6 +996,7 @@ impl LayoutCalculator { memory_index: [0].into(), }, largest_niche, + uninhabited, backend_repr: abi, align, size, @@ -1355,9 +1357,7 @@ impl LayoutCalculator { _ => {} } } - if fields.iter().any(|f| f.is_uninhabited()) { - abi = BackendRepr::Uninhabited; - } + let uninhabited = fields.iter().any(|f| f.is_uninhabited()); let unadjusted_abi_align = if repr.transparent() { match layout_of_single_non_zst_field { @@ -1378,6 +1378,7 @@ impl LayoutCalculator { fields: FieldsShape::Arbitrary { offsets, memory_index }, backend_repr: abi, largest_niche, + uninhabited, align, size, max_repr_align, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index dbb4bed5cdd..14a8a579200 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1404,7 +1404,6 @@ impl AddressSpace { #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] #[cfg_attr(feature = "nightly", derive(HashStable_Generic))] pub enum BackendRepr { - Uninhabited, Scalar(Scalar), ScalarPair(Scalar, Scalar), Vector { @@ -1423,10 +1422,9 @@ impl BackendRepr { #[inline] pub fn is_unsized(&self) -> bool { match *self { - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::ScalarPair(..) - | BackendRepr::Vector { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => { + false + } BackendRepr::Memory { sized } => !sized, } } @@ -1445,12 +1443,6 @@ impl BackendRepr { } } - /// Returns `true` if this is an uninhabited type - #[inline] - pub fn is_uninhabited(&self) -> bool { - matches!(*self, BackendRepr::Uninhabited) - } - /// Returns `true` if this is a scalar type #[inline] pub fn is_scalar(&self) -> bool { @@ -1471,7 +1463,7 @@ impl BackendRepr { BackendRepr::Vector { element, count } => { cx.data_layout().vector_align(element.size(cx) * count) } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => return None, + BackendRepr::Memory { .. } => return None, }) } @@ -1492,7 +1484,7 @@ impl BackendRepr { // to make the size a multiple of align (e.g. for vectors of size 3). (element.size(cx) * count).align_to(self.inherent_align(cx)?.abi) } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => return None, + BackendRepr::Memory { .. } => return None, }) } @@ -1506,9 +1498,7 @@ impl BackendRepr { BackendRepr::Vector { element, count } => { BackendRepr::Vector { element: element.to_union(), count } } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => { - BackendRepr::Memory { sized: true } - } + BackendRepr::Memory { .. } => BackendRepr::Memory { sized: true }, } } @@ -1704,6 +1694,11 @@ pub struct LayoutData { /// The leaf scalar with the largest number of invalid values /// (i.e. outside of its `valid_range`), if it exists. pub largest_niche: Option, + /// Is this type known to be uninhabted? + /// + /// This is separate from BackendRepr, because an uninhabited return type may require special + /// consideration based on its size or other attributes. + pub uninhabited: bool, pub align: AbiAndPrefAlign, pub size: Size, @@ -1735,14 +1730,14 @@ impl LayoutData { /// Returns `true` if this is an aggregate type (including a ScalarPair!) pub fn is_aggregate(&self) -> bool { match self.backend_repr { - BackendRepr::Uninhabited | BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => false, BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => true, } } /// Returns `true` if this is an uninhabited type pub fn is_uninhabited(&self) -> bool { - self.backend_repr.is_uninhabited() + self.uninhabited } pub fn scalar(cx: &C, scalar: Scalar) -> Self { @@ -1778,6 +1773,7 @@ impl LayoutData { fields: FieldsShape::Primitive, backend_repr: BackendRepr::Scalar(scalar), largest_niche, + uninhabited: false, size, align, max_repr_align: None, @@ -1802,6 +1798,7 @@ where backend_repr, fields, largest_niche, + uninhabited, variants, max_repr_align, unadjusted_abi_align, @@ -1813,6 +1810,7 @@ where .field("abi", backend_repr) .field("fields", fields) .field("largest_niche", largest_niche) + .field("uninhabited", uninhabited) .field("variants", variants) .field("max_repr_align", max_repr_align) .field("unadjusted_abi_align", unadjusted_abi_align) @@ -1877,7 +1875,6 @@ impl LayoutData { BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => { false } - BackendRepr::Uninhabited => self.size.bytes() == 0, BackendRepr::Memory { sized } => sized && self.size.bytes() == 0, } } diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs index a9b8e1bd393..1b3f86c8405 100644 --- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs +++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs @@ -638,9 +638,7 @@ impl<'tcx> CPlace<'tcx> { } CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self), CPlaceInner::Addr(to_ptr, None) => { - if dst_layout.size == Size::ZERO - || dst_layout.backend_repr == BackendRepr::Uninhabited - { + if dst_layout.size == Size::ZERO { return; } diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index 5322b731d8b..433868e238a 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -315,7 +315,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc let layout = self.layout_of(tp_ty).layout; let _use_integer_compare = match layout.backend_repr() { Scalar(_) | ScalarPair(_, _) => true, - Uninhabited | Vector { .. } => false, + Vector { .. } => false, Memory { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), diff --git a/compiler/rustc_codegen_gcc/src/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs index 8b8b54753e7..bac4fc51300 100644 --- a/compiler/rustc_codegen_gcc/src/type_of.rs +++ b/compiler/rustc_codegen_gcc/src/type_of.rs @@ -84,7 +84,7 @@ fn uncached_gcc_type<'gcc, 'tcx>( false, ); } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {} + BackendRepr::Memory { .. } => {} } let name = match *layout.ty.kind() { @@ -179,19 +179,16 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { fn is_gcc_immediate(&self) -> bool { match self.backend_repr { BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true, - BackendRepr::ScalarPair(..) | BackendRepr::Uninhabited | BackendRepr::Memory { .. } => { - false - } + BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, } } fn is_gcc_scalar_pair(&self) -> bool { match self.backend_repr { BackendRepr::ScalarPair(..) => true, - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::Vector { .. } - | BackendRepr::Memory { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => { + false + } } } diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 7e1a9d361e6..f68365f6c69 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -476,7 +476,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { let layout = self.layout_of(tp_ty).layout; let use_integer_compare = match layout.backend_repr() { Scalar(_) | ScalarPair(_, _) => true, - Uninhabited | Vector { .. } => false, + Vector { .. } => false, Memory { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index b0b6da869da..ba01fbff385 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -23,7 +23,7 @@ fn uncached_llvm_type<'a, 'tcx>( let element = layout.scalar_llvm_type_at(cx, element); return cx.type_vector(element, count); } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } | BackendRepr::ScalarPair(..) => {} + BackendRepr::Memory { .. } | BackendRepr::ScalarPair(..) => {} } let name = match layout.ty.kind() { @@ -172,19 +172,16 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { fn is_llvm_immediate(&self) -> bool { match self.backend_repr { BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true, - BackendRepr::ScalarPair(..) | BackendRepr::Uninhabited | BackendRepr::Memory { .. } => { - false - } + BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, } } fn is_llvm_scalar_pair(&self) -> bool { match self.backend_repr { BackendRepr::ScalarPair(..) => true, - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::Vector { .. } - | BackendRepr::Memory { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => { + false + } } } diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index 958a52a2cb1..faf1300e473 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -422,9 +422,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { See ", ); } - BackendRepr::Uninhabited - | BackendRepr::ScalarPair(_, _) - | BackendRepr::Memory { sized: false } => bug!(), + BackendRepr::ScalarPair(_, _) | BackendRepr::Memory { sized: false } => bug!(), }) }; diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 5d905cff1f2..36da9037e43 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -385,7 +385,7 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> { (Immediate::Uninit, _) => Immediate::Uninit, // If the field is uninhabited, we can forget the data (can happen in ConstProp). // `enum S { A(!), B, C }` is an example of an enum with Scalar layout that - // has an `Uninhabited` variant, which means this case is possible. + // has an uninhabited variant, which means this case is possible. _ if layout.is_uninhabited() => Immediate::Uninit, // the field contains no information, can be left uninit // (Scalar/ScalarPair can contain even aligned ZST, not just 1-ZST) diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 0ac34f4633b..3667cc84d70 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -1274,11 +1274,11 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt, // FIXME: We could avoid some redundant checks here. For newtypes wrapping // scalars, we do the same check on every "level" (e.g., first we check // MyNewtype and then the scalar in there). + if val.layout.is_uninhabited() { + let ty = val.layout.ty; + throw_validation_failure!(self.path, UninhabitedVal { ty }); + } match val.layout.backend_repr { - BackendRepr::Uninhabited => { - let ty = val.layout.ty; - throw_validation_failure!(self.path, UninhabitedVal { ty }); - } BackendRepr::Scalar(scalar_layout) => { if !scalar_layout.is_uninit_valid() { // There is something to check here. diff --git a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs index 79baf91c3ce..6426bca2332 100644 --- a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs +++ b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs @@ -111,13 +111,15 @@ fn check_validity_requirement_lax<'tcx>( }; // Check the ABI. - let valid = match this.backend_repr { - BackendRepr::Uninhabited => false, // definitely UB - BackendRepr::Scalar(s) => scalar_allows_raw_init(s), - BackendRepr::ScalarPair(s1, s2) => scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2), - BackendRepr::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s), - BackendRepr::Memory { .. } => true, // Fields are checked below. - }; + let valid = !this.is_uninhabited() // definitely UB if uninhabited + && match this.backend_repr { + BackendRepr::Scalar(s) => scalar_allows_raw_init(s), + BackendRepr::ScalarPair(s1, s2) => { + scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2) + } + BackendRepr::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s), + BackendRepr::Memory { .. } => true, // Fields are checked below. + }; if !valid { // This is definitely not okay. return Ok(false); diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 19fa8323574..eb14ed20fba 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -794,8 +794,9 @@ where Some(fields) => FieldsShape::Union(fields), None => FieldsShape::Arbitrary { offsets: IndexVec::new(), memory_index: IndexVec::new() }, }, - backend_repr: BackendRepr::Uninhabited, + backend_repr: BackendRepr::Memory { sized: true }, largest_niche: None, + uninhabited: true, align: tcx.data_layout.i8_align, size: Size::ZERO, max_repr_align: None, diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 77a3854ebde..2f8a3050199 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -1558,8 +1558,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { return true; }; + if layout.uninhabited { + return true; + } + match layout.backend_repr { - BackendRepr::Uninhabited => true, BackendRepr::Scalar(a) => !a.is_always_valid(&self.ecx), BackendRepr::ScalarPair(a, b) => { !a.is_always_valid(&self.ecx) || !b.is_always_valid(&self.ecx) diff --git a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs index fb2e838cdc9..a627e0e69b6 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs @@ -202,7 +202,6 @@ impl<'tcx> Stable<'tcx> for rustc_abi::BackendRepr { fn stable(&self, tables: &mut Tables<'_>) -> Self::T { match *self { - rustc_abi::BackendRepr::Uninhabited => ValueAbi::Uninhabited, rustc_abi::BackendRepr::Scalar(scalar) => ValueAbi::Scalar(scalar.stable(tables)), rustc_abi::BackendRepr::ScalarPair(first, second) => { ValueAbi::ScalarPair(first.stable(tables), second.stable(tables)) diff --git a/compiler/rustc_target/src/callconv/loongarch.rs b/compiler/rustc_target/src/callconv/loongarch.rs index 47566bde6b4..3fa67c624a7 100644 --- a/compiler/rustc_target/src/callconv/loongarch.rs +++ b/compiler/rustc_target/src/callconv/loongarch.rs @@ -80,7 +80,7 @@ where } } }, - BackendRepr::Vector { .. } | BackendRepr::Uninhabited => return Err(CannotUseFpConv), + BackendRepr::Vector { .. } => return Err(CannotUseFpConv), BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields { FieldsShape::Primitive => { unreachable!("aggregates can't have `FieldsShape::Primitive`") diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index c2a176facdf..e5f986269dd 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -38,7 +38,7 @@ mod xtensa; pub enum PassMode { /// Ignore the argument. /// - /// The argument is either uninhabited or a ZST. + /// The argument is a ZST. Ignore, /// Pass the argument directly. /// @@ -350,7 +350,6 @@ impl<'a, Ty> ArgAbi<'a, Ty> { scalar_attrs: impl Fn(&TyAndLayout<'a, Ty>, Scalar, Size) -> ArgAttributes, ) -> Self { let mode = match layout.backend_repr { - BackendRepr::Uninhabited => PassMode::Ignore, BackendRepr::Scalar(scalar) => { PassMode::Direct(scalar_attrs(&layout, scalar, Size::ZERO)) } diff --git a/compiler/rustc_target/src/callconv/riscv.rs b/compiler/rustc_target/src/callconv/riscv.rs index 265ae20f991..785175229b0 100644 --- a/compiler/rustc_target/src/callconv/riscv.rs +++ b/compiler/rustc_target/src/callconv/riscv.rs @@ -86,7 +86,7 @@ where } } }, - BackendRepr::Vector { .. } | BackendRepr::Uninhabited => return Err(CannotUseFpConv), + BackendRepr::Vector { .. } => return Err(CannotUseFpConv), BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields { FieldsShape::Primitive => { unreachable!("aggregates can't have `FieldsShape::Primitive`") diff --git a/compiler/rustc_target/src/callconv/x86.rs b/compiler/rustc_target/src/callconv/x86.rs index 5f4f4cd57f6..7e5aab0201b 100644 --- a/compiler/rustc_target/src/callconv/x86.rs +++ b/compiler/rustc_target/src/callconv/x86.rs @@ -108,9 +108,7 @@ where Ty: TyAbiInterface<'a, C> + Copy, { match layout.backend_repr { - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::ScalarPair(..) => false, + BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) => false, BackendRepr::Vector { .. } => true, BackendRepr::Memory { .. } => { for i in 0..layout.fields.count() { diff --git a/compiler/rustc_target/src/callconv/x86_64.rs b/compiler/rustc_target/src/callconv/x86_64.rs index b15d82c26da..ab306e20239 100644 --- a/compiler/rustc_target/src/callconv/x86_64.rs +++ b/compiler/rustc_target/src/callconv/x86_64.rs @@ -51,8 +51,6 @@ where } let mut c = match layout.backend_repr { - BackendRepr::Uninhabited => return Ok(()), - BackendRepr::Scalar(scalar) => match scalar.primitive() { Primitive::Int(..) | Primitive::Pointer(_) => Class::Int, Primitive::Float(_) => Class::Sse, diff --git a/compiler/rustc_target/src/callconv/x86_win64.rs b/compiler/rustc_target/src/callconv/x86_win64.rs index 2ef5127de04..4d99a9f9ba0 100644 --- a/compiler/rustc_target/src/callconv/x86_win64.rs +++ b/compiler/rustc_target/src/callconv/x86_win64.rs @@ -8,7 +8,7 @@ use crate::spec::{HasTargetSpec, RustcAbi}; pub(crate) fn compute_abi_info(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) { let fixup = |a: &mut ArgAbi<'_, Ty>, is_ret: bool| { match a.layout.backend_repr { - BackendRepr::Uninhabited | BackendRepr::Memory { sized: false } => {} + BackendRepr::Memory { sized: false } => {} BackendRepr::ScalarPair(..) | BackendRepr::Memory { sized: true } => { match a.layout.size.bits() { 8 => a.cast_to(Reg::i8()), diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index c5d2d0afbfa..2d20ef3d690 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -472,9 +472,7 @@ fn fn_abi_sanity_check<'tcx>( // `layout.backend_repr` and ignore everything else. We should just reject //`Aggregate` entirely here, but some targets need to be fixed first. match arg.layout.backend_repr { - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::Vector { .. } => {} + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => {} BackendRepr::ScalarPair(..) => { panic!("`PassMode::Direct` used for ScalarPair type {}", arg.layout.ty) } diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 556512e0236..b6a14d147ca 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -348,19 +348,17 @@ fn layout_of_uncached<'tcx>( .checked_mul(count, dl) .ok_or_else(|| error(cx, LayoutError::SizeOverflow(ty)))?; - let abi = if count != 0 && ty.is_privately_uninhabited(tcx, cx.typing_env) { - BackendRepr::Uninhabited - } else { - BackendRepr::Memory { sized: true } - }; + let abi = BackendRepr::Memory { sized: true }; let largest_niche = if count != 0 { element.largest_niche } else { None }; + let uninhabited = if count != 0 { element.uninhabited } else { false }; tcx.mk_layout(LayoutData { variants: Variants::Single { index: FIRST_VARIANT }, fields: FieldsShape::Array { stride: element.size, count }, backend_repr: abi, largest_niche, + uninhabited, align: element.align, size, max_repr_align: None, @@ -375,6 +373,7 @@ fn layout_of_uncached<'tcx>( fields: FieldsShape::Array { stride: element.size, count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: element.align, size: Size::ZERO, max_repr_align: None, @@ -390,6 +389,7 @@ fn layout_of_uncached<'tcx>( fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: dl.i8_align, size: Size::ZERO, max_repr_align: None, @@ -555,6 +555,7 @@ fn layout_of_uncached<'tcx>( fields, backend_repr: abi, largest_niche: e_ly.largest_niche, + uninhabited: false, size, align, max_repr_align: None, @@ -1014,13 +1015,8 @@ fn coroutine_layout<'tcx>( size = size.align_to(align.abi); - let abi = if prefix.backend_repr.is_uninhabited() - || variants.iter().all(|v| v.backend_repr.is_uninhabited()) - { - BackendRepr::Uninhabited - } else { - BackendRepr::Memory { sized: true } - }; + let uninhabited = prefix.uninhabited || variants.iter().all(|v| v.is_uninhabited()); + let abi = BackendRepr::Memory { sized: true }; // this is similar to how ReprOptions populates its field_shuffle_seed let def_hash = tcx.def_path_hash(def_id).0.to_smaller_hash(); @@ -1041,6 +1037,7 @@ fn coroutine_layout<'tcx>( // See , . // FIXME: Remove when is implemented and aliased coroutine fields are wrapped in `UnsafePinned`. largest_niche: None, + uninhabited, size, align, max_repr_align: None, diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index 8d5403ed324..5ea6716c5ca 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -10,7 +10,11 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou // Type-level uninhabitedness should always imply ABI uninhabitedness. if layout.ty.is_privately_uninhabited(tcx, cx.typing_env) { - assert!(layout.is_uninhabited()); + assert!( + layout.is_uninhabited(), + "{:?} is type-level uninhabited but not ABI-uninhabited?", + layout.ty + ); } if layout.size.bytes() % layout.align.abi.bytes() != 0 { @@ -71,7 +75,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou let Some((align, size)) = align.zip(size) else { assert_matches!( layout.layout.backend_repr(), - BackendRepr::Uninhabited | BackendRepr::Memory { .. }, + BackendRepr::Memory { .. }, "ABI unexpectedly missing alignment and/or size in {layout:#?}" ); return; @@ -235,7 +239,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou assert!(align >= element.align(cx).abi); // just sanity-checking `vector_align`. // FIXME: Do some kind of check of the inner type, like for Scalar and ScalarPair. } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {} // Nothing to check. + BackendRepr::Memory { .. } => {} // Nothing to check. } } @@ -291,8 +295,8 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou || variant.is_uninhabited() { // These are never actually accessed anyway, so we can skip the coherence check - // for them. They also fail that check, since they have - // `Aggregate`/`Uninhabited` ABI even when the main type is + // for them. They also fail that check, since they may have + // a different ABI even when the main type is // `Scalar`/`ScalarPair`. (Note that sometimes, variants with fields have size // 0, and sometimes, variants without fields have non-0 size.) continue; @@ -306,7 +310,6 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou (BackendRepr::ScalarPair(a1, b1), BackendRepr::ScalarPair(a2, b2)) => { scalar_coherent(a1, a2) && scalar_coherent(b1, b2) } - (BackendRepr::Uninhabited, _) => true, (BackendRepr::Memory { .. }, _) => true, _ => false, }; diff --git a/compiler/stable_mir/src/abi.rs b/compiler/stable_mir/src/abi.rs index 861b6692b53..091f3e1a95e 100644 --- a/compiler/stable_mir/src/abi.rs +++ b/compiler/stable_mir/src/abi.rs @@ -227,7 +227,6 @@ pub enum TagEncoding { /// in terms of categories of C types there are ABI rules for. #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] pub enum ValueAbi { - Uninhabited, Scalar(Scalar), ScalarPair(Scalar, Scalar), Vector { @@ -244,10 +243,7 @@ impl ValueAbi { /// Returns `true` if the layout corresponds to an unsized type. pub fn is_unsized(&self) -> bool { match *self { - ValueAbi::Uninhabited - | ValueAbi::Scalar(_) - | ValueAbi::ScalarPair(..) - | ValueAbi::Vector { .. } => false, + ValueAbi::Scalar(_) | ValueAbi::ScalarPair(..) | ValueAbi::Vector { .. } => false, ValueAbi::Aggregate { sized } => !sized, } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index b6f7c44c2ae..f5a7b658123 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -194,6 +194,7 @@ fn layout_of_simd_ty( fields, backend_repr: BackendRepr::Vector { element: e_abi, count: e_len }, largest_niche: e_ly.largest_niche, + uninhabited: false, size, align, max_repr_align: None, @@ -297,20 +298,17 @@ pub fn layout_of_ty_query( .checked_mul(count, dl) .ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?; - let backend_repr = - if count != 0 && matches!(element.backend_repr, BackendRepr::Uninhabited) { - BackendRepr::Uninhabited - } else { - BackendRepr::Memory { sized: true } - }; + let backend_repr = BackendRepr::Memory { sized: true }; let largest_niche = if count != 0 { element.largest_niche } else { None }; + let uninhabited = if count != 0 { element.uninhabited } else { false }; Layout { variants: Variants::Single { index: struct_variant_idx() }, fields: FieldsShape::Array { stride: element.size, count }, backend_repr, largest_niche, + uninhabited, align: element.align, size, max_repr_align: None, @@ -325,6 +323,7 @@ pub fn layout_of_ty_query( fields: FieldsShape::Array { stride: element.size, count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: element.align, size: Size::ZERO, max_repr_align: None, @@ -337,6 +336,7 @@ pub fn layout_of_ty_query( fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: dl.i8_align, size: Size::ZERO, max_repr_align: None, -- cgit 1.4.1-3-g733a5 From 46f7a7d378972b4034118f798657a6d35091a4ca Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Tue, 18 Feb 2025 19:27:26 -0800 Subject: rust-analyzer: use new function in (incorrect) layout computation This is only to fix the build. --- src/tools/rust-analyzer/crates/hir-ty/src/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tools/rust-analyzer') diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index f5a7b658123..a72bcad50a0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -179,7 +179,7 @@ fn layout_of_simd_ty( .size .checked_mul(e_len, dl) .ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?; - let align = dl.vector_align(size); + let align = dl.llvmlike_vector_align(size); let size = size.align_to(align.abi); // Compute the placement of the vector fields: -- cgit 1.4.1-3-g733a5 From 12e3911d81034864314503b9c2d9fba2773c7904 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 20 Feb 2025 18:58:46 +0000 Subject: Greatly simplify lifetime captures in edition 2024 --- compiler/rustc_abi/src/lib.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 17 +++++++------- .../src/attributes/allow_unstable.rs | 24 ++++++++++---------- .../src/diagnostics/conflict_errors.rs | 7 +++--- compiler/rustc_borrowck/src/member_constraints.rs | 7 ++---- .../rustc_borrowck/src/polonius/loan_liveness.rs | 2 +- compiler/rustc_borrowck/src/region_infer/mod.rs | 10 ++++----- .../src/region_infer/reverse_sccs.rs | 5 +---- compiler/rustc_borrowck/src/region_infer/values.rs | 24 ++++++++------------ .../src/type_check/free_region_relations.rs | 2 +- .../src/type_check/liveness/local_use_map.rs | 8 +++---- compiler/rustc_borrowck/src/universal_regions.rs | 8 +++---- compiler/rustc_const_eval/src/interpret/intern.rs | 4 ++-- .../src/graph/implementation/mod.rs | 8 +++---- .../rustc_data_structures/src/graph/scc/mod.rs | 2 +- .../src/sorted_map/index_map.rs | 4 ++-- compiler/rustc_data_structures/src/sso/map.rs | 2 +- compiler/rustc_data_structures/src/sso/set.rs | 2 +- compiler/rustc_data_structures/src/sync/vec.rs | 4 ++-- .../src/transitive_relation.rs | 2 +- compiler/rustc_expand/src/proc_macro.rs | 2 +- compiler/rustc_hir/src/definitions.rs | 2 +- compiler/rustc_hir/src/lang_items.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 5 ++--- .../src/collect/resolve_bound_vars.rs | 7 ++---- compiler/rustc_index/src/bit_set.rs | 2 +- compiler/rustc_index/src/interval.rs | 4 ++-- compiler/rustc_index/src/slice.rs | 6 ++--- compiler/rustc_index/src/vec.rs | 4 ++-- .../src/infer/canonical/query_response.rs | 13 +++++------ compiler/rustc_infer/src/infer/free_regions.rs | 2 +- compiler/rustc_infer/src/infer/mod.rs | 7 ++---- compiler/rustc_infer/src/infer/outlives/mod.rs | 2 +- compiler/rustc_lexer/src/lib.rs | 2 +- compiler/rustc_lint/src/context.rs | 4 +--- compiler/rustc_metadata/src/rmeta/decoder.rs | 26 +++++++++------------- compiler/rustc_middle/src/hir/map.rs | 13 +++++------ compiler/rustc_middle/src/hir/mod.rs | 16 ++++++------- compiler/rustc_middle/src/hir/place.rs | 2 +- .../src/mir/interpret/allocation/provenance_map.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 9 +++----- compiler/rustc_middle/src/mir/pretty.rs | 2 +- compiler/rustc_middle/src/ty/adt.rs | 3 +-- compiler/rustc_middle/src/ty/closure.rs | 3 +-- compiler/rustc_middle/src/ty/context.rs | 8 +++---- compiler/rustc_middle/src/ty/generic_args.rs | 10 ++++----- compiler/rustc_middle/src/ty/mod.rs | 9 +++----- compiler/rustc_middle/src/ty/predicate.rs | 13 +++++------ compiler/rustc_middle/src/ty/sty.rs | 5 ++--- compiler/rustc_middle/src/ty/trait_def.rs | 4 ++-- compiler/rustc_middle/src/ty/typeck_results.rs | 2 +- .../rustc_mir_build/src/builder/expr/as_place.rs | 6 ++--- compiler/rustc_mir_build/src/thir/cx/mod.rs | 6 ++--- compiler/rustc_mir_dataflow/src/move_paths/mod.rs | 2 +- compiler/rustc_mir_dataflow/src/un_derefer.rs | 2 +- compiler/rustc_mir_dataflow/src/value_analysis.rs | 6 +---- compiler/rustc_mir_transform/src/coverage/graph.rs | 3 +-- compiler/rustc_mir_transform/src/coverage/query.rs | 3 +-- compiler/rustc_mir_transform/src/coverage/spans.rs | 3 +-- compiler/rustc_mir_transform/src/jump_threading.rs | 4 ++-- compiler/rustc_mir_transform/src/sroa.rs | 2 +- compiler/rustc_mir_transform/src/ssa.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- compiler/rustc_parse/src/parser/mod.rs | 2 +- compiler/rustc_pattern_analysis/src/lib.rs | 10 ++++----- compiler/rustc_pattern_analysis/src/pat_column.rs | 4 ++-- compiler/rustc_pattern_analysis/src/rustc.rs | 26 +++++++++------------- compiler/rustc_pattern_analysis/src/usefulness.rs | 25 +++++++++------------ .../rustc_pattern_analysis/tests/common/mod.rs | 13 +++++------ .../rustc_query_system/src/dep_graph/serialized.rs | 2 +- compiler/rustc_session/src/parse.rs | 2 +- compiler/rustc_session/src/search_paths.rs | 11 +++++---- .../src/error_reporting/infer/need_type_info.rs | 2 +- .../rustc_trait_selection/src/solve/fulfill.rs | 4 +--- .../rustc_trait_selection/src/traits/fulfill.rs | 7 +++--- .../src/traits/specialize/specialization_graph.rs | 7 ++---- .../rustc_trait_selection/src/traits/vtable.rs | 2 +- compiler/rustc_ty_utils/src/implied_bounds.rs | 4 ++-- compiler/rustc_ty_utils/src/layout/invariant.rs | 2 +- compiler/rustc_ty_utils/src/needs_drop.rs | 2 +- compiler/rustc_type_ir/src/search_graph/mod.rs | 2 +- compiler/stable_mir/src/mir/body.rs | 2 +- compiler/stable_mir/src/ty.rs | 2 +- .../src/diagnostics/match_check/pat_analysis.rs | 10 ++++----- 84 files changed, 223 insertions(+), 294 deletions(-) (limited to 'src/tools/rust-analyzer') diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 34228912041..879e4bf64a8 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1345,7 +1345,7 @@ impl FieldsShape { /// Gets source indices of the fields by increasing offsets. #[inline] - pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator + '_ { + pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator { let mut inverse_small = [0u8; 64]; let mut inverse_big = IndexVec::new(); let use_small = self.count() <= inverse_small.len(); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1c777111896..b865cbedbbb 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -45,7 +45,6 @@ use std::sync::Arc; use rustc_ast::node_id::NodeMap; use rustc_ast::{self as ast, *}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -1821,11 +1820,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { self.new_named_lifetime_with_res(new_id, ident, res) } - fn lower_generic_params_mut<'s>( - &'s mut self, - params: &'s [GenericParam], + fn lower_generic_params_mut( + &mut self, + params: &[GenericParam], source: hir::GenericParamSource, - ) -> impl Iterator> + Captures<'a> + Captures<'s> { + ) -> impl Iterator> { params.iter().map(move |param| self.lower_generic_param(param, source)) } @@ -1986,11 +1985,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, itctx)) } - fn lower_param_bounds_mut<'s>( - &'s mut self, - bounds: &'s [GenericBound], + fn lower_param_bounds_mut( + &mut self, + bounds: &[GenericBound], itctx: ImplTraitContext, - ) -> impl Iterator> + Captures<'s> + Captures<'a> { + ) -> impl Iterator> { bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx)) } diff --git a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs index 471168ed4f5..13d246b08a8 100644 --- a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs +++ b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs @@ -4,25 +4,25 @@ use rustc_span::{Symbol, sym}; use crate::session_diagnostics; -pub fn allow_internal_unstable<'a>( - sess: &'a Session, - attrs: &'a [impl AttributeExt], -) -> impl Iterator + 'a { +pub fn allow_internal_unstable( + sess: &Session, + attrs: &[impl AttributeExt], +) -> impl Iterator { allow_unstable(sess, attrs, sym::allow_internal_unstable) } -pub fn rustc_allow_const_fn_unstable<'a>( - sess: &'a Session, - attrs: &'a [impl AttributeExt], -) -> impl Iterator + 'a { +pub fn rustc_allow_const_fn_unstable( + sess: &Session, + attrs: &[impl AttributeExt], +) -> impl Iterator { allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable) } -fn allow_unstable<'a>( - sess: &'a Session, - attrs: &'a [impl AttributeExt], +fn allow_unstable( + sess: &Session, + attrs: &[impl AttributeExt], symbol: Symbol, -) -> impl Iterator + 'a { +) -> impl Iterator { let attrs = filter_by_name(attrs, symbol); let list = attrs .filter_map(move |attr| { diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 94662070db4..f33f2ab58e0 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -8,7 +8,6 @@ use std::ops::ControlFlow; use either::Either; use hir::{ClosureKind, Path}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::codes::*; use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err}; @@ -3530,10 +3529,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { location: Location, mpi: MovePathIndex, ) -> (Vec, Vec) { - fn predecessor_locations<'a, 'tcx>( - body: &'a mir::Body<'tcx>, + fn predecessor_locations<'tcx>( + body: &mir::Body<'tcx>, location: Location, - ) -> impl Iterator + Captures<'tcx> + 'a { + ) -> impl Iterator { if location.statement_index == 0 { let predecessors = body.basic_blocks.predecessors()[location.block].to_vec(); Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb))) diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index a0adf471fd3..bdd0f6fe11e 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -1,7 +1,6 @@ use std::hash::Hash; use std::ops::Index; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexMap; use rustc_index::{IndexSlice, IndexVec}; use rustc_middle::ty::{self, Ty}; @@ -147,9 +146,7 @@ impl<'tcx, R> MemberConstraintSet<'tcx, R> where R: Copy + Hash + Eq, { - pub(crate) fn all_indices( - &self, - ) -> impl Iterator + Captures<'tcx> + '_ { + pub(crate) fn all_indices(&self) -> impl Iterator { self.constraints.indices() } @@ -159,7 +156,7 @@ where pub(crate) fn indices( &self, member_region_vid: R, - ) -> impl Iterator + Captures<'tcx> + '_ { + ) -> impl Iterator { let mut next = self.first_constraints.get(&member_region_vid).cloned(); std::iter::from_fn(move || -> Option { if let Some(current) = next { diff --git a/compiler/rustc_borrowck/src/polonius/loan_liveness.rs b/compiler/rustc_borrowck/src/polonius/loan_liveness.rs index 768c12a97a6..5cd265e0db9 100644 --- a/compiler/rustc_borrowck/src/polonius/loan_liveness.rs +++ b/compiler/rustc_borrowck/src/polonius/loan_liveness.rs @@ -175,7 +175,7 @@ impl LocalizedConstraintGraph { } /// Returns the outgoing edges of a given node, not its transitive closure. - fn outgoing_edges(&self, node: LocalizedNode) -> impl Iterator + use<'_> { + fn outgoing_edges(&self, node: LocalizedNode) -> impl Iterator { // The outgoing edges are: // - the physical edges present at this node, // - the materialized logical edges that exist virtually at all points for this node's diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index e0e3e028c61..a00fce08c9b 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -576,9 +576,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Returns an iterator over all the outlives constraints. - pub(crate) fn outlives_constraints( - &self, - ) -> impl Iterator> + '_ { + pub(crate) fn outlives_constraints(&self) -> impl Iterator> { self.constraints.outlives().iter().copied() } @@ -615,10 +613,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { self.scc_values.region_value_str(scc) } - pub(crate) fn placeholders_contained_in<'a>( - &'a self, + pub(crate) fn placeholders_contained_in( + &self, r: RegionVid, - ) -> impl Iterator + 'a { + ) -> impl Iterator { let scc = self.constraint_sccs.scc(r); self.scc_values.placeholders_contained_in(scc) } diff --git a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs index d0cfe572d08..b2ed8a35827 100644 --- a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs +++ b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs @@ -20,10 +20,7 @@ pub(crate) struct ReverseSccGraph { impl ReverseSccGraph { /// Find all universal regions that are required to outlive the given SCC. - pub(super) fn upper_bounds<'a>( - &'a self, - scc0: ConstraintSccIndex, - ) -> impl Iterator + 'a { + pub(super) fn upper_bounds(&self, scc0: ConstraintSccIndex) -> impl Iterator { let mut duplicates = FxIndexSet::default(); graph::depth_first_search(&self.graph, scc0) .flat_map(move |scc1| { diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index f1bcb353dc6..d9ac5b5cb13 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -88,7 +88,7 @@ impl LivenessValues { } /// Iterate through each region that has a value in this set. - pub(crate) fn regions(&self) -> impl Iterator + '_ { + pub(crate) fn regions(&self) -> impl Iterator { self.points.as_ref().expect("use with_specific_points").rows() } @@ -96,7 +96,7 @@ impl LivenessValues { // We are passing query instability implications to the caller. #[rustc_lint_query_instability] #[allow(rustc::potential_query_instability)] - pub(crate) fn live_regions_unordered(&self) -> impl Iterator + '_ { + pub(crate) fn live_regions_unordered(&self) -> impl Iterator { self.live_regions.as_ref().unwrap().iter().copied() } @@ -143,7 +143,7 @@ impl LivenessValues { } /// Returns an iterator of all the points where `region` is live. - fn live_points(&self, region: RegionVid) -> impl Iterator + '_ { + fn live_points(&self, region: RegionVid) -> impl Iterator { let Some(points) = &self.points else { unreachable!( "Should be using LivenessValues::with_specific_points to ask whether live at a location" @@ -340,7 +340,7 @@ impl RegionValues { } /// Returns the locations contained within a given region `r`. - pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator + 'a { + pub(crate) fn locations_outlived_by(&self, r: N) -> impl Iterator { self.points.row(r).into_iter().flat_map(move |set| { set.iter() .take_while(move |&p| self.location_map.point_in_range(p)) @@ -349,18 +349,15 @@ impl RegionValues { } /// Returns just the universal regions that are contained in a given region's value. - pub(crate) fn universal_regions_outlived_by<'a>( - &'a self, - r: N, - ) -> impl Iterator + 'a { + pub(crate) fn universal_regions_outlived_by(&self, r: N) -> impl Iterator { self.free_regions.row(r).into_iter().flat_map(|set| set.iter()) } /// Returns all the elements contained in a given region's value. - pub(crate) fn placeholders_contained_in<'a>( - &'a self, + pub(crate) fn placeholders_contained_in( + &self, r: N, - ) -> impl Iterator + 'a { + ) -> impl Iterator { self.placeholders .row(r) .into_iter() @@ -369,10 +366,7 @@ impl RegionValues { } /// Returns all the elements contained in a given region's value. - pub(crate) fn elements_contained_in<'a>( - &'a self, - r: N, - ) -> impl Iterator + 'a { + pub(crate) fn elements_contained_in(&self, r: N) -> impl Iterator { let points_iter = self.locations_outlived_by(r).map(RegionElement::Location); let free_regions_iter = 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 efbae1e1535..eaac633b512 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -172,7 +172,7 @@ impl UniversalRegionRelations<'_> { } /// Returns the _non-transitive_ set of known `outlives` constraints between free regions. - pub(crate) fn known_outlives(&self) -> impl Iterator + '_ { + pub(crate) fn known_outlives(&self) -> impl Iterator { self.outlives.base_edges() } } 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 6182b68f6f4..9591da83708 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 @@ -54,7 +54,7 @@ rustc_index::newtype_index! { fn appearances_iter( first: Option, appearances: &Appearances, -) -> impl Iterator + '_ { +) -> impl Iterator { AppearancesIter { appearances, current: first } } @@ -107,17 +107,17 @@ impl LocalUseMap { local_use_map } - pub(crate) fn defs(&self, local: Local) -> impl Iterator + '_ { + pub(crate) fn defs(&self, local: Local) -> impl Iterator { appearances_iter(self.first_def_at[local], &self.appearances) .map(move |aa| self.appearances[aa].point_index) } - pub(crate) fn uses(&self, local: Local) -> impl Iterator + '_ { + pub(crate) fn uses(&self, local: Local) -> impl Iterator { appearances_iter(self.first_use_at[local], &self.appearances) .map(move |aa| self.appearances[aa].point_index) } - pub(crate) fn drops(&self, local: Local) -> impl Iterator + '_ { + pub(crate) fn drops(&self, local: Local) -> impl Iterator { appearances_iter(self.first_drop_at[local], &self.appearances) .map(move |aa| self.appearances[aa].point_index) } diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index c578eb4dc45..b39ead66e95 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -308,7 +308,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// Returns an iterator over all the RegionVids corresponding to /// universally quantified free regions. - pub(crate) fn universal_regions_iter(&self) -> impl Iterator + use<> { + pub(crate) fn universal_regions_iter(&self) -> impl Iterator + 'static { (FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize) } @@ -332,9 +332,9 @@ impl<'tcx> UniversalRegions<'tcx> { } /// Gets an iterator over all the early-bound regions that have names. - pub(crate) fn named_universal_regions_iter<'s>( - &'s self, - ) -> impl Iterator, ty::RegionVid)> + 's { + pub(crate) fn named_universal_regions_iter( + &self, + ) -> impl Iterator, ty::RegionVid)> { self.indices.indices.iter().map(|(&r, &v)| (r, v)) } diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index e14cc1dad36..43631330f89 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -61,8 +61,8 @@ impl HasStaticRootDefId for const_eval::CompileTimeMachine<'_> { /// already mutable (as a sanity check). /// /// Returns an iterator over all relocations referred to by this allocation. -fn intern_shallow<'rt, 'tcx, T, M: CompileTimeMachine<'tcx, T>>( - ecx: &'rt mut InterpCx<'tcx, M>, +fn intern_shallow<'tcx, T, M: CompileTimeMachine<'tcx, T>>( + ecx: &mut InterpCx<'tcx, M>, alloc_id: AllocId, mutability: Mutability, ) -> Result + 'tcx, ()> { diff --git a/compiler/rustc_data_structures/src/graph/implementation/mod.rs b/compiler/rustc_data_structures/src/graph/implementation/mod.rs index 7724e9347d8..a80365938b9 100644 --- a/compiler/rustc_data_structures/src/graph/implementation/mod.rs +++ b/compiler/rustc_data_structures/src/graph/implementation/mod.rs @@ -193,11 +193,11 @@ impl Graph { AdjacentEdges { graph: self, direction, next: first_edge } } - pub fn successor_nodes(&self, source: NodeIndex) -> impl Iterator + '_ { + pub fn successor_nodes(&self, source: NodeIndex) -> impl Iterator { self.outgoing_edges(source).targets() } - pub fn predecessor_nodes(&self, target: NodeIndex) -> impl Iterator + '_ { + pub fn predecessor_nodes(&self, target: NodeIndex) -> impl Iterator { self.incoming_edges(target).sources() } @@ -255,11 +255,11 @@ pub struct AdjacentEdges<'g, N, E> { } impl<'g, N: Debug, E: Debug> AdjacentEdges<'g, N, E> { - fn targets(self) -> impl Iterator + 'g { + fn targets(self) -> impl Iterator { self.map(|(_, edge)| edge.target) } - fn sources(self) -> impl Iterator + 'g { + fn sources(self) -> impl Iterator { self.map(|(_, edge)| edge.source) } } diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 2241b538738..e7c4ea3daae 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -133,7 +133,7 @@ impl Sccs { /// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after. /// This is convenient when the edges represent dependencies: when you visit /// `S1`, the value for `S2` will already have been computed. - pub fn all_sccs(&self) -> impl Iterator + use { + pub fn all_sccs(&self) -> impl Iterator + 'static { (0..self.scc_data.len()).map(S::new) } diff --git a/compiler/rustc_data_structures/src/sorted_map/index_map.rs b/compiler/rustc_data_structures/src/sorted_map/index_map.rs index e9a5fb51975..1654867739f 100644 --- a/compiler/rustc_data_structures/src/sorted_map/index_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map/index_map.rs @@ -84,7 +84,7 @@ impl SortedIndexMultiMap { /// If there are multiple items that are equivalent to `key`, they will be yielded in /// insertion order. #[inline] - pub fn get_by_key(&self, key: K) -> impl Iterator + '_ { + pub fn get_by_key(&self, key: K) -> impl Iterator { self.get_by_key_enumerated(key).map(|(_, v)| v) } @@ -94,7 +94,7 @@ impl SortedIndexMultiMap { /// If there are multiple items that are equivalent to `key`, they will be yielded in /// insertion order. #[inline] - pub fn get_by_key_enumerated(&self, key: K) -> impl Iterator + '_ { + pub fn get_by_key_enumerated(&self, key: K) -> impl Iterator { let lower_bound = self.idx_sorted_by_item_key.partition_point(|&i| self.items[i].0 < key); self.idx_sorted_by_item_key[lower_bound..].iter().map_while(move |&i| { let (k, v) = &self.items[i]; diff --git a/compiler/rustc_data_structures/src/sso/map.rs b/compiler/rustc_data_structures/src/sso/map.rs index 3200249a2dc..827c82fa46a 100644 --- a/compiler/rustc_data_structures/src/sso/map.rs +++ b/compiler/rustc_data_structures/src/sso/map.rs @@ -165,7 +165,7 @@ impl SsoHashMap { /// Clears the map, returning all key-value pairs as an iterator. Keeps the /// allocated memory for reuse. - pub fn drain(&mut self) -> impl Iterator + '_ { + pub fn drain(&mut self) -> impl Iterator { match self { SsoHashMap::Array(array) => Either::Left(array.drain(..)), SsoHashMap::Map(map) => Either::Right(map.drain()), diff --git a/compiler/rustc_data_structures/src/sso/set.rs b/compiler/rustc_data_structures/src/sso/set.rs index a4b40138933..e3fa1cbf4cc 100644 --- a/compiler/rustc_data_structures/src/sso/set.rs +++ b/compiler/rustc_data_structures/src/sso/set.rs @@ -80,7 +80,7 @@ impl SsoHashSet { /// Clears the set, returning all elements in an iterator. #[inline] - pub fn drain(&mut self) -> impl Iterator + '_ { + pub fn drain(&mut self) -> impl Iterator { self.map.drain().map(entry_to_key) } } diff --git a/compiler/rustc_data_structures/src/sync/vec.rs b/compiler/rustc_data_structures/src/sync/vec.rs index 21ec5cf6c13..afbb0cef9f9 100644 --- a/compiler/rustc_data_structures/src/sync/vec.rs +++ b/compiler/rustc_data_structures/src/sync/vec.rs @@ -45,14 +45,14 @@ impl AppendOnlyVec { self.vec.read().get(i).copied() } - pub fn iter_enumerated(&self) -> impl Iterator + '_ { + pub fn iter_enumerated(&self) -> impl Iterator { (0..) .map(|i| (i, self.get(i))) .take_while(|(_, o)| o.is_some()) .filter_map(|(i, o)| Some((i, o?))) } - pub fn iter(&self) -> impl Iterator + '_ { + pub fn iter(&self) -> impl Iterator { (0..).map(|i| self.get(i)).take_while(|o| o.is_some()).flatten() } } diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs index e81ebb9a4be..33ac279f3e0 100644 --- a/compiler/rustc_data_structures/src/transitive_relation.rs +++ b/compiler/rustc_data_structures/src/transitive_relation.rs @@ -363,7 +363,7 @@ impl TransitiveRelation { /// Lists all the base edges in the graph: the initial _non-transitive_ set of element /// relations, which will be later used as the basis for the transitive closure computation. - pub fn base_edges(&self) -> impl Iterator + '_ { + pub fn base_edges(&self) -> impl Iterator { self.edges .iter() .map(move |edge| (self.elements[edge.source.0], self.elements[edge.target.0])) diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index 814d2b04d8d..a6cdeaee176 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -31,7 +31,7 @@ impl pm::bridge::server::MessagePipe for MessagePipe { } } -fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + use<> { +fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + 'static { pm::bridge::server::MaybeCrossThread::>::new( ecx.sess.opts.unstable_opts.proc_macro_execution_strategy == ProcMacroExecutionStrategy::CrossThread, diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 08a0a5225e7..c4c309e77e1 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -93,7 +93,7 @@ impl DefPathTable { pub fn enumerated_keys_and_path_hashes( &self, - ) -> impl Iterator + ExactSizeIterator + '_ { + ) -> impl Iterator + ExactSizeIterator { self.index_to_key .iter_enumerated() .map(move |(index, key)| (index, key, self.def_path_hash(index))) diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 34c0837b25a..f5626937ec4 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -60,7 +60,7 @@ impl LanguageItems { self.reverse_items.get(&def_id).copied() } - pub fn iter(&self) -> impl Iterator + '_ { + pub fn iter(&self) -> impl Iterator { self.items .iter() .enumerate() diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 5bb77c096dc..1a89c9dedc5 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -20,7 +20,6 @@ use std::ops::Bound; use rustc_abi::ExternAbi; use rustc_ast::Recovered; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::unord::UnordMap; use rustc_errors::{ @@ -1690,10 +1689,10 @@ fn polarity_of_impl( /// the lifetimes that are declared. For fns or methods, we have to /// screen out those that do not appear in any where-clauses etc using /// `resolve_lifetime::early_bound_lifetimes`. -fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( +fn early_bound_lifetimes_from_generics<'a, 'tcx>( tcx: TyCtxt<'tcx>, generics: &'a hir::Generics<'a>, -) -> impl Iterator> + Captures<'tcx> { +) -> impl Iterator> { generics.params.iter().filter(move |param| match param.kind { GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id), _ => false, diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index fee3c6088ed..efd65ba3cc4 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -160,7 +160,7 @@ enum Scope<'a> { impl<'a> Scope<'a> { // A helper for debugging scopes without printing parent scopes - fn debug_truncated(&'a self) -> impl fmt::Debug + 'a { + fn debug_truncated(&self) -> impl fmt::Debug { fmt::from_fn(move |f| match self { Self::Binder { bound_vars, scope_type, hir_id, where_bound_origin, s: _ } => f .debug_struct("Binder") @@ -2159,10 +2159,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { /// Walk the generics of the item for a trait bound whose self type /// corresponds to the expected res, and return the trait def id. - fn for_each_trait_bound_on_res( - &self, - expected_res: Res, - ) -> impl Iterator + use<'tcx, '_> { + fn for_each_trait_bound_on_res(&self, expected_res: Res) -> impl Iterator { std::iter::from_coroutine( #[coroutine] move || { diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index d7d90ea16e4..6dc044a6d38 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -1666,7 +1666,7 @@ impl SparseBitMatrix { /// Iterates through all the columns set to true in a given row of /// the matrix. - pub fn iter(&self, row: R) -> impl Iterator + '_ { + pub fn iter(&self, row: R) -> impl Iterator { self.row(row).into_iter().flat_map(|r| r.iter()) } diff --git a/compiler/rustc_index/src/interval.rs b/compiler/rustc_index/src/interval.rs index a3d87f59567..0225c5c4f32 100644 --- a/compiler/rustc_index/src/interval.rs +++ b/compiler/rustc_index/src/interval.rs @@ -51,7 +51,7 @@ impl IntervalSet { self.map.clear(); } - pub fn iter(&self) -> impl Iterator + '_ + pub fn iter(&self) -> impl Iterator where I: Step, { @@ -59,7 +59,7 @@ impl IntervalSet { } /// Iterates through intervals stored in the set, in order. - pub fn iter_intervals(&self) -> impl Iterator> + '_ + pub fn iter_intervals(&self) -> impl Iterator> where I: Step, { diff --git a/compiler/rustc_index/src/slice.rs b/compiler/rustc_index/src/slice.rs index 956d32c9a69..4636f294f13 100644 --- a/compiler/rustc_index/src/slice.rs +++ b/compiler/rustc_index/src/slice.rs @@ -63,9 +63,7 @@ impl IndexSlice { } #[inline] - pub fn iter_enumerated( - &self, - ) -> impl DoubleEndedIterator + ExactSizeIterator + '_ { + pub fn iter_enumerated(&self) -> impl DoubleEndedIterator + ExactSizeIterator { self.raw.iter().enumerate().map(|(n, t)| (I::new(n), t)) } @@ -84,7 +82,7 @@ impl IndexSlice { #[inline] pub fn iter_enumerated_mut( &mut self, - ) -> impl DoubleEndedIterator + ExactSizeIterator + '_ { + ) -> impl DoubleEndedIterator + ExactSizeIterator { self.raw.iter_mut().enumerate().map(|(n, t)| (I::new(n), t)) } diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs index 1cb8bc861af..7f3f3ead5f2 100644 --- a/compiler/rustc_index/src/vec.rs +++ b/compiler/rustc_index/src/vec.rs @@ -132,7 +132,7 @@ impl IndexVec { } #[inline] - pub fn drain>(&mut self, range: R) -> impl Iterator + '_ { + pub fn drain>(&mut self, range: R) -> impl Iterator { self.raw.drain(range) } @@ -140,7 +140,7 @@ impl IndexVec { pub fn drain_enumerated>( &mut self, range: R, - ) -> impl Iterator + '_ { + ) -> impl Iterator { let begin = match range.start_bound() { std::ops::Bound::Included(i) => *i, std::ops::Bound::Excluded(i) => i.checked_add(1).unwrap(), diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 23f63af778d..8a61631c69c 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -10,7 +10,6 @@ use std::fmt::Debug; use std::iter; -use rustc_data_structures::captures::Captures; use rustc_index::{Idx, IndexVec}; use rustc_middle::arena::ArenaAllocatable; use rustc_middle::mir::ConstraintCategory; @@ -541,13 +540,13 @@ impl<'tcx> InferCtxt<'tcx> { /// Converts the region constraints resulting from a query into an /// iterator of obligations. - fn query_outlives_constraints_into_obligations<'a>( - &'a self, - cause: &'a ObligationCause<'tcx>, + fn query_outlives_constraints_into_obligations( + &self, + cause: &ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, - uninstantiated_region_constraints: &'a [QueryOutlivesConstraint<'tcx>], - result_args: &'a CanonicalVarValues<'tcx>, - ) -> impl Iterator> + 'a + Captures<'tcx> { + uninstantiated_region_constraints: &[QueryOutlivesConstraint<'tcx>], + result_args: &CanonicalVarValues<'tcx>, + ) -> impl Iterator> { uninstantiated_region_constraints.iter().map(move |&constraint| { let predicate = instantiate_value(self.tcx, result_args, constraint); self.query_outlives_constraint_to_obligation(predicate, cause.clone(), param_env) diff --git a/compiler/rustc_infer/src/infer/free_regions.rs b/compiler/rustc_infer/src/infer/free_regions.rs index 5452ba67497..8fa5361121c 100644 --- a/compiler/rustc_infer/src/infer/free_regions.rs +++ b/compiler/rustc_infer/src/infer/free_regions.rs @@ -38,7 +38,7 @@ pub struct FreeRegionMap<'tcx> { } impl<'tcx> FreeRegionMap<'tcx> { - pub fn elements(&self) -> impl Iterator> + '_ { + pub fn elements(&self) -> impl Iterator> { self.relation.elements().copied() } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index de49c246c15..537e8119ada 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -15,7 +15,6 @@ use region_constraints::{ }; pub use relate::StructurallyRelateAliases; pub use relate::combine::PredicateEmittingRelation; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::undo_log::{Rollback, UndoLogs}; use rustc_data_structures::unify as ut; @@ -233,7 +232,7 @@ impl<'tcx> InferCtxtInner<'tcx> { // while looping through this. pub fn iter_opaque_types( &self, - ) -> impl Iterator, ty::OpaqueHiddenType<'tcx>)> + '_ { + ) -> impl Iterator, ty::OpaqueHiddenType<'tcx>)> { self.opaque_type_storage.opaque_types.iter().map(|(&k, &v)| (k, v)) } } @@ -1295,9 +1294,7 @@ impl<'tcx> InferCtxt<'tcx> { /// The returned function is used in a fast path. If it returns `true` the variable is /// unchanged, `false` indicates that the status is unknown. #[inline] - pub fn is_ty_infer_var_definitely_unchanged<'a>( - &'a self, - ) -> (impl Fn(TyOrConstInferVar) -> bool + Captures<'tcx> + 'a) { + pub fn is_ty_infer_var_definitely_unchanged(&self) -> impl Fn(TyOrConstInferVar) -> bool { // This hoists the borrow/release out of the loop body. let inner = self.inner.try_borrow(); diff --git a/compiler/rustc_infer/src/infer/outlives/mod.rs b/compiler/rustc_infer/src/infer/outlives/mod.rs index 1afe50e336d..2a4544c1140 100644 --- a/compiler/rustc_infer/src/infer/outlives/mod.rs +++ b/compiler/rustc_infer/src/infer/outlives/mod.rs @@ -20,7 +20,7 @@ pub(crate) mod verify; #[instrument(level = "debug", skip(param_env), ret)] pub fn explicit_outlives_bounds<'tcx>( param_env: ty::ParamEnv<'tcx>, -) -> impl Iterator> + 'tcx { +) -> impl Iterator> { param_env .caller_bounds() .into_iter() diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index c63ab77deca..bf18845a083 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -291,7 +291,7 @@ pub fn validate_raw_str(input: &str, prefix_len: u32) -> Result<(), RawStrError> } /// Creates an iterator that produces tokens from the input string. -pub fn tokenize(input: &str) -> impl Iterator + '_ { +pub fn tokenize(input: &str) -> impl Iterator { let mut cursor = Cursor::new(input); std::iter::from_fn(move || { let token = cursor.advance_token(); diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index c74158102c7..74663e6b4bb 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -139,9 +139,7 @@ impl LintStore { &self.lints } - pub fn get_lint_groups<'t>( - &'t self, - ) -> impl Iterator, bool)> + 't { + pub fn get_lint_groups(&self) -> impl Iterator, bool)> { self.lint_groups .iter() .filter(|(_, LintGroup { depr, .. })| { diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index e8dcda875e6..0604892e34d 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -8,7 +8,6 @@ use std::{io, iter, mem}; pub(super) use cstore_impl::provide; use proc_macro::bridge::client::ProcMacro; use rustc_ast as ast; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::owned_slice::OwnedSlice; @@ -963,14 +962,14 @@ impl CrateRoot { pub(crate) fn decode_crate_deps<'a>( &self, metadata: &'a MetadataBlob, - ) -> impl ExactSizeIterator + Captures<'a> { + ) -> impl ExactSizeIterator { self.crate_deps.decode(metadata) } pub(crate) fn decode_target_modifiers<'a>( &self, metadata: &'a MetadataBlob, - ) -> impl ExactSizeIterator + Captures<'a> { + ) -> impl ExactSizeIterator { self.target_modifiers.decode(metadata) } } @@ -1276,7 +1275,7 @@ impl<'a> CrateMetadataRef<'a> { self, id: DefIndex, sess: &'a Session, - ) -> impl Iterator + 'a { + ) -> impl Iterator { iter::from_coroutine( #[coroutine] move || { @@ -1326,10 +1325,7 @@ impl<'a> CrateMetadataRef<'a> { .is_some_and(|ident| ident.name == kw::SelfLower) } - fn get_associated_item_or_field_def_ids( - self, - id: DefIndex, - ) -> impl Iterator + 'a { + fn get_associated_item_or_field_def_ids(self, id: DefIndex) -> impl Iterator { self.root .tables .associated_item_or_field_def_ids @@ -1380,7 +1376,7 @@ impl<'a> CrateMetadataRef<'a> { self, id: DefIndex, sess: &'a Session, - ) -> impl Iterator + 'a { + ) -> impl Iterator { self.root .tables .attributes @@ -1417,12 +1413,12 @@ impl<'a> CrateMetadataRef<'a> { } /// Decodes all traits in the crate (for rustdoc and rustc diagnostics). - fn get_traits(self) -> impl Iterator + 'a { + fn get_traits(self) -> impl Iterator { self.root.traits.decode(self).map(move |index| self.local_def_id(index)) } /// Decodes all trait impls in the crate (for rustdoc). - fn get_trait_impls(self) -> impl Iterator + 'a { + fn get_trait_impls(self) -> impl Iterator { self.cdata.trait_impls.values().flat_map(move |impls| { impls.decode(self).map(move |(impl_index, _)| self.local_def_id(impl_index)) }) @@ -1463,7 +1459,7 @@ impl<'a> CrateMetadataRef<'a> { } } - fn get_native_libraries(self, sess: &'a Session) -> impl Iterator + 'a { + fn get_native_libraries(self, sess: &'a Session) -> impl Iterator { self.root.native_libraries.decode((self, sess)) } @@ -1476,7 +1472,7 @@ impl<'a> CrateMetadataRef<'a> { .decode((self, sess)) } - fn get_foreign_modules(self, sess: &'a Session) -> impl Iterator + 'a { + fn get_foreign_modules(self, sess: &'a Session) -> impl Iterator { self.root.foreign_modules.decode((self, sess)) } @@ -1816,7 +1812,7 @@ impl<'a> CrateMetadataRef<'a> { .decode(self) } - fn get_doc_link_traits_in_scope(self, index: DefIndex) -> impl Iterator + 'a { + fn get_doc_link_traits_in_scope(self, index: DefIndex) -> impl Iterator { self.root .tables .doc_link_traits_in_scope @@ -1887,7 +1883,7 @@ impl CrateMetadata { cdata } - pub(crate) fn dependencies(&self) -> impl Iterator + '_ { + pub(crate) fn dependencies(&self) -> impl Iterator { self.dependencies.iter().copied() } diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 40dd6aa73fd..7d632f592af 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -174,15 +174,12 @@ impl<'tcx> TyCtxt<'tcx> { } #[inline] - pub fn hir_free_items(self) -> impl Iterator + 'tcx { + pub fn hir_free_items(self) -> impl Iterator { self.hir_crate_items(()).free_items.iter().copied() } #[inline] - pub fn hir_module_free_items( - self, - module: LocalModDefId, - ) -> impl Iterator + 'tcx { + pub fn hir_module_free_items(self, module: LocalModDefId) -> impl Iterator { self.hir_module_items(module).free_items() } @@ -283,7 +280,7 @@ impl<'tcx> TyCtxt<'tcx> { }) } - pub fn hir_body_param_names(self, id: BodyId) -> impl Iterator + 'tcx { + pub fn hir_body_param_names(self, id: BodyId) -> impl Iterator { self.hir_body(id).params.iter().map(|arg| match arg.pat.kind { PatKind::Binding(_, _, ident, _) => ident, _ => Ident::empty(), @@ -337,7 +334,7 @@ impl<'tcx> TyCtxt<'tcx> { /// crate. If you would prefer to iterate over the bodies /// themselves, you can do `self.hir().krate().body_ids.iter()`. #[inline] - pub fn hir_body_owners(self) -> impl Iterator + 'tcx { + pub fn hir_body_owners(self) -> impl Iterator { self.hir_crate_items(()).body_owners.iter().copied() } @@ -502,7 +499,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// until the crate root is reached. Prefer this over your own loop using `parent_id`. #[inline] - pub fn hir_parent_id_iter(self, current_id: HirId) -> impl Iterator + 'tcx { + pub fn hir_parent_id_iter(self, current_id: HirId) -> impl Iterator { ParentHirIterator::new(self, current_id) } diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 2a201e23015..6071a58367e 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -40,25 +40,25 @@ impl ModuleItems { /// include foreign items. If you want to e.g. get all functions, use `definitions()` below. /// /// However, this does include the `impl` blocks themselves. - pub fn free_items(&self) -> impl Iterator + '_ { + pub fn free_items(&self) -> impl Iterator { self.free_items.iter().copied() } - pub fn trait_items(&self) -> impl Iterator + '_ { + pub fn trait_items(&self) -> impl Iterator { self.trait_items.iter().copied() } /// Returns all items that are associated with some `impl` block (both inherent and trait impl /// blocks). - pub fn impl_items(&self) -> impl Iterator + '_ { + pub fn impl_items(&self) -> impl Iterator { self.impl_items.iter().copied() } - pub fn foreign_items(&self) -> impl Iterator + '_ { + pub fn foreign_items(&self) -> impl Iterator { self.foreign_items.iter().copied() } - pub fn owners(&self) -> impl Iterator + '_ { + pub fn owners(&self) -> impl Iterator { self.free_items .iter() .map(|id| id.owner_id) @@ -67,15 +67,15 @@ impl ModuleItems { .chain(self.foreign_items.iter().map(|id| id.owner_id)) } - pub fn opaques(&self) -> impl Iterator + '_ { + pub fn opaques(&self) -> impl Iterator { self.opaques.iter().copied() } - pub fn nested_bodies(&self) -> impl Iterator + '_ { + pub fn nested_bodies(&self) -> impl Iterator { self.nested_bodies.iter().copied() } - pub fn definitions(&self) -> impl Iterator + '_ { + pub fn definitions(&self) -> impl Iterator { self.owners().map(|id| id.def_id) } diff --git a/compiler/rustc_middle/src/hir/place.rs b/compiler/rustc_middle/src/hir/place.rs index 66b701523b7..316ad80eb98 100644 --- a/compiler/rustc_middle/src/hir/place.rs +++ b/compiler/rustc_middle/src/hir/place.rs @@ -97,7 +97,7 @@ impl<'tcx> Place<'tcx> { /// The types are in the reverse order that they are applied. So if /// `x: &*const u32` and the `Place` is `**x`, then the types returned are ///`*const u32` then `&*const u32`. - pub fn deref_tys(&self) -> impl Iterator> + '_ { + pub fn deref_tys(&self) -> impl Iterator> { self.projections.iter().enumerate().rev().filter_map(move |(index, proj)| { if ProjectionKind::Deref == proj.kind { Some(self.ty_before_projection(index)) diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs index 78196b05361..2f13f963578 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs @@ -121,7 +121,7 @@ impl ProvenanceMap { } /// Yields all the provenances stored in this map. - pub fn provenances(&self) -> impl Iterator + '_ { + pub fn provenances(&self) -> impl Iterator { let bytes = self.bytes.iter().flat_map(|b| b.values()); self.ptrs.values().chain(bytes).copied() } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 227cb97c76b..cf90df1b198 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -12,7 +12,6 @@ use either::Either; use polonius_engine::Atom; use rustc_abi::{FieldIdx, VariantIdx}; pub use rustc_ast::Mutability; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::graph::dominators::Dominators; use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg}; @@ -472,7 +471,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable locals. #[inline] - pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator + Captures<'tcx> + 'a { + pub fn mut_vars_iter(&self) -> impl Iterator { (self.arg_count + 1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; @@ -482,9 +481,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable arguments and locals. #[inline] - pub fn mut_vars_and_args_iter<'a>( - &'a self, - ) -> impl Iterator + Captures<'tcx> + 'a { + pub fn mut_vars_and_args_iter(&self) -> impl Iterator { (1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; @@ -514,7 +511,7 @@ impl<'tcx> Body<'tcx> { } #[inline] - pub fn drain_vars_and_temps<'a>(&'a mut self) -> impl Iterator> + 'a { + pub fn drain_vars_and_temps(&mut self) -> impl Iterator> { self.local_decls.drain(self.arg_count + 1..) } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 1d61cf48ad2..875f5282bf2 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1523,7 +1523,7 @@ pub fn write_allocations<'tcx>( ) -> io::Result<()> { fn alloc_ids_from_alloc( alloc: ConstAllocation<'_>, - ) -> impl DoubleEndedIterator + '_ { + ) -> impl DoubleEndedIterator { alloc.inner().provenance().ptrs().values().map(|p| p.alloc_id()) } diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index b529d17540a..3585f28b4a5 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -4,7 +4,6 @@ use std::ops::Range; use std::str; use rustc_abi::{FIRST_VARIANT, ReprOptions, VariantIdx}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; @@ -540,7 +539,7 @@ impl<'tcx> AdtDef<'tcx> { pub fn discriminants( self, tcx: TyCtxt<'tcx>, - ) -> impl Iterator)> + Captures<'tcx> { + ) -> impl Iterator)> { assert!(self.is_enum()); let repr_type = self.repr().discr_type(); let initial = repr_type.initial_discriminant(tcx); diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index c4d5367e2f0..3605f2402e7 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -1,6 +1,5 @@ use std::fmt::Write; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_hir::HirId; @@ -415,7 +414,7 @@ pub fn analyze_coroutine_closure_captures<'a, 'tcx: 'a, T>( parent_captures: impl IntoIterator>, child_captures: impl IntoIterator>, mut for_each: impl FnMut((usize, &'a CapturedPlace<'tcx>), (usize, &'a CapturedPlace<'tcx>)) -> T, -) -> impl Iterator + Captures<'a> + Captures<'tcx> { +) -> impl Iterator { std::iter::from_coroutine( #[coroutine] move || { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 32a9e67f9ad..d20e8bd42e6 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1939,7 +1939,7 @@ impl<'tcx> TyCtxt<'tcx> { Ok(TyCtxtFeed { key: num, tcx: self }) } - pub fn iter_local_def_id(self) -> impl Iterator + 'tcx { + pub fn iter_local_def_id(self) -> impl Iterator { // Create a dependency to the red node to be sure we re-execute this when the amount of // definitions change. self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE); @@ -2171,14 +2171,14 @@ impl<'tcx> TyCtxt<'tcx> { } /// All traits in the crate graph, including those not visible to the user. - pub fn all_traits(self) -> impl Iterator + 'tcx { + pub fn all_traits(self) -> impl Iterator { iter::once(LOCAL_CRATE) .chain(self.crates(()).iter().copied()) .flat_map(move |cnum| self.traits(cnum).iter().copied()) } /// All traits that are visible within the crate graph (i.e. excluding private dependencies). - pub fn visible_traits(self) -> impl Iterator + 'tcx { + pub fn visible_traits(self) -> impl Iterator { let visible_crates = self.crates(()).iter().copied().filter(move |cnum| self.is_user_visible_dep(*cnum)); @@ -2363,7 +2363,7 @@ macro_rules! sty_debug_print { } impl<'tcx> TyCtxt<'tcx> { - pub fn debug_stats(self) -> impl fmt::Debug + 'tcx { + pub fn debug_stats(self) -> impl fmt::Debug { fmt::from_fn(move |fmt| { sty_debug_print!( fmt, diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index b74ddb81710..ed0b3059d75 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -479,25 +479,23 @@ impl<'tcx> GenericArgs<'tcx> { } #[inline] - pub fn types(&'tcx self) -> impl DoubleEndedIterator> + 'tcx { + pub fn types(&self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_type()) } #[inline] - pub fn regions(&'tcx self) -> impl DoubleEndedIterator> + 'tcx { + pub fn regions(&self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_region()) } #[inline] - pub fn consts(&'tcx self) -> impl DoubleEndedIterator> + 'tcx { + pub fn consts(&self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_const()) } /// Returns generic arguments that are not lifetimes. #[inline] - pub fn non_erasable_generics( - &'tcx self, - ) -> impl DoubleEndedIterator> + 'tcx { + pub fn non_erasable_generics(&self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| match k.unpack() { ty::GenericArgKind::Lifetime(_) => None, generic => Some(generic), diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index bd1fb0ca41c..8ed5a118093 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1798,14 +1798,11 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn get_attrs_by_path<'attr>( + pub fn get_attrs_by_path( self, did: DefId, - attr: &'attr [Symbol], - ) -> impl Iterator + 'attr - where - 'tcx: 'attr, - { + attr: &[Symbol], + ) -> impl Iterator { let filter_fn = move |a: &&hir::Attribute| a.path_matches(attr); if let Some(did) = did.as_local() { self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn) diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 584cac22ae8..553de83dfcb 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -1,6 +1,5 @@ use std::cmp::Ordering; -use rustc_data_structures::captures::Captures; use rustc_data_structures::intern::Interned; use rustc_hir::def_id::DefId; use rustc_macros::{HashStable, extension}; @@ -336,9 +335,9 @@ impl<'tcx> ty::List> { } #[inline] - pub fn projection_bounds<'a>( - &'a self, - ) -> impl Iterator>> + 'a { + pub fn projection_bounds( + &self, + ) -> impl Iterator>> { self.iter().filter_map(|predicate| { predicate .map_bound(|pred| match pred { @@ -350,16 +349,14 @@ impl<'tcx> ty::List> { } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator + Captures<'tcx> + 'a { + pub fn auto_traits(&self) -> impl Iterator { self.iter().filter_map(|predicate| match predicate.skip_binder() { ExistentialPredicate::AutoTrait(did) => Some(did), _ => None, }) } - pub fn without_auto_traits( - &self, - ) -> impl Iterator> + '_ { + pub fn without_auto_traits(&self) -> impl Iterator> { self.iter().filter(|predicate| { !matches!(predicate.as_ref().skip_binder(), ExistentialPredicate::AutoTrait(_)) }) diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index dd4da2cf4ac..d5617adf26b 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -9,7 +9,6 @@ use std::ops::{ControlFlow, Range}; use hir::def::{CtorKind, DefKind}; use rustc_abi::{ExternAbi, FIRST_VARIANT, FieldIdx, VariantIdx}; -use rustc_data_structures::captures::Captures; use rustc_errors::{ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; use rustc_hir::LangItem; @@ -105,7 +104,7 @@ impl<'tcx> ty::CoroutineArgs> { self, def_id: DefId, tcx: TyCtxt<'tcx>, - ) -> impl Iterator)> + Captures<'tcx> { + ) -> impl Iterator)> { self.variant_range(def_id, tcx).map(move |index| { (index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) }) }) @@ -139,7 +138,7 @@ impl<'tcx> ty::CoroutineArgs> { self, def_id: DefId, tcx: TyCtxt<'tcx>, - ) -> impl Iterator> + Captures<'tcx>> { + ) -> impl Iterator>> { let layout = tcx.coroutine_layout(def_id, self.kind_ty()).unwrap(); layout.variant_fields.iter().map(move |variant| { variant.iter().map(move |field| { diff --git a/compiler/rustc_middle/src/ty/trait_def.rs b/compiler/rustc_middle/src/ty/trait_def.rs index 17e90c15d41..8fa1c569737 100644 --- a/compiler/rustc_middle/src/ty/trait_def.rs +++ b/compiler/rustc_middle/src/ty/trait_def.rs @@ -188,7 +188,7 @@ impl<'tcx> TyCtxt<'tcx> { self, trait_def_id: DefId, self_ty: Ty<'tcx>, - ) -> impl Iterator + 'tcx { + ) -> impl Iterator { let impls = self.trait_impls_of(trait_def_id); if let Some(simp) = fast_reject::simplify_type(self, self_ty, TreatParams::InstantiateWithInfer) @@ -204,7 +204,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns an iterator containing all impls for `trait_def_id`. /// /// `trait_def_id` MUST BE the `DefId` of a trait. - pub fn all_impls(self, trait_def_id: DefId) -> impl Iterator + 'tcx { + pub fn all_impls(self, trait_def_id: DefId) -> impl Iterator { let TraitImpls { blanket_impls, non_blanket_impls } = self.trait_impls_of(trait_def_id); blanket_impls.iter().chain(non_blanket_impls.iter().flat_map(|(_, v)| v)).cloned() diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index b8c73d25843..d4484a16fea 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -575,7 +575,7 @@ impl<'a, V> LocalTableInContext<'a, V> { } pub fn items( - &'a self, + &self, ) -> UnordItems<(hir::ItemLocalId, &'a V), impl Iterator> { self.data.items().map(|(id, value)| (*id, value)) diff --git a/compiler/rustc_mir_build/src/builder/expr/as_place.rs b/compiler/rustc_mir_build/src/builder/expr/as_place.rs index 308ca442b40..581f45db6c4 100644 --- a/compiler/rustc_mir_build/src/builder/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_place.rs @@ -216,11 +216,11 @@ fn to_upvars_resolved_place_builder<'tcx>( /// Supports only HIR projection kinds that represent a path that might be /// captured by a closure or a coroutine, i.e., an `Index` or a `Subslice` /// projection kinds are unsupported. -fn strip_prefix<'a, 'tcx>( +fn strip_prefix<'tcx>( mut base_ty: Ty<'tcx>, - projections: &'a [PlaceElem<'tcx>], + projections: &[PlaceElem<'tcx>], prefix_projections: &[HirProjection<'tcx>], -) -> impl Iterator> + 'a { +) -> impl Iterator> { let mut iter = projections .iter() .copied() diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 7a9f6e46304..41a642f95b6 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -159,12 +159,12 @@ impl<'tcx> ThirBuildCx<'tcx> { }) } - fn explicit_params<'a>( - &'a mut self, + fn explicit_params( + &mut self, owner_id: HirId, fn_decl: &'tcx hir::FnDecl<'tcx>, body: &'tcx hir::Body<'tcx>, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> { let fn_sig = self.typeck_results.liberated_fn_sigs()[owner_id]; body.params.iter().enumerate().map(move |(index, param)| { diff --git a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs index 8aea8d2ae3c..18985ba0da2 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs @@ -343,7 +343,7 @@ impl<'tcx> MovePathLookup<'tcx> { /// `MovePathIndex`es. pub fn iter_locals_enumerated( &self, - ) -> impl DoubleEndedIterator + '_ { + ) -> impl DoubleEndedIterator { self.locals.iter_enumerated().filter_map(|(l, &idx)| Some((l, idx?))) } } diff --git a/compiler/rustc_mir_dataflow/src/un_derefer.rs b/compiler/rustc_mir_dataflow/src/un_derefer.rs index bb15b8106a1..b38dd9d40f5 100644 --- a/compiler/rustc_mir_dataflow/src/un_derefer.rs +++ b/compiler/rustc_mir_dataflow/src/un_derefer.rs @@ -28,7 +28,7 @@ impl<'tcx> UnDerefer<'tcx> { pub(crate) fn iter_projections( &self, place: PlaceRef<'tcx>, - ) -> impl Iterator, PlaceElem<'tcx>)> + '_ { + ) -> impl Iterator, PlaceElem<'tcx>)> { ProjectionIter::new(self.deref_chain(place.local), place) } } diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 9cba07e15a4..36fb1c2b36d 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -2,7 +2,6 @@ use std::fmt::{Debug, Formatter}; use std::ops::Range; use rustc_abi::{FieldIdx, VariantIdx}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxIndexSet, StdEntry}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_index::IndexVec; @@ -676,10 +675,7 @@ impl<'tcx> Map<'tcx> { } /// Iterate over all direct children. - fn children( - &self, - parent: PlaceIndex, - ) -> impl Iterator + Captures<'_> + Captures<'tcx> { + fn children(&self, parent: PlaceIndex) -> impl Iterator { Children::new(self, parent) } diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 6d84248ddfb..09384defea8 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -2,7 +2,6 @@ use std::cmp::Ordering; use std::ops::{Index, IndexMut}; use std::{mem, slice}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::dominators::Dominators; use rustc_data_structures::graph::{self, DirectedGraph, StartNode}; @@ -218,7 +217,7 @@ impl CoverageGraph { pub(crate) fn reloop_predecessors( &self, to_bcb: BasicCoverageBlock, - ) -> impl Iterator + Captures<'_> { + ) -> impl Iterator { self.predecessors[to_bcb].iter().copied().filter(move |&pred| self.dominates(to_bcb, pred)) } } diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs index ef86358b205..58461be01f1 100644 --- a/compiler/rustc_mir_transform/src/coverage/query.rs +++ b/compiler/rustc_mir_transform/src/coverage/query.rs @@ -1,4 +1,3 @@ -use rustc_data_structures::captures::Captures; use rustc_index::bit_set::DenseBitSet; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::coverage::{BasicCoverageBlock, CoverageIdsInfo, CoverageKind, MappingKind}; @@ -153,7 +152,7 @@ fn coverage_ids_info<'tcx>( fn all_coverage_in_mir_body<'a, 'tcx>( body: &'a Body<'tcx>, -) -> impl Iterator + Captures<'tcx> { +) -> impl Iterator { body.basic_blocks.iter().flat_map(|bb_data| &bb_data.statements).filter_map(|statement| { match statement.kind { StatementKind::Coverage(ref kind) if !is_inlined(body, statement) => Some(kind), diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 314a86ea52f..b9ed6984ddb 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -1,6 +1,5 @@ use std::collections::VecDeque; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_middle::mir; use rustc_span::{DesugaringKind, ExpnKind, MacroKind, Span}; @@ -182,7 +181,7 @@ fn divide_spans_into_buckets(input_covspans: Vec, holes: &[Hole]) -> Ve fn drain_front_while<'a, T>( queue: &'a mut VecDeque, mut pred_fn: impl FnMut(&T) -> bool, -) -> impl Iterator + Captures<'a> { +) -> impl Iterator { std::iter::from_fn(move || if pred_fn(queue.front()?) { queue.pop_front() } else { None }) } diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index bd310b07897..0a72a9d669f 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -172,11 +172,11 @@ impl HasBottom for ConditionSet<'_> { } impl<'a> ConditionSet<'a> { - fn iter(self) -> impl Iterator + 'a { + fn iter(self) -> impl Iterator { self.0.iter().copied() } - fn iter_matches(self, value: ScalarInt) -> impl Iterator + 'a { + fn iter_matches(self, value: ScalarInt) -> impl Iterator { self.iter().filter(move |c| c.matches(value)) } diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index 28de99f9193..7c6ccc89c4f 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -185,7 +185,7 @@ impl<'tcx> ReplacementMap<'tcx> { fn place_fragments( &self, place: Place<'tcx>, - ) -> Option, Local)> + '_> { + ) -> Option, Local)>> { let local = place.as_local()?; let fields = self.fragments[local].as_ref()?; Some(fields.iter_enumerated().filter_map(|(field, &opt_ty_local)| { diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index 9f769077e77..3d512fb064e 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -138,7 +138,7 @@ impl SsaLocals { pub(super) fn assignments<'a, 'tcx>( &'a self, body: &'a Body<'tcx>, - ) -> impl Iterator, Location)> + 'a { + ) -> impl Iterator, Location)> { self.assignment_order.iter().filter_map(|&local| { if let Set1::One(DefLocation::Assignment(loc)) = self.assignments[local] { let stmt = body.stmt_at(loc).left()?; diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 1195c25e130..9b652cddc49 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -323,7 +323,7 @@ impl<'tcx> MonoItems<'tcx> { self.items.entry(item.node).or_insert(item.span); } - fn items(&self) -> impl Iterator> + '_ { + fn items(&self) -> impl Iterator> { self.items.keys().cloned() } } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index bbd73dec2e4..80a33a76005 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1657,7 +1657,7 @@ impl<'a> Parser<'a> { // Debug view of the parser's token stream, up to `{lookahead}` tokens. // Only used when debugging. #[allow(unused)] - pub(crate) fn debug_lookahead(&self, lookahead: usize) -> impl fmt::Debug + '_ { + pub(crate) fn debug_lookahead(&self, lookahead: usize) -> impl fmt::Debug { fmt::from_fn(move |f| { let mut dbg_fmt = f.debug_struct("Parser"); // or at least, one view of diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index fec44d5af55..a3400ebb799 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -61,11 +61,11 @@ pub trait PatCx: Sized + fmt::Debug { fn ctor_arity(&self, ctor: &Constructor, ty: &Self::Ty) -> usize; /// The types of the fields for this constructor. The result must contain `ctor_arity()` fields. - fn ctor_sub_tys<'a>( - &'a self, - ctor: &'a Constructor, - ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator + Captures<'a>; + fn ctor_sub_tys( + &self, + ctor: &Constructor, + ty: &Self::Ty, + ) -> impl Iterator + ExactSizeIterator; /// The set of all the constructors for `ty`. /// diff --git a/compiler/rustc_pattern_analysis/src/pat_column.rs b/compiler/rustc_pattern_analysis/src/pat_column.rs index eb4e095c1c6..814eb8afcfc 100644 --- a/compiler/rustc_pattern_analysis/src/pat_column.rs +++ b/compiler/rustc_pattern_analysis/src/pat_column.rs @@ -1,6 +1,6 @@ use crate::constructor::{Constructor, SplitConstructorSet}; use crate::pat::{DeconstructedPat, PatOrWild}; -use crate::{Captures, MatchArm, PatCx}; +use crate::{MatchArm, PatCx}; /// A column of patterns in a match, where a column is the intuitive notion of "subpatterns that /// inspect the same subvalue/place". @@ -41,7 +41,7 @@ impl<'p, Cx: PatCx> PatternColumn<'p, Cx> { pub fn head_ty(&self) -> Option<&Cx::Ty> { self.patterns.first().map(|pat| pat.ty()) } - pub fn iter<'a>(&'a self) -> impl Iterator> + Captures<'a> { + pub fn iter(&self) -> impl Iterator> { self.patterns.iter().copied() } diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 0b1e954d64d..88194c737a6 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -25,7 +25,7 @@ use crate::lints::lint_nonexhaustive_missing_variants; use crate::pat_column::PatternColumn; use crate::rustc::print::EnumInfo; use crate::usefulness::{PlaceValidity, compute_match_usefulness}; -use crate::{Captures, PatCx, PrivateUninhabitedField, errors}; +use crate::{PatCx, PrivateUninhabitedField, errors}; mod print; @@ -175,8 +175,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { &self, ty: RevealedTy<'tcx>, variant: &'tcx VariantDef, - ) -> impl Iterator)> + Captures<'p> + Captures<'_> - { + ) -> impl Iterator)> { let ty::Adt(_, args) = ty.kind() else { bug!() }; variant.fields.iter().map(move |field| { let ty = field.ty(self.tcx, args); @@ -203,13 +202,11 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { /// Returns the types of the fields for a given constructor. The result must have a length of /// `ctor.arity()`. - pub(crate) fn ctor_sub_tys<'a>( - &'a self, - ctor: &'a Constructor<'p, 'tcx>, + pub(crate) fn ctor_sub_tys( + &self, + ctor: &Constructor<'p, 'tcx>, ty: RevealedTy<'tcx>, - ) -> impl Iterator, PrivateUninhabitedField)> - + ExactSizeIterator - + Captures<'a> { + ) -> impl Iterator, PrivateUninhabitedField)> + ExactSizeIterator { fn reveal_and_alloc<'a, 'tcx>( cx: &'a RustcPatCtxt<'_, 'tcx>, iter: impl Iterator>, @@ -936,12 +933,11 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> { fn ctor_arity(&self, ctor: &crate::constructor::Constructor, ty: &Self::Ty) -> usize { self.ctor_arity(ctor, *ty) } - fn ctor_sub_tys<'a>( - &'a self, - ctor: &'a crate::constructor::Constructor, - ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator + Captures<'a> - { + fn ctor_sub_tys( + &self, + ctor: &crate::constructor::Constructor, + ty: &Self::Ty, + ) -> impl Iterator + ExactSizeIterator { self.ctor_sub_tys(ctor, *ty) } fn ctors_for_ty( diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index 1dff76141da..11ebbea07fa 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -719,7 +719,7 @@ use tracing::{debug, instrument}; use self::PlaceValidity::*; use crate::constructor::{Constructor, ConstructorSet, IntRange}; use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat}; -use crate::{Captures, MatchArm, PatCx, PrivateUninhabitedField}; +use crate::{MatchArm, PatCx, PrivateUninhabitedField}; #[cfg(not(feature = "rustc"))] pub fn ensure_sufficient_stack(f: impl FnOnce() -> R) -> R { f() @@ -902,11 +902,11 @@ struct PlaceInfo { impl PlaceInfo { /// Given a constructor for the current place, we return one `PlaceInfo` for each field of the /// constructor. - fn specialize<'a>( - &'a self, - cx: &'a Cx, - ctor: &'a Constructor, - ) -> impl Iterator + ExactSizeIterator + Captures<'a> { + fn specialize( + &self, + cx: &Cx, + ctor: &Constructor, + ) -> impl Iterator + ExactSizeIterator { let ctor_sub_tys = cx.ctor_sub_tys(ctor, &self.ty); let ctor_sub_validity = self.validity.specialize(ctor); ctor_sub_tys.map(move |(ty, PrivateUninhabitedField(private_uninhabited))| PlaceInfo { @@ -1046,13 +1046,13 @@ impl<'p, Cx: PatCx> PatStack<'p, Cx> { self.pats[0] } - fn iter(&self) -> impl Iterator> + Captures<'_> { + fn iter(&self) -> impl Iterator> { self.pats.iter().copied() } // Expand the first or-pattern into its subpatterns. Only useful if the pattern is an // or-pattern. Panics if `self` is empty. - fn expand_or_pat(&self) -> impl Iterator> + Captures<'_> { + fn expand_or_pat(&self) -> impl Iterator> { self.head().expand_or_pat().into_iter().map(move |pat| { let mut new = self.clone(); new.pats[0] = pat; @@ -1157,15 +1157,12 @@ impl<'p, Cx: PatCx> MatrixRow<'p, Cx> { self.pats.head() } - fn iter(&self) -> impl Iterator> + Captures<'_> { + fn iter(&self) -> impl Iterator> { self.pats.iter() } // Expand the first or-pattern (if any) into its subpatterns. Panics if `self` is empty. - fn expand_or_pat( - &self, - parent_row: usize, - ) -> impl Iterator> + Captures<'_> { + fn expand_or_pat(&self, parent_row: usize) -> impl Iterator> { let is_or_pat = self.pats.head().is_or_pat(); self.pats.expand_or_pat().map(move |patstack| MatrixRow { pats: patstack, @@ -1275,7 +1272,7 @@ impl<'p, Cx: PatCx> Matrix<'p, Cx> { } /// Iterate over the first pattern of each row. - fn heads(&self) -> impl Iterator> + Clone + Captures<'_> { + fn heads(&self) -> impl Iterator> + Clone { self.rows().map(|r| r.head()) } diff --git a/compiler/rustc_pattern_analysis/tests/common/mod.rs b/compiler/rustc_pattern_analysis/tests/common/mod.rs index 23560ad6419..365bc2d863f 100644 --- a/compiler/rustc_pattern_analysis/tests/common/mod.rs +++ b/compiler/rustc_pattern_analysis/tests/common/mod.rs @@ -2,7 +2,7 @@ use rustc_pattern_analysis::constructor::{ Constructor, ConstructorSet, IntRange, MaybeInfiniteInt, RangeEnd, VariantVisibility, }; use rustc_pattern_analysis::usefulness::{PlaceValidity, UsefulnessReport}; -use rustc_pattern_analysis::{Captures, MatchArm, PatCx, PrivateUninhabitedField}; +use rustc_pattern_analysis::{MatchArm, PatCx, PrivateUninhabitedField}; /// Sets up `tracing` for easier debugging. Tries to look like the `rustc` setup. pub fn init_tracing() { @@ -156,12 +156,11 @@ impl PatCx for Cx { ty.sub_tys(ctor).len() } - fn ctor_sub_tys<'a>( - &'a self, - ctor: &'a Constructor, - ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator + Captures<'a> - { + fn ctor_sub_tys( + &self, + ctor: &Constructor, + ty: &Self::Ty, + ) -> impl Iterator + ExactSizeIterator { ty.sub_tys(ctor).into_iter().map(|ty| (ty, PrivateUninhabitedField(false))) } diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index a4fb0a5b072..bc78878a84a 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -98,7 +98,7 @@ impl SerializedDepGraph { pub fn edge_targets_from( &self, source: SerializedDepNodeIndex, - ) -> impl Iterator + Clone + '_ { + ) -> impl Iterator + Clone { let header = self.edge_list_indices[source]; let mut raw = &self.edge_list_data[header.start()..]; // Figure out where the edge list for `source` ends by getting the start index of the next diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index e0405a71f65..1fe521bd32d 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -329,7 +329,7 @@ impl ParseSess { self.proc_macro_quoted_spans.push(span) } - pub fn proc_macro_quoted_spans(&self) -> impl Iterator + '_ { + pub fn proc_macro_quoted_spans(&self) -> impl Iterator { // This is equivalent to `.iter().copied().enumerate()`, but that isn't possible for // AppendOnlyVec, so we resort to this scheme. self.proc_macro_quoted_spans.iter_enumerated() diff --git a/compiler/rustc_session/src/search_paths.rs b/compiler/rustc_session/src/search_paths.rs index b750d870cb6..00e12b45baf 100644 --- a/compiler/rustc_session/src/search_paths.rs +++ b/compiler/rustc_session/src/search_paths.rs @@ -20,12 +20,11 @@ pub struct FilesIndex(Vec<(Arc, SearchPathFile)>); impl FilesIndex { /// Look up [SearchPathFile] by (prefix, suffix) pair. - pub fn query<'this, 'prefix, 'suffix>( - &'this self, - prefix: &'prefix str, - suffix: &'suffix str, - ) -> Option + use<'this, 'prefix, 'suffix>> - { + pub fn query<'s>( + &'s self, + prefix: &str, + suffix: &str, + ) -> Option> { let start = self.0.partition_point(|(k, _)| **k < *prefix); if start == self.0.len() { return None; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index 42b8199cb26..bed9734f389 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -1074,7 +1074,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { &self, path: &'tcx hir::Path<'tcx>, args: GenericArgsRef<'tcx>, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> + 'tcx { let tcx = self.tecx.tcx; let have_turbofish = path.segments.iter().any(|segment| { segment.args.is_some_and(|args| args.args.iter().any(|arg| arg.is_ty_or_const())) diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 51d560d4c43..704ba6e501d 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -67,9 +67,7 @@ impl<'tcx> ObligationStorage<'tcx> { obligations } - fn unstalled_for_select( - &mut self, - ) -> impl Iterator> + use<'tcx> { + fn unstalled_for_select(&mut self) -> impl Iterator> + 'tcx { mem::take(&mut self.pending).into_iter() } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index f2d2dd2f3ce..e39f8e673db 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -1,6 +1,5 @@ use std::marker::PhantomData; -use rustc_data_structures::captures::Captures; use rustc_data_structures::obligation_forest::{ Error, ForestObligation, ObligationForest, ObligationProcessor, Outcome, ProcessResult, }; @@ -900,10 +899,10 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> { } /// Returns the set of inference variables contained in `args`. -fn args_infer_vars<'a, 'tcx>( - selcx: &SelectionContext<'a, 'tcx>, +fn args_infer_vars<'tcx>( + selcx: &SelectionContext<'_, 'tcx>, args: ty::Binder<'tcx, GenericArgsRef<'tcx>>, -) -> impl Iterator + Captures<'tcx> { +) -> impl Iterator { selcx .infcx .resolve_vars_if_possible(args) 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 f39c611d19f..19d3561dd59 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs @@ -200,15 +200,12 @@ impl<'tcx> Children { } } -fn iter_children(children: &Children) -> impl Iterator + '_ { +fn iter_children(children: &Children) -> impl Iterator { let nonblanket = children.non_blanket_impls.iter().flat_map(|(_, v)| v.iter()); children.blanket_impls.iter().chain(nonblanket).cloned() } -fn filtered_children( - children: &mut Children, - st: SimplifiedType, -) -> impl Iterator + '_ { +fn filtered_children(children: &mut Children, st: SimplifiedType) -> impl Iterator { let nonblanket = children.non_blanket_impls.entry(st).or_default().iter(); children.blanket_impls.iter().chain(nonblanket).cloned() } diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index 0024316b877..165174c0bcc 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -196,7 +196,7 @@ fn own_existential_vtable_entries(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &[Def fn own_existential_vtable_entries_iter( tcx: TyCtxt<'_>, trait_def_id: DefId, -) -> impl Iterator + '_ { +) -> impl Iterator { let trait_methods = tcx .associated_items(trait_def_id) .in_definition_order() diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index cc7baf8daac..6205578bf74 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -151,7 +151,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' } } -fn fn_sig_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator + '_ { +fn fn_sig_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator { let node = tcx.hir_node_by_def_id(def_id); if let Some(decl) = node.fn_decl() { decl.inputs.iter().map(|ty| ty.span).chain(iter::once(decl.output.span())) @@ -160,7 +160,7 @@ fn fn_sig_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator, def_id: LocalDefId) -> impl Iterator + '_ { +fn impl_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator { let item = tcx.hir().expect_item(def_id); if let hir::ItemKind::Impl(impl_) = item.kind { let trait_args = impl_ diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index 5ea6716c5ca..525199801c3 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -33,7 +33,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou fn non_zst_fields<'tcx, 'a>( cx: &'a LayoutCx<'tcx>, layout: &'a TyAndLayout<'tcx>, - ) -> impl Iterator)> + 'a { + ) -> impl Iterator)> { (0..layout.layout.fields().count()).filter_map(|i| { let field = layout.field(cx, i); // Also checking `align == 1` here leads to test failures in diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 80de7e20951..52955ec59a4 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -373,7 +373,7 @@ fn drop_tys_helper<'tcx>( fn adt_consider_insignificant_dtor<'tcx>( tcx: TyCtxt<'tcx>, -) -> impl Fn(ty::AdtDef<'tcx>) -> Option + 'tcx { +) -> impl Fn(ty::AdtDef<'tcx>) -> Option { move |adt_def: ty::AdtDef<'tcx>| { let is_marked_insig = tcx.has_attr(adt_def.did(), sym::rustc_insignificant_dtor); if is_marked_insig { diff --git a/compiler/rustc_type_ir/src/search_graph/mod.rs b/compiler/rustc_type_ir/src/search_graph/mod.rs index 3cc2dcbaca6..082cfff72e2 100644 --- a/compiler/rustc_type_ir/src/search_graph/mod.rs +++ b/compiler/rustc_type_ir/src/search_graph/mod.rs @@ -285,7 +285,7 @@ impl NestedGoals { #[cfg_attr(feature = "nightly", rustc_lint_query_instability)] #[allow(rustc::potential_query_instability)] - fn iter(&self) -> impl Iterator + '_ { + fn iter(&self) -> impl Iterator { self.nested_goals.iter().map(|(i, p)| (*i, *p)) } diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index bc2e427f50c..f8b46f50a52 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -864,7 +864,7 @@ impl SwitchTargets { } /// The conditional targets which are only taken if the pattern matches the given value. - pub fn branches(&self) -> impl Iterator + '_ { + pub fn branches(&self) -> impl Iterator { self.branches.iter().copied() } diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index 9ef80edb82a..b857a735b72 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -809,7 +809,7 @@ impl AdtDef { } /// Iterate over the variants in this ADT. - pub fn variants_iter(&self) -> impl Iterator + '_ { + pub fn variants_iter(&self) -> impl Iterator { (0..self.num_variants()) .map(|idx| VariantDef { idx: VariantIdx::to_val(idx), adt_def: *self }) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs index 3312da470c0..91eb59fb314 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs @@ -361,11 +361,11 @@ impl PatCx for MatchCheckCtx<'_> { } } - fn ctor_sub_tys<'a>( - &'a self, - ctor: &'a rustc_pattern_analysis::constructor::Constructor, - ty: &'a Self::Ty, - ) -> impl ExactSizeIterator + Captures<'a> { + fn ctor_sub_tys( + &self, + ctor: &rustc_pattern_analysis::constructor::Constructor, + ty: &Self::Ty, + ) -> impl ExactSizeIterator { let single = |ty| smallvec![(ty, PrivateUninhabitedField(false))]; let tys: SmallVec<[_; 2]> = match ctor { Struct | Variant(_) | UnionField => match ty.kind(Interner) { -- cgit 1.4.1-3-g733a5 From 386d7a5d0a9a8e4273dcdf34c05bca69d7ca600d Mon Sep 17 00:00:00 2001 From: Laurențiu Nicola Date: Mon, 24 Feb 2025 09:42:28 +0200 Subject: Preparing for merge from rust-lang/rust --- src/tools/rust-analyzer/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tools/rust-analyzer') diff --git a/src/tools/rust-analyzer/rust-version b/src/tools/rust-analyzer/rust-version index 4006d06e4fe..6cd39fabeee 100644 --- a/src/tools/rust-analyzer/rust-version +++ b/src/tools/rust-analyzer/rust-version @@ -1 +1 @@ -273465e1f2932a30a5b56ac95859cdc86f3f33fa +e0be1a02626abef2878cb7f4aaef7ae409477112 -- cgit 1.4.1-3-g733a5 From df39a77534e7572bb8ac2b8aa57ff5c931d555e8 Mon Sep 17 00:00:00 2001 From: Laurențiu Nicola Date: Mon, 24 Feb 2025 10:10:51 +0200 Subject: Add rustc_hashes and bump the others --- src/tools/rust-analyzer/Cargo.lock | 42 ++++++++++++++++------- src/tools/rust-analyzer/Cargo.toml | 11 +++--- src/tools/rust-analyzer/crates/hir-def/Cargo.toml | 1 + src/tools/rust-analyzer/crates/hir-ty/Cargo.toml | 1 + 4 files changed, 38 insertions(+), 17 deletions(-) (limited to 'src/tools/rust-analyzer') diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index fc3680ce274..01e6a39f7c9 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -561,6 +561,7 @@ dependencies = [ "la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "mbe", "ra-ap-rustc_abi", + "ra-ap-rustc_hashes", "ra-ap-rustc_parse_format", "rustc-hash 2.0.0", "rustc_apfloat", @@ -628,6 +629,7 @@ dependencies = [ "oorandom", "project-model", "ra-ap-rustc_abi", + "ra-ap-rustc_hashes", "ra-ap-rustc_index", "ra-ap-rustc_pattern_analysis", "rustc-hash 2.0.0", @@ -1505,20 +1507,30 @@ dependencies = [ [[package]] name = "ra-ap-rustc_abi" -version = "0.95.0" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40c4e339b71a8f075a829b1acaf32f870a11b466d9b8623d50b0ce33e65af95" +checksum = "3829c3355d1681ffeaf1450ec71edcdace6820fe2e86469d8fc1ad45e2c96460" dependencies = [ "bitflags 2.7.0", + "ra-ap-rustc_hashes", "ra-ap-rustc_index", "tracing", ] +[[package]] +name = "ra-ap-rustc_hashes" +version = "0.97.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd4d6d4c434bec08e02370a4f64a4985312097215a62e82d0f757f3a98e502e" +dependencies = [ + "rustc-stable-hash", +] + [[package]] name = "ra-ap-rustc_index" -version = "0.95.0" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872072e2ba11d11147ebe9fde1608fe7f7d9b5c51dac524af28ee07c6dade468" +checksum = "bad6fc4bd7522e31096e2de5b0351144fe0684b608791ee26c842bf2da1b19ae" dependencies = [ "ra-ap-rustc_index_macros", "smallvec", @@ -1526,9 +1538,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_index_macros" -version = "0.95.0" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffcd77debcaf2ad690a57c2d041c11eb33fe66869754b2c5f35c52954b46af0c" +checksum = "cfb234e1f84b92be45276c3025bee18789e9bc95bec8789bec961e78edb01c52" dependencies = [ "proc-macro2", "quote", @@ -1537,9 +1549,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_lexer" -version = "0.95.0" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49265cdf8823f8d246e476c79c60bd6e5b551c81ae76e1c8d6a5e0dc73df0bca" +checksum = "7a3a40bd11dc43d1cb110e730b80620cf8102f4cca8920a02b65954da0ed931f" dependencies = [ "memchr", "unicode-properties", @@ -1548,9 +1560,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_parse_format" -version = "0.95.0" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3da239fdc971176de0db45cb631d71475b52033a3d0027d91964da7be89eee6" +checksum = "5feb877478994cb4c0c0c7a5116a352eefc0634aefc8636feb00a893fa5b7135" dependencies = [ "ra-ap-rustc_index", "ra-ap-rustc_lexer", @@ -1558,9 +1570,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_pattern_analysis" -version = "0.95.0" +version = "0.97.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56057d08fdfa0d95494e461bbdd5d4b3fdb349cca6be05ad7759bc964be1b8d4" +checksum = "a76774d35934d464c4115908cde16f76a4f7e540fe1eea6b79336c556e37bdd3" dependencies = [ "ra-ap-rustc_index", "rustc-hash 2.0.0", @@ -1735,6 +1747,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +[[package]] +name = "rustc-stable-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2febf9acc5ee5e99d1ad0afcdbccc02d87aa3f857a1f01f825b80eacf8edfcd1" + [[package]] name = "rustc_apfloat" version = "0.2.1+llvm-462a31f5a5ab" diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml index 5060013b139..1ff36a68e8f 100644 --- a/src/tools/rust-analyzer/Cargo.toml +++ b/src/tools/rust-analyzer/Cargo.toml @@ -86,11 +86,12 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" } vfs = { path = "./crates/vfs", version = "0.0.0" } edition = { path = "./crates/edition", version = "0.0.0" } -ra-ap-rustc_lexer = { version = "0.95", default-features = false } -ra-ap-rustc_parse_format = { version = "0.95", default-features = false } -ra-ap-rustc_index = { version = "0.95", default-features = false } -ra-ap-rustc_abi = { version = "0.95", default-features = false } -ra-ap-rustc_pattern_analysis = { version = "0.95", default-features = false } +ra-ap-rustc_hashes = { version = "0.97", default-features = false } +ra-ap-rustc_lexer = { version = "0.97", default-features = false } +ra-ap-rustc_parse_format = { version = "0.97", default-features = false } +ra-ap-rustc_index = { version = "0.97", default-features = false } +ra-ap-rustc_abi = { version = "0.97", default-features = false } +ra-ap-rustc_pattern_analysis = { version = "0.97", default-features = false } # local crates that aren't published to crates.io. These should not have versions. diff --git a/src/tools/rust-analyzer/crates/hir-def/Cargo.toml b/src/tools/rust-analyzer/crates/hir-def/Cargo.toml index 74fe49b7676..9a448ec14ea 100644 --- a/src/tools/rust-analyzer/crates/hir-def/Cargo.toml +++ b/src/tools/rust-analyzer/crates/hir-def/Cargo.toml @@ -31,6 +31,7 @@ triomphe.workspace = true rustc_apfloat = "0.2.0" text-size.workspace = true +ra-ap-rustc_hashes.workspace = true ra-ap-rustc_parse_format.workspace = true ra-ap-rustc_abi.workspace = true diff --git a/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml b/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml index eaa258a6b5d..4d36de0b383 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml +++ b/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml @@ -36,6 +36,7 @@ indexmap.workspace = true rustc_apfloat = "0.2.0" ra-ap-rustc_abi.workspace = true +ra-ap-rustc_hashes.workspace = true ra-ap-rustc_index.workspace = true ra-ap-rustc_pattern_analysis.workspace = true -- cgit 1.4.1-3-g733a5 From 1375df2fbaae99708111f03367d1ff622eee3664 Mon Sep 17 00:00:00 2001 From: Laurențiu Nicola Date: Mon, 24 Feb 2025 10:28:46 +0200 Subject: Format code --- src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs | 8 +++++++- src/tools/rust-analyzer/crates/hir-ty/src/layout.rs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/tools/rust-analyzer') diff --git a/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs b/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs index 5d1834a8642..c94622016d3 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs @@ -173,7 +173,13 @@ fn parse_repr_tt(tt: &TopSubtree) -> Option { } } - Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: Hash64::ZERO }) + Some(ReprOptions { + int, + align: max_align, + pack: min_pack, + flags, + field_shuffle_seed: Hash64::ZERO, + }) } impl StructData { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index a72bcad50a0..e2ab336d2e4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -14,8 +14,8 @@ use hir_def::{ }; use la_arena::{Idx, RawIdx}; use rustc_abi::AddressSpace; -use rustc_index::{IndexSlice, IndexVec}; use rustc_hashes::Hash64; +use rustc_index::{IndexSlice, IndexVec}; use triomphe::Arc; -- cgit 1.4.1-3-g733a5 From a2bd5a5ed388c71b253c1ad5cdd35c570ea0418e Mon Sep 17 00:00:00 2001 From: Laurențiu Nicola Date: Mon, 24 Feb 2025 10:28:52 +0200 Subject: Update assist docs --- .../docs/book/src/assists_generated.md | 324 +++++++++++---------- 1 file changed, 175 insertions(+), 149 deletions(-) (limited to 'src/tools/rust-analyzer') diff --git a/src/tools/rust-analyzer/docs/book/src/assists_generated.md b/src/tools/rust-analyzer/docs/book/src/assists_generated.md index 761a7f859be..9d68a873ffe 100644 --- a/src/tools/rust-analyzer/docs/book/src/assists_generated.md +++ b/src/tools/rust-analyzer/docs/book/src/assists_generated.md @@ -1,7 +1,7 @@ //! Generated by `cargo xtask codegen assists-doc-tests`, do not edit by hand. ### `add_braces` -**Source:** [add_braces.rs](/crates/ide-assists/src/handlers/add_braces.rs#8) +**Source:** [add_braces.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_braces.rs#L8) Adds braces to lambda and match arm expressions. @@ -29,7 +29,7 @@ fn foo(n: i32) -> i32 { ### `add_explicit_type` -**Source:** [add_explicit_type.rs](/crates/ide-assists/src/handlers/add_explicit_type.rs#7) +**Source:** [add_explicit_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_explicit_type.rs#L7) Specify type for a let binding. @@ -49,7 +49,7 @@ fn main() { ### `add_hash` -**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#89) +**Source:** [raw_string.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/raw_string.rs#L89) Adds a hash to a raw string literal. @@ -69,7 +69,7 @@ fn main() { ### `add_impl_default_members` -**Source:** [add_missing_impl_members.rs](/crates/ide-assists/src/handlers/add_missing_impl_members.rs#58) +**Source:** [add_missing_impl_members.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_missing_impl_members.rs#L58) Adds scaffold for overriding default impl members. @@ -105,7 +105,7 @@ impl Trait for () { ### `add_impl_missing_members` -**Source:** [add_missing_impl_members.rs](/crates/ide-assists/src/handlers/add_missing_impl_members.rs#16) +**Source:** [add_missing_impl_members.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_missing_impl_members.rs#L16) Adds scaffold for required impl members. @@ -141,7 +141,7 @@ impl Trait for () { ### `add_label_to_loop` -**Source:** [add_label_to_loop.rs](/crates/ide-assists/src/handlers/add_label_to_loop.rs#9) +**Source:** [add_label_to_loop.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_label_to_loop.rs#L9) Adds a label to a loop. @@ -167,7 +167,7 @@ fn main() { ### `add_lifetime_to_type` -**Source:** [add_lifetime_to_type.rs](/crates/ide-assists/src/handlers/add_lifetime_to_type.rs#5) +**Source:** [add_lifetime_to_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_lifetime_to_type.rs#L5) Adds a new lifetime to a struct, enum or union. @@ -189,7 +189,7 @@ struct Point<'a> { ### `add_missing_match_arms` -**Source:** [add_missing_match_arms.rs](/crates/ide-assists/src/handlers/add_missing_match_arms.rs#14) +**Source:** [add_missing_match_arms.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_missing_match_arms.rs#L16) Adds missing clauses to a `match` expression. @@ -218,7 +218,7 @@ fn handle(action: Action) { ### `add_return_type` -**Source:** [add_return_type.rs](/crates/ide-assists/src/handlers/add_return_type.rs#6) +**Source:** [add_return_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_return_type.rs#L6) Adds the return type to a function or closure inferred from its tail expression if it doesn't have a return type specified. This assists is useable in a functions or closures tail expression or return type position. @@ -235,7 +235,7 @@ fn foo() -> i32 { 42i32 } ### `add_turbo_fish` -**Source:** [add_turbo_fish.rs](/crates/ide-assists/src/handlers/add_turbo_fish.rs#14) +**Source:** [add_turbo_fish.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/add_turbo_fish.rs#L14) Adds `::<_>` to a call of a generic method or function. @@ -257,7 +257,7 @@ fn main() { ### `apply_demorgan` -**Source:** [apply_demorgan.rs](/crates/ide-assists/src/handlers/apply_demorgan.rs#16) +**Source:** [apply_demorgan.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/apply_demorgan.rs#L16) Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). This transforms expressions of the form `!l || !r` into `!(l && r)`. @@ -280,7 +280,7 @@ fn main() { ### `apply_demorgan_iterator` -**Source:** [apply_demorgan.rs](/crates/ide-assists/src/handlers/apply_demorgan.rs#132) +**Source:** [apply_demorgan.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/apply_demorgan.rs#L132) Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws) to `Iterator::all` and `Iterator::any`. @@ -311,7 +311,7 @@ fn main() { ### `auto_import` -**Source:** [auto_import.rs](/crates/ide-assists/src/handlers/auto_import.rs#73) +**Source:** [auto_import.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/auto_import.rs#L73) If the name is unresolved, provides all possible imports for it. @@ -333,7 +333,7 @@ fn main() { ### `bind_unused_param` -**Source:** [bind_unused_param.rs](/crates/ide-assists/src/handlers/bind_unused_param.rs#12) +**Source:** [bind_unused_param.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/bind_unused_param.rs#L12) Binds unused function parameter to an underscore. @@ -351,7 +351,7 @@ fn some_function(x: i32) { ### `bool_to_enum` -**Source:** [bool_to_enum.rs](/crates/ide-assists/src/handlers/bool_to_enum.rs#29) +**Source:** [bool_to_enum.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/bool_to_enum.rs#L29) This converts boolean local variables, fields, constants, and statics into a new enum with two variants `Bool::True` and `Bool::False`, as well as replacing @@ -385,7 +385,7 @@ fn main() { ### `change_visibility` -**Source:** [change_visibility.rs](/crates/ide-assists/src/handlers/change_visibility.rs#13) +**Source:** [change_visibility.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/change_visibility.rs#L13) Adds or changes existing visibility specifier. @@ -401,7 +401,7 @@ pub(crate) fn frobnicate() {} ### `comment_to_doc` -**Source:** [convert_comment_from_or_to_doc.rs](/crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs#9) +**Source:** [convert_comment_from_or_to_doc.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs#L9) Converts comments to documentation. @@ -419,7 +419,7 @@ Converts comments to documentation. ### `convert_bool_then_to_if` -**Source:** [convert_bool_then.rs](/crates/ide-assists/src/handlers/convert_bool_then.rs#131) +**Source:** [convert_bool_then.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_bool_then.rs#L131) Converts a `bool::then` method call to an equivalent if expression. @@ -443,7 +443,7 @@ fn main() { ### `convert_closure_to_fn` -**Source:** [convert_closure_to_fn.rs](/crates/ide-assists/src/handlers/convert_closure_to_fn.rs#25) +**Source:** [convert_closure_to_fn.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_closure_to_fn.rs#L25) This converts a closure to a freestanding function, changing all captures to parameters. @@ -469,7 +469,7 @@ fn main() { ### `convert_for_loop_with_for_each` -**Source:** [convert_iter_for_each_to_for.rs](/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#76) +**Source:** [convert_iter_for_each_to_for.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#L76) Converts a for loop into a for_each loop on the Iterator. @@ -495,7 +495,7 @@ fn main() { ### `convert_from_to_tryfrom` -**Source:** [convert_from_to_tryfrom.rs](/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs#10) +**Source:** [convert_from_to_tryfrom.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs#L10) Converts a From impl to a TryFrom impl, wrapping returns in `Ok`. @@ -527,7 +527,7 @@ impl TryFrom for Thing { ### `convert_if_to_bool_then` -**Source:** [convert_bool_then.rs](/crates/ide-assists/src/handlers/convert_bool_then.rs#20) +**Source:** [convert_bool_then.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_bool_then.rs#L20) Converts an if expression into a corresponding `bool::then` call. @@ -551,7 +551,7 @@ fn main() { ### `convert_integer_literal` -**Source:** [convert_integer_literal.rs](/crates/ide-assists/src/handlers/convert_integer_literal.rs#5) +**Source:** [convert_integer_literal.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_integer_literal.rs#L5) Converts the base of integer literals to other bases. @@ -567,7 +567,7 @@ const _: i32 = 0b1010; ### `convert_into_to_from` -**Source:** [convert_into_to_from.rs](/crates/ide-assists/src/handlers/convert_into_to_from.rs#8) +**Source:** [convert_into_to_from.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_into_to_from.rs#L8) Converts an Into impl to an equivalent From impl. @@ -597,7 +597,7 @@ impl From for Thing { ### `convert_iter_for_each_to_for` -**Source:** [convert_iter_for_each_to_for.rs](/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#11) +**Source:** [convert_iter_for_each_to_for.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#L11) Converts an Iterator::for_each function into a for loop. @@ -623,7 +623,7 @@ fn main() { ### `convert_let_else_to_match` -**Source:** [convert_let_else_to_match.rs](/crates/ide-assists/src/handlers/convert_let_else_to_match.rs#9) +**Source:** [convert_let_else_to_match.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_let_else_to_match.rs#L9) Converts let-else statement to let statement and match expression. @@ -646,7 +646,7 @@ fn main() { ### `convert_match_to_let_else` -**Source:** [convert_match_to_let_else.rs](/crates/ide-assists/src/handlers/convert_match_to_let_else.rs#12) +**Source:** [convert_match_to_let_else.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_match_to_let_else.rs#L12) Converts let statement with match initializer to let-else statement. @@ -669,7 +669,7 @@ fn foo(opt: Option<()>) { ### `convert_named_struct_to_tuple_struct` -**Source:** [convert_named_struct_to_tuple_struct.rs](/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs#11) +**Source:** [convert_named_struct_to_tuple_struct.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs#L11) Converts struct with named fields to tuple struct, and analogously for enum variants with named fields. @@ -714,7 +714,7 @@ impl Point { ### `convert_nested_function_to_closure` -**Source:** [convert_nested_function_to_closure.rs](/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs#7) +**Source:** [convert_nested_function_to_closure.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs#L7) Converts a function that is defined within the body of another function into a closure. @@ -742,7 +742,7 @@ fn main() { ### `convert_to_guarded_return` -**Source:** [convert_to_guarded_return.rs](/crates/ide-assists/src/handlers/convert_to_guarded_return.rs#24) +**Source:** [convert_to_guarded_return.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_to_guarded_return.rs#L24) Replace a large conditional with a guarded return. @@ -769,7 +769,7 @@ fn main() { ### `convert_tuple_return_type_to_struct` -**Source:** [convert_tuple_return_type_to_struct.rs](/crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs#20) +**Source:** [convert_tuple_return_type_to_struct.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs#L20) This converts the return type of a function from a tuple type into a tuple struct and updates the body accordingly. @@ -800,7 +800,7 @@ fn foo() -> FooResult { ### `convert_tuple_struct_to_named_struct` -**Source:** [convert_tuple_struct_to_named_struct.rs](/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs#10) +**Source:** [convert_tuple_struct_to_named_struct.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs#L10) Converts tuple struct to struct with named fields, and analogously for tuple enum variants. @@ -844,7 +844,7 @@ impl Point { ### `convert_two_arm_bool_match_to_matches_macro` -**Source:** [convert_two_arm_bool_match_to_matches_macro.rs](/crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs#8) +**Source:** [convert_two_arm_bool_match_to_matches_macro.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs#L8) Convert 2-arm match that evaluates to a boolean into the equivalent matches! invocation. @@ -867,7 +867,7 @@ fn main() { ### `convert_while_to_loop` -**Source:** [convert_while_to_loop.rs](/crates/ide-assists/src/handlers/convert_while_to_loop.rs#20) +**Source:** [convert_while_to_loop.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_while_to_loop.rs#L20) Replace a while with a loop. @@ -894,7 +894,7 @@ fn main() { ### `destructure_struct_binding` -**Source:** [destructure_struct_binding.rs](/crates/ide-assists/src/handlers/destructure_struct_binding.rs#18) +**Source:** [destructure_struct_binding.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/destructure_struct_binding.rs#L18) Destructures a struct binding in place. @@ -926,7 +926,7 @@ fn main() { ### `destructure_tuple_binding` -**Source:** [destructure_tuple_binding.rs](/crates/ide-assists/src/handlers/destructure_tuple_binding.rs#19) +**Source:** [destructure_tuple_binding.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/destructure_tuple_binding.rs#L19) Destructures a tuple binding in place. @@ -948,7 +948,7 @@ fn main() { ### `desugar_async_into_impl_future` -**Source:** [toggle_async_sugar.rs](/crates/ide-assists/src/handlers/toggle_async_sugar.rs#103) +**Source:** [toggle_async_sugar.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/toggle_async_sugar.rs#L103) Rewrites asynchronous function from `async fn` into `-> impl Future`. This action does not touch the function body and therefore `0` @@ -970,7 +970,7 @@ pub fn foo() -> impl core::future::Future { ### `desugar_doc_comment` -**Source:** [desugar_doc_comment.rs](/crates/ide-assists/src/handlers/desugar_doc_comment.rs#14) +**Source:** [desugar_doc_comment.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/desugar_doc_comment.rs#L14) Desugars doc-comments to the attribute form. @@ -988,7 +988,7 @@ comment"] ### `expand_glob_import` -**Source:** [expand_glob_import.rs](/crates/ide-assists/src/handlers/expand_glob_import.rs#18) +**Source:** [expand_glob_import.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/expand_glob_import.rs#L19) Expands glob imports. @@ -1017,8 +1017,34 @@ fn qux(bar: Bar, baz: Baz) {} ``` +### `expand_glob_reexport` +**Source:** [expand_glob_import.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/expand_glob_import.rs#L81) + +Expands non-private glob imports. + +#### Before +```rust +mod foo { + pub struct Bar; + pub struct Baz; +} + +pub use foo::*┃; +``` + +#### After +```rust +mod foo { + pub struct Bar; + pub struct Baz; +} + +pub use foo::{Bar, Baz}; +``` + + ### `explicit_enum_discriminant` -**Source:** [explicit_enum_discriminant.rs](/crates/ide-assists/src/handlers/explicit_enum_discriminant.rs#11) +**Source:** [explicit_enum_discriminant.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/explicit_enum_discriminant.rs#L11) Adds explicit discriminant to all enum variants. @@ -1044,7 +1070,7 @@ enum TheEnum { ### `extract_constant` -**Source:** [extract_variable.rs](/crates/ide-assists/src/handlers/extract_variable.rs#35) +**Source:** [extract_variable.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_variable.rs#L35) Extracts subexpression into a constant. @@ -1065,7 +1091,7 @@ fn main() { ### `extract_expressions_from_format_string` -**Source:** [extract_expressions_from_format_string.rs](/crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs#14) +**Source:** [extract_expressions_from_format_string.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs#L14) Move an expression out of a format string. @@ -1085,7 +1111,7 @@ fn main() { ### `extract_function` -**Source:** [extract_function.rs](/crates/ide-assists/src/handlers/extract_function.rs#39) +**Source:** [extract_function.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_function.rs#L39) Extracts selected statements and comments into new function. @@ -1117,7 +1143,7 @@ fn ┃fun_name(n: i32) { ### `extract_module` -**Source:** [extract_module.rs](/crates/ide-assists/src/handlers/extract_module.rs#29) +**Source:** [extract_module.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_module.rs#L29) Extracts a selected region as separate module. All the references, visibility and imports are resolved. @@ -1148,7 +1174,7 @@ fn bar(name: i32) -> i32 { ### `extract_static` -**Source:** [extract_variable.rs](/crates/ide-assists/src/handlers/extract_variable.rs#52) +**Source:** [extract_variable.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_variable.rs#L52) Extracts subexpression into a static. @@ -1169,7 +1195,7 @@ fn main() { ### `extract_struct_from_enum_variant` -**Source:** [extract_struct_from_enum_variant.rs](/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs#26) +**Source:** [extract_struct_from_enum_variant.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs#L26) Extracts a struct from enum variant. @@ -1187,7 +1213,7 @@ enum A { One(One) } ### `extract_type_alias` -**Source:** [extract_type_alias.rs](/crates/ide-assists/src/handlers/extract_type_alias.rs#10) +**Source:** [extract_type_alias.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_type_alias.rs#L10) Extracts the selected type as a type alias. @@ -1209,7 +1235,7 @@ struct S { ### `extract_variable` -**Source:** [extract_variable.rs](/crates/ide-assists/src/handlers/extract_variable.rs#18) +**Source:** [extract_variable.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_variable.rs#L18) Extracts subexpression into a variable. @@ -1230,7 +1256,7 @@ fn main() { ### `fill_record_pattern_fields` -**Source:** [fill_record_pattern_fields.rs](/crates/ide-assists/src/handlers/fill_record_pattern_fields.rs#8) +**Source:** [fill_record_pattern_fields.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/fill_record_pattern_fields.rs#L8) Fills fields by replacing rest pattern in record patterns. @@ -1254,7 +1280,7 @@ fn foo(bar: Bar) { ### `fix_visibility` -**Source:** [fix_visibility.rs](/crates/ide-assists/src/handlers/fix_visibility.rs#14) +**Source:** [fix_visibility.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/fix_visibility.rs#L14) Makes inaccessible item public. @@ -1280,7 +1306,7 @@ fn main() { ### `flip_binexpr` -**Source:** [flip_binexpr.rs](/crates/ide-assists/src/handlers/flip_binexpr.rs#8) +**Source:** [flip_binexpr.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/flip_binexpr.rs#L8) Flips operands of a binary expression. @@ -1300,7 +1326,7 @@ fn main() { ### `flip_comma` -**Source:** [flip_comma.rs](/crates/ide-assists/src/handlers/flip_comma.rs#10) +**Source:** [flip_comma.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/flip_comma.rs#L10) Flips two comma-separated items. @@ -1320,7 +1346,7 @@ fn main() { ### `flip_trait_bound` -**Source:** [flip_trait_bound.rs](/crates/ide-assists/src/handlers/flip_trait_bound.rs#9) +**Source:** [flip_trait_bound.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/flip_trait_bound.rs#L9) Flips two trait bounds. @@ -1336,7 +1362,7 @@ fn foo() { } ### `generate_constant` -**Source:** [generate_constant.rs](/crates/ide-assists/src/handlers/generate_constant.rs#14) +**Source:** [generate_constant.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_constant.rs#L14) Generate a named constant. @@ -1361,7 +1387,7 @@ fn main() { ### `generate_default_from_enum_variant` -**Source:** [generate_default_from_enum_variant.rs](/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs#6) +**Source:** [generate_default_from_enum_variant.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs#L6) Adds a Default impl for an enum using a variant. @@ -1391,7 +1417,7 @@ impl Default for Version { ### `generate_default_from_new` -**Source:** [generate_default_from_new.rs](/crates/ide-assists/src/handlers/generate_default_from_new.rs#13) +**Source:** [generate_default_from_new.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_default_from_new.rs#L13) Generates default implementation from new method. @@ -1425,7 +1451,7 @@ impl Default for Example { ### `generate_delegate_methods` -**Source:** [generate_delegate_methods.rs](/crates/ide-assists/src/handlers/generate_delegate_methods.rs#15) +**Source:** [generate_delegate_methods.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_delegate_methods.rs#L15) Generate delegate methods. @@ -1465,7 +1491,7 @@ impl Person { ### `generate_delegate_trait` -**Source:** [generate_delegate_trait.rs](/crates/ide-assists/src/handlers/generate_delegate_trait.rs#29) +**Source:** [generate_delegate_trait.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_delegate_trait.rs#L29) Generate delegate trait implementation for `StructField`s. @@ -1531,7 +1557,7 @@ impl SomeTrait for B { ### `generate_deref` -**Source:** [generate_deref.rs](/crates/ide-assists/src/handlers/generate_deref.rs#16) +**Source:** [generate_deref.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_deref.rs#L16) Generate `Deref` impl using the given struct field. @@ -1561,7 +1587,7 @@ impl core::ops::Deref for B { ### `generate_derive` -**Source:** [generate_derive.rs](/crates/ide-assists/src/handlers/generate_derive.rs#8) +**Source:** [generate_derive.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_derive.rs#L8) Adds a new `#[derive()]` clause to a struct or enum. @@ -1584,7 +1610,7 @@ struct Point { ### `generate_doc_example` -**Source:** [generate_documentation_template.rs](/crates/ide-assists/src/handlers/generate_documentation_template.rs#76) +**Source:** [generate_documentation_template.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_documentation_template.rs#L76) Generates a rustdoc example when editing an item's documentation. @@ -1610,7 +1636,7 @@ pub fn add(a: i32, b: i32) -> i32 { a + b } ### `generate_documentation_template` -**Source:** [generate_documentation_template.rs](/crates/ide-assists/src/handlers/generate_documentation_template.rs#13) +**Source:** [generate_documentation_template.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_documentation_template.rs#L13) Adds a documentation template above a function definition / declaration. @@ -1645,7 +1671,7 @@ impl S { ### `generate_enum_as_method` -**Source:** [generate_enum_projection_method.rs](/crates/ide-assists/src/handlers/generate_enum_projection_method.rs#59) +**Source:** [generate_enum_projection_method.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_enum_projection_method.rs#L59) Generate an `as_` method for this enum variant. @@ -1677,7 +1703,7 @@ impl Value { ### `generate_enum_is_method` -**Source:** [generate_enum_is_method.rs](/crates/ide-assists/src/handlers/generate_enum_is_method.rs#11) +**Source:** [generate_enum_is_method.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_enum_is_method.rs#L11) Generate an `is_` method for this enum variant. @@ -1711,7 +1737,7 @@ impl Version { ### `generate_enum_try_into_method` -**Source:** [generate_enum_projection_method.rs](/crates/ide-assists/src/handlers/generate_enum_projection_method.rs#12) +**Source:** [generate_enum_projection_method.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_enum_projection_method.rs#L12) Generate a `try_into_` method for this enum variant. @@ -1743,7 +1769,7 @@ impl Value { ### `generate_enum_variant` -**Source:** [generate_enum_variant.rs](/crates/ide-assists/src/handlers/generate_enum_variant.rs#10) +**Source:** [generate_enum_variant.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_enum_variant.rs#L10) Adds a variant to an enum. @@ -1772,7 +1798,7 @@ fn main() { ### `generate_fn_type_alias_named` -**Source:** [generate_fn_type_alias.rs](/crates/ide-assists/src/handlers/generate_fn_type_alias.rs#10) +**Source:** [generate_fn_type_alias.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_fn_type_alias.rs#L10) Generate a type alias for the function with named parameters. @@ -1790,7 +1816,7 @@ unsafe fn foo(n: i32) -> i32 { 42i32 } ### `generate_fn_type_alias_unnamed` -**Source:** [generate_fn_type_alias.rs](/crates/ide-assists/src/handlers/generate_fn_type_alias.rs#24) +**Source:** [generate_fn_type_alias.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_fn_type_alias.rs#L24) Generate a type alias for the function with unnamed parameters. @@ -1808,7 +1834,7 @@ unsafe fn foo(n: i32) -> i32 { 42i32 } ### `generate_from_impl_for_enum` -**Source:** [generate_from_impl_for_enum.rs](/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs#8) +**Source:** [generate_from_impl_for_enum.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs#L8) Adds a From impl for this enum variant with one tuple field. @@ -1830,7 +1856,7 @@ impl From for A { ### `generate_function` -**Source:** [generate_function.rs](/crates/ide-assists/src/handlers/generate_function.rs#28) +**Source:** [generate_function.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_function.rs#L28) Adds a stub function with a signature matching the function under the cursor. @@ -1860,7 +1886,7 @@ fn bar(arg: &str, baz: Baz) ${0:-> _} { ### `generate_getter` -**Source:** [generate_getter_or_setter.rs](/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#73) +**Source:** [generate_getter_or_setter.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#L73) Generate a getter method. @@ -1886,7 +1912,7 @@ impl Person { ### `generate_getter_mut` -**Source:** [generate_getter_or_setter.rs](/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#127) +**Source:** [generate_getter_or_setter.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#L127) Generate a mut getter method. @@ -1912,7 +1938,7 @@ impl Person { ### `generate_impl` -**Source:** [generate_impl.rs](/crates/ide-assists/src/handlers/generate_impl.rs#20) +**Source:** [generate_impl.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_impl.rs#L20) Adds a new inherent impl for a type. @@ -1934,7 +1960,7 @@ impl Ctx {┃} ### `generate_is_empty_from_len` -**Source:** [generate_is_empty_from_len.rs](/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs#12) +**Source:** [generate_is_empty_from_len.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs#L12) Generates is_empty implementation from the len method. @@ -1969,7 +1995,7 @@ impl MyStruct { ### `generate_mut_trait_impl` -**Source:** [generate_mut_trait_impl.rs](/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs#12) +**Source:** [generate_mut_trait_impl.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs#L12) Adds a IndexMut impl from the `Index` trait. @@ -2007,7 +2033,7 @@ impl core::ops::Index for [T; 3] { ### `generate_new` -**Source:** [generate_new.rs](/crates/ide-assists/src/handlers/generate_new.rs#14) +**Source:** [generate_new.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_new.rs#L14) Adds a `fn new` for a type. @@ -2033,7 +2059,7 @@ impl Ctx { ### `generate_setter` -**Source:** [generate_getter_or_setter.rs](/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#13) +**Source:** [generate_getter_or_setter.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#L13) Generate a setter method. @@ -2059,7 +2085,7 @@ impl Person { ### `generate_trait_from_impl` -**Source:** [generate_trait_from_impl.rs](/crates/ide-assists/src/handlers/generate_trait_from_impl.rs#18) +**Source:** [generate_trait_from_impl.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_trait_from_impl.rs#L18) Generate trait for an already defined inherent impl and convert impl to a trait impl. @@ -2118,7 +2144,7 @@ impl ${0:NewTrait} for Foo { ### `generate_trait_impl` -**Source:** [generate_impl.rs](/crates/ide-assists/src/handlers/generate_impl.rs#66) +**Source:** [generate_impl.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_impl.rs#L66) Adds a new trait impl for a type. @@ -2140,7 +2166,7 @@ impl ${0:_} for Ctx {} ### `inline_call` -**Source:** [inline_call.rs](/crates/ide-assists/src/handlers/inline_call.rs#170) +**Source:** [inline_call.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_call.rs#L170) Inlines a function or method body creating a `let` statement per parameter unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local @@ -2165,7 +2191,7 @@ fn foo(name: Option<&str>) { ### `inline_const_as_literal` -**Source:** [inline_const_as_literal.rs](/crates/ide-assists/src/handlers/inline_const_as_literal.rs#6) +**Source:** [inline_const_as_literal.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_const_as_literal.rs#L6) Evaluate and inline const variable as literal. @@ -2189,7 +2215,7 @@ fn something() -> &'static str { ### `inline_into_callers` -**Source:** [inline_call.rs](/crates/ide-assists/src/handlers/inline_call.rs#32) +**Source:** [inline_call.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_call.rs#L32) Inline a function or method body into all of its callers where possible, creating a `let` statement per parameter unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local @@ -2232,7 +2258,7 @@ fn bar() { ### `inline_local_variable` -**Source:** [inline_local_variable.rs](/crates/ide-assists/src/handlers/inline_local_variable.rs#17) +**Source:** [inline_local_variable.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_local_variable.rs#L17) Inlines a local variable. @@ -2253,7 +2279,7 @@ fn main() { ### `inline_macro` -**Source:** [inline_macro.rs](/crates/ide-assists/src/handlers/inline_macro.rs#7) +**Source:** [inline_macro.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_macro.rs#L7) Takes a macro and inlines it one step. @@ -2289,7 +2315,7 @@ fn main() { ### `inline_type_alias` -**Source:** [inline_type_alias.rs](/crates/ide-assists/src/handlers/inline_type_alias.rs#106) +**Source:** [inline_type_alias.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_type_alias.rs#L106) Replace a type alias with its concrete type. @@ -2313,7 +2339,7 @@ fn main() { ### `inline_type_alias_uses` -**Source:** [inline_type_alias.rs](/crates/ide-assists/src/handlers/inline_type_alias.rs#24) +**Source:** [inline_type_alias.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_type_alias.rs#L24) Inline a type alias into all of its uses where possible. @@ -2341,7 +2367,7 @@ fn foo() { ### `into_to_qualified_from` -**Source:** [into_to_qualified_from.rs](/crates/ide-assists/src/handlers/into_to_qualified_from.rs#10) +**Source:** [into_to_qualified_from.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/into_to_qualified_from.rs#L10) Convert an `into` method call to a fully qualified `from` call. @@ -2378,7 +2404,7 @@ fn main() -> () { ### `introduce_named_generic` -**Source:** [introduce_named_generic.rs](/crates/ide-assists/src/handlers/introduce_named_generic.rs#7) +**Source:** [introduce_named_generic.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/introduce_named_generic.rs#L7) Replaces `impl Trait` function argument with the named generic. @@ -2394,7 +2420,7 @@ fn foo<┃B: Bar>(bar: B) {} ### `introduce_named_lifetime` -**Source:** [introduce_named_lifetime.rs](/crates/ide-assists/src/handlers/introduce_named_lifetime.rs#13) +**Source:** [introduce_named_lifetime.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/introduce_named_lifetime.rs#L13) Change an anonymous lifetime to a named lifetime. @@ -2422,7 +2448,7 @@ impl<'a> Cursor<'a> { ### `invert_if` -**Source:** [invert_if.rs](/crates/ide-assists/src/handlers/invert_if.rs#13) +**Source:** [invert_if.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/invert_if.rs#L13) This transforms if expressions of the form `if !x {A} else {B}` into `if x {B} else {A}` This also works with `!=`. This assist can only be applied with the cursor on `if`. @@ -2443,7 +2469,7 @@ fn main() { ### `line_to_block` -**Source:** [convert_comment_block.rs](/crates/ide-assists/src/handlers/convert_comment_block.rs#9) +**Source:** [convert_comment_block.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/convert_comment_block.rs#L9) Converts comments between block and single-line form. @@ -2463,7 +2489,7 @@ Converts comments between block and single-line form. ### `make_raw_string` -**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#7) +**Source:** [raw_string.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/raw_string.rs#L7) Adds `r#` to a plain string literal. @@ -2483,7 +2509,7 @@ fn main() { ### `make_usual_string` -**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#47) +**Source:** [raw_string.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/raw_string.rs#L47) Turns a raw string into a plain string. @@ -2503,7 +2529,7 @@ fn main() { ### `merge_imports` -**Source:** [merge_imports.rs](/crates/ide-assists/src/handlers/merge_imports.rs#21) +**Source:** [merge_imports.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/merge_imports.rs#L21) Merges neighbor imports with a common prefix. @@ -2520,7 +2546,7 @@ use std::{fmt::Formatter, io}; ### `merge_match_arms` -**Source:** [merge_match_arms.rs](/crates/ide-assists/src/handlers/merge_match_arms.rs#12) +**Source:** [merge_match_arms.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/merge_match_arms.rs#L12) Merges the current match arm with the following if their bodies are identical. @@ -2549,7 +2575,7 @@ fn handle(action: Action) { ### `merge_nested_if` -**Source:** [merge_nested_if.rs](/crates/ide-assists/src/handlers/merge_nested_if.rs#11) +**Source:** [merge_nested_if.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/merge_nested_if.rs#L11) This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}` This assist can only be applied with the cursor on `if`. @@ -2570,7 +2596,7 @@ fn main() { ### `move_arm_cond_to_match_guard` -**Source:** [move_guard.rs](/crates/ide-assists/src/handlers/move_guard.rs#69) +**Source:** [move_guard.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/move_guard.rs#L69) Moves if expression from match arm body into a guard. @@ -2600,7 +2626,7 @@ fn handle(action: Action) { ### `move_bounds_to_where_clause` -**Source:** [move_bounds.rs](/crates/ide-assists/src/handlers/move_bounds.rs#12) +**Source:** [move_bounds.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/move_bounds.rs#L12) Moves inline type bounds to a where clause. @@ -2620,7 +2646,7 @@ fn apply(f: F, x: T) -> U where F: FnOnce(T) -> U { ### `move_const_to_impl` -**Source:** [move_const_to_impl.rs](/crates/ide-assists/src/handlers/move_const_to_impl.rs#14) +**Source:** [move_const_to_impl.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/move_const_to_impl.rs#L14) Move a local constant item in a method to impl's associated constant. All the references will be qualified with `Self::`. @@ -2653,7 +2679,7 @@ impl S { ### `move_from_mod_rs` -**Source:** [move_from_mod_rs.rs](/crates/ide-assists/src/handlers/move_from_mod_rs.rs#12) +**Source:** [move_from_mod_rs.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/move_from_mod_rs.rs#L12) Moves xxx/mod.rs to xxx.rs. @@ -2672,7 +2698,7 @@ fn t() {} ### `move_guard_to_arm_body` -**Source:** [move_guard.rs](/crates/ide-assists/src/handlers/move_guard.rs#8) +**Source:** [move_guard.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/move_guard.rs#L8) Moves match guard into match arm body. @@ -2704,7 +2730,7 @@ fn handle(action: Action) { ### `move_module_to_file` -**Source:** [move_module_to_file.rs](/crates/ide-assists/src/handlers/move_module_to_file.rs#15) +**Source:** [move_module_to_file.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/move_module_to_file.rs#L15) Moves inline module's contents to a separate file. @@ -2722,7 +2748,7 @@ mod foo; ### `move_to_mod_rs` -**Source:** [move_to_mod_rs.rs](/crates/ide-assists/src/handlers/move_to_mod_rs.rs#12) +**Source:** [move_to_mod_rs.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/move_to_mod_rs.rs#L12) Moves xxx.rs to xxx/mod.rs. @@ -2741,7 +2767,7 @@ fn t() {} ### `normalize_import` -**Source:** [normalize_import.rs](/crates/ide-assists/src/handlers/normalize_import.rs#9) +**Source:** [normalize_import.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/normalize_import.rs#L9) Normalizes an import. @@ -2757,7 +2783,7 @@ use std::{fmt::Formatter, io}; ### `promote_local_to_const` -**Source:** [promote_local_to_const.rs](/crates/ide-assists/src/handlers/promote_local_to_const.rs#17) +**Source:** [promote_local_to_const.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/promote_local_to_const.rs#L17) Promotes a local variable to a const item changing its name to a `SCREAMING_SNAKE_CASE` variant if the local uses no non-const expressions. @@ -2790,7 +2816,7 @@ fn main() { ### `pull_assignment_up` -**Source:** [pull_assignment_up.rs](/crates/ide-assists/src/handlers/pull_assignment_up.rs#11) +**Source:** [pull_assignment_up.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/pull_assignment_up.rs#L11) Extracts variable assignment to outside an if or match statement. @@ -2822,7 +2848,7 @@ fn main() { ### `qualify_method_call` -**Source:** [qualify_method_call.rs](/crates/ide-assists/src/handlers/qualify_method_call.rs#10) +**Source:** [qualify_method_call.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/qualify_method_call.rs#L10) Replaces the method call with a qualified function call. @@ -2852,7 +2878,7 @@ fn main() { ### `qualify_path` -**Source:** [qualify_path.rs](/crates/ide-assists/src/handlers/qualify_path.rs#24) +**Source:** [qualify_path.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/qualify_path.rs#L24) If the name is unresolved, provides all possible qualified paths for it. @@ -2872,7 +2898,7 @@ fn main() { ### `reformat_number_literal` -**Source:** [number_representation.rs](/crates/ide-assists/src/handlers/number_representation.rs#7) +**Source:** [number_representation.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/number_representation.rs#L7) Adds or removes separators from integer literal. @@ -2888,7 +2914,7 @@ const _: i32 = 1_012_345; ### `remove_dbg` -**Source:** [remove_dbg.rs](/crates/ide-assists/src/handlers/remove_dbg.rs#9) +**Source:** [remove_dbg.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/remove_dbg.rs#L9) Removes `dbg!()` macro call. @@ -2908,7 +2934,7 @@ fn main() { ### `remove_hash` -**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#117) +**Source:** [raw_string.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/raw_string.rs#L117) Removes a hash from a raw string literal. @@ -2928,7 +2954,7 @@ fn main() { ### `remove_mut` -**Source:** [remove_mut.rs](/crates/ide-assists/src/handlers/remove_mut.rs#5) +**Source:** [remove_mut.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/remove_mut.rs#L5) Removes the `mut` keyword. @@ -2948,7 +2974,7 @@ impl Walrus { ### `remove_parentheses` -**Source:** [remove_parentheses.rs](/crates/ide-assists/src/handlers/remove_parentheses.rs#5) +**Source:** [remove_parentheses.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/remove_parentheses.rs#L5) Removes redundant parentheses. @@ -2968,7 +2994,7 @@ fn main() { ### `remove_unused_imports` -**Source:** [remove_unused_imports.rs](/crates/ide-assists/src/handlers/remove_unused_imports.rs#17) +**Source:** [remove_unused_imports.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/remove_unused_imports.rs#L17) Removes any use statements in the current selection that are unused. @@ -2989,7 +3015,7 @@ mod foo { ### `remove_unused_param` -**Source:** [remove_unused_param.rs](/crates/ide-assists/src/handlers/remove_unused_param.rs#15) +**Source:** [remove_unused_param.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/remove_unused_param.rs#L15) Removes unused function parameter. @@ -3013,7 +3039,7 @@ fn main() { ### `reorder_fields` -**Source:** [reorder_fields.rs](/crates/ide-assists/src/handlers/reorder_fields.rs#8) +**Source:** [reorder_fields.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/reorder_fields.rs#L8) Reorder the fields of record literals and record patterns in the same order as in the definition. @@ -3032,7 +3058,7 @@ const test: Foo = Foo {foo: 1, bar: 0} ### `reorder_impl_items` -**Source:** [reorder_impl_items.rs](/crates/ide-assists/src/handlers/reorder_impl_items.rs#11) +**Source:** [reorder_impl_items.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/reorder_impl_items.rs#L11) Reorder the items of an `impl Trait`. The items will be ordered in the same order as in the trait definition. @@ -3071,7 +3097,7 @@ impl Foo for Bar { ### `replace_arith_with_checked` -**Source:** [replace_arith_op.rs](/crates/ide-assists/src/handlers/replace_arith_op.rs#9) +**Source:** [replace_arith_op.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_arith_op.rs#L9) Replaces arithmetic on integers with the `checked_*` equivalent. @@ -3091,7 +3117,7 @@ fn main() { ### `replace_arith_with_saturating` -**Source:** [replace_arith_op.rs](/crates/ide-assists/src/handlers/replace_arith_op.rs#28) +**Source:** [replace_arith_op.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_arith_op.rs#L28) Replaces arithmetic on integers with the `saturating_*` equivalent. @@ -3111,7 +3137,7 @@ fn main() { ### `replace_arith_with_wrapping` -**Source:** [replace_arith_op.rs](/crates/ide-assists/src/handlers/replace_arith_op.rs#50) +**Source:** [replace_arith_op.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_arith_op.rs#L50) Replaces arithmetic on integers with the `wrapping_*` equivalent. @@ -3131,7 +3157,7 @@ fn main() { ### `replace_char_with_string` -**Source:** [replace_string_with_char.rs](/crates/ide-assists/src/handlers/replace_string_with_char.rs#51) +**Source:** [replace_string_with_char.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_string_with_char.rs#L51) Replace a char literal with a string literal. @@ -3151,7 +3177,7 @@ fn main() { ### `replace_derive_with_manual_impl` -**Source:** [replace_derive_with_manual_impl.rs](/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs#20) +**Source:** [replace_derive_with_manual_impl.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs#L20) Converts a `derive` impl into a manual one. @@ -3175,7 +3201,7 @@ impl Debug for S { ### `replace_if_let_with_match` -**Source:** [replace_if_let_with_match.rs](/crates/ide-assists/src/handlers/replace_if_let_with_match.rs#20) +**Source:** [replace_if_let_with_match.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_if_let_with_match.rs#L20) Replaces a `if let` expression with a `match` expression. @@ -3206,7 +3232,7 @@ fn handle(action: Action) { ### `replace_is_some_with_if_let_some` -**Source:** [replace_is_method_with_if_let_method.rs](/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs#9) +**Source:** [replace_is_method_with_if_let_method.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs#L9) Replace `if x.is_some()` with `if let Some(_tmp) = x` or `if x.is_ok()` with `if let Ok(_tmp) = x`. @@ -3228,7 +3254,7 @@ fn main() { ### `replace_let_with_if_let` -**Source:** [replace_let_with_if_let.rs](/crates/ide-assists/src/handlers/replace_let_with_if_let.rs#9) +**Source:** [replace_let_with_if_let.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_let_with_if_let.rs#L9) Replaces `let` with an `if let`. @@ -3255,7 +3281,7 @@ fn compute() -> Option { None } ### `replace_match_with_if_let` -**Source:** [replace_if_let_with_match.rs](/crates/ide-assists/src/handlers/replace_if_let_with_match.rs#188) +**Source:** [replace_if_let_with_match.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_if_let_with_match.rs#L188) Replaces a binary `match` with a wildcard pattern and no guards with an `if let` expression. @@ -3286,7 +3312,7 @@ fn handle(action: Action) { ### `replace_named_generic_with_impl` -**Source:** [replace_named_generic_with_impl.rs](/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs#18) +**Source:** [replace_named_generic_with_impl.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs#L18) Replaces named generic with an `impl Trait` in function argument. @@ -3302,7 +3328,7 @@ fn new(location: impl AsRef) -> Self {} ### `replace_qualified_name_with_use` -**Source:** [replace_qualified_name_with_use.rs](/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs#13) +**Source:** [replace_qualified_name_with_use.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs#L13) Adds a use statement for a given fully-qualified name. @@ -3320,7 +3346,7 @@ fn process(map: HashMap) {} ### `replace_string_with_char` -**Source:** [replace_string_with_char.rs](/crates/ide-assists/src/handlers/replace_string_with_char.rs#11) +**Source:** [replace_string_with_char.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_string_with_char.rs#L11) Replace string literal with char literal. @@ -3340,7 +3366,7 @@ fn main() { ### `replace_try_expr_with_match` -**Source:** [replace_try_expr_with_match.rs](/crates/ide-assists/src/handlers/replace_try_expr_with_match.rs#18) +**Source:** [replace_try_expr_with_match.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_try_expr_with_match.rs#L18) Replaces a `try` expression with a `match` expression. @@ -3363,7 +3389,7 @@ fn handle() { ### `replace_turbofish_with_explicit_type` -**Source:** [replace_turbofish_with_explicit_type.rs](/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs#12) +**Source:** [replace_turbofish_with_explicit_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs#L12) Converts `::<_>` to an explicit type assignment. @@ -3385,7 +3411,7 @@ fn main() { ### `replace_with_eager_method` -**Source:** [replace_method_eager_lazy.rs](/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#89) +**Source:** [replace_method_eager_lazy.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#L89) Replace `unwrap_or_else` with `unwrap_or` and `ok_or_else` with `ok_or`. @@ -3407,7 +3433,7 @@ fn foo() { ### `replace_with_lazy_method` -**Source:** [replace_method_eager_lazy.rs](/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#9) +**Source:** [replace_method_eager_lazy.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#L9) Replace `unwrap_or` with `unwrap_or_else` and `ok_or` with `ok_or_else`. @@ -3429,7 +3455,7 @@ fn foo() { ### `sort_items` -**Source:** [sort_items.rs](/crates/ide-assists/src/handlers/sort_items.rs#12) +**Source:** [sort_items.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/sort_items.rs#L12) Sorts item members alphabetically: fields, enum variants and methods. @@ -3520,7 +3546,7 @@ enum Animal { ### `split_import` -**Source:** [split_import.rs](/crates/ide-assists/src/handlers/split_import.rs#5) +**Source:** [split_import.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/split_import.rs#L5) Wraps the tail of import into braces. @@ -3536,7 +3562,7 @@ use std::{collections::HashMap}; ### `sugar_impl_future_into_async` -**Source:** [toggle_async_sugar.rs](/crates/ide-assists/src/handlers/toggle_async_sugar.rs#13) +**Source:** [toggle_async_sugar.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/toggle_async_sugar.rs#L13) Rewrites asynchronous function from `-> impl Future` into `async fn`. This action does not touch the function body and therefore `async { 0 }` @@ -3558,7 +3584,7 @@ pub async fn foo() -> usize { ### `toggle_ignore` -**Source:** [toggle_ignore.rs](/crates/ide-assists/src/handlers/toggle_ignore.rs#8) +**Source:** [toggle_ignore.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/toggle_ignore.rs#L8) Adds `#[ignore]` attribute to the test. @@ -3581,7 +3607,7 @@ fn arithmetics { ### `toggle_macro_delimiter` -**Source:** [toggle_macro_delimiter.rs](/crates/ide-assists/src/handlers/toggle_macro_delimiter.rs#9) +**Source:** [toggle_macro_delimiter.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/toggle_macro_delimiter.rs#L9) Change macro delimiters in the order of `( -> { -> [ -> (`. @@ -3605,7 +3631,7 @@ sth!{ } ### `unmerge_match_arm` -**Source:** [unmerge_match_arm.rs](/crates/ide-assists/src/handlers/unmerge_match_arm.rs#10) +**Source:** [unmerge_match_arm.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unmerge_match_arm.rs#L10) Splits the current match with a `|` pattern into two arms with identical bodies. @@ -3634,7 +3660,7 @@ fn handle(action: Action) { ### `unmerge_use` -**Source:** [unmerge_use.rs](/crates/ide-assists/src/handlers/unmerge_use.rs#12) +**Source:** [unmerge_use.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unmerge_use.rs#L12) Extracts single use item from use list. @@ -3651,7 +3677,7 @@ use std::fmt::Display; ### `unnecessary_async` -**Source:** [unnecessary_async.rs](/crates/ide-assists/src/handlers/unnecessary_async.rs#17) +**Source:** [unnecessary_async.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unnecessary_async.rs#L17) Removes the `async` mark from functions which have no `.await` in their body. Looks for calls to the functions and removes the `.await` on the call site. @@ -3670,7 +3696,7 @@ pub async fn bar() { foo() } ### `unqualify_method_call` -**Source:** [unqualify_method_call.rs](/crates/ide-assists/src/handlers/unqualify_method_call.rs#9) +**Source:** [unqualify_method_call.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unqualify_method_call.rs#L9) Transforms universal function call syntax into a method call. @@ -3692,7 +3718,7 @@ fn main() { ### `unwrap_block` -**Source:** [unwrap_block.rs](/crates/ide-assists/src/handlers/unwrap_block.rs#12) +**Source:** [unwrap_block.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unwrap_block.rs#L12) This assist removes if...else, for, while and loop control statements to just keep the body. @@ -3714,7 +3740,7 @@ fn foo() { ### `unwrap_option_return_type` -**Source:** [unwrap_return_type.rs](/crates/ide-assists/src/handlers/unwrap_return_type.rs#13) +**Source:** [unwrap_return_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unwrap_return_type.rs#L13) Unwrap the function's return type. @@ -3730,7 +3756,7 @@ fn foo() -> i32 { 42i32 } ### `unwrap_result_return_type` -**Source:** [unwrap_return_type.rs](/crates/ide-assists/src/handlers/unwrap_return_type.rs#26) +**Source:** [unwrap_return_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unwrap_return_type.rs#L26) Unwrap the function's return type. @@ -3746,7 +3772,7 @@ fn foo() -> i32 { 42i32 } ### `unwrap_tuple` -**Source:** [unwrap_tuple.rs](/crates/ide-assists/src/handlers/unwrap_tuple.rs#8) +**Source:** [unwrap_tuple.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/unwrap_tuple.rs#L8) Unwrap the tuple to different variables. @@ -3767,7 +3793,7 @@ fn main() { ### `wrap_return_type_in_option` -**Source:** [wrap_return_type.rs](/crates/ide-assists/src/handlers/wrap_return_type.rs#16) +**Source:** [wrap_return_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/wrap_return_type.rs#L16) Wrap the function's return type into Option. @@ -3783,7 +3809,7 @@ fn foo() -> Option { Some(42i32) } ### `wrap_return_type_in_result` -**Source:** [wrap_return_type.rs](/crates/ide-assists/src/handlers/wrap_return_type.rs#29) +**Source:** [wrap_return_type.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/wrap_return_type.rs#L29) Wrap the function's return type into Result. @@ -3799,7 +3825,7 @@ fn foo() -> Result { Ok(42i32) } ### `wrap_unwrap_cfg_attr` -**Source:** [wrap_unwrap_cfg_attr.rs](/crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs#12) +**Source:** [wrap_unwrap_cfg_attr.rs](https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs#L12) Wraps an attribute to a cfg_attr attribute or unwraps a cfg_attr attribute to the inner attributes. -- cgit 1.4.1-3-g733a5