From d3305f1a4b6fa80b734dfb25971ed483743c9b05 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Mon, 21 Sep 2026 17:03:36 +0100 Subject: [PATCH 1/7] Borrow the destination place with a raw pointer in MIR inlining --- compiler/rustc_mir_transform/src/inline.rs | 23 +++------ tests/mir-opt/inline/indirect_destination.rs | 53 +++++++++++++++++++- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index c70b957da130e..3fd414579e6bb 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -886,24 +886,13 @@ fn inline_call<'tcx, I: Inliner<'tcx>>( // Place could result in two different locations if `f` // writes to `i`. To prevent this we need to create a temporary // borrow of the place and pass the destination as `*temp` instead. - fn dest_needs_borrow(place: Place<'_>) -> bool { - for elem in place.projection.iter() { - match elem { - ProjectionElem::Deref | ProjectionElem::Index(_) => return true, - _ => {} - } - } - - false - } - - let dest = if dest_needs_borrow(destination) { + // + // This must be a raw pointer: a mutable reference could be invalidated by + // reading the arguments later, and would be invalid if the destination type + // is uninhabited. + let dest = if !destination.is_stable_offset() { trace!("creating temp for return destination"); - let dest = Rvalue::Ref( - tcx.lifetimes.re_erased, - BorrowKind::Mut { kind: MutBorrowKind::Default }, - destination, - ); + let dest = Rvalue::RawPtr(RawPtrKind::Mut, destination); let dest_ty = dest.ty(caller_body, tcx); let temp = Place::from(new_call_temp(caller_body, callsite, dest_ty, return_block)); caller_body[callsite.block].statements.push(Statement::new( diff --git a/tests/mir-opt/inline/indirect_destination.rs b/tests/mir-opt/inline/indirect_destination.rs index 4246eef08f704..08e34419bdf7a 100644 --- a/tests/mir-opt/inline/indirect_destination.rs +++ b/tests/mir-opt/inline/indirect_destination.rs @@ -11,7 +11,7 @@ use core::intrinsics::mir::*; // CHECK-LABEL: fn f( // CHECK: bb1: { // CHECK-NEXT: StorageLive([[A:.*]]); -// CHECK-NEXT: [[A]] = &mut (*_1); +// CHECK-NEXT: [[A]] = &raw mut (*_1); // CHECK-NEXT: StorageLive([[B:.*]]); // CHECK-NEXT: [[B]] = const 42_u8; // CHECK-NEXT: (*[[A]]) = move [[B]]; @@ -40,3 +40,54 @@ fn g() -> u8 { } } } + +// Reading the argument must not invalidate the saved destination pointer. +#[custom_mir(dialect = "runtime", phase = "initial")] +// CHECK-LABEL: fn indexed( +// CHECK: [[DEST:_[0-9]+]] = &raw mut _2[_1]; +// CHECK: [[ARG:_[0-9]+]] = copy _2[_1]; +// CHECK-NEXT: [[RET:_[0-9]+]] = copy [[ARG]]; +// CHECK-NEXT: (*[[DEST]]) = move [[RET]]; +pub fn indexed(index: usize) -> u32 { + mir! { + let values: [u32; 2]; + { + values = [41, 99]; + Call(values[index] = identity(values[index]), ReturnTo(done), UnwindContinue()) + } + done = { + RET = values[index]; + Return() + } + } +} + +#[inline(always)] +fn identity(value: u32) -> u32 { + value +} + +// Saving an uninhabited destination must not construct an invalid reference. +#[custom_mir(dialect = "runtime", phase = "initial")] +// CHECK-LABEL: fn uninhabited( +// CHECK: [[PTR:_[0-9]+]] = &raw mut _1; +// CHECK: [[DEST:_[0-9]+]] = &raw mut (*[[PTR]]); +// CHECK: panic_fmt +pub fn uninhabited() { + mir! { + let slot: !; + let ptr: *mut !; + { + ptr = &raw mut slot; + Call(*ptr = fail(), ReturnTo(done), UnwindContinue()) + } + done = { + Return() + } + } +} + +#[inline(always)] +fn fail() -> ! { + panic!("expected panic") +} From d296cf28bce858e6917efe12c941ce3d62dbcd23 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 15 Sep 2026 15:10:25 -0400 Subject: [PATCH 2/7] bootstrap: link the offload runtimes with the in-tree lld when it is built --- src/bootstrap/src/core/build_steps/llvm.rs | 48 ++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index f89ccb4c2a6a8..914c06272ba01 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -832,6 +832,40 @@ fn debuginfo_map_cflags(builder: &Builder<'_>, target: TargetSelection) -> Vec, + target: TargetSelection, + llvm_output: &LlvmOutput, + cfg: &mut cmake::Config, + ldflags: &mut LdFlags, +) { + // Apple has it's own ld64 linker, so don't use LLD on Darwin. + if target.contains("apple") { + return; + } + + if builder.config.llvm_use_linker.is_some() || !builder.config.lld_enabled || target.is_msvc() { + // Logic derived from `configure_llvm` + // ThinLTO is only available when building with LLVM, enabling LLD is required. + if builder.config.llvm_thin_lto { + ldflags.push_all("-fuse-ld=lld"); + } + return; + } + + let lld_bin = builder.ensure(Lld { target }).join("bin"); + ldflags.push_all(format!("-B{} -fuse-ld=lld", lld_bin.display())); + + if llvm_output.link_shared() { + // LLD in this case needs the LLVM lib, so tell where to look for it. + let mut dylib_path = helpers::dylib_path(); + dylib_path.insert(0, llvm_output.root_dir().join("lib")); + cfg.env(helpers::dylib_path_var(), t!(env::join_paths(&dylib_path))); + } +} + fn configure_cmake( builder: &Builder<'_>, target: TargetSelection, @@ -1180,13 +1214,8 @@ impl CommandLineStep for RustOffload { let mut cfg = cmake::Config::new(builder.src.join("compiler/rustc_llvm/llvm-wrapper/offload/")); - // Logic copied from `configure_llvm` - // ThinLTO is only available when building with LLVM, enabling LLD is required. - // Apple's linker ld64 supports ThinLTO out of the box though, so don't use LLD on Darwin. let mut ldflags = LdFlags::default(); - if builder.config.llvm_thin_lto && !target.contains("apple") { - ldflags.push_all("-fuse-ld=lld"); - } + try_link_with_in_tree_lld(builder, target, &llvm_output, &mut cfg, &mut ldflags); configure_cmake(builder, target, &mut cfg, true, ldflags, CcFlags::default(), &[]); @@ -1397,13 +1426,8 @@ impl CommandLineStep for OmpOffload { cflags.push_all(format!(" -I {inc_dir}")); } - // Logic copied from `configure_llvm` - // ThinLTO is only available when building with LLVM, enabling LLD is required. - // Apple's linker ld64 supports ThinLTO out of the box though, so don't use LLD on Darwin. let mut ldflags = LdFlags::default(); - if builder.config.llvm_thin_lto && !target.contains("apple") { - ldflags.push_all("-fuse-ld=lld"); - } + try_link_with_in_tree_lld(builder, target, &llvm_output, &mut cfg, &mut ldflags); if let Some(dir) = &cxx_lib_dir { ldflags.push_all(format!("-L{}", dir.display())); From 90d7327077f5eb03d90f0620c5cff62cdece950a Mon Sep 17 00:00:00 2001 From: Max Dexheimer Date: Tue, 22 Sep 2026 20:58:11 +0200 Subject: [PATCH 3/7] Make it clear what the alignment needs to be for `deallocate` --- library/core/src/alloc/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs index 6069c468f96e4..a2c81364ed155 100644 --- a/library/core/src/alloc/mod.rs +++ b/library/core/src/alloc/mod.rs @@ -148,7 +148,8 @@ impl fmt::Display for AllocError { /// /// Some of the methods require that a `layout` *fits* a memory block or vice versa. This means /// that the following conditions must hold: -/// * the memory block must be *currently allocated* with alignment of [`layout.align()`], and +/// * the memory block must be *currently allocated* by the allocator, +/// * [`layout.align()`] must be the same as the alignment of the layout used to allocate the block, and /// * [`layout.size()`] must fall in the range `min ..= max`, where: /// - `min` is the size of the layout used to allocate the block, and /// - `max` is the actual size returned from [`allocate`], [`allocate_zeroed`], From 85110fbf422e438ba8ff23e3e76c85da3b5a50b7 Mon Sep 17 00:00:00 2001 From: malezjaa Date: Tue, 22 Sep 2026 22:03:03 +0200 Subject: [PATCH 4/7] implement LazyLock::(get_unchecked, get_unchecked_mut) and make counterparts on OnceLock public --- library/std/src/lib.rs | 1 + library/std/src/sync/lazy_lock.rs | 70 ++++++++++++++++++++++++++++--- library/std/src/sync/once_lock.rs | 46 ++++++++++++++++++-- 3 files changed, 108 insertions(+), 9 deletions(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 3f853df52bc53..59734e2402373 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -369,6 +369,7 @@ #![feature(maybe_dangling)] #![feature(maybe_uninit_array_assume_init)] #![feature(maybe_uninit_fill)] +#![feature(once_lazy_lock_get_unchecked)] #![feature(panic_can_unwind)] #![feature(panic_internals)] #![feature(pin_coerce_unsized_trait)] diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs index f150d42a3137c..d1e5fd0af66f1 100644 --- a/library/std/src/sync/lazy_lock.rs +++ b/library/std/src/sync/lazy_lock.rs @@ -197,14 +197,14 @@ impl T> LazyLock { guard.0.once.set_state(OnceExclusiveState::Complete); core::mem::forget(guard); // SAFETY: We put the value there above. - unsafe { &mut this.data.get_mut().value } + unsafe { LazyLock::get_unchecked_mut(this) } } let state = this.once.state(); match state { OnceExclusiveState::Poisoned => panic_poisoned(), // SAFETY: The `Once` states we completed the initialization. - OnceExclusiveState::Complete => unsafe { &mut this.data.get_mut().value }, + OnceExclusiveState::Complete => unsafe { LazyLock::get_unchecked_mut(this) }, // SAFETY: The state is `Incomplete`. OnceExclusiveState::Incomplete => unsafe { really_init_mut(this) }, } @@ -258,7 +258,7 @@ impl T> LazyLock { // * the closure was not called, but a previous call initialized `value`. // * the closure was not called because the Once is poisoned, which we handled above. // So `value` has definitely been initialized and will not be modified again. - unsafe { &(*this.data.get()).value } + unsafe { LazyLock::get_unchecked(this) } } } @@ -286,7 +286,7 @@ impl LazyLock { match state { // SAFETY: // The closure has been run successfully, so `value` has been initialized. - OnceExclusiveState::Complete => Some(unsafe { &mut this.data.get_mut().value }), + OnceExclusiveState::Complete => Some(unsafe { LazyLock::get_unchecked_mut(this) }), _ => None, } } @@ -313,11 +313,71 @@ impl LazyLock { // SAFETY: // The closure has been run successfully, so `value` has been initialized // and will not be modified again. - Some(unsafe { &(*this.data.get()).value }) + Some(unsafe { LazyLock::get_unchecked(this) }) } else { None } } + + /// Returns a shared reference to the value stored in the `LazyLock` without + /// checking whether it has been initialized. + /// + /// # Safety + /// + /// The lazy value must be initialized before calling this function. + /// + /// # Examples + /// + /// ``` + /// #![feature(once_lazy_lock_get_unchecked)] + /// + /// use std::sync::LazyLock; + /// + /// let lazy = LazyLock::new(|| 42); + /// + /// // Initialize the lazy. + /// let _ = &*lazy; + /// + /// let value = unsafe { LazyLock::get_unchecked(&lazy) }; + /// assert_eq!(*value, 42); + /// ``` + #[inline] + #[unstable(feature = "once_lazy_lock_get_unchecked", issue = "162716")] + pub unsafe fn get_unchecked(this: &LazyLock) -> &T { + debug_assert!(this.once.is_completed()); + unsafe { &(*this.data.get()).value } + } + + /// Returns a mutable reference to the value stored in the `LazyLock` without + /// checking whether it has been initialized. + /// + /// # Safety + /// + /// The lazy value must be initialized before calling this function. + /// + /// # Examples + /// + /// ``` + /// #![feature(once_lazy_lock_get_unchecked)] + /// + /// use std::sync::LazyLock; + /// + /// let mut lazy = LazyLock::new(|| 42); + /// + /// // Initialize the lazy. + /// let _ = &*lazy; + /// + /// let value = unsafe { LazyLock::get_unchecked_mut(&mut lazy) }; + /// *value = 100; + /// + /// assert_eq!(*lazy, 100); + /// ``` + #[inline] + #[unstable(feature = "once_lazy_lock_get_unchecked", issue = "162716")] + pub unsafe fn get_unchecked_mut(this: &mut LazyLock) -> &mut T { + debug_assert!(this.once.is_completed()); + unsafe { &mut this.data.get_mut().value } + } } #[stable(feature = "lazy_cell", since = "1.80.0")] diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs index 4b41fc4587829..e8e8f869dd038 100644 --- a/library/std/src/sync/once_lock.rs +++ b/library/std/src/sync/once_lock.rs @@ -585,20 +585,58 @@ impl OnceLock { res } + /// Returns a reference to the value in the `OnceLock` without checking + /// whether it has been initialized. + /// /// # Safety /// - /// The cell must be initialized + /// The `OnceLock` must be initialized before calling this function. + /// + /// # Examples + /// + /// ``` + /// #![feature(once_lazy_lock_get_unchecked)] + /// + /// use std::sync::OnceLock; + /// + /// let cell = OnceLock::new(); + /// cell.set(42).unwrap(); + /// + /// let value = unsafe { cell.get_unchecked() }; + /// assert_eq!(*value, 42); + /// ``` #[inline] - unsafe fn get_unchecked(&self) -> &T { + #[unstable(feature = "once_lazy_lock_get_unchecked", issue = "162716")] + pub unsafe fn get_unchecked(&self) -> &T { debug_assert!(self.initialized()); unsafe { (&*self.value.get()).assume_init_ref() } } + /// Returns a mutable reference to the value in the `OnceLock` without + /// checking whether it has been initialized. + /// /// # Safety /// - /// The cell must be initialized + /// The `OnceLock` must be initialized before calling this function. + /// + /// # Examples + /// + /// ``` + /// #![feature(once_lazy_lock_get_unchecked)] + /// + /// use std::sync::OnceLock; + /// + /// let mut cell = OnceLock::new(); + /// cell.set(42).unwrap(); + /// + /// let value = unsafe { cell.get_unchecked_mut() }; + /// *value = 100; + /// + /// assert_eq!(*cell.get().unwrap(), 100); + /// ``` #[inline] - unsafe fn get_unchecked_mut(&mut self) -> &mut T { + #[unstable(feature = "once_lazy_lock_get_unchecked", issue = "162716")] + pub unsafe fn get_unchecked_mut(&mut self) -> &mut T { debug_assert!(self.initialized_mut()); unsafe { self.value.get_mut().assume_init_mut() } } From 7779f5cf60bf306f537d1d2fb6c57b7fdf33b7bb Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 22 Sep 2026 20:14:32 +0000 Subject: [PATCH 5/7] Test unused lifetime params for 'type' and 'union' --- tests/ui/variance/variance-unused-region-param.rs | 2 ++ tests/ui/variance/variance-unused-region-param.stderr | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/ui/variance/variance-unused-region-param.rs b/tests/ui/variance/variance-unused-region-param.rs index f0e4e03c9db8d..0ada6b4aa7907 100644 --- a/tests/ui/variance/variance-unused-region-param.rs +++ b/tests/ui/variance/variance-unused-region-param.rs @@ -2,6 +2,8 @@ struct SomeStruct<'a> { x: u32 } //~ ERROR parameter `'a` is never used enum SomeEnum<'a> { Nothing } //~ ERROR parameter `'a` is never used +union SomeUnion<'a> { x: u32 } //~ ERROR parameter `'a` is never used trait SomeTrait<'a> { fn foo(&self); } // OK on traits. +type SomeAlias<'a> = u32; // OK on type aliases. fn main() {} diff --git a/tests/ui/variance/variance-unused-region-param.stderr b/tests/ui/variance/variance-unused-region-param.stderr index b9c08bd43c454..b74cb977522d4 100644 --- a/tests/ui/variance/variance-unused-region-param.stderr +++ b/tests/ui/variance/variance-unused-region-param.stderr @@ -14,6 +14,14 @@ LL | enum SomeEnum<'a> { Nothing } | = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` -error: aborting due to 2 previous errors +error[E0392]: lifetime parameter `'a` is never used + --> $DIR/variance-unused-region-param.rs:5:17 + | +LL | union SomeUnion<'a> { x: u32 } + | ^^ unused lifetime parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0392`. From 4eb7bb33234293cbc0b4bebfc5e37e6eaffeddda Mon Sep 17 00:00:00 2001 From: Nia Deckers Date: Sun, 31 May 2026 13:56:23 +0200 Subject: [PATCH 6/7] core/alloc: stabilise `Allocator` --- compiler/rustc_data_structures/src/lib.rs | 3 +- compiler/rustc_middle/src/lib.rs | 3 +- library/alloc/src/alloc.rs | 16 +-- library/alloc/src/boxed.rs | 103 +++++++--------- library/alloc/src/boxed/thin.rs | 1 - .../alloc/src/collections/binary_heap/mod.rs | 33 +++--- library/alloc/src/collections/btree/map.rs | 17 ++- .../alloc/src/collections/btree/map/entry.rs | 8 +- library/alloc/src/collections/btree/set.rs | 22 ++-- .../alloc/src/collections/btree/set/entry.rs | 6 +- library/alloc/src/collections/linked_list.rs | 14 +-- .../alloc/src/collections/vec_deque/drain.rs | 2 +- .../src/collections/vec_deque/extract_if.rs | 4 +- .../src/collections/vec_deque/into_iter.rs | 2 +- .../alloc/src/collections/vec_deque/mod.rs | 12 +- .../alloc/src/collections/vec_deque/splice.rs | 2 +- library/alloc/src/lib.rs | 2 +- library/alloc/src/rc.rs | 105 ++++++++--------- library/alloc/src/slice.rs | 4 +- library/alloc/src/sync.rs | 111 +++++++++--------- library/alloc/src/vec/drain.rs | 4 +- library/alloc/src/vec/extract_if.rs | 4 +- library/alloc/src/vec/into_iter.rs | 4 +- library/alloc/src/vec/mod.rs | 48 +++----- library/alloc/src/vec/peek_mut.rs | 2 +- library/alloc/src/vec/splice.rs | 2 +- library/alloctests/lib.rs | 2 +- library/alloctests/tests/lib.rs | 2 +- .../alloctests/tests/vec_deque_alloc_error.rs | 2 +- library/core/src/alloc/mod.rs | 38 +++--- library/core/src/ptr/non_null.rs | 2 +- library/std/src/alloc.rs | 8 +- library/std/src/collections/hash/map.rs | 36 +++--- library/std/src/collections/hash/set.rs | 38 +++--- library/std/src/lib.rs | 2 +- .../{allocator-api.md => allocator-ext.md} | 2 +- src/tools/clippy/tests/ui/vec_box_sized.rs | 2 +- .../tests/fail/alloc/alloc_error_handler.rs | 2 +- .../fail/alloc/alloc_error_handler_custom.rs | 2 +- .../fail/alloc/alloc_error_handler_no_std.rs | 2 +- .../tests/fail/alloc/global_system_mixup.rs | 2 +- .../validity/box-custom-alloc-dangling-ptr.rs | 2 +- .../box-custom-alloc-invalid-alloc.rs | 2 +- .../tests/panic/alloc_error_handler_hook.rs | 2 +- .../tests/pass/box-custom-alloc-aliasing.rs | 1 - src/tools/miri/tests/pass/box-custom-alloc.rs | 1 - src/tools/miri/tests/pass/global_allocator.rs | 2 +- src/tools/miri/tests/pass/heap_allocator.rs | 2 +- tests/incremental/lint-unused-features.rs | 7 +- .../mir-opt/box_conditional_drop_allocator.rs | 2 +- .../issue_117368_print_invalid_constant.rs | 2 +- tests/run-make/std-core-cycle/bar.rs | 2 +- tests/ui/README.md | 2 +- tests/ui/allocator/156920-allocator-clone.rs | 2 +- tests/ui/allocator/157089-box-pin-in.rs | 2 +- tests/ui/allocator/159445-unsize-pin-box.rs | 2 +- tests/ui/allocator/alloc-shrink-oob-read.rs | 1 - tests/ui/allocator/auxiliary/custom.rs | 2 +- tests/ui/allocator/custom.rs | 1 - tests/ui/allocator/dyn-compatible.rs | 2 - tests/ui/allocator/xcrate-use.rs | 1 - tests/ui/array-slice-vec/vec-res-add.stderr | 1 + .../async-drop/async-drop-box-allocator.rs | 2 +- tests/ui/box/alloc-unstable-fail.rs | 6 - tests/ui/box/alloc-unstable-fail.stderr | 13 -- tests/ui/box/alloc-unstable.rs | 5 - tests/ui/box/issue-95036.rs | 2 +- tests/ui/box/large-allocator-ice.rs | 2 +- tests/ui/box/leak-alloc.rs | 2 +- .../impl-foreign-for-box[foreign_local].rs | 2 +- ...parison_instead_of_pattern_matching.stderr | 4 + .../debuginfo-box-with-large-allocator.rs | 2 +- .../ui/drop/box-conditional-drop-allocator.rs | 1 - .../could-not-resolve-issue-121503.rs | 2 +- tests/ui/lint/must_not_suspend/allocator.rs | 2 +- .../unused-features/used-library-features.rs | 4 +- tests/ui/lto/issue-100772.rs | 2 +- .../implicit-const-deref.stderr | 1 + tests/ui/pattern/issue-115599.stderr | 1 + tests/ui/pattern/pattern-tyvar-2.stderr | 1 + .../ui/precondition-checks/vec-from-parts.rs | 2 +- .../precondition-checks/vec-from-raw-parts.rs | 2 +- tests/ui/regions/regions-mock-codegen.rs | 1 - .../suggest-vec-allocator-api.rs | 9 -- .../suggest-vec-allocator-api.stderr | 53 --------- tests/ui/traits/const-traits/issue-102156.rs | 2 +- 86 files changed, 362 insertions(+), 478 deletions(-) rename src/doc/unstable-book/src/library-features/{allocator-api.md => allocator-ext.md} (96%) delete mode 100644 tests/ui/box/alloc-unstable-fail.rs delete mode 100644 tests/ui/box/alloc-unstable-fail.stderr delete mode 100644 tests/ui/box/alloc-unstable.rs delete mode 100644 tests/ui/stability-attribute/suggest-vec-allocator-api.rs delete mode 100644 tests/ui/stability-attribute/suggest-vec-allocator-api.stderr diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index ab30806bd2a59..041763f57fc9e 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -10,10 +10,11 @@ #![allow(internal_features)] #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] +#![cfg_attr(bootstrap, feature(allocator_api))] #![cfg_attr(bootstrap, feature(never_type))] +#![cfg_attr(not(bootstrap), feature(allocator_ext))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] -#![feature(allocator_api)] #![feature(ascii_char)] #![feature(ascii_char_variants)] #![feature(auto_traits)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 48d90f9c704fc..5acf9e150bb5c 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -27,9 +27,10 @@ // tidy-alphabetical-start #![allow(internal_features)] #![allow(rustc::direct_use_of_rustc_type_ir)] +#![cfg_attr(bootstrap, feature(allocator_api))] #![cfg_attr(bootstrap, feature(never_type))] #![cfg_attr(doc, feature(intra_doc_pointers))] -#![feature(allocator_api)] +#![cfg_attr(not(bootstrap), feature(allocator_ext))] #![feature(associated_type_defaults)] #![feature(closure_track_caller)] #![feature(const_default)] diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index f921bc292568d..ccac980706571 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -51,17 +51,17 @@ unsafe extern "Rust" { /// /// Note: while this type is unstable, the functionality it provides can be /// accessed through the [free functions in `alloc`](self#functions). -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[derive(Copy, Debug)] #[derive_const(Clone, Default)] // the compiler needs to know when a Box uses the global allocator vs a custom one #[lang = "global_alloc_ty"] pub struct Global; -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl core::alloc::AllocatorClone for Global {} -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl core::alloc::StaticAllocator for Global {} /// Allocates memory with the global allocator. @@ -539,7 +539,7 @@ impl Global { } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] const unsafe impl Allocator for Global { #[inline] @@ -690,13 +690,13 @@ pub mod __alloc_error_handler { /// a type with an `#[unstable] A: Allocator = Global` parameter may be /// callable for `A != Global`. #[marker] -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[doc(hidden)] pub trait AllocatorNightly: Allocator {} -#[unstable(feature = "allocator_api", issue = "32838")] -#[unstable_feature_bound(allocator_api)] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] +#[unstable_feature_bound(allocator_ext)] impl AllocatorNightly for A {} -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] impl AllocatorNightly for Global {} diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index ce36a9324b119..38d30b8f4f9ad 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -235,7 +235,7 @@ pub use thin::ThinBox; // compiler or ICEs will happen. pub struct Box< T: ?Sized, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] A: Allocator = Global, >(Unique, A); /// Monomorphic function for allocating an uninit `Box`. @@ -371,12 +371,12 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// let five = Box::try_new(5)?; /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new(x: T) -> Result { Self::try_new_in(x, Global) @@ -388,7 +388,7 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// let mut five = Box::::try_new_uninit()?; /// // Deferred initialization: @@ -398,7 +398,7 @@ impl Box { /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_uninit() -> Result>, AllocError> { Box::try_new_uninit_in(Global) @@ -413,7 +413,7 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// let zero = Box::::try_new_zeroed()?; /// let zero = unsafe { zero.assume_init() }; @@ -423,7 +423,7 @@ impl Box { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_zeroed() -> Result>, AllocError> { Box::try_new_zeroed_in(Global) @@ -438,14 +438,12 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let five = Box::new_in(5, System); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[must_use] #[inline] pub fn new_in(x: T, alloc: A) -> Self { @@ -463,14 +461,14 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// /// let five = Box::try_new_in(5, System)?; /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_in(x: T, alloc: A) -> Result { let mut boxed = Self::try_new_uninit_in(alloc)?; @@ -484,7 +482,7 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -495,7 +493,7 @@ impl Box { /// /// assert_eq!(*five, 5) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[cfg(not(no_global_oom_handling))] #[must_use] pub fn new_uninit_in(alloc: A) -> Box, A> { @@ -514,7 +512,7 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -526,7 +524,7 @@ impl Box { /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_new_uninit_in(alloc: A) -> Result, A>, AllocError> { let ptr = if T::IS_ZST { NonNull::dangling() @@ -547,7 +545,7 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -558,7 +556,7 @@ impl Box { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[cfg(not(no_global_oom_handling))] #[must_use] pub fn new_zeroed_in(alloc: A) -> Box, A> { @@ -581,7 +579,7 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -593,7 +591,7 @@ impl Box { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_new_zeroed_in(alloc: A) -> Result, A>, AllocError> { let ptr = if T::IS_ZST { NonNull::dangling() @@ -616,13 +614,13 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::alloc::System; /// /// let x = Box::pin_in(1, System); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[must_use] #[inline(always)] pub fn pin_in(x: T, alloc: A) -> Pin @@ -802,13 +800,12 @@ impl Box { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] /// /// let hello: Box = Box::try_clone_from_ref("hello")?; /// # Ok::<(), std::alloc::AllocError>(()) /// ``` #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_clone_from_ref(src: &T) -> Result, AllocError> { Box::try_clone_from_ref_in(src, Global) @@ -824,7 +821,6 @@ impl Box { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] /// /// use std::alloc::System; /// @@ -832,7 +828,7 @@ impl Box { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[must_use] #[inline] pub fn clone_from_ref_in(src: &T, alloc: A) -> Box { @@ -851,7 +847,6 @@ impl Box { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] /// /// use std::alloc::System; /// @@ -859,7 +854,7 @@ impl Box { /// # Ok::<(), std::alloc::AllocError>(()) /// ``` #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_clone_from_ref_in(src: &T, alloc: A) -> Result, AllocError> { struct DeallocDropGuard<'a, A: Allocator>(Layout, &'a A, NonNull); @@ -947,7 +942,7 @@ impl Box<[T]> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// let mut values = Box::<[u32]>::try_new_uninit_slice(3)?; /// // Deferred initialization: @@ -959,7 +954,7 @@ impl Box<[T]> { /// assert_eq!(*values, [1, 2, 3]); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_uninit_slice(len: usize) -> Result]>, AllocError> { let ptr = if T::IS_ZST || len == 0 { @@ -987,7 +982,7 @@ impl Box<[T]> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// let values = Box::<[u32]>::try_new_zeroed_slice(3)?; /// let values = unsafe { values.assume_init() }; @@ -997,7 +992,7 @@ impl Box<[T]> { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_zeroed_slice(len: usize) -> Result]>, AllocError> { let ptr = if T::IS_ZST || len == 0 { @@ -1023,7 +1018,7 @@ impl Box<[T], A> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -1037,7 +1032,7 @@ impl Box<[T], A> { /// assert_eq!(*values, [1, 2, 3]) /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[must_use] pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit], A> { // SAFETY: `len` is exactly the capacity of this `RawVec`. @@ -1053,7 +1048,7 @@ impl Box<[T], A> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -1065,7 +1060,7 @@ impl Box<[T], A> { /// /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[must_use] pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit], A> { // SAFETY: `len` is exactly the capacity of this `RawVec`. @@ -1078,7 +1073,7 @@ impl Box<[T], A> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -1092,7 +1087,7 @@ impl Box<[T], A> { /// assert_eq!(*values, [1, 2, 3]); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_uninit_slice_in( len: usize, @@ -1123,7 +1118,7 @@ impl Box<[T], A> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -1135,7 +1130,7 @@ impl Box<[T], A> { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_zeroed_slice_in( len: usize, @@ -1544,8 +1539,6 @@ impl Box { /// Recreate a `Box` which was previously converted to a raw pointer /// using [`Box::into_raw_with_allocator`]: /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let x = Box::new_in(5, System); @@ -1554,7 +1547,7 @@ impl Box { /// ``` /// Manually create a `Box` from scratch by using the system allocator: /// ``` - /// #![feature(allocator_api, slice_ptr_get)] + /// #![feature(slice_ptr_get)] /// /// use std::alloc::{Allocator, Layout, System}; /// @@ -1571,7 +1564,7 @@ impl Box { /// /// [memory layout]: self#memory-layout /// [considerations for unsafe code]: self#considerations-for-unsafe-code - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[inline] pub unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self { // SAFETY: Upheld by caller. @@ -1602,8 +1595,6 @@ impl Box { /// Recreate a `Box` which was previously converted to a `NonNull` pointer /// using [`Box::into_non_null_with_allocator`]: /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let x = Box::new_in(5, System); @@ -1612,8 +1603,6 @@ impl Box { /// ``` /// Manually create a `Box` from scratch by using the system allocator: /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::{Allocator, Layout, System}; /// /// unsafe { @@ -1628,7 +1617,7 @@ impl Box { /// /// [memory layout]: self#memory-layout /// [considerations for unsafe code]: self#considerations-for-unsafe-code - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[inline] pub unsafe fn from_non_null_in(raw: NonNull, alloc: A) -> Self { // SAFETY: guaranteed by the caller. @@ -1655,8 +1644,6 @@ impl Box { /// Converting the raw pointer back into a `Box` with [`Box::from_raw_in`] /// for automatic cleanup: /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let x = Box::new_in(String::from("Hello"), System); @@ -1666,8 +1653,6 @@ impl Box { /// Manual cleanup by explicitly running the destructor and deallocating /// the memory: /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::{Allocator, Layout, System}; /// use std::ptr::{self, NonNull}; /// @@ -1682,7 +1667,7 @@ impl Box { /// /// [memory layout]: self#memory-layout #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] #[inline] pub const fn into_raw_with_allocator(b: Self) -> (*mut T, A) { @@ -1719,8 +1704,6 @@ impl Box { /// Converting the `NonNull` pointer back into a `Box` with /// [`Box::from_non_null_in`] for automatic cleanup: /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let x = Box::new_in(String::from("Hello"), System); @@ -1730,8 +1713,6 @@ impl Box { /// Manual cleanup by explicitly running the destructor and deallocating /// the memory: /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::{Allocator, Layout, System}; /// /// let x = Box::new_in(String::from("Hello"), System); @@ -1744,7 +1725,7 @@ impl Box { /// /// [memory layout]: self#memory-layout #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[inline] pub fn into_non_null_with_allocator(b: Self) -> (NonNull, A) { let (ptr, alloc) = Box::into_raw_with_allocator(b); @@ -1890,7 +1871,7 @@ impl Box { /// Note: this is an associated function, which means that you have /// to call it as `Box::allocator(&b)` instead of `b.allocator()`. This /// is so that there is no conflict with a method on the inner type. - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[inline] pub fn allocator(b: &Self) -> &A { &b.1 @@ -2511,7 +2492,7 @@ impl Error for Box { } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe impl Allocator for Box { #[inline] fn allocate(&self, layout: Layout) -> Result, AllocError> { diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 7d08991659787..90bb2ef9b838c 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -78,7 +78,6 @@ impl ThinBox { /// # Examples /// /// ``` - /// #![feature(allocator_api)] /// #![feature(thin_box)] /// use std::boxed::ThinBox; /// diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index 8d730a49182bd..f3698a997c925 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -273,7 +273,7 @@ use crate::vec::{self, Vec}; #[cfg_attr(not(test), rustc_diagnostic_item = "BinaryHeap")] pub struct BinaryHeap< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { data: Vec, } @@ -289,7 +289,7 @@ pub struct BinaryHeap< pub struct PeekMut< 'a, T: 'a + Ord, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { heap: &'a mut BinaryHeap, // If a set_len + sift_down are required, this is Some. If a &mut T has not @@ -482,7 +482,7 @@ impl fmt::Debug for BinaryHeap { struct RebuildOnDrop< 'a, T: Ord, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { heap: &'a mut BinaryHeap, rebuild_from: usize, @@ -543,14 +543,15 @@ impl BinaryHeap { /// Basic usage: /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// use std::collections::BinaryHeap; /// /// let heap : BinaryHeap = BinaryHeap::new_in(System); /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] + #[rustc_const_unstable(feature = "allocator_ext", issue = "163177")] #[must_use] pub const fn new_in(alloc: A) -> BinaryHeap { BinaryHeap { data: Vec::new_in(alloc) } @@ -567,14 +568,14 @@ impl BinaryHeap { /// Basic usage: /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// use std::collections::BinaryHeap; /// /// let heap: BinaryHeap = BinaryHeap::with_capacity_in(10, System); /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[must_use] pub fn with_capacity_in(capacity: usize, alloc: A) -> BinaryHeap { BinaryHeap { data: Vec::with_capacity_in(capacity, alloc) } @@ -1417,7 +1418,7 @@ impl BinaryHeap { } /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn allocator(&self) -> &A { self.data.allocator() @@ -1692,14 +1693,14 @@ impl FusedIterator for Iter<'_, T> {} #[derive(Clone)] pub struct IntoIter< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { iter: vec::IntoIter, } impl IntoIter { /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(&self) -> &A { self.iter.allocator() } @@ -1797,14 +1798,14 @@ unsafe impl AsVecIntoIter for IntoIter { #[derive(Clone, Debug)] pub struct IntoIterSorted< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { inner: BinaryHeap, } impl IntoIterSorted { /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(&self) -> &A { self.inner.allocator() } @@ -1846,14 +1847,14 @@ unsafe impl TrustedLen for IntoIterSorted {} pub struct Drain< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { iter: vec::Drain<'a, T, A>, } impl Drain<'_, T, A> { /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(&self) -> &A { self.iter.allocator() } @@ -1903,14 +1904,14 @@ impl FusedIterator for Drain<'_, T, A> {} pub struct DrainSorted< 'a, T: Ord, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { inner: &'a mut BinaryHeap, } impl<'a, T: Ord, A: Allocator> DrainSorted<'a, T, A> { /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(&self) -> &A { self.inner.allocator() } diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index e8ee6fa628bfa..6b74024613dee 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -189,7 +189,7 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; pub struct BTreeMap< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { root: Option>, length: usize, @@ -446,7 +446,7 @@ impl<'a, K: 'a, V: 'a> Default for IterMut<'a, K, V> { pub struct IntoIter< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { range: LazyLeafRange, length: usize, @@ -554,7 +554,7 @@ impl fmt::Debug for ValuesMut<'_, K, V> { pub struct IntoKeys< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { inner: IntoIter, } @@ -577,7 +577,7 @@ impl fmt::Debug for IntoKeys { pub struct IntoValues< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { inner: IntoIter, } @@ -684,7 +684,6 @@ impl BTreeMap { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] /// # #![feature(btreemap_alloc)] /// /// use std::collections::BTreeMap; @@ -692,7 +691,7 @@ impl BTreeMap { /// /// let map: BTreeMap = BTreeMap::new_in(Global); /// ``` - #[unstable(feature = "btreemap_alloc", issue = "32838")] + #[unstable(feature = "btreemap_alloc", issue = "163177")] #[must_use] pub const fn new_in(alloc: A) -> BTreeMap { BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(alloc), _marker: PhantomData } @@ -2143,7 +2142,7 @@ pub struct ExtractIf< V, R, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { pred: F, inner: ExtractIfInner<'a, K, V, R>, @@ -3152,7 +3151,7 @@ pub struct CursorMut< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A = Global, > { inner: CursorMutKey<'a, K, V, A>, } @@ -3190,7 +3189,7 @@ pub struct CursorMutKey< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A = Global, > { // If current is None then it means the tree has not been allocated yet. current: Option, K, V, marker::Leaf>, marker::Edge>>, diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs index d3a9651799ab8..3d5b4cf2b46f1 100644 --- a/library/alloc/src/collections/btree/map/entry.rs +++ b/library/alloc/src/collections/btree/map/entry.rs @@ -20,7 +20,7 @@ pub enum Entry< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { /// A vacant entry. #[stable(feature = "rust1", since = "1.0.0")] @@ -48,7 +48,7 @@ pub struct VacantEntry< 'a, K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { pub(super) key: K, /// `None` for a (empty) map without root @@ -76,7 +76,7 @@ pub struct OccupiedEntry< 'a, K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { pub(super) handle: Handle, K, V, marker::LeafOrInternal>, marker::KV>, pub(super) dormant_map: DormantMutRef<'a, BTreeMap>, @@ -104,7 +104,7 @@ pub struct OccupiedError< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { /// The entry in the map that was already occupied. pub entry: OccupiedEntry<'a, K, V, A>, diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 3b15bda185d9d..2a17b0b4c43f9 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -77,7 +77,7 @@ pub use self::entry::{Entry, OccupiedEntry, VacantEntry}; #[cfg_attr(not(test), rustc_diagnostic_item = "BTreeSet")] pub struct BTreeSet< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { map: BTreeMap, } @@ -153,7 +153,7 @@ impl fmt::Debug for Iter<'_, T> { #[derive(Debug)] pub struct IntoIter< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { iter: super::map::IntoIter, } @@ -183,7 +183,7 @@ pub struct Range<'a, T: 'a> { pub struct Difference< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { inner: DifferenceInner<'a, T, A>, } @@ -257,7 +257,7 @@ impl fmt::Debug for SymmetricDifference<'_, T> { pub struct Intersection< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { inner: IntersectionInner<'a, T, A>, } @@ -353,7 +353,6 @@ impl BTreeSet { /// /// ``` /// # #![allow(unused_mut)] - /// # #![feature(allocator_api)] /// # #![feature(btreemap_alloc)] /// /// use std::collections::BTreeSet; @@ -361,7 +360,7 @@ impl BTreeSet { /// /// let set: BTreeSet = BTreeSet::new_in(Global); /// ``` - #[unstable(feature = "btreemap_alloc", issue = "32838")] + #[unstable(feature = "btreemap_alloc", issue = "163177")] #[must_use] pub const fn new_in(alloc: A) -> BTreeSet { BTreeSet { map: BTreeMap::new_in(alloc) } @@ -1559,7 +1558,7 @@ pub struct ExtractIf< T, R, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { pred: F, inner: super::map::ExtractIfInner<'a, T, SetValZST, R>, @@ -2156,8 +2155,11 @@ impl Debug for Cursor<'_, K> { /// A `CursorMut` is created with the [`BTreeSet::lower_bound_mut`] and [`BTreeSet::upper_bound_mut`] /// methods. #[unstable(feature = "btree_cursors", issue = "107540")] -pub struct CursorMut<'a, K: 'a, #[unstable(feature = "allocator_api", issue = "32838")] A = Global> -{ +pub struct CursorMut< + 'a, + K: 'a, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A = Global, +> { inner: super::map::CursorMut<'a, K, SetValZST, A>, } @@ -2193,7 +2195,7 @@ impl Debug for CursorMut<'_, K, A> { pub struct CursorMutKey< 'a, K: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A = Global, > { inner: super::map::CursorMutKey<'a, K, SetValZST, A>, } diff --git a/library/alloc/src/collections/btree/set/entry.rs b/library/alloc/src/collections/btree/set/entry.rs index 89bc09bca2f5c..71978c6e2168d 100644 --- a/library/alloc/src/collections/btree/set/entry.rs +++ b/library/alloc/src/collections/btree/set/entry.rs @@ -42,7 +42,7 @@ use crate::alloc::{AllocatorClone, Global}; pub enum Entry< 'a, T, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { /// An occupied entry. /// @@ -133,7 +133,7 @@ impl Debug for Entry<'_, T, A> { pub struct OccupiedEntry< 'a, T, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { pub(super) inner: map::OccupiedEntry<'a, T, SetValZST, A>, } @@ -175,7 +175,7 @@ impl Debug for OccupiedEntry<'_, T, A> { pub struct VacantEntry< 'a, T, - #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: AllocatorClone = Global, > { pub(super) inner: map::VacantEntry<'a, T, SetValZST, A>, } diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 872b5e0d7682d..3acf4e6b18e16 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -50,7 +50,7 @@ mod tests; #[rustc_insignificant_dtor] pub struct LinkedList< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { head: Option>>, tail: Option>>, @@ -141,7 +141,7 @@ impl fmt::Debug for IterMut<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { list: LinkedList, } @@ -515,7 +515,7 @@ impl LinkedList { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// use std::collections::LinkedList; @@ -523,7 +523,7 @@ impl LinkedList { /// let list: LinkedList = LinkedList::new_in(System); /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub const fn new_in(alloc: A) -> Self { LinkedList { head: None, tail: None, len: 0, alloc, marker: PhantomData } } @@ -1365,7 +1365,7 @@ impl Default for IterMut<'_, T> { pub struct Cursor< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { index: usize, current: Option>>, @@ -1401,7 +1401,7 @@ impl fmt::Debug for Cursor<'_, T, A> { pub struct CursorMut< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { index: usize, current: Option>>, @@ -2000,7 +2000,7 @@ pub struct ExtractIf< 'a, T: 'a, F: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { list: &'a mut LinkedList, it: Option>>, diff --git a/library/alloc/src/collections/vec_deque/drain.rs b/library/alloc/src/collections/vec_deque/drain.rs index b56af5f0e85b6..38d540ab08040 100644 --- a/library/alloc/src/collections/vec_deque/drain.rs +++ b/library/alloc/src/collections/vec_deque/drain.rs @@ -18,7 +18,7 @@ use crate::alloc::{Allocator, Global}; pub struct Drain< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { // We can't just use a &mut VecDeque, as that would make Drain invariant over T // and we want it to be covariant instead diff --git a/library/alloc/src/collections/vec_deque/extract_if.rs b/library/alloc/src/collections/vec_deque/extract_if.rs index 61a75cadf4a26..4e74b0b84cb54 100644 --- a/library/alloc/src/collections/vec_deque/extract_if.rs +++ b/library/alloc/src/collections/vec_deque/extract_if.rs @@ -27,7 +27,7 @@ pub struct ExtractIf< 'a, T, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { vec: &'a mut VecDeque, /// The index of the item that will be inspected by the next call to `next`. @@ -57,7 +57,7 @@ impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> { } /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn allocator(&self) -> &A { self.vec.allocator() diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs index e18b85dd4b694..7cac57421ac5e 100644 --- a/library/alloc/src/collections/vec_deque/into_iter.rs +++ b/library/alloc/src/collections/vec_deque/into_iter.rs @@ -18,7 +18,7 @@ use crate::alloc::{Allocator, Global}; #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { inner: VecDeque, } diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index e068add469f3b..8e4507c6fd0aa 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -103,7 +103,7 @@ mod tests; #[rustc_insignificant_dtor] pub struct VecDeque< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { // `self[0]`, if it exists, is `buf[head]`. // `head < buf.capacity()`, unless `buf.capacity() == 0` when `head == 0`. @@ -904,7 +904,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// /// use std::collections::VecDeque; /// use std::alloc::Global; @@ -912,7 +912,7 @@ impl VecDeque { /// let deque: VecDeque = VecDeque::new_in(Global); /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub const fn new_in(alloc: A) -> VecDeque { VecDeque { head: WrappedIndex::zero(), len: 0, buf: RawVec::new_in(alloc) } } @@ -922,14 +922,14 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// /// use std::collections::VecDeque; /// use std::alloc::Global; /// /// let deque: VecDeque = VecDeque::with_capacity_in(10, Global); /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn with_capacity_in(capacity: usize, alloc: A) -> VecDeque { VecDeque { head: WrappedIndex::zero(), @@ -1648,7 +1648,7 @@ impl VecDeque { } /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn allocator(&self) -> &A { self.buf.allocator() diff --git a/library/alloc/src/collections/vec_deque/splice.rs b/library/alloc/src/collections/vec_deque/splice.rs index 93e5a0b4addf0..b1fd67df3d2d7 100644 --- a/library/alloc/src/collections/vec_deque/splice.rs +++ b/library/alloc/src/collections/vec_deque/splice.rs @@ -24,7 +24,7 @@ use crate::vec::Vec; pub struct Splice< 'a, I: Iterator + 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + 'a = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator + 'a = Global, > { pub(super) drain: Drain<'a, I::Item, A>, pub(super) replace_with: I, diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 664e3a4b1e218..de6830a514656 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -89,7 +89,7 @@ // // Library features: // tidy-alphabetical-start -#![feature(allocator_api)] +#![feature(allocator_ext)] #![feature(array_into_iter_constructors)] #![feature(ascii_char)] #![feature(async_fn_traits)] diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 229de8337d94b..0571f50b8a23b 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -323,7 +323,7 @@ fn rc_inner_layout_for_value_layout(layout: Layout) -> Layout { pub struct Rc< T: ?Sized, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { ptr: NonNull>, phantom: PhantomData>, @@ -566,13 +566,13 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::rc::Rc; /// /// let five = Rc::try_new(5); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_new(value: T) -> Result, AllocError> { // SAFETY: There is an implicit weak pointer owned by all the strong // pointers, which ensures that the weak destructor never frees @@ -592,7 +592,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// @@ -606,7 +606,7 @@ impl Rc { /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_new_uninit() -> Result>, AllocError> { // ignore-tidy-undocumented-unsafe unsafe { @@ -627,7 +627,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// @@ -639,7 +639,7 @@ impl Rc { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_new_zeroed() -> Result>, AllocError> { // ignore-tidy-undocumented-unsafe unsafe { @@ -667,7 +667,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -675,7 +675,7 @@ impl Rc { /// let five = Rc::new_in(5, System); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_in(value: T, alloc: A) -> Rc { // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable. @@ -692,7 +692,7 @@ impl Rc { /// /// ``` /// #![feature(get_mut_unchecked)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -709,7 +709,7 @@ impl Rc { /// assert_eq!(*five, 5) /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_uninit_in(alloc: A) -> Rc, A> { // ignore-tidy-undocumented-unsafe @@ -734,7 +734,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -747,7 +747,7 @@ impl Rc { /// /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_zeroed_in(alloc: A) -> Rc, A> { // ignore-tidy-undocumented-unsafe @@ -793,7 +793,7 @@ impl Rc { /// [`new_cyclic`]: Rc::new_cyclic /// [`upgrade`]: Weak::upgrade #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn new_cyclic_in(data_fn: F, alloc: A) -> Rc where F: FnOnce(&Weak) -> T, @@ -845,14 +845,14 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::rc::Rc; /// use std::alloc::System; /// /// let five = Rc::try_new_in(5, System); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_in(value: T, alloc: A) -> Result { // There is an implicit weak pointer owned by all the strong @@ -873,7 +873,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// #![feature(get_mut_unchecked)] /// /// use std::rc::Rc; @@ -891,7 +891,7 @@ impl Rc { /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_uninit_in(alloc: A) -> Result, A>, AllocError> { // ignore-tidy-undocumented-unsafe @@ -917,7 +917,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -930,7 +930,7 @@ impl Rc { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_zeroed_in(alloc: A) -> Result, A>, AllocError> { // ignore-tidy-undocumented-unsafe @@ -949,7 +949,7 @@ impl Rc { /// Constructs a new `Pin>` in the provided allocator. If `T` does not implement `Unpin`, then /// `value` will be pinned in memory and unable to be moved. #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn pin_in(value: T, alloc: A) -> Pin where @@ -1204,7 +1204,7 @@ impl Rc<[T], A> { /// /// ``` /// #![feature(get_mut_unchecked)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -1223,7 +1223,7 @@ impl Rc<[T], A> { /// assert_eq!(*values, [1, 2, 3]) /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_uninit_slice_in(len: usize, alloc: A) -> Rc<[mem::MaybeUninit], A> { // ignore-tidy-undocumented-unsafe @@ -1239,7 +1239,7 @@ impl Rc<[T], A> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -1252,7 +1252,7 @@ impl Rc<[T], A> { /// /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Rc<[mem::MaybeUninit], A> { // ignore-tidy-undocumented-unsafe @@ -1361,14 +1361,13 @@ impl Rc { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] /// use std::rc::Rc; /// /// let hello: Rc = Rc::try_clone_from_ref("hello")?; /// # Ok::<(), std::alloc::AllocError>(()) /// ``` #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_clone_from_ref(value: &T) -> Result, AllocError> { Rc::try_clone_from_ref_in(value, Global) } @@ -1381,7 +1380,7 @@ impl Rc { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::rc::Rc; /// use std::alloc::System; /// @@ -1389,7 +1388,7 @@ impl Rc { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn clone_from_ref_in(value: &T, alloc: A) -> Rc { // `in_progress` drops the allocation if we panic before finishing initializing it. let mut in_progress: UniqueRcUninit = UniqueRcUninit::new(value, alloc); @@ -1410,7 +1409,7 @@ impl Rc { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::rc::Rc; /// use std::alloc::System; /// @@ -1418,7 +1417,7 @@ impl Rc { /// # Ok::<(), std::alloc::AllocError>(()) /// ``` #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_clone_from_ref_in(value: &T, alloc: A) -> Result, AllocError> { // `in_progress` drops the allocation if we panic before finishing initializing it. let mut in_progress: UniqueRcUninit = UniqueRcUninit::try_new(value, alloc)?; @@ -1696,7 +1695,7 @@ impl Rc { /// to call it as `Rc::allocator(&r)` instead of `r.allocator()`. This /// is so that there is no conflict with a method on the inner type. #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(this: &Self) -> &A { &this.alloc } @@ -1709,7 +1708,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::rc::Rc; /// use std::alloc::System; /// @@ -1720,7 +1719,7 @@ impl Rc { /// assert_eq!(&*x, "hello"); /// ``` #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn into_raw_with_allocator(this: Self) -> (*const T, A) { let this = mem::ManuallyDrop::new(this); let ptr = Self::as_ptr(&this); @@ -1791,7 +1790,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -1813,7 +1812,7 @@ impl Rc { /// Convert a slice back into its original array: /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -1826,7 +1825,7 @@ impl Rc { /// assert_eq!(&*x, &[1, 2, 3]); /// } /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self { // ignore-tidy-undocumented-unsafe let offset = unsafe { data_offset(ptr) }; @@ -1915,7 +1914,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -1933,7 +1932,7 @@ impl Rc { /// } /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A) where A: AllocatorClone, @@ -1962,7 +1961,7 @@ impl Rc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::rc::Rc; /// use std::alloc::System; @@ -1980,7 +1979,7 @@ impl Rc { /// } /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A) { // SAFETY: Upheld by caller. unsafe { drop(Rc::from_raw_in(ptr, alloc)) }; @@ -3304,7 +3303,7 @@ impl> ToRcSlice for I { #[rustc_diagnostic_item = "RcWeak"] pub struct Weak< T: ?Sized, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { // This is a `NonNull` to allow optimizing the size of this type in enums, // but it is not necessarily a valid pointer. @@ -3369,7 +3368,7 @@ impl Weak { /// assert!(empty.upgrade().is_none()); /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn new_in(alloc: A) -> Weak { Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc } } @@ -3473,7 +3472,7 @@ impl Weak { impl Weak { /// Returns a reference to the underlying allocator. #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(&self) -> &A { &self.alloc } @@ -3532,7 +3531,7 @@ impl Weak { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::rc::{Rc, Weak}; /// use std::alloc::System; /// @@ -3551,7 +3550,7 @@ impl Weak { /// [`as_ptr`]: Weak::as_ptr #[must_use = "losing the pointer will leak memory"] #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn into_raw_with_allocator(self) -> (*const T, A) { let this = mem::ManuallyDrop::new(self); let result = this.as_ptr(); @@ -3603,7 +3602,7 @@ impl Weak { /// [`upgrade`]: Weak::upgrade /// [`new`]: Weak::new #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self { // See Weak::as_ptr for context on how the input pointer is derived. @@ -4039,7 +4038,7 @@ fn data_offset_alignment(alignment: Alignment) -> usize { #[unstable(feature = "unique_rc_arc", issue = "112566")] pub struct UniqueRc< T: ?Sized, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { ptr: NonNull>, // Define the ownership of `RcInner` for drop-check @@ -4337,7 +4336,7 @@ impl UniqueRc { /// point to the new [`Rc`]. #[cfg(not(no_global_oom_handling))] #[unstable(feature = "unique_rc_arc", issue = "112566")] - // #[unstable(feature = "allocator_api", issue = "32838")] + // #[unstable(feature = "allocator_api", issue = "163177")] #[must_use] pub fn new_in(value: T, alloc: A) -> Self { let (ptr, alloc) = Box::into_non_null_with_allocator(Box::new_in( @@ -4356,7 +4355,7 @@ impl UniqueRc { /// Like [`new_in`](Self::new_in), but returns an error if the allocation /// fails, instead of calling [`handle_alloc_error`]. #[unstable(feature = "unique_rc_arc", issue = "112566")] - // #[unstable(feature = "allocator_api", issue = "32838")] + // #[unstable(feature = "allocator_api", issue = "163177")] pub fn try_new_in(value: T, alloc: A) -> Result { let (ptr, alloc) = Box::into_non_null_with_allocator(Box::try_new_in( RcInner { @@ -4373,7 +4372,7 @@ impl UniqueRc { /// Consumes the `UniqueRc`, returning its wrapped value and allocator. #[unstable(feature = "unique_rc_arc", issue = "112566")] - // #[unstable(feature = "allocator_api", issue = "32838")] + // #[unstable(feature = "allocator_api", issue = "163177")] #[must_use] pub fn unwrap_with_allocator(this: Self) -> (T, A) { let inner_ptr = this.ptr; @@ -4742,7 +4741,7 @@ impl Drop for UniqueRcUninit { } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe impl Allocator for Rc { #[inline] fn allocate(&self, layout: Layout) -> Result, AllocError> { @@ -4794,5 +4793,5 @@ unsafe impl Allocator for Rc { } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl AllocatorClone for Rc {} diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index 4741fe12ae89c..438549160a1c6 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -381,7 +381,7 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::alloc::System; /// @@ -392,7 +392,7 @@ impl [T] { #[cfg(not(no_global_oom_handling))] #[rustc_allow_incoherent_impl] #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn to_vec_in(&self, alloc: A) -> Vec where T: Clone, diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index c71544925bef7..13e70a436234c 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -273,7 +273,7 @@ macro_rules! acquire { )] pub struct Arc< T: ?Sized, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { ptr: NonNull>, phantom: PhantomData>, @@ -359,7 +359,7 @@ impl Arc { #[rustc_diagnostic_item = "ArcWeak"] pub struct Weak< T: ?Sized, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { // This is a `NonNull` to allow optimizing the size of this type in enums, // but it is not necessarily a valid pointer. @@ -589,7 +589,7 @@ impl Arc { } /// Constructs a new `Pin>`, return an error if allocation fails. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_pin(data: T) -> Result>, AllocError> { // SAFETY: We own and create the pinned pointer. @@ -601,13 +601,13 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::sync::Arc; /// /// let five = Arc::try_new(5)?; /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new(data: T) -> Result, AllocError> { // Start the weak pointer count as 1 which is the weak pointer that's @@ -627,7 +627,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// @@ -641,7 +641,7 @@ impl Arc { /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_new_uninit() -> Result>, AllocError> { // ignore-tidy-undocumented-unsafe unsafe { @@ -662,7 +662,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature( allocator_api)] + /// #![feature( allocator_ext)] /// /// use std::sync::Arc; /// @@ -674,7 +674,7 @@ impl Arc { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_new_zeroed() -> Result>, AllocError> { // ignore-tidy-undocumented-unsafe unsafe { @@ -693,7 +693,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -702,7 +702,7 @@ impl Arc { /// ``` #[inline] #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn new_in(data: T, alloc: A) -> Arc { // Start the weak pointer count as 1 which is the weak pointer that's // held by all the strong pointers (kinda), see std/rc.rs for more info @@ -725,7 +725,7 @@ impl Arc { /// /// ``` /// #![feature(get_mut_unchecked)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -742,7 +742,7 @@ impl Arc { /// assert_eq!(*five, 5) /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_uninit_in(alloc: A) -> Arc, A> { // ignore-tidy-undocumented-unsafe @@ -767,7 +767,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -780,7 +780,7 @@ impl Arc { /// /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_zeroed_in(alloc: A) -> Arc, A> { // ignore-tidy-undocumented-unsafe @@ -827,7 +827,7 @@ impl Arc { /// [`upgrade`]: Weak::upgrade #[cfg(not(no_global_oom_handling))] #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn new_cyclic_in(data_fn: F, alloc: A) -> Arc where F: FnOnce(&Weak) -> T, @@ -889,7 +889,7 @@ impl Arc { /// Constructs a new `Pin>` in the provided allocator. If `T` does not implement `Unpin`, /// then `data` will be pinned in memory and unable to be moved. #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn pin_in(data: T, alloc: A) -> Pin> where @@ -902,7 +902,7 @@ impl Arc { /// Constructs a new `Pin>` in the provided allocator, return an error if allocation /// fails. #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_pin_in(data: T, alloc: A) -> Result>, AllocError> where A: 'static, @@ -916,7 +916,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -924,7 +924,7 @@ impl Arc { /// let five = Arc::try_new_in(5, System)?; /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_in(data: T, alloc: A) -> Result, AllocError> { // Start the weak pointer count as 1 which is the weak pointer that's @@ -948,7 +948,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// #![feature(get_mut_unchecked)] /// /// use std::sync::Arc; @@ -966,7 +966,7 @@ impl Arc { /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) /// ``` - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_uninit_in(alloc: A) -> Result, A>, AllocError> { // ignore-tidy-undocumented-unsafe @@ -992,7 +992,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -1005,7 +1005,7 @@ impl Arc { /// ``` /// /// [zeroed]: mem::MaybeUninit::zeroed - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn try_new_zeroed_in(alloc: A) -> Result, A>, AllocError> { // ignore-tidy-undocumented-unsafe @@ -1371,7 +1371,7 @@ impl Arc<[T], A> { /// /// ``` /// #![feature(get_mut_unchecked)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -1390,7 +1390,7 @@ impl Arc<[T], A> { /// assert_eq!(*values, [1, 2, 3]) /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_uninit_slice_in(len: usize, alloc: A) -> Arc<[mem::MaybeUninit], A> { // ignore-tidy-undocumented-unsafe @@ -1406,7 +1406,7 @@ impl Arc<[T], A> { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -1419,7 +1419,7 @@ impl Arc<[T], A> { /// /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Arc<[mem::MaybeUninit], A> { // ignore-tidy-undocumented-unsafe @@ -1529,14 +1529,13 @@ impl Arc { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] /// use std::sync::Arc; /// /// let hello: Arc = Arc::try_clone_from_ref("hello")?; /// # Ok::<(), std::alloc::AllocError>(()) /// ``` #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_clone_from_ref(value: &T) -> Result, AllocError> { Arc::try_clone_from_ref_in(value, Global) } @@ -1549,7 +1548,7 @@ impl Arc { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::sync::Arc; /// use std::alloc::System; /// @@ -1557,7 +1556,7 @@ impl Arc { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn clone_from_ref_in(value: &T, alloc: A) -> Arc { // `in_progress` drops the allocation if we panic before finishing initializing it. let mut in_progress: UniqueArcUninit = UniqueArcUninit::new(value, alloc); @@ -1578,7 +1577,7 @@ impl Arc { /// /// ``` /// #![feature(clone_from_ref)] - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::sync::Arc; /// use std::alloc::System; /// @@ -1586,7 +1585,7 @@ impl Arc { /// # Ok::<(), std::alloc::AllocError>(()) /// ``` #[unstable(feature = "clone_from_ref", issue = "149075")] - //#[unstable(feature = "allocator_api", issue = "32838")] + //#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn try_clone_from_ref_in(value: &T, alloc: A) -> Result, AllocError> { // `in_progress` drops the allocation if we panic before finishing initializing it. let mut in_progress: UniqueArcUninit = UniqueArcUninit::try_new(value, alloc)?; @@ -1880,7 +1879,7 @@ impl Arc { /// to call it as `Arc::allocator(&a)` instead of `a.allocator()`. This /// is so that there is no conflict with a method on the inner type. #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(this: &Self) -> &A { &this.alloc } @@ -1893,7 +1892,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::sync::Arc; /// use std::alloc::System; /// @@ -1904,7 +1903,7 @@ impl Arc { /// assert_eq!(&*x, "hello"); /// ``` #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn into_raw_with_allocator(this: Self) -> (*const T, A) { let this = mem::ManuallyDrop::new(this); let ptr = Self::as_ptr(&this); @@ -1976,7 +1975,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -1998,7 +1997,7 @@ impl Arc { /// Convert a slice back into its original array: /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -2012,7 +2011,7 @@ impl Arc { /// } /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self { // SAFETY: Upheld by caller. unsafe { @@ -2150,7 +2149,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -2170,7 +2169,7 @@ impl Arc { /// } /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A) where A: AllocatorClone, @@ -2200,7 +2199,7 @@ impl Arc { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Arc; /// use std::alloc::System; @@ -2220,7 +2219,7 @@ impl Arc { /// } /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A) { // SAFETY: Upheld by caller. unsafe { drop(Arc::from_raw_in(ptr, alloc)) }; @@ -3142,7 +3141,7 @@ impl Weak { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// /// use std::sync::Weak; /// use std::alloc::System; @@ -3151,7 +3150,7 @@ impl Weak { /// assert!(empty.upgrade().is_none()); /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn new_in(alloc: A) -> Weak { Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc } } @@ -3250,7 +3249,7 @@ impl Weak { impl Weak { /// Returns a reference to the underlying allocator. #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn allocator(&self) -> &A { &self.alloc } @@ -3309,7 +3308,7 @@ impl Weak { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::sync::{Arc, Weak}; /// use std::alloc::System; /// @@ -3327,7 +3326,7 @@ impl Weak { /// [`from_raw_in`]: Weak::from_raw_in /// [`as_ptr`]: Weak::as_ptr #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn into_raw_with_allocator(self) -> (*const T, A) { let this = mem::ManuallyDrop::new(self); let result = this.as_ptr(); @@ -3379,7 +3378,7 @@ impl Weak { /// [`into_raw`]: Weak::into_raw /// [`upgrade`]: Weak::upgrade #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self { // See Weak::as_ptr for context on how the input pointer is derived. @@ -4542,7 +4541,7 @@ impl core::error::Error for Arc { #[unstable(feature = "unique_rc_arc", issue = "112566")] pub struct UniqueArc< T: ?Sized, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { ptr: NonNull>, // Define the ownership of `ArcInner` for drop-check @@ -4816,7 +4815,7 @@ impl UniqueArc { /// point to the new [`Arc`]. #[cfg(not(no_global_oom_handling))] #[unstable(feature = "unique_rc_arc", issue = "112566")] - // #[unstable(feature = "allocator_api", issue = "32838")] + // #[unstable(feature = "allocator_api", issue = "163177")] #[must_use] pub fn new_in(data: T, alloc: A) -> Self { let (ptr, alloc) = Box::into_non_null_with_allocator(Box::new_in( @@ -4835,7 +4834,7 @@ impl UniqueArc { /// Like [`new_in`](Self::new_in), but returns an error if the allocation /// fails, instead of calling [`handle_alloc_error`]. #[unstable(feature = "unique_rc_arc", issue = "112566")] - // #[unstable(feature = "allocator_api", issue = "32838")] + // #[unstable(feature = "allocator_api", issue = "163177")] pub fn try_new_in(data: T, alloc: A) -> Result { let (ptr, alloc) = Box::into_non_null_with_allocator(Box::try_new_in( ArcInner { @@ -4852,7 +4851,7 @@ impl UniqueArc { /// Consumes the `UniqueArc`, returning its wrapped value and allocator. #[unstable(feature = "unique_rc_arc", issue = "112566")] - // #[unstable(feature = "allocator_api", issue = "32838")] + // #[unstable(feature = "allocator_api", issue = "163177")] #[must_use] pub fn unwrap_with_allocator(this: Self) -> (T, A) { let inner_ptr = this.ptr; @@ -5159,7 +5158,7 @@ unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for UniqueArc { } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe impl Allocator for Arc { #[inline] fn allocate(&self, layout: Layout) -> Result, AllocError> { @@ -5211,5 +5210,5 @@ unsafe impl Allocator for Arc { } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl AllocatorClone for Arc {} diff --git a/library/alloc/src/vec/drain.rs b/library/alloc/src/vec/drain.rs index df3ff0a9b769f..a4059db012c63 100644 --- a/library/alloc/src/vec/drain.rs +++ b/library/alloc/src/vec/drain.rs @@ -21,7 +21,7 @@ use crate::alloc::{Allocator, Global}; pub struct Drain< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + 'a = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator + 'a = Global, > { /// Index of tail to preserve pub(super) tail_start: usize, @@ -58,7 +58,7 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> { } /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[must_use] #[inline] pub fn allocator(&self) -> &A { diff --git a/library/alloc/src/vec/extract_if.rs b/library/alloc/src/vec/extract_if.rs index 366ee1c4e0cbf..4396798067942 100644 --- a/library/alloc/src/vec/extract_if.rs +++ b/library/alloc/src/vec/extract_if.rs @@ -22,7 +22,7 @@ pub struct ExtractIf< 'a, T, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { vec: &'a mut Vec, /// The index of the item that will be inspected by the next call to `next`. @@ -51,7 +51,7 @@ impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> { } /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn allocator(&self) -> &A { self.vec.allocator() diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index d99d2126810ba..48b1db0d5bf49 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -46,7 +46,7 @@ macro non_null { #[rustc_insignificant_dtor] pub struct IntoIter< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { pub(super) buf: NonNull, pub(super) phantom: PhantomData, @@ -112,7 +112,7 @@ impl IntoIter { } /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[inline] pub fn allocator(&self) -> &A { &self.alloc diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 7a9ac8bae32e2..4537e50e634f2 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -436,7 +436,10 @@ mod sve_retain; #[rustc_insignificant_dtor] #[doc(alias = "list")] #[doc(alias = "vector")] -pub struct Vec { +pub struct Vec< + T, + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] A: Allocator = Global, +> { buf: RawVec, len: usize, } @@ -940,8 +943,6 @@ const impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let mut vec = Vec::with_capacity_in(10, System); @@ -968,7 +969,7 @@ const impl Vec { /// assert_eq!(vec_units.capacity(), usize::MAX); /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 } } @@ -1055,14 +1056,13 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let vec: Vec = Vec::new_in(System); /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_unstable(feature = "allocator_ext", issue = "163177")] pub const fn new_in(alloc: A) -> Self { Vec { buf: RawVec::new_in(alloc), len: 0 } } @@ -1079,7 +1079,7 @@ impl Vec { /// Returns an error if the capacity exceeds `isize::MAX` _bytes_, /// or if the allocator reports allocation failure. #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] // #[unstable(feature = "try_with_capacity", issue = "91913")] pub fn try_with_capacity_in(capacity: usize, alloc: A) -> Result { Ok(Vec { buf: RawVec::try_with_capacity_in(capacity, alloc)?, len: 0 }) @@ -1133,8 +1133,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// use std::ptr; @@ -1162,8 +1160,6 @@ impl Vec { /// Using memory that was allocated elsewhere: /// /// ```rust - /// #![feature(allocator_api)] - /// /// use std::alloc::{AllocError, Allocator, Global, Layout}; /// /// fn main() { @@ -1185,8 +1181,8 @@ impl Vec { /// } /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] - #[rustc_const_unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_unstable(feature = "const_heap", issue = "79597")] pub const unsafe fn from_raw_parts_in( ptr: *mut T, length: usize, @@ -1251,8 +1247,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let mut v = Vec::with_capacity_in(3, System); @@ -1278,8 +1272,6 @@ impl Vec { /// Using memory that was allocated elsewhere: /// /// ```rust - /// #![feature(allocator_api)] - /// /// use std::alloc::{AllocError, Allocator, Global, Layout}; /// /// fn main() { @@ -1301,8 +1293,8 @@ impl Vec { /// } /// ``` #[inline] - #[unstable(feature = "allocator_api", issue = "32838")] - #[rustc_const_unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_unstable(feature = "const_heap", issue = "79597")] pub const unsafe fn from_parts_in( ptr: NonNull, length: usize, @@ -1335,8 +1327,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let mut v: Vec = Vec::new_in(System); @@ -1356,8 +1346,8 @@ impl Vec { /// assert_eq!(rebuilt, [4294967295, 0, 1]); /// ``` #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "allocator_api", issue = "32838")] - #[rustc_const_unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_unstable(feature = "const_heap", issue = "79597")] pub const fn into_raw_parts_with_allocator(self) -> (*mut T, usize, usize, A) { let mut me = ManuallyDrop::new(self); let len = me.len(); @@ -1386,8 +1376,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api)] - /// /// use std::alloc::System; /// /// let mut v: Vec = Vec::new_in(System); @@ -1407,8 +1395,8 @@ impl Vec { /// assert_eq!(rebuilt, [4294967295, 0, 1]); /// ``` #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "allocator_api", issue = "32838")] - #[rustc_const_unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_unstable(feature = "const_heap", issue = "79597")] pub const fn into_parts_with_allocator(self) -> (NonNull, usize, usize, A) { let (ptr, len, capacity, alloc) = self.into_raw_parts_with_allocator(); // SAFETY: A `Vec` always has a non-null pointer. @@ -2126,7 +2114,7 @@ impl Vec { } /// Returns a reference to the underlying allocator. - #[unstable(feature = "allocator_api", issue = "32838")] + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] #[inline] pub const fn allocator(&self) -> &A { @@ -3822,7 +3810,7 @@ pub fn from_elem(elem: T, n: usize) -> Vec { #[doc(hidden)] #[cfg(not(no_global_oom_handling))] -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn from_elem_in(elem: T, n: usize, alloc: A) -> Vec { ::from_elem(elem, n, alloc) } diff --git a/library/alloc/src/vec/peek_mut.rs b/library/alloc/src/vec/peek_mut.rs index 979bcaa1111d5..f84262352289a 100644 --- a/library/alloc/src/vec/peek_mut.rs +++ b/library/alloc/src/vec/peek_mut.rs @@ -15,7 +15,7 @@ use crate::fmt; pub struct PeekMut< 'a, T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { vec: &'a mut Vec, } diff --git a/library/alloc/src/vec/splice.rs b/library/alloc/src/vec/splice.rs index 534db037c3bdc..103bc5e00e521 100644 --- a/library/alloc/src/vec/splice.rs +++ b/library/alloc/src/vec/splice.rs @@ -20,7 +20,7 @@ use crate::alloc::{Allocator, Global}; pub struct Splice< 'a, I: Iterator + 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + 'a = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator + 'a = Global, > { pub(super) drain: Drain<'a, I::Item, A>, pub(super) replace_with: I, diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 50c58092bd41a..76550081a703c 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -13,7 +13,7 @@ // // Library features: // tidy-alphabetical-start -#![feature(allocator_api)] +#![feature(allocator_ext)] #![feature(array_into_iter_constructors)] #![feature(char_internals)] #![feature(const_alloc_error)] diff --git a/library/alloctests/tests/lib.rs b/library/alloctests/tests/lib.rs index b2a3e8f8f8e2a..9bcb545c8e87d 100644 --- a/library/alloctests/tests/lib.rs +++ b/library/alloctests/tests/lib.rs @@ -3,7 +3,7 @@ #![deny(implicit_provenance_casts)] #![deny(unsafe_op_in_unsafe_fn)] #![feature(alloc_io)] -#![feature(allocator_api)] +#![feature(allocator_ext)] #![feature(binary_heap_drain_sorted)] #![feature(binary_heap_into_iter_sorted)] #![feature(binary_heap_pop_if)] diff --git a/library/alloctests/tests/vec_deque_alloc_error.rs b/library/alloctests/tests/vec_deque_alloc_error.rs index 21a9118a05bd6..863af31e1cd1e 100644 --- a/library/alloctests/tests/vec_deque_alloc_error.rs +++ b/library/alloctests/tests/vec_deque_alloc_error.rs @@ -1,4 +1,4 @@ -#![feature(alloc_error_hook, allocator_api)] +#![feature(alloc_error_hook, allocator_ext)] use std::alloc::{AllocError, Allocator, Layout, System, set_alloc_error_hook}; use std::collections::VecDeque; diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs index 3355880478509..1ca14b1cde064 100644 --- a/library/core/src/alloc/mod.rs +++ b/library/core/src/alloc/mod.rs @@ -27,19 +27,15 @@ use crate::ptr::{self, NonNull}; /// that may be due to resource exhaustion or to /// something wrong when combining the given input arguments with this /// allocator. -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct AllocError; -#[unstable( - feature = "allocator_api", - reason = "the precise API and guarantees it provides may be tweaked.", - issue = "32838" -)] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] impl Error for AllocError {} // (we need this for downstream impl of trait Error) -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for AllocError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("memory allocation failed") @@ -196,7 +192,7 @@ impl fmt::Display for AllocError { // and make sure they cannot be triggered before relaxing this: // https://rust.tf/156490 // https://rust.tf/159982 -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] pub const unsafe trait Allocator { /// Attempts to allocate a block of memory. @@ -231,6 +227,7 @@ pub const unsafe trait Allocator { /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar. /// /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] fn allocate(&self, layout: Layout) -> Result, AllocError>; /// Behaves like `allocate`, but also ensures that the returned memory is zero-initialized. @@ -248,6 +245,7 @@ pub const unsafe trait Allocator { /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar. /// /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] fn allocate_zeroed(&self, layout: Layout) -> Result, AllocError> { let ptr = self.allocate(layout)?; // SAFETY: `alloc` returns a valid memory block @@ -271,6 +269,7 @@ pub const unsafe trait Allocator { /// /// [*currently allocated*]: #currently-allocated-memory /// [*fit*]: #memory-fitting + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe fn deallocate(&self, ptr: NonNull, layout: Layout); /// Attempts to extend the memory block. @@ -312,6 +311,7 @@ pub const unsafe trait Allocator { /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar. /// /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe fn grow( &self, ptr: NonNull, @@ -372,6 +372,7 @@ pub const unsafe trait Allocator { /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar. /// /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe fn grow_zeroed( &self, ptr: NonNull, @@ -438,6 +439,7 @@ pub const unsafe trait Allocator { /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar. /// /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html + #[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe fn shrink( &self, ptr: NonNull, @@ -521,7 +523,7 @@ pub const unsafe trait Allocator { /// [`std::thread::park`]: ../../std/thread/fn.park.html /// [`std::thread::Thread`]: ../../std/thread/struct.Thread.html /// [`unpark`]: ../../std/thread/struct.Thread.html#method.unpark -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[expect(multiple_supertrait_upcastable)] pub unsafe trait GlobalAllocator: StaticAllocator + Sync + 'static {} @@ -537,7 +539,7 @@ pub unsafe trait GlobalAllocator: StaticAllocator + Sync + 'static {} /// It must also be the case that types which are `AllocatorClone` are either explicitly not /// copyable (such as by containing a `!Copy` field) or that copying them also respects allocator /// equivalence as if it had been a clone. -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe trait AllocatorClone: Allocator + Clone {} /// Marks that an allocator and its supertypes will never invalidate currently allocated @@ -568,10 +570,10 @@ pub unsafe trait AllocatorClone: Allocator + Clone {} /// /// [`Pin`]: ../../core/pin/struct.Pin.html /// [unsound]: https://github.com/rust-lang/rust/issues/157089 -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub unsafe trait StaticAllocator: Allocator {} -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] const unsafe impl Allocator for &A where @@ -627,7 +629,7 @@ where } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] const unsafe impl Allocator for &mut A where @@ -683,9 +685,9 @@ where } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] -#[unstable_feature_bound(allocator_api)] +#[unstable_feature_bound(allocator_ext)] const unsafe impl

Allocator for core::pin::Pin

where P: [const] core::ops::Deref + core::pin::PinSafePointer, @@ -740,13 +742,13 @@ where } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl AllocatorClone for &A {} // If an allocator is `StaticAllocator` all equivalent allocators must also uphold // its semantics, and references are equivalent to the allocator they reference. -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl StaticAllocator for &A {} -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl StaticAllocator for &mut A {} diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 5ec875cf47868..a279c373dea4a 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -1559,7 +1559,7 @@ impl NonNull<[T]> { /// # Examples /// /// ```rust - /// #![feature(allocator_api, ptr_as_uninit)] + /// #![feature(ptr_as_uninit)] /// /// use std::alloc::{Allocator, Layout, Global}; /// use std::mem::MaybeUninit; diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 8e0143c137b5e..c6f94944006c9 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -145,10 +145,10 @@ use crate::{hint, mem, ptr}; #[derive_const(Clone, Default)] pub struct System; -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl core::alloc::AllocatorClone for System {} -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl core::alloc::StaticAllocator for System {} impl System { @@ -216,7 +216,7 @@ impl System { // The Allocator impl checks the layout size to be non-zero and forwards to the // platform functions in `std::sys::*::alloc`. -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "allocator_api", since = "CURRENT_RUSTC_VERSION")] unsafe impl Allocator for System { #[inline] fn allocate(&self, layout: Layout) -> Result, AllocError> { @@ -303,7 +303,7 @@ unsafe impl Allocator for System { } } -#[unstable(feature = "allocator_api", issue = "32838")] +#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] unsafe impl GlobalAllocator for System {} static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut()); diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 121a525bd0c4b..d95fcf38a3b49 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -246,7 +246,7 @@ pub struct HashMap< K, V, S = RandomState, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::HashMap, } @@ -299,7 +299,7 @@ impl HashMap { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// use std::collections::HashMap; /// use std::alloc::Global; /// @@ -307,7 +307,7 @@ impl HashMap { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn new_in(alloc: A) -> Self { HashMap::with_hasher_in(Default::default(), alloc) } @@ -322,7 +322,7 @@ impl HashMap { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// use std::collections::HashMap; /// use std::alloc::Global; /// @@ -330,7 +330,7 @@ impl HashMap { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { HashMap::with_capacity_and_hasher_in(capacity, Default::default(), alloc) } @@ -418,7 +418,7 @@ impl HashMap { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::alloc::Global; /// use std::collections::HashMap; /// use std::hash::RandomState; @@ -428,7 +428,7 @@ impl HashMap { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn with_hasher_in(hash_builder: S, alloc: A) -> Self { HashMap { base: base::HashMap::with_hasher_in(hash_builder, alloc) } } @@ -451,7 +451,7 @@ impl HashMap { /// # Examples /// /// ``` - /// #![feature(allocator_api)] + /// #![feature(allocator_ext)] /// use std::alloc::Global; /// use std::collections::HashMap; /// use std::hash::RandomState; @@ -461,7 +461,7 @@ impl HashMap { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn with_capacity_and_hasher_in(capacity: usize, hash_builder: S, alloc: A) -> Self { HashMap { base: base::HashMap::with_capacity_and_hasher_in(capacity, hash_builder, alloc) } } @@ -1660,7 +1660,7 @@ impl Default for IterMut<'_, K, V> { pub struct IntoIter< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::IntoIter, } @@ -1798,7 +1798,7 @@ pub struct Drain< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::Drain<'a, K, V, A>, } @@ -1835,7 +1835,7 @@ pub struct ExtractIf< K, V, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::ExtractIf<'a, K, V, F, A>, } @@ -1892,7 +1892,7 @@ impl Default for ValuesMut<'_, K, V> { pub struct IntoKeys< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { inner: IntoIter, } @@ -1926,7 +1926,7 @@ impl Default for IntoKeys { pub struct IntoValues< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { inner: IntoIter, } @@ -1950,7 +1950,7 @@ pub enum Entry< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { /// An occupied entry. #[stable(feature = "rust1", since = "1.0.0")] @@ -1978,7 +1978,7 @@ pub struct OccupiedEntry< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::RustcOccupiedEntry<'a, K, V, A>, } @@ -2000,7 +2000,7 @@ pub struct VacantEntry< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::RustcVacantEntry<'a, K, V, A>, } @@ -2021,7 +2021,7 @@ pub struct OccupiedError< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { /// The entry in the map that was already occupied. pub entry: OccupiedEntry<'a, K, V, A>, diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index b0a8e8ff42149..ea1307895b7f8 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -126,7 +126,7 @@ use crate::ops::{BitAnd, BitOr, BitXor, Sub}; pub struct HashSet< T, S = RandomState, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::HashSet, } @@ -179,7 +179,7 @@ impl HashSet { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// use std::alloc::Global; /// use std::collections::HashSet; /// @@ -187,7 +187,7 @@ impl HashSet { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn new_in(alloc: A) -> HashSet { HashSet::with_hasher_in(Default::default(), alloc) } @@ -201,7 +201,7 @@ impl HashSet { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// use std::collections::HashSet; /// use std::alloc::Global; /// @@ -209,7 +209,7 @@ impl HashSet { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn with_capacity_in(capacity: usize, alloc: A) -> HashSet { HashSet::with_capacity_and_hasher_in(capacity, Default::default(), alloc) } @@ -297,7 +297,7 @@ impl HashSet { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// use std::alloc::Global; /// use std::collections::HashSet; /// use std::hash::RandomState; @@ -307,7 +307,7 @@ impl HashSet { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn with_hasher_in(hasher: S, alloc: A) -> HashSet { HashSet { base: base::HashSet::with_hasher_in(hasher, alloc) } } @@ -330,7 +330,7 @@ impl HashSet { /// # Examples /// /// ``` - /// # #![feature(allocator_api)] + /// # #![feature(allocator_ext)] /// use std::alloc::Global; /// use std::collections::HashSet; /// use std::hash::RandomState; @@ -340,7 +340,7 @@ impl HashSet { /// ``` #[inline] #[must_use] - #[unstable(feature = "allocator_api", issue = "32838")] + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] pub fn with_capacity_and_hasher_in(capacity: usize, hasher: S, alloc: A) -> HashSet { HashSet { base: base::HashSet::with_capacity_and_hasher_in(capacity, hasher, alloc) } } @@ -1468,7 +1468,7 @@ impl Default for Iter<'_, K> { #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter< K, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::IntoIter, } @@ -1502,7 +1502,7 @@ impl Default for IntoIter { pub struct Drain< 'a, K: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::Drain<'a, K, A>, } @@ -1529,7 +1529,7 @@ pub struct ExtractIf< 'a, K, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::ExtractIf<'a, K, F, A>, } @@ -1558,7 +1558,7 @@ pub struct Intersection< 'a, T: 'a, S: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { // iterator of the first set iter: Iter<'a, T>, @@ -1590,7 +1590,7 @@ pub struct Difference< 'a, T: 'a, S: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { // iterator of the first set iter: Iter<'a, T>, @@ -1622,7 +1622,7 @@ pub struct SymmetricDifference< 'a, T: 'a, S: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { iter: Chain, Difference<'a, T, S, A>>, } @@ -1651,7 +1651,7 @@ pub struct Union< 'a, T: 'a, S: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { iter: Chain, Difference<'a, T, S, A>>, } @@ -2145,7 +2145,7 @@ pub enum Entry< 'a, T, S, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { /// An occupied entry. /// @@ -2237,7 +2237,7 @@ pub struct OccupiedEntry< 'a, T, S, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::OccupiedEntry<'a, T, S, A>, } @@ -2282,7 +2282,7 @@ pub struct VacantEntry< 'a, T, S, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] A: Allocator = Global, > { base: base::VacantEntry<'a, T, S, A>, } diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index acc8cdfc8281d..23e30379aefc4 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -399,7 +399,7 @@ // Library features (alloc): // tidy-alphabetical-start #![feature(alloc_io)] -#![feature(allocator_api)] +#![feature(allocator_ext)] #![feature(buf_read_has_data_left)] #![feature(clone_from_ref)] #![feature(get_mut_unchecked)] diff --git a/src/doc/unstable-book/src/library-features/allocator-api.md b/src/doc/unstable-book/src/library-features/allocator-ext.md similarity index 96% rename from src/doc/unstable-book/src/library-features/allocator-api.md rename to src/doc/unstable-book/src/library-features/allocator-ext.md index 9f045ce08a433..f1e7551bdfa08 100644 --- a/src/doc/unstable-book/src/library-features/allocator-api.md +++ b/src/doc/unstable-book/src/library-features/allocator-ext.md @@ -1,4 +1,4 @@ -# `allocator_api` +# `allocator_ext` The tracking issue for this feature is [#32838] diff --git a/src/tools/clippy/tests/ui/vec_box_sized.rs b/src/tools/clippy/tests/ui/vec_box_sized.rs index 5cc140953cecc..3694d32be9eb0 100644 --- a/src/tools/clippy/tests/ui/vec_box_sized.rs +++ b/src/tools/clippy/tests/ui/vec_box_sized.rs @@ -1,7 +1,7 @@ //@no-rustfix #![warn(clippy::vec_box)] -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::alloc::{AllocError, Allocator, Layout}; use std::ptr::NonNull; diff --git a/src/tools/miri/tests/fail/alloc/alloc_error_handler.rs b/src/tools/miri/tests/fail/alloc/alloc_error_handler.rs index 35b8e20e56b3c..71e4eadc4e0b8 100644 --- a/src/tools/miri/tests/fail/alloc/alloc_error_handler.rs +++ b/src/tools/miri/tests/fail/alloc/alloc_error_handler.rs @@ -1,5 +1,5 @@ //@error-in-other-file: aborted -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::alloc::*; diff --git a/src/tools/miri/tests/fail/alloc/alloc_error_handler_custom.rs b/src/tools/miri/tests/fail/alloc/alloc_error_handler_custom.rs index 8d41002735cc9..72f45be61b299 100644 --- a/src/tools/miri/tests/fail/alloc/alloc_error_handler_custom.rs +++ b/src/tools/miri/tests/fail/alloc/alloc_error_handler_custom.rs @@ -1,7 +1,7 @@ //@compile-flags: -Cpanic=abort #![feature(core_intrinsics)] #![feature(alloc_error_handler)] -#![feature(allocator_api)] +#![feature(allocator_ext)] #![no_std] #![no_main] diff --git a/src/tools/miri/tests/fail/alloc/alloc_error_handler_no_std.rs b/src/tools/miri/tests/fail/alloc/alloc_error_handler_no_std.rs index f73f8e3e7e196..c7c51c95e9c26 100644 --- a/src/tools/miri/tests/fail/alloc/alloc_error_handler_no_std.rs +++ b/src/tools/miri/tests/fail/alloc/alloc_error_handler_no_std.rs @@ -1,7 +1,7 @@ //@compile-flags: -Cpanic=abort #![feature(core_intrinsics)] #![feature(alloc_error_handler)] -#![feature(allocator_api)] +#![feature(allocator_ext)] #![no_std] #![no_main] diff --git a/src/tools/miri/tests/fail/alloc/global_system_mixup.rs b/src/tools/miri/tests/fail/alloc/global_system_mixup.rs index bbf069b7a2def..f80ac906fd952 100644 --- a/src/tools/miri/tests/fail/alloc/global_system_mixup.rs +++ b/src/tools/miri/tests/fail/alloc/global_system_mixup.rs @@ -8,7 +8,7 @@ //@normalize-stderr-test: "alloc::[A-Za-z]+::" -> "alloc::PLATFORM::" //@normalize-stderr-test: "alloc/[A-Za-z]+.rs" -> "alloc/PLATFORM.rs" -#![feature(allocator_api, slice_ptr_get)] +#![feature(allocator_ext, slice_ptr_get)] use std::alloc::{Allocator, Global, Layout, System}; diff --git a/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs b/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs index 5fb81296494e5..cc0bd3fc3a22c 100644 --- a/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs +++ b/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs @@ -1,5 +1,5 @@ //! Ensure that a box with a custom allocator detects when the pointer is dangling. -#![feature(allocator_api)] +#![feature(allocator_ext)] // This should not need the aliasing model. //@compile-flags: -Zmiri-disable-stacked-borrows use std::alloc::Layout; diff --git a/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs b/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs index 101a550593f90..0ed54d0112dd4 100644 --- a/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs +++ b/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs @@ -1,5 +1,5 @@ //! Ensure that a box with a custom allocator detects when the allocator itself is invalid. -#![feature(allocator_api)] +#![feature(allocator_ext)] // This should not need the aliasing model. //@compile-flags: -Zmiri-disable-stacked-borrows use std::alloc::Layout; diff --git a/src/tools/miri/tests/panic/alloc_error_handler_hook.rs b/src/tools/miri/tests/panic/alloc_error_handler_hook.rs index a1eadb45fd13b..f7516ce86e883 100644 --- a/src/tools/miri/tests/panic/alloc_error_handler_hook.rs +++ b/src/tools/miri/tests/panic/alloc_error_handler_hook.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api, alloc_error_hook)] +#![feature(allocator_ext, alloc_error_hook)] use std::alloc::*; diff --git a/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs b/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs index ab57ab246b4f3..00b340125b7c3 100644 --- a/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs +++ b/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs @@ -5,7 +5,6 @@ //@revisions: stack tree tree_implicit_writes //@[tree_implicit_writes]compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(allocator_api)] use std::alloc::{AllocError, Allocator, Layout}; use std::cell::{Cell, UnsafeCell}; diff --git a/src/tools/miri/tests/pass/box-custom-alloc.rs b/src/tools/miri/tests/pass/box-custom-alloc.rs index 8016cb2c13c0b..21667e1a52be0 100644 --- a/src/tools/miri/tests/pass/box-custom-alloc.rs +++ b/src/tools/miri/tests/pass/box-custom-alloc.rs @@ -1,7 +1,6 @@ //@revisions: stack tree tree_implicit_writes //@[tree_implicit_writes]compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(allocator_api)] use std::alloc::{AllocError, Allocator, Global, Layout}; use std::cell::Cell; diff --git a/src/tools/miri/tests/pass/global_allocator.rs b/src/tools/miri/tests/pass/global_allocator.rs index ecb3a5e46e3a4..788c58a3c54c0 100644 --- a/src/tools/miri/tests/pass/global_allocator.rs +++ b/src/tools/miri/tests/pass/global_allocator.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api, slice_ptr_get)] +#![feature(slice_ptr_get)] use std::alloc::{Allocator as _, Global, GlobalAlloc, Layout, System}; diff --git a/src/tools/miri/tests/pass/heap_allocator.rs b/src/tools/miri/tests/pass/heap_allocator.rs index 2c38dcb49f1ce..dcd8515ab99f6 100644 --- a/src/tools/miri/tests/pass/heap_allocator.rs +++ b/src/tools/miri/tests/pass/heap_allocator.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api, slice_ptr_get)] +#![feature(slice_ptr_get)] use std::alloc::{Allocator, Global, Layout, System}; use std::ptr::NonNull; diff --git a/tests/incremental/lint-unused-features.rs b/tests/incremental/lint-unused-features.rs index 0bf9730727f74..a3004871aa292 100644 --- a/tests/incremental/lint-unused-features.rs +++ b/tests/incremental/lint-unused-features.rs @@ -10,8 +10,8 @@ // Used library features #![feature(error_iter)] //[bfail]~^ ERROR feature `error_iter` is declared but not used -#![cfg_attr(all(), feature(allocator_api))] -//[bfail]~^ ERROR feature `allocator_api` is declared but not used +#![cfg_attr(all(), feature(allocator_ext))] +//[bfail]~^ ERROR feature `allocator_ext` is declared but not used macro m() {} pub fn use_decl_macro() { @@ -28,8 +28,7 @@ pub fn use_error_iter(e: &(dyn std::error::Error + 'static)) { #[cfg(rpass)] pub fn use_allocator_api() { - use std::alloc::Global; - let _ = Vec::::new_in(Global); + let _a: std::rc::Rc; } fn main() {} diff --git a/tests/mir-opt/box_conditional_drop_allocator.rs b/tests/mir-opt/box_conditional_drop_allocator.rs index 741c396b0c2d7..766c81340f6e8 100644 --- a/tests/mir-opt/box_conditional_drop_allocator.rs +++ b/tests/mir-opt/box_conditional_drop_allocator.rs @@ -1,7 +1,7 @@ //@ skip-filecheck //@ test-mir-pass: ElaborateDrops //@ needs-unwind -#![feature(allocator_api)] +#![feature(allocator_ext)] // Regression test for #131082. // Testing that the allocator of a Box is dropped in conditional drops diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs index 08347f71b4239..1613b8cb8c2c2 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs @@ -3,7 +3,7 @@ // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::alloc::{Allocator, Global, Layout}; diff --git a/tests/run-make/std-core-cycle/bar.rs b/tests/run-make/std-core-cycle/bar.rs index 9f5e7c29bddd7..d1a3c5089dddb 100644 --- a/tests/run-make/std-core-cycle/bar.rs +++ b/tests/run-make/std-core-cycle/bar.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api)] +#![feature(allocator_ext)] #![crate_type = "rlib"] use std::alloc::*; diff --git a/tests/ui/README.md b/tests/ui/README.md index 8df2769996f41..27995e0ab4cd5 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -18,7 +18,7 @@ See . ## `tests/ui/allocator` -These tests exercise `#![feature(allocator_api)]` and the `#[global_allocator]` attribute. +These tests exercise `#![feature(allocator_ext)]` and the `#[global_allocator]` attribute. See [Allocator traits and `std::heap` #32838](https://github.com/rust-lang/rust/issues/32838). diff --git a/tests/ui/allocator/156920-allocator-clone.rs b/tests/ui/allocator/156920-allocator-clone.rs index 2b9966b68eca8..cf38c1f4b04fe 100644 --- a/tests/ui/allocator/156920-allocator-clone.rs +++ b/tests/ui/allocator/156920-allocator-clone.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::{ alloc::{Allocator, Global, System}, diff --git a/tests/ui/allocator/157089-box-pin-in.rs b/tests/ui/allocator/157089-box-pin-in.rs index 307a933bba6f6..f24092fd66745 100644 --- a/tests/ui/allocator/157089-box-pin-in.rs +++ b/tests/ui/allocator/157089-box-pin-in.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::{ alloc::{AllocError, Allocator, Layout}, diff --git a/tests/ui/allocator/159445-unsize-pin-box.rs b/tests/ui/allocator/159445-unsize-pin-box.rs index 391c8c95813a0..836d938d1d3c6 100644 --- a/tests/ui/allocator/159445-unsize-pin-box.rs +++ b/tests/ui/allocator/159445-unsize-pin-box.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::{ alloc::{AllocError, Allocator, Layout}, diff --git a/tests/ui/allocator/alloc-shrink-oob-read.rs b/tests/ui/allocator/alloc-shrink-oob-read.rs index b9edfca3b7b51..120d327e2a344 100644 --- a/tests/ui/allocator/alloc-shrink-oob-read.rs +++ b/tests/ui/allocator/alloc-shrink-oob-read.rs @@ -4,7 +4,6 @@ //@ run-pass -#![feature(allocator_api)] #![feature(slice_ptr_get)] use std::alloc::{Allocator, Global, Layout, handle_alloc_error}; diff --git a/tests/ui/allocator/auxiliary/custom.rs b/tests/ui/allocator/auxiliary/custom.rs index b6835307dec2f..0cde0547351d2 100644 --- a/tests/ui/allocator/auxiliary/custom.rs +++ b/tests/ui/allocator/auxiliary/custom.rs @@ -1,6 +1,6 @@ //@ no-prefer-dynamic -#![feature(allocator_api)] +#![feature(allocator_ext)] #![crate_type = "rlib"] use std::alloc::{GlobalAlloc, System, Layout}; diff --git a/tests/ui/allocator/custom.rs b/tests/ui/allocator/custom.rs index 97de54dd4d6e3..eefd89c7b5a25 100644 --- a/tests/ui/allocator/custom.rs +++ b/tests/ui/allocator/custom.rs @@ -3,7 +3,6 @@ //@ aux-build:helper.rs //@ no-prefer-dynamic -#![feature(allocator_api)] #![feature(slice_ptr_get)] extern crate helper; diff --git a/tests/ui/allocator/dyn-compatible.rs b/tests/ui/allocator/dyn-compatible.rs index 9d8235e58d929..0e4ccb6fd162b 100644 --- a/tests/ui/allocator/dyn-compatible.rs +++ b/tests/ui/allocator/dyn-compatible.rs @@ -2,8 +2,6 @@ // Check that `Allocator` is dyn-compatible, this allows for polymorphic allocators -#![feature(allocator_api)] - use std::alloc::{Allocator, System}; fn ensure_dyn_compatible(_: &dyn Allocator) {} diff --git a/tests/ui/allocator/xcrate-use.rs b/tests/ui/allocator/xcrate-use.rs index 5934d73981305..a2b71c4498b13 100644 --- a/tests/ui/allocator/xcrate-use.rs +++ b/tests/ui/allocator/xcrate-use.rs @@ -4,7 +4,6 @@ //@ aux-build:helper.rs //@ no-prefer-dynamic -#![feature(allocator_api)] #![feature(slice_ptr_get)] extern crate custom; diff --git a/tests/ui/array-slice-vec/vec-res-add.stderr b/tests/ui/array-slice-vec/vec-res-add.stderr index 4e13dbd0366d0..6d5ad1d3c9694 100644 --- a/tests/ui/array-slice-vec/vec-res-add.stderr +++ b/tests/ui/array-slice-vec/vec-res-add.stderr @@ -8,6 +8,7 @@ LL | let k = i + j; | note: `Vec` does not implement `Add` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec` is defined in another crate diff --git a/tests/ui/async-await/async-drop/async-drop-box-allocator.rs b/tests/ui/async-await/async-drop/async-drop-box-allocator.rs index 86ebf8a0ffd13..58aa5c422bd61 100644 --- a/tests/ui/async-await/async-drop/async-drop-box-allocator.rs +++ b/tests/ui/async-await/async-drop/async-drop-box-allocator.rs @@ -4,7 +4,7 @@ // It's used as the allocator of a `Box` which is conditionally moved out of. // Sync version is called in sync context, async version is called in async function. -#![feature(async_drop, allocator_api)] +#![feature(async_drop)] #![allow(incomplete_features)] use std::mem::ManuallyDrop; diff --git a/tests/ui/box/alloc-unstable-fail.rs b/tests/ui/box/alloc-unstable-fail.rs deleted file mode 100644 index e209af97d7f75..0000000000000 --- a/tests/ui/box/alloc-unstable-fail.rs +++ /dev/null @@ -1,6 +0,0 @@ -use std::boxed::Box; - -fn main() { - let _boxed: Box = Box::new(10); - //~^ ERROR use of unstable library feature `allocator_api` -} diff --git a/tests/ui/box/alloc-unstable-fail.stderr b/tests/ui/box/alloc-unstable-fail.stderr deleted file mode 100644 index 6ce63a7996662..0000000000000 --- a/tests/ui/box/alloc-unstable-fail.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: use of unstable library feature `allocator_api` - --> $DIR/alloc-unstable-fail.rs:4:26 - | -LL | let _boxed: Box = Box::new(10); - | ^ - | - = note: see issue #32838 for more information - = help: add `#![feature(allocator_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/box/alloc-unstable.rs b/tests/ui/box/alloc-unstable.rs deleted file mode 100644 index b8c8bc0c70af4..0000000000000 --- a/tests/ui/box/alloc-unstable.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ run-pass -#![feature(allocator_api)] -fn main() { - let _boxed: Box = Box::new(10); -} diff --git a/tests/ui/box/issue-95036.rs b/tests/ui/box/issue-95036.rs index f20f4b98437fd..505cb996fd57e 100644 --- a/tests/ui/box/issue-95036.rs +++ b/tests/ui/box/issue-95036.rs @@ -1,7 +1,7 @@ //@ compile-flags: -O //@ build-pass -#![feature(allocator_api)] +#![feature(allocator_ext)] #[inline(never)] pub fn by_ref(node: &mut Box<[u8; 1], &std::alloc::Global>) { diff --git a/tests/ui/box/large-allocator-ice.rs b/tests/ui/box/large-allocator-ice.rs index d5c7069cfb951..e85b308428fe4 100644 --- a/tests/ui/box/large-allocator-ice.rs +++ b/tests/ui/box/large-allocator-ice.rs @@ -1,5 +1,5 @@ //@ build-pass -#![feature(allocator_api)] +#![feature(allocator_ext)] #![allow(unused_must_use)] use std::alloc::Allocator; diff --git a/tests/ui/box/leak-alloc.rs b/tests/ui/box/leak-alloc.rs index e87650f42ab61..2308e0c585e3d 100644 --- a/tests/ui/box/leak-alloc.rs +++ b/tests/ui/box/leak-alloc.rs @@ -1,4 +1,4 @@ -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::alloc::{AllocError, Allocator, Layout, System}; use std::ptr::NonNull; diff --git a/tests/ui/coherence/impl-foreign-for-box[foreign_local].rs b/tests/ui/coherence/impl-foreign-for-box[foreign_local].rs index 2a1d4828f4a93..ec243f0be8498 100644 --- a/tests/ui/coherence/impl-foreign-for-box[foreign_local].rs +++ b/tests/ui/coherence/impl-foreign-for-box[foreign_local].rs @@ -4,7 +4,7 @@ // Ensure that `Box` in particular isn't fundamental over // the allocator parameter (but is over T). -#![feature(allocator_api)] +#![feature(allocator_ext)] extern crate coherence_lib as lib; diff --git a/tests/ui/consts/const_in_pattern/suggest_equality_comparison_instead_of_pattern_matching.stderr b/tests/ui/consts/const_in_pattern/suggest_equality_comparison_instead_of_pattern_matching.stderr index 38440af675feb..ab823c8fc73b9 100644 --- a/tests/ui/consts/const_in_pattern/suggest_equality_comparison_instead_of_pattern_matching.stderr +++ b/tests/ui/consts/const_in_pattern/suggest_equality_comparison_instead_of_pattern_matching.stderr @@ -123,6 +123,7 @@ LL | V => {} | ^ constant of non-structural type | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<()>` is not usable in patterns | @@ -143,6 +144,7 @@ LL | if let V = vec![] {} | ^ constant of non-structural type | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<()>` is not usable in patterns | @@ -158,6 +160,7 @@ LL | let V = vec![] else { return; }; | ^ constant of non-structural type | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<()>` is not usable in patterns | @@ -173,6 +176,7 @@ LL | let V = Vec::new() else { return; }; | ^ constant of non-structural type | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<()>` is not usable in patterns | diff --git a/tests/ui/debuginfo/debuginfo-box-with-large-allocator.rs b/tests/ui/debuginfo/debuginfo-box-with-large-allocator.rs index ac857ff34a4d7..e5233c696c8a8 100644 --- a/tests/ui/debuginfo/debuginfo-box-with-large-allocator.rs +++ b/tests/ui/debuginfo/debuginfo-box-with-large-allocator.rs @@ -2,7 +2,7 @@ //@ compile-flags: -Cdebuginfo=2 // fixes issue #94725 -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::alloc::{AllocError, Allocator, Layout}; use std::ptr::NonNull; diff --git a/tests/ui/drop/box-conditional-drop-allocator.rs b/tests/ui/drop/box-conditional-drop-allocator.rs index 8f78da16473e7..605969c58f0a0 100644 --- a/tests/ui/drop/box-conditional-drop-allocator.rs +++ b/tests/ui/drop/box-conditional-drop-allocator.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(allocator_api)] // Regression test for #131082. // Testing that the allocator of a Box is dropped in conditional drops diff --git a/tests/ui/lifetimes/could-not-resolve-issue-121503.rs b/tests/ui/lifetimes/could-not-resolve-issue-121503.rs index 363162370f21b..6721fde174ef9 100644 --- a/tests/ui/lifetimes/could-not-resolve-issue-121503.rs +++ b/tests/ui/lifetimes/could-not-resolve-issue-121503.rs @@ -1,6 +1,6 @@ //@ edition:2018 -#![feature(allocator_api)] +#![feature(allocator_ext)] struct Struct; impl Struct { async fn box_ref_Struct(self: Box) -> &u32 { diff --git a/tests/ui/lint/must_not_suspend/allocator.rs b/tests/ui/lint/must_not_suspend/allocator.rs index c2ceb3297f37f..8c65c5889d987 100644 --- a/tests/ui/lint/must_not_suspend/allocator.rs +++ b/tests/ui/lint/must_not_suspend/allocator.rs @@ -1,6 +1,6 @@ //@ edition: 2021 -#![feature(must_not_suspend, allocator_api)] +#![feature(must_not_suspend, allocator_ext)] #![deny(must_not_suspend)] use std::alloc::*; diff --git a/tests/ui/lint/unused-features/used-library-features.rs b/tests/ui/lint/unused-features/used-library-features.rs index 1747c7741880e..5d18356febdc7 100644 --- a/tests/ui/lint/unused-features/used-library-features.rs +++ b/tests/ui/lint/unused-features/used-library-features.rs @@ -5,7 +5,7 @@ // Used library features #![feature(error_iter)] -#![cfg_attr(all(), feature(allocator_api))] +#![cfg_attr(all(), feature(allocator_ext))] pub fn use_error_iter(e: &(dyn std::error::Error + 'static)) { for _ in e.sources() {} @@ -13,5 +13,5 @@ pub fn use_error_iter(e: &(dyn std::error::Error + 'static)) { pub fn use_allocator_api() { use std::alloc::Global; - let _ = Vec::::new_in(Global); + let _ = Vec::::try_with_capacity_in(1, Global); } diff --git a/tests/ui/lto/issue-100772.rs b/tests/ui/lto/issue-100772.rs index e07d44e3be880..4452688c7187b 100644 --- a/tests/ui/lto/issue-100772.rs +++ b/tests/ui/lto/issue-100772.rs @@ -5,7 +5,7 @@ //@ only-x86_64-unknown-linux-gnu //@ ignore-backends: gcc -#![feature(allocator_api)] +#![feature(allocator_ext)] fn main() { let _ = Box::new_in(&[0, 1], &std::alloc::Global); diff --git a/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr index 7c176162ad184..c03137fcc4151 100644 --- a/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr +++ b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr @@ -8,6 +8,7 @@ LL | EMPTY => {} | ^^^^^ constant of non-structural type | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<()>` is not usable in patterns | diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr index f776623ff75b2..280516deba14b 100644 --- a/tests/ui/pattern/issue-115599.stderr +++ b/tests/ui/pattern/issue-115599.stderr @@ -8,6 +8,7 @@ LL | if let CONST_STRING = empty_str {} | ^^^^^^^^^^^^ constant of non-structural type | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec` is not usable in patterns | diff --git a/tests/ui/pattern/pattern-tyvar-2.stderr b/tests/ui/pattern/pattern-tyvar-2.stderr index 6676d5129872b..4761a4e829b85 100644 --- a/tests/ui/pattern/pattern-tyvar-2.stderr +++ b/tests/ui/pattern/pattern-tyvar-2.stderr @@ -8,6 +8,7 @@ LL | fn foo(t: Bar) -> isize { match t { Bar::T1(_, Some(x)) => { return x * 3; | note: `Vec` does not implement `Mul<{integer}>` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec` is defined in another crate diff --git a/tests/ui/precondition-checks/vec-from-parts.rs b/tests/ui/precondition-checks/vec-from-parts.rs index ace90770360e5..2b4c3edc8b4a6 100644 --- a/tests/ui/precondition-checks/vec-from-parts.rs +++ b/tests/ui/precondition-checks/vec-from-parts.rs @@ -1,7 +1,7 @@ //@ run-crash //@ compile-flags: -Cdebug-assertions=yes //@ error-pattern: unsafe precondition(s) violated: Vec::from_parts_in requires that length <= capacity -#![feature(allocator_api)] +#![feature(allocator_ext)] use std::ptr::NonNull; diff --git a/tests/ui/precondition-checks/vec-from-raw-parts.rs b/tests/ui/precondition-checks/vec-from-raw-parts.rs index 1bc8e6ada10d9..db883d2589754 100644 --- a/tests/ui/precondition-checks/vec-from-raw-parts.rs +++ b/tests/ui/precondition-checks/vec-from-raw-parts.rs @@ -3,7 +3,7 @@ //@ error-pattern: unsafe precondition(s) violated: Vec::from_raw_parts_in requires that length <= capacity //@ revisions: vec_from_raw_parts vec_from_raw_parts_in string_from_raw_parts -#![feature(allocator_api)] +#![feature(allocator_ext)] fn main() { let ptr = std::ptr::null_mut::(); diff --git a/tests/ui/regions/regions-mock-codegen.rs b/tests/ui/regions/regions-mock-codegen.rs index 99c863640669e..0677e0fabbf6d 100644 --- a/tests/ui/regions/regions-mock-codegen.rs +++ b/tests/ui/regions/regions-mock-codegen.rs @@ -1,7 +1,6 @@ //@ run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] -#![feature(allocator_api)] use std::alloc::{handle_alloc_error, Allocator, Global, Layout}; use std::ptr::NonNull; diff --git a/tests/ui/stability-attribute/suggest-vec-allocator-api.rs b/tests/ui/stability-attribute/suggest-vec-allocator-api.rs deleted file mode 100644 index 61a48c19e72ad..0000000000000 --- a/tests/ui/stability-attribute/suggest-vec-allocator-api.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - let _: Vec = vec![]; //~ ERROR use of unstable library feature `allocator_api` - #[rustfmt::skip] - let _: Vec< - String, - _> = vec![]; //~ ERROR use of unstable library feature `allocator_api` - let _ = Vec::::new(); //~ ERROR use of unstable library feature `allocator_api` - let _boxed: Box = Box::new(10); //~ ERROR use of unstable library feature `allocator_api` -} diff --git a/tests/ui/stability-attribute/suggest-vec-allocator-api.stderr b/tests/ui/stability-attribute/suggest-vec-allocator-api.stderr deleted file mode 100644 index 78b7d07b60cc3..0000000000000 --- a/tests/ui/stability-attribute/suggest-vec-allocator-api.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0658]: use of unstable library feature `allocator_api` - --> $DIR/suggest-vec-allocator-api.rs:2:20 - | -LL | let _: Vec = vec![]; - | ----^ - | | - | help: consider wrapping the inner types in tuple: `(u8, _)` - | - = note: see issue #32838 for more information - = help: add `#![feature(allocator_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `allocator_api` - --> $DIR/suggest-vec-allocator-api.rs:6:9 - | -LL | _> = vec![]; - | ^ - | - = note: see issue #32838 for more information - = help: add `#![feature(allocator_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -help: consider wrapping the inner types in tuple - | -LL ~ let _: Vec<( -LL + String, -LL ~ _)> = vec![]; - | - -error[E0658]: use of unstable library feature `allocator_api` - --> $DIR/suggest-vec-allocator-api.rs:7:24 - | -LL | let _ = Vec::::new(); - | -----^ - | | - | help: consider wrapping the inner types in tuple: `(u16, _)` - | - = note: see issue #32838 for more information - = help: add `#![feature(allocator_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `allocator_api` - --> $DIR/suggest-vec-allocator-api.rs:8:26 - | -LL | let _boxed: Box = Box::new(10); - | ^ - | - = note: see issue #32838 for more information - = help: add `#![feature(allocator_api)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/const-traits/issue-102156.rs b/tests/ui/traits/const-traits/issue-102156.rs index 506fdaa79c6f3..a6bd26eb2c8db 100644 --- a/tests/ui/traits/const-traits/issue-102156.rs +++ b/tests/ui/traits/const-traits/issue-102156.rs @@ -1,5 +1,5 @@ //@ edition:2015 -#![feature(allocator_api)] +#![feature(allocator_ext)] #![feature(const_trait_impl)] use core::convert::{From, TryFrom}; From 78d478a7e4bdf8dcb0275168e65722f77f5e3e9c Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Tue, 22 Sep 2026 20:12:57 +0200 Subject: [PATCH 7/7] Update deprecated rustc_hir imports --- Cargo.lock | 6 ++- compiler/rustc_ast_lowering/src/block.rs | 2 +- compiler/rustc_ast_lowering/src/contract.rs | 9 ++-- .../src/delegation/attributes.rs | 26 +++++----- .../rustc_ast_lowering/src/delegation/mod.rs | 2 +- .../rustc_ast_lowering/src/expr/closure.rs | 12 +++-- compiler/rustc_ast_lowering/src/format.rs | 2 +- compiler/rustc_ast_lowering/src/item.rs | 39 ++++++++------- compiler/rustc_ast_lowering/src/lib.rs | 19 ++++---- compiler/rustc_ast_lowering/src/pat.rs | 5 +- compiler/rustc_hir/src/lib.rs | 18 ++++--- compiler/rustc_hir_pretty/Cargo.toml | 1 + compiler/rustc_hir_pretty/src/lib.rs | 47 +++++++++---------- compiler/rustc_middle/src/arena.rs | 8 ++-- compiler/rustc_middle/src/hir/map.rs | 1 + compiler/rustc_middle/src/hir/mod.rs | 3 +- .../src/middle/debugger_visualizer.rs | 2 +- .../rustc_middle/src/middle/lang_items.rs | 2 +- compiler/rustc_middle/src/mir/syntax.rs | 2 +- compiler/rustc_middle/src/mir/terminator.rs | 4 +- compiler/rustc_middle/src/mono.rs | 2 +- compiler/rustc_middle/src/queries.rs | 11 +++-- compiler/rustc_middle/src/query/erase.rs | 6 +-- compiler/rustc_middle/src/thir.rs | 2 +- .../src/traits/specialization_graph.rs | 2 +- compiler/rustc_middle/src/ty/adjustment.rs | 2 +- compiler/rustc_middle/src/ty/adt.rs | 5 +- compiler/rustc_middle/src/ty/consts/lit.rs | 3 +- compiler/rustc_middle/src/ty/context.rs | 7 +-- .../src/ty/context/impl_interner.rs | 2 +- compiler/rustc_middle/src/ty/diagnostics.rs | 2 +- compiler/rustc_middle/src/ty/instance.rs | 4 +- compiler/rustc_middle/src/ty/layout.rs | 2 +- compiler/rustc_middle/src/ty/mod.rs | 4 +- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- .../rustc_middle/src/ty/structural_impls.rs | 2 +- compiler/rustc_middle/src/ty/sty.rs | 2 +- compiler/rustc_middle/src/ty/trait_def.rs | 3 +- compiler/rustc_middle/src/ty/util.rs | 3 +- compiler/rustc_passes/src/abi_test.rs | 3 +- .../rustc_passes/src/canonical_symbols.rs | 4 +- compiler/rustc_passes/src/check_attr.rs | 18 +++---- .../rustc_passes/src/debugger_visualizer.rs | 3 +- compiler/rustc_passes/src/diagnostic_items.rs | 5 +- compiler/rustc_passes/src/eii.rs | 2 +- compiler/rustc_passes/src/lang_items.rs | 4 +- compiler/rustc_passes/src/layout_test.rs | 3 +- compiler/rustc_passes/src/lib_features.rs | 3 +- compiler/rustc_passes/src/stability.rs | 10 ++-- compiler/rustc_passes/src/weak_lang_items.rs | 4 +- compiler/rustc_resolve/Cargo.toml | 1 + compiler/rustc_resolve/src/def_collector.rs | 5 +- compiler/rustc_symbol_mangling/Cargo.toml | 1 + compiler/rustc_symbol_mangling/src/test.rs | 3 +- compiler/rustc_transmute/Cargo.toml | 4 +- compiler/rustc_transmute/src/lib.rs | 2 +- compiler/rustc_ty_utils/Cargo.toml | 1 + compiler/rustc_ty_utils/src/abi.rs | 2 +- compiler/rustc_ty_utils/src/common_traits.rs | 2 +- compiler/rustc_ty_utils/src/instance.rs | 2 +- compiler/rustc_ty_utils/src/layout.rs | 2 +- .../rustc_ty_utils/src/structural_match.rs | 2 +- .../src/attrs/deprecated_semver.rs | 2 +- .../clippy/clippy_lints/src/missing_doc.rs | 6 +-- tests/ui-fulldeps/internal-lints/find_attr.rs | 4 +- tests/ui-fulldeps/polymorphic-drop-glue.rs | 3 +- 66 files changed, 200 insertions(+), 177 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc62ae98e0372..471734dd69e3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4174,6 +4174,7 @@ dependencies = [ "rustc_abi", "rustc_ast", "rustc_ast_pretty", + "rustc_attr_ir", "rustc_hir", "rustc_span", ] @@ -4738,6 +4739,7 @@ dependencies = [ "rustc_arena", "rustc_ast", "rustc_ast_pretty", + "rustc_attr_ir", "rustc_attr_parsing", "rustc_data_structures", "rustc_errors", @@ -4854,6 +4856,7 @@ dependencies = [ "punycode", "rustc-demangle", "rustc_abi", + "rustc_attr_ir", "rustc_data_structures", "rustc_hashes", "rustc_hir", @@ -4953,8 +4956,8 @@ version = "0.0.0" dependencies = [ "itertools", "rustc_abi", + "rustc_attr_ir", "rustc_data_structures", - "rustc_hir", "rustc_middle", "rustc_span", "smallvec", @@ -4967,6 +4970,7 @@ version = "0.0.0" dependencies = [ "itertools", "rustc_abi", + "rustc_attr_ir", "rustc_data_structures", "rustc_errors", "rustc_hashes", diff --git a/compiler/rustc_ast_lowering/src/block.rs b/compiler/rustc_ast_lowering/src/block.rs index b52af8fd3715a..b2cb1718b86a3 100644 --- a/compiler/rustc_ast_lowering/src/block.rs +++ b/compiler/rustc_ast_lowering/src/block.rs @@ -1,6 +1,6 @@ use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind}; +use rustc_attr_ir::target::Target; use rustc_hir as hir; -use rustc_hir::Target; use rustc_span::sym; use smallvec::SmallVec; diff --git a/compiler/rustc_ast_lowering/src/contract.rs b/compiler/rustc_ast_lowering/src/contract.rs index eaebff521cb68..80bd0f7f4bb95 100644 --- a/compiler/rustc_ast_lowering/src/contract.rs +++ b/compiler/rustc_ast_lowering/src/contract.rs @@ -1,6 +1,7 @@ use std::sync::Arc; -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; +use rustc_attr_ir::target::Target; use thin_vec::thin_vec; use crate::LoweringContext; @@ -209,7 +210,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let postcond_checker = self.arena.alloc(self.expr_enum_variant_lang_item( postcond_checker.span, - rustc_hir::attrs::lang_items::LangItem::OptionSome, + LangItem::OptionSome, &*arena_vec![self; *postcond_checker], )); let then_block_stmts = self.block_all(span, stmts, Some(postcond_checker)); @@ -217,7 +218,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let none_expr = self.arena.alloc(self.expr_enum_variant_lang_item( postcond_checker.span, - rustc_hir::attrs::lang_items::LangItem::OptionNone, + LangItem::OptionNone, Default::default(), )); let else_block = self.block_expr(none_expr); @@ -350,7 +351,7 @@ impl<'hir> LoweringContext<'_, 'hir> { )); let attrs: rustc_ast::AttrVec = thin_vec![self.unreachable_code_attr(span)]; - self.lower_attrs(contract_check.hir_id, &attrs, span, rustc_hir::Target::Expression); + self.lower_attrs(contract_check.hir_id, &attrs, span, Target::Expression); let ret_block = self.block_all(span, arena_vec![self; ret_stmt], Some(contract_check)); self.arena.alloc(self.expr_block(self.arena.alloc(ret_block))) diff --git a/compiler/rustc_ast_lowering/src/delegation/attributes.rs b/compiler/rustc_ast_lowering/src/delegation/attributes.rs index 834f85450a2cd..686f5bbf06acc 100644 --- a/compiler/rustc_ast_lowering/src/delegation/attributes.rs +++ b/compiler/rustc_ast_lowering/src/delegation/attributes.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::{AttributeKind, InlineAttr}; use rustc_hir as hir; -use rustc_hir::attrs::{AttributeKind, InlineAttr}; use rustc_span::Span; use rustc_span::def_id::DefId; @@ -7,33 +7,37 @@ use crate::LoweringContext; use crate::delegation::DelegationResolution; struct AdditionInfo { - pub equals: fn(&hir::Attribute) -> bool, + pub equals: fn(&rustc_attr_ir::Attribute) -> bool, pub kind: AdditionKind, } enum AdditionKind { - Default { factory: fn(Span) -> hir::Attribute }, - Inherit { factory: fn(Span, &hir::Attribute) -> hir::Attribute }, + Default { factory: fn(Span) -> rustc_attr_ir::Attribute }, + Inherit { factory: fn(Span, &rustc_attr_ir::Attribute) -> rustc_attr_ir::Attribute }, } static ADDITIONS: &[AdditionInfo] = &[ AdditionInfo { - equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::MustUse { .. })), + equals: |a| matches!(a, rustc_attr_ir::Attribute::Parsed(AttributeKind::MustUse { .. })), kind: AdditionKind::Inherit { factory: |span, original_attr| { let reason = match original_attr { - hir::Attribute::Parsed(AttributeKind::MustUse { reason, .. }) => *reason, + rustc_attr_ir::Attribute::Parsed(AttributeKind::MustUse { reason, .. }) => { + *reason + } _ => None, }; - hir::Attribute::Parsed(AttributeKind::MustUse { span, reason }) + rustc_attr_ir::Attribute::Parsed(AttributeKind::MustUse { span, reason }) }, }, }, AdditionInfo { - equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::Inline(..))), + equals: |a| matches!(a, rustc_attr_ir::Attribute::Parsed(AttributeKind::Inline(..))), kind: AdditionKind::Default { - factory: |span| hir::Attribute::Parsed(AttributeKind::Inline(InlineAttr::Hint, span)), + factory: |span| { + rustc_attr_ir::Attribute::Parsed(AttributeKind::Inline(InlineAttr::Hint, span)) + }, }, }, ]; @@ -61,8 +65,8 @@ impl<'hir> LoweringContext<'_, 'hir> { &self, span: Span, sig_id: DefId, - existing: Option<&&[hir::Attribute]>, - ) -> Vec { + existing: Option<&&[rustc_attr_ir::Attribute]>, + ) -> Vec { ADDITIONS .iter() .filter_map(|addition| { diff --git a/compiler/rustc_ast_lowering/src/delegation/mod.rs b/compiler/rustc_ast_lowering/src/delegation/mod.rs index 0e94016963c78..b2c0e1ffa81b1 100644 --- a/compiler/rustc_ast_lowering/src/delegation/mod.rs +++ b/compiler/rustc_ast_lowering/src/delegation/mod.rs @@ -45,7 +45,7 @@ use hir::def::Res; use rustc_abi::ExternAbi; use rustc_ast as ast; use rustc_ast::*; -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; use rustc_hir::def::DefKind; use rustc_hir::{self as hir, FnDeclFlags, QPath}; use rustc_middle::ty::Asyncness; diff --git a/compiler/rustc_ast_lowering/src/expr/closure.rs b/compiler/rustc_ast_lowering/src/expr/closure.rs index 1b8740948d726..c72956545b7c8 100644 --- a/compiler/rustc_ast_lowering/src/expr/closure.rs +++ b/compiler/rustc_ast_lowering/src/expr/closure.rs @@ -1,6 +1,8 @@ use rustc_ast::*; +use rustc_attr_ir::find_attr; +use rustc_attr_ir::target::Target; use rustc_hir as hir; -use rustc_hir::{HirId, Target, find_attr}; +use rustc_hir::HirId; use rustc_span::{Span, span_bug}; use super::{LoweringContext, MoveExprState}; @@ -55,7 +57,7 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_expr_coroutine_closure_with_move_exprs( &mut self, expr_hir_id: HirId, - attrs: &[hir::Attribute], + attrs: &[rustc_attr_ir::Attribute], binder: &ClosureBinder, capture_clause: CaptureBy, closure_id: NodeId, @@ -114,7 +116,7 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_expr_plain_closure_with_move_exprs( &mut self, expr_hir_id: HirId, - attrs: &[hir::Attribute], + attrs: &[rustc_attr_ir::Attribute], binder: &ClosureBinder, capture_clause: CaptureBy, closure_id: NodeId, @@ -153,7 +155,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // local uses and the caller can later add the matching initializers. fn lower_expr_closure( &mut self, - attrs: &[hir::Attribute], + attrs: &[rustc_attr_ir::Attribute], binder: &ClosureBinder, capture_clause: CaptureBy, closure_id: NodeId, @@ -283,7 +285,7 @@ impl<'hir> LoweringContext<'_, 'hir> { body: &Expr, fn_decl_span: Span, fn_arg_span: Span, - attrs: &[hir::Attribute], + attrs: &[rustc_attr_ir::Attribute], ) -> hir::ExprKind<'hir> { let closure_def_id = self.local_def_id(closure_id); let (binder_clause, generic_params) = self.lower_closure_binder(binder); diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index b9974edea71a4..9da42511c0d7f 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -1,9 +1,9 @@ use std::borrow::Cow; use rustc_ast::*; +use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_session::config::FmtDebug; use rustc_span::{ByteSymbol, DesugaringKind, Ident, Span, Symbol, sym}; diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index f8106bd68d82c..33b73ed30c518 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1,12 +1,11 @@ use rustc_abi::ExternAbi; use rustc_ast::visit::AssocCtxt; use rustc_ast::*; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttributeKind, EiiImplResolution, find_attr}; use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err}; -use rustc_hir::attrs::{AttributeKind, EiiImplResolution}; use rustc_hir::def::{DefKind, PerNS, Res}; -use rustc_hir::{ - self as hir, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin, Target, find_attr, -}; +use rustc_hir::{self as hir, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin}; use rustc_middle::ty::data_structures::IndexMap; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::edit_distance::find_best_match_for_name; @@ -68,8 +67,8 @@ impl<'hir> LoweringContext<'_, 'hir> { id: NodeId, name: Ident, EiiDecl { foreign_item, impl_unsafe }: &EiiDecl, - ) -> Option { - self.lower_path_simple_eii(id, foreign_item).map(|did| hir::attrs::EiiDecl { + ) -> Option { + self.lower_path_simple_eii(id, foreign_item).map(|did| rustc_attr_ir::EiiDecl { foreign_item: did, impl_unsafe: *impl_unsafe, name, @@ -87,7 +86,7 @@ impl<'hir> LoweringContext<'_, 'hir> { is_default, known_eii_macro_resolution, }: &EiiImpl, - ) -> hir::attrs::EiiImpl { + ) -> rustc_attr_ir::EiiImpl { let resolution = if let Some(target) = known_eii_macro_resolution && let Some(foreign_item_did) = self.lower_path_simple_eii(*node_id, target) { @@ -100,7 +99,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ) }; - hir::attrs::EiiImpl { + rustc_attr_ir::EiiImpl { span: self.lower_span(*span), inner_span: self.lower_span(*inner_span), impl_unsafe_span: match *impl_safety { @@ -116,19 +115,21 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, id: NodeId, i: &ItemKind, - ) -> Vec { + ) -> Vec { match i { ItemKind::Fn(Fn { eii_impl: None, .. }) | ItemKind::Static(StaticItem { eii_impl: None, .. }) => Vec::new(), ItemKind::Fn(Fn { eii_impl: Some(eii_impl), .. }) | ItemKind::Static(StaticItem { eii_impl: Some(eii_impl), .. }) => { - vec![hir::Attribute::Parsed(AttributeKind::EiiImpl(Box::new( + vec![rustc_attr_ir::Attribute::Parsed(AttributeKind::EiiImpl(Box::new( self.lower_eii_impl(eii_impl), )))] } ItemKind::MacroDef(name, MacroDef { eii_declaration: Some(target), .. }) => self .lower_eii_decl(id, *name, target) - .map(|decl| vec![hir::Attribute::Parsed(AttributeKind::EiiDeclaration(decl))]) + .map(|decl| { + vec![rustc_attr_ir::Attribute::Parsed(AttributeKind::EiiDeclaration(decl))] + }) .unwrap_or_default(), ItemKind::ExternCrate(..) @@ -184,7 +185,7 @@ impl<'hir> LoweringContext<'_, 'hir> { span: Span, id: NodeId, hir_id: hir::HirId, - attrs: &'hir [hir::Attribute], + attrs: &'hir [rustc_attr_ir::Attribute], vis_span: Span, i: &ItemKind, ) -> hir::ItemKind<'hir> { @@ -551,7 +552,7 @@ impl<'hir> LoweringContext<'_, 'hir> { prefix: &Path, id: NodeId, vis_span: Span, - attrs: &'hir [hir::Attribute], + attrs: &'hir [rustc_attr_ir::Attribute], ) -> hir::ItemKind<'hir> { let path = &tree.prefix; let segments = prefix.segments.iter().chain(path.segments.iter()).cloned().collect(); @@ -1351,7 +1352,7 @@ impl<'hir> LoweringContext<'_, 'hir> { decl: &FnDecl, coroutine_marker: Option, body: Option<&Block>, - attrs: &'hir [hir::Attribute], + attrs: &'hir [rustc_attr_ir::Attribute], contract: Option<&FnContract>, ) -> hir::BodyId { let Some(body) = body else { @@ -1612,7 +1613,7 @@ impl<'hir> LoweringContext<'_, 'hir> { id: NodeId, kind: FnDeclKind, coroutine_marker: Option, - attrs: &[hir::Attribute], + attrs: &[rustc_attr_ir::Attribute], ) -> (&'hir hir::Generics<'hir>, hir::FnSig<'hir>) { let header = self.lower_fn_header(sig.header, hir::Safety::Safe, attrs); let itctx = ImplTraitContext::Universal; @@ -1626,7 +1627,7 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, h: FnHeader, default_safety: hir::Safety, - attrs: &[hir::Attribute], + attrs: &[rustc_attr_ir::Attribute], ) -> hir::FnHeader { let asyncness = if let Some(coroutine_marker) = h.coroutine_marker && let CoroutineKind::Async = coroutine_marker.kind @@ -1713,7 +1714,11 @@ impl<'hir> LoweringContext<'_, 'hir> { /// Lowers constness or comptime attribute. /// Whether `const` is allowed here is checked by ast validation. /// Whether `comptime` is allowed here is checked by the `comptime` attribute parser. - pub(super) fn lower_constness(&mut self, attrs: &[hir::Attribute], c: Const) -> hir::Constness { + pub(super) fn lower_constness( + &mut self, + attrs: &[rustc_attr_ir::Attribute], + c: Const, + ) -> hir::Constness { let mut constness = match c { Const::Yes(_) => hir::Constness::Const { always: false }, Const::No => hir::Constness::NotConst, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7ff6a2538c1e7..d35e8df40f20b 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -45,6 +45,9 @@ use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::node_id::NodeMap; use rustc_ast::visit::{self, Visitor}; use rustc_ast::{self as ast, *}; +use rustc_attr_ir::find_attr; +use rustc_attr_ir::lang_items::LangItem; +use rustc_attr_ir::target::Target; use rustc_attr_parsing::{AttributeParser, Recovery, ShouldEmit}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sorted_map::SortedMap; @@ -54,15 +57,13 @@ use rustc_data_structures::tagged_ptr::TaggedRef; use rustc_data_structures::unord::ExtendUnord; use rustc_errors::codes::*; use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, ErrorGuaranteed}; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::{DefKind, Namespace, PerNS, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::PerParentDisambiguatorState; use rustc_hir::lints::DelayedLint; use rustc_hir::{ self as hir, AngleBrackets, CRATE_OWNER_ID, ConstArg, GenericArg, HirId, ItemLocalMap, - LifetimeSource, LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, - find_attr, + LifetimeSource, LifetimeSyntax, MissingLifetimeKind, ParamName, TraitCandidate, }; use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_macros::extension; @@ -169,7 +170,7 @@ struct PerOwnerLoweringState<'a, 'hir> { // -- Accumulated outputs -- /// Attributes inside the owner being lowered. - attrs: SortedMap, + attrs: SortedMap, /// Bodies inside the owner being lowered. bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>, /// `#[define_opaque]` attributes @@ -1206,7 +1207,7 @@ impl<'hir> LoweringContext<'_, 'hir> { attrs: &[Attribute], target_span: Span, target: Target, - ) -> &'hir [hir::Attribute] { + ) -> &'hir [rustc_attr_ir::Attribute] { self.lower_attrs_with_extra(id, attrs, target_span, target, None, &[]) } @@ -1217,8 +1218,8 @@ impl<'hir> LoweringContext<'_, 'hir> { target_span: Span, target: Target, target_item: Option<&ast::Item>, - extra_hir_attributes: &[hir::Attribute], - ) -> &'hir [hir::Attribute] { + extra_hir_attributes: &[rustc_attr_ir::Attribute], + ) -> &'hir [rustc_attr_ir::Attribute] { if attrs.is_empty() && extra_hir_attributes.is_empty() { &[] } else { @@ -1251,7 +1252,7 @@ impl<'hir> LoweringContext<'_, 'hir> { target_hir_id: HirId, target: Target, target_item: Option<&ast::Item>, - ) -> Vec { + ) -> Vec { let l = self.span_lowerer(); self.attribute_parser.parse_attribute_list( attrs, @@ -3111,7 +3112,7 @@ impl<'hir> LoweringContext<'_, 'hir> { fn stmt_let_pat( &mut self, - attrs: Option<&'hir [hir::Attribute]>, + attrs: Option<&'hir [rustc_attr_ir::Attribute]>, span: Span, init: Option<&'hir hir::Expr<'hir>>, pat: &'hir hir::Pat<'hir>, diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index 0edba3fe0cd14..df3d7b1a3c0a6 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -1,9 +1,10 @@ use std::sync::Arc; use rustc_ast::*; -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; +use rustc_attr_ir::target::Target; +use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{self as hir, Target}; use rustc_span::{DesugaringKind, Ident, Span, Spanned, respan, span_bug}; use crate::diagnostics::{ diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index 0f31ed196c3df..5855c1126a971 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -24,20 +24,18 @@ pub mod pat_util; mod stable_hash_impls; mod target_impls; +// FIXME: Remove this use tree, replace by `rustc_attr_ir` imports +#[doc(hidden)] +pub use attrs::{ + Attribute, ConstStability, DefaultBodyStability, Stability, StabilityLevel, StableSince, + UnstableReason, target::Target, +}; #[doc(no_inline)] pub use hir::*; +// FIXME: Remove this use tree, replace by `rustc_attr_ir` imports +#[doc(hidden)] pub use rustc_attr_ir::{self as attrs, find_attr}; pub use rustc_hir_id::*; pub use rustc_span::def_id; -// FIXME: Remove this use tree, replace by `rustc_hir::attrs` or `rustc_attr_ir` imports -#[doc(hidden)] -pub use { - attrs::target::{self, AssocCtxt, MethodKind, Target}, - attrs::{ - AttrArgs, AttrItem, AttrPath, Attribute, ConstStability, DefaultBodyStability, - HashIgnoredAttrId, PartialConstStability, Stability, StabilityLevel, StableSince, - UnstableReason, VERSION_PLACEHOLDER, - }, -}; pub use crate::arena::Arena; diff --git a/compiler/rustc_hir_pretty/Cargo.toml b/compiler/rustc_hir_pretty/Cargo.toml index f5d7dbd3f96e4..8279d9c6d620a 100644 --- a/compiler/rustc_hir_pretty/Cargo.toml +++ b/compiler/rustc_hir_pretty/Cargo.toml @@ -8,6 +8,7 @@ edition = "2024" rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_hir = { path = "../rustc_hir" } rustc_span = { path = "../rustc_span" } # tidy-alphabetical-end diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 6d1ae563a9fa2..ddd1a296ecd35 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -16,8 +16,8 @@ use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent}; use rustc_ast_pretty::pp::{self, BoxMarker, Breaks}; use rustc_ast_pretty::pprust::state::MacHeader; use rustc_ast_pretty::pprust::{Comments, PrintState}; +use rustc_attr_ir::{AttrArgs, AttrItem, Attribute, AttributeKind, PrintAttribute}; use rustc_hir as hir; -use rustc_hir::attrs::{AttributeKind, PrintAttribute}; use rustc_hir::{ BindingMode, ByRef, ConstArg, ConstArgExprField, ConstArgKind, GenericArg, GenericBound, GenericParam, GenericParamKind, HirId, ImplicitSelfKind, LifetimeParamKind, Node, PatKind, @@ -72,12 +72,12 @@ impl PpAnn for &dyn rustc_hir::intravisit::HirTyCtxt<'_> { pub struct State<'a> { pub s: pp::Printer, comments: Option>, - attrs: &'a dyn Fn(HirId) -> &'a [hir::Attribute], + attrs: &'a dyn Fn(HirId) -> &'a [Attribute], ann: &'a (dyn PpAnn + 'a), } impl<'a> State<'a> { - fn attrs(&self, id: HirId) -> &'a [hir::Attribute] { + fn attrs(&self, id: HirId) -> &'a [Attribute] { (self.attrs)(id) } @@ -86,7 +86,7 @@ impl<'a> State<'a> { expr.precedence(&has_attr) } - fn print_attrs(&mut self, attrs: &[hir::Attribute]) { + fn print_attrs(&mut self, attrs: &[Attribute]) { if attrs.is_empty() { return; } @@ -99,9 +99,9 @@ impl<'a> State<'a> { /// Print a single attribute as if it has style `style`, disregarding the /// actual style of the attribute. - fn print_attribute_as_style(&mut self, attr: &hir::Attribute, style: ast::AttrStyle) { + fn print_attribute_as_style(&mut self, attr: &Attribute, style: ast::AttrStyle) { match &attr { - hir::Attribute::Unparsed(unparsed) => { + Attribute::Unparsed(unparsed) => { self.maybe_print_comment(unparsed.span.lo()); match style { ast::AttrStyle::Inner => self.word("#!["), @@ -111,13 +111,13 @@ impl<'a> State<'a> { self.word("]"); self.hardbreak() } - hir::Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => { + Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => { self.word(rustc_ast_pretty::pprust::state::doc_comment_to_string( *kind, style, *comment, )); self.hardbreak() } - hir::Attribute::Parsed(pa) => { + Attribute::Parsed(pa) => { match style { ast::AttrStyle::Inner => self.word("#![attr = "), ast::AttrStyle::Outer => self.word("#[attr = "), @@ -129,7 +129,7 @@ impl<'a> State<'a> { } } - fn print_attr_item(&mut self, item: &hir::AttrItem, span: Span) { + fn print_attr_item(&mut self, item: &AttrItem, span: Span) { let ib = self.ibox(0); let path = ast::Path { span, @@ -146,21 +146,20 @@ impl<'a> State<'a> { }; match &item.args { - hir::AttrArgs::Delimited(DelimArgs { dspan: _, delim, tokens }) => self - .print_mac_common( - Some(MacHeader::Path(&path)), - false, - None, - *delim, - None, - &tokens, - true, - span, - ), - hir::AttrArgs::Empty => { + AttrArgs::Delimited(DelimArgs { dspan: _, delim, tokens }) => self.print_mac_common( + Some(MacHeader::Path(&path)), + false, + None, + *delim, + None, + &tokens, + true, + span, + ), + AttrArgs::Empty => { PrintState::print_path(self, &path, false, 0); } - hir::AttrArgs::Eq { eq_span: _, expr } => { + AttrArgs::Eq { eq_span: _, expr } => { PrintState::print_path(self, &path, false, 0); self.space(); self.word_space("="); @@ -277,7 +276,7 @@ pub fn print_crate<'a>( krate: &hir::Mod<'_>, filename: FileName, input: String, - attrs: &'a dyn Fn(HirId) -> &'a [hir::Attribute], + attrs: &'a dyn Fn(HirId) -> &'a [Attribute], ann: &'a dyn PpAnn, ) -> String { let mut s = State { @@ -311,7 +310,7 @@ where printer.s.eof() } -pub fn attribute_to_string(ann: &dyn PpAnn, attr: &hir::Attribute) -> String { +pub fn attribute_to_string(ann: &dyn PpAnn, attr: &Attribute) -> String { to_string(ann, |s| s.print_attribute_as_style(attr, ast::AttrStyle::Outer)) } diff --git a/compiler/rustc_middle/src/arena.rs b/compiler/rustc_middle/src/arena.rs index ee71d4d46e48f..a423b6bdca5b2 100644 --- a/compiler/rustc_middle/src/arena.rs +++ b/compiler/rustc_middle/src/arena.rs @@ -107,9 +107,9 @@ rustc_arena::declare_arena! { upvars_mentioned: rustc_data_structures::fx::FxIndexMap, dyn_compatibility_violations: rustc_middle::traits::DynCompatibilityViolation, codegen_unit: rustc_middle::mono::CodegenUnit<'tcx>, - attribute: rustc_hir::Attribute, + attribute: rustc_attr_ir::Attribute, name_set: rustc_data_structures::unord::UnordSet, - autodiff_item: rustc_hir::attrs::AutoDiffItem, + autodiff_item: rustc_attr_ir::AutoDiffItem, ordered_name_set: rustc_data_structures::fx::FxIndexSet, stable_order_of_exportable_impls: rustc_data_structures::fx::FxIndexMap, @@ -131,7 +131,7 @@ rustc_arena::declare_arena! { >, external_constraints: rustc_middle::traits::solve::ExternalConstraintsData>, doc_link_resolutions: rustc_middle::middle::resolve::DocLinkResMap, - stripped_cfg_items: rustc_hir::attrs::StrippedCfgItem, + stripped_cfg_items: rustc_attr_ir::StrippedCfgItem, mod_child: rustc_middle::middle::resolve::ModChild, features: rustc_feature::Features, specialization_graph: rustc_middle::traits::specialization_graph::Graph, @@ -204,9 +204,9 @@ impl_ref_decodable_into_arena! { Spanned>, rustc_ast::InlineAsmTemplatePiece, rustc_ast::tokenstream::TokenStream, + rustc_attr_ir::Attribute, rustc_data_structures::unord::UnordMap>>, rustc_data_structures::unord::UnordSet, - rustc_hir::Attribute, rustc_index::IndexVec>, rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs, rustc_middle::mir::Body<'tcx>, diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index affadfd0c6aaf..664c85980addd 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -4,6 +4,7 @@ use rustc_abi::ExternAbi; use rustc_ast::visit::{VisitorResult, walk_list}; +use rustc_attr_ir::{Attribute, find_attr}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::stable_hash::{StableHash, StableHasher}; use rustc_data_structures::steal::Steal; diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index eae84fde7e305..d899ba0190f00 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -6,12 +6,13 @@ pub mod map; pub mod nested_filter; pub mod place; +use rustc_attr_ir::Attribute; +use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::stable_hash::{StableHash, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{DynSend, DynSync, try_par_for_each_in}; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap, LocalModId}; use rustc_hir::lints::DelayedLints; diff --git a/compiler/rustc_middle/src/middle/debugger_visualizer.rs b/compiler/rustc_middle/src/middle/debugger_visualizer.rs index b6fc2d4f1a8d0..0fded7a77662d 100644 --- a/compiler/rustc_middle/src/middle/debugger_visualizer.rs +++ b/compiler/rustc_middle/src/middle/debugger_visualizer.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use std::sync::Arc; -use rustc_hir::attrs::DebuggerVisualizerType; +use rustc_attr_ir::DebuggerVisualizerType; use rustc_macros::{Decodable, Encodable, StableHash}; /// A single debugger visualizer file. diff --git a/compiler/rustc_middle/src/middle/lang_items.rs b/compiler/rustc_middle/src/middle/lang_items.rs index 829df12ff543c..9d07c2edeb386 100644 --- a/compiler/rustc_middle/src/middle/lang_items.rs +++ b/compiler/rustc_middle/src/middle/lang_items.rs @@ -7,7 +7,7 @@ //! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`. //! * Functions called by the compiler itself. -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; use rustc_hir::def_id::DefId; use rustc_span::Span; use rustc_target::spec::PanicStrategy; diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 4c4a16953d5ed..6bb0190cd70b8 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1712,7 +1712,7 @@ pub enum BinOp { /// - `Ordering::Equal` (`0_i8`, as a Scalar) if `A == B` /// - `Ordering::Greater` (`+1_i8`, as a Scalar) if `A > B` /// - /// [`LangItem::OrderingEnum`]: rustc_hir::attrs::lang_items::LangItem + /// [`LangItem::OrderingEnum`]: rustc_attr_ir::lang_items::LangItem Cmp, /// The `ptr.offset` operator Offset, diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index cc75bebbb3f93..2d51f382f0998 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -3,9 +3,9 @@ use std::slice; use rustc_ast::InlineAsmOptions; +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::packed::Pu128; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::attrs::lang_items::LangItem; use rustc_macros::{StableHash, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_span::bug; use smallvec::{SmallVec, smallvec}; diff --git a/compiler/rustc_middle/src/mono.rs b/compiler/rustc_middle/src/mono.rs index 76828cbee60f1..a54ca4faf81ee 100644 --- a/compiler/rustc_middle/src/mono.rs +++ b/compiler/rustc_middle/src/mono.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::fmt; use std::hash::Hash; +use rustc_attr_ir::{InlineAttr, Linkage}; use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexMap; @@ -11,7 +12,6 @@ use rustc_data_structures::stable_hash::{ use rustc_data_structures::unord::UnordMap; use rustc_hashes::Hash128; use rustc_hir::ItemId; -use rustc_hir::attrs::{InlineAttr, Linkage}; use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, LOCAL_CRATE}; use rustc_macros::{StableHash, TyDecodable, TyEncodable}; use rustc_session::config::OptLevel; diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index 9e1bafa4fd2a2..cb39c17cd4023 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -53,6 +53,7 @@ use rustc_arena::TypedArena; use rustc_ast as ast; use rustc_ast::expand::allocator::AllocatorKind; use rustc_ast::tokenstream::TokenStream; +use rustc_attr_ir::diagnostic_items::DiagnosticItems; use rustc_attr_ir::lang_items::{LangItem, LanguageItems}; use rustc_attr_ir::{CanonicalSymbols, EiiDecl, EiiImpl, StrippedCfgItem}; use rustc_crate_store::{ @@ -1493,19 +1494,19 @@ rustc_queries! { cache_on_disk } - query lookup_stability(def_id: DefId) -> Option { + query lookup_stability(def_id: DefId) -> Option { desc { "looking up stability of `{}`", tcx.def_path_str(def_id) } cache_on_disk separate_provide_extern } - query lookup_const_stability(def_id: DefId) -> Option { + query lookup_const_stability(def_id: DefId) -> Option { desc { "looking up const stability of `{}`", tcx.def_path_str(def_id) } cache_on_disk separate_provide_extern } - query lookup_default_body_stability(def_id: DefId) -> Option { + query lookup_default_body_stability(def_id: DefId) -> Option { desc { "looking up default body stability of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } @@ -2302,7 +2303,7 @@ rustc_queries! { } /// Returns all diagnostic items defined in all crates. - query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::attrs::diagnostic_items::DiagnosticItems { + query all_diagnostic_items(_: ()) -> &'tcx DiagnosticItems { arena_cache eval_always desc { "calculating the diagnostic items map" } @@ -2322,7 +2323,7 @@ rustc_queries! { } /// Returns the diagnostic items defined in a crate. - query diagnostic_items(_: CrateNum) -> &'tcx rustc_hir::attrs::diagnostic_items::DiagnosticItems { + query diagnostic_items(_: CrateNum) -> &'tcx DiagnosticItems { arena_cache desc { "calculating the diagnostic items map in a crate" } separate_provide_extern diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 15a684491dcab..b0281a70eeb73 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -185,11 +185,11 @@ impl_erasable_for_types_with_no_type_params! { Option<(rustc_span::def_id::DefId, rustc_session::config::EntryFnType)>, Option, Option, + Option, + Option, + Option, Option, - Option, Option, - Option, - Option, Option, Option, Option, diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index b20dfe68d98e2..69d518bf82786 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -15,10 +15,10 @@ use std::sync::Arc; use rustc_abi::{FieldIdx, Integer, Size, VariantIdx}; use rustc_ast::{AsmMacro, InlineAsmOptions, InlineAsmTemplatePiece, Mutability}; +use rustc_attr_ir::AttributeKind; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::thin_vec::ThinVec; use rustc_hir as hir; -use rustc_hir::attrs::AttributeKind; use rustc_hir::def_id::DefId; use rustc_hir::{BindingMode, ByRef, HirId, MatchSource, RangeEnd}; use rustc_index::{IndexVec, newtype_index}; diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs index 19b72d1a7d1c4..b13af2705c736 100644 --- a/compiler/rustc_middle/src/traits/specialization_graph.rs +++ b/compiler/rustc_middle/src/traits/specialization_graph.rs @@ -1,7 +1,7 @@ +use rustc_attr_ir::find_attr; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::{DefId, DefIdMap}; -use rustc_hir::find_attr; use rustc_macros::{StableHash, TyDecodable, TyEncodable}; use crate::diagnostics::StrictCoherenceNeedsNegativeCoherence; diff --git a/compiler/rustc_middle/src/ty/adjustment.rs b/compiler/rustc_middle/src/ty/adjustment.rs index 00efbe912b883..b3a2925b24bfa 100644 --- a/compiler/rustc_middle/src/ty/adjustment.rs +++ b/compiler/rustc_middle/src/ty/adjustment.rs @@ -1,6 +1,6 @@ use rustc_abi::FieldIdx; +use rustc_attr_ir::lang_items::LangItem; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def_id::DefId; use rustc_macros::{StableHash, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_span::Span; diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index d189fbc5d59bd..8ad5de3fa85cc 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -4,6 +4,8 @@ use std::ops::Range; use std::str; use rustc_abi::{FIRST_VARIANT, FieldIdx, ReprOptions, VariantIdx}; +use rustc_attr_ir::find_attr; +use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; @@ -11,10 +13,9 @@ use rustc_data_structures::stable_hash::{ StableHash, StableHashControls, StableHashCtxt, StableHasher, }; use rustc_errors::ErrorGuaranteed; -use rustc_hir::attrs::lang_items::LangItem; +use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, find_attr}; use rustc_index::{IndexSlice, IndexVec}; use rustc_macros::{StableHash, TyDecodable, TyEncodable}; use rustc_session::DataTypeKind; diff --git a/compiler/rustc_middle/src/ty/consts/lit.rs b/compiler/rustc_middle/src/ty/consts/lit.rs index 08dadf6ad9f5f..9dd8c958cd2f0 100644 --- a/compiler/rustc_middle/src/ty/consts/lit.rs +++ b/compiler/rustc_middle/src/ty/consts/lit.rs @@ -1,6 +1,5 @@ use rustc_ast::{LitFloatType, LitIntType, LitKind}; -use rustc_hir; -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; use rustc_macros::StableHash; use crate::ty::{self, Ty, TyCtxt}; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 4009191430afb..9edb12949f4cf 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -17,6 +17,8 @@ use std::{debug_assert_matches, fmt, iter, mem}; use rustc_abi::{ExternAbi, FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx}; use rustc_ast as ast; +use rustc_attr_ir::find_attr; +use rustc_attr_ir::lang_items::LangItem; use rustc_crate_store::{CrateStoreDyn, Untracked}; use rustc_data_structures::defer; use rustc_data_structures::fx::FxHashMap; @@ -29,12 +31,11 @@ use rustc_data_structures::sync::{ self, DynSend, DynSync, FreezeReadGuard, Lock, RwLock, WorkerLocal, }; use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, MultiSpan}; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::definitions::{DefPathData, Definitions, PerParentDisambiguatorState}; use rustc_hir::intravisit::Visitor; -use rustc_hir::{self as hir, CRATE_HIR_ID, HirId, Node, TraitCandidate, find_attr}; +use rustc_hir::{self as hir, CRATE_HIR_ID, HirId, Node, TraitCandidate}; use rustc_index::IndexVec; use rustc_lint_defs::Lint; use rustc_lint_defs::builtin::UNUSED_FEATURES; @@ -990,7 +991,7 @@ impl<'tcx> TyCtxt<'tcx> { } /// Obtain all lang items of this crate and all dependencies (recursively) - pub fn lang_items(self) -> &'tcx rustc_hir::attrs::lang_items::LanguageItems { + pub fn lang_items(self) -> &'tcx rustc_attr_ir::lang_items::LanguageItems { self.get_lang_items(()) } diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs index f13797b48fcbf..fdaf5cacfbf27 100644 --- a/compiler/rustc_middle/src/ty/context/impl_interner.rs +++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs @@ -2,10 +2,10 @@ use std::{debug_assert_matches, fmt}; +use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::intern::Interned; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::{CtorKind, DefKind}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_span::{DUMMY_SP, Span, Symbol, bug}; diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 1f2a9aca60142..df1daac366c53 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -3,9 +3,9 @@ use std::fmt::Write; use std::ops::ControlFlow; +use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagArg, listify, pluralize}; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, AmbigArg, PredicateOrigin, WherePredicateKind}; diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 44e5a875a74ae..1a00293f8ffc6 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -1,9 +1,9 @@ use std::{assert_matches, fmt}; +use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::{CtorKind, DefKind, Namespace}; use rustc_hir::def_id::{CrateNum, DefId}; use rustc_macros::{Lift, StableHash, TyDecodable, TyEncodable}; @@ -231,7 +231,7 @@ impl<'tcx> Instance<'tcx> { if !tcx.sess.opts.share_generics() // However, if the def_id is marked inline(never), then it's fine to just reuse the // upstream monomorphization. - && tcx.codegen_fn_attrs(self.def_id()).inline != rustc_hir::attrs::InlineAttr::Never + && tcx.codegen_fn_attrs(self.def_id()).inline != rustc_attr_ir::InlineAttr::Never { return None; } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 1e4e96ceed576..7952b97e94e13 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -6,9 +6,9 @@ use rustc_abi::{ PointerKind, Primitive, ReprFlags, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, TyAbiInterface, VariantIdx, Variants, }; +use rustc_attr_ir::lang_items::LangItem; use rustc_errors::{Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, IntoDiagArg, Level}; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def_id::DefId; use rustc_macros::{StableHash, TyDecodable, TyEncodable, extension}; use rustc_session::config::OptLevel; diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index c7de3afb7cd3c..1f2ffb17cc2c7 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1870,7 +1870,7 @@ impl<'tcx> TyCtxt<'tcx> { } /// Gets all attributes with the given name. - #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."] + #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to use `rustc_attr_ir::find_attr!` instead."] pub fn get_attrs( self, did: impl Into, @@ -1889,7 +1889,7 @@ impl<'tcx> TyCtxt<'tcx> { /// /// /// - #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."] + #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to use `rustc_attr_ir::find_attr!` instead."] pub fn get_all_attrs(self, did: impl Into) -> &'tcx [rustc_attr_ir::Attribute] { let did: DefId = did.into(); if let Some(did) = did.as_local() { diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 3ba7ea6d43794..cafe93c591090 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -6,11 +6,11 @@ use std::ops::{Deref, DerefMut}; use rustc_abi::{ExternAbi, Size}; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; +use rustc_attr_ir::lang_items::LangItem; use rustc_crate_store::{ExternCrate, ExternCrateSource}; use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; use rustc_data_structures::unord::UnordMap; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::{self, CtorKind, DefKind, Namespace}; use rustc_hir::def_id::{DefIdMap, DefIdSet, LOCAL_CRATE, ModId}; use rustc_hir::definitions::{DefKey, DefPathDataName}; diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 02107fee370cb..3710a159b3fdd 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -217,11 +217,11 @@ TrivialTypeTraversalImpls! { rustc_abi::VariantIdx, rustc_ast::InlineAsmOptions, rustc_ast::InlineAsmTemplatePiece, + rustc_attr_ir::AttributeKind, rustc_hir::CoroutineKind, rustc_hir::HirId, rustc_hir::MatchSource, rustc_hir::RangeEnd, - rustc_hir::attrs::AttributeKind, rustc_hir::def_id::LocalDefId, rustc_span::Ident, rustc_span::Span, diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index fe569bf282d36..c32ddb724e71e 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -8,9 +8,9 @@ use std::ops::{ControlFlow, Range}; use hir::def::{CtorKind, DefKind}; use rustc_abi::{FIRST_VARIANT, FieldIdx, NumScalableVectors, ScalableElt, VariantIdx}; +use rustc_attr_ir::lang_items::LangItem; use rustc_errors::{ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def_id::DefId; use rustc_macros::{StableHash, TyDecodable, TyEncodable, TypeFoldable, extension}; use rustc_span::{DUMMY_SP, Span, Symbol, bug, kw, sym}; diff --git a/compiler/rustc_middle/src/ty/trait_def.rs b/compiler/rustc_middle/src/ty/trait_def.rs index fce9af1c465af..114e5331b8b9b 100644 --- a/compiler/rustc_middle/src/ty/trait_def.rs +++ b/compiler/rustc_middle/src/ty/trait_def.rs @@ -1,10 +1,11 @@ use std::iter; +use rustc_attr_ir::find_attr; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::ErrorGuaranteed; +use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; -use rustc_hir::{self as hir, find_attr}; use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::{Span, bug}; use tracing::debug; diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index a66d15299f16c..ac16d9da6867d 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -4,13 +4,14 @@ use std::{fmt, iter}; use rustc_abi::{Float, Integer, IntegerType, Size}; use rustc_apfloat::Float as _; +use rustc_attr_ir::find_attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hash::{StableHash, StableHasher}; use rustc_errors::ErrorGuaranteed; use rustc_hashes::Hash128; +use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; -use rustc_hir::{self as hir, find_attr}; use rustc_index::bit_set::GrowableBitSet; use rustc_macros::{StableHash, TyDecodable, TyEncodable, extension}; use rustc_span::{bug, span_bug, sym}; diff --git a/compiler/rustc_passes/src/abi_test.rs b/compiler/rustc_passes/src/abi_test.rs index f2b98f1fa2c03..1a2ccc75d0bcf 100644 --- a/compiler/rustc_passes/src/abi_test.rs +++ b/compiler/rustc_passes/src/abi_test.rs @@ -1,7 +1,6 @@ -use rustc_hir::attrs::RustcAbiAttrKind; +use rustc_attr_ir::{RustcAbiAttrKind, find_attr}; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; -use rustc_hir::find_attr; use rustc_middle::ty::layout::{FnAbiError, LayoutError}; use rustc_middle::ty::{self, GenericArgs, Instance, Ty, TyCtxt}; use rustc_span::{Span, span_bug}; diff --git a/compiler/rustc_passes/src/canonical_symbols.rs b/compiler/rustc_passes/src/canonical_symbols.rs index 7a67a46c5a738..afecab452bf3d 100644 --- a/compiler/rustc_passes/src/canonical_symbols.rs +++ b/compiler/rustc_passes/src/canonical_symbols.rs @@ -1,5 +1,5 @@ -use rustc_hir::attrs::CanonicalSymbols; -use rustc_hir::{ForeignItemId, find_attr}; +use rustc_attr_ir::{CanonicalSymbols, find_attr}; +use rustc_hir::ForeignItemId; use rustc_middle::query::{LocalCrate, Providers}; use rustc_middle::ty::{Instance, List, TyCtxt}; use rustc_span::def_id::{DefId, LOCAL_CRATE}; diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index f6bd780802401..4926ec9872d3b 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -10,23 +10,23 @@ use std::slice; use rustc_abi::ExternAbi; use rustc_ast::MetaItemKind; +use rustc_attr_ir::diagnostic::Directive; +use rustc_attr_ir::lang_items::LangItem; +use rustc_attr_ir::target::{AssocCtxt, MethodKind, Target}; +use rustc_attr_ir::{ + Attribute, AttributeKind, DocAttribute, DocInline, EiiDecl, EiiImpl, EiiImplResolution, + InlineAttr, OptimizeAttr, ReprAttr, find_attr, +}; use rustc_attr_parsing::AttributeParser; use rustc_data_structures::thin_vec::ThinVec; use rustc_errors::{DiagCtxtHandle, IntoDiagArg, MultiSpan, msg}; use rustc_feature::BUILTIN_ATTRIBUTE_SET; -use rustc_hir::attrs::diagnostic::Directive; -use rustc_hir::attrs::lang_items::LangItem; -use rustc_hir::attrs::{ - AttributeKind, DocAttribute, DocInline, EiiDecl, EiiImpl, EiiImplResolution, InlineAttr, - OptimizeAttr, ReprAttr, -}; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalModId; use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{ - self as hir, AssocCtxt, Attribute, CRATE_HIR_ID, Constness, FnSig, ForeignItem, GenericParam, - GenericParamKind, HirId, Item, ItemKind, MethodKind, Mod, Node, ParamName, Target, TraitItem, - find_attr, + self as hir, CRATE_HIR_ID, Constness, FnSig, ForeignItem, GenericParam, GenericParamKind, + HirId, Item, ItemKind, Mod, Node, ParamName, TraitItem, }; use rustc_lint_defs::builtin::{ CONFLICTING_REPR_HINTS, INVALID_DOC_ATTRIBUTES, MALFORMED_DIAGNOSTIC_ATTRIBUTES, diff --git a/compiler/rustc_passes/src/debugger_visualizer.rs b/compiler/rustc_passes/src/debugger_visualizer.rs index 91e7c69c2efdb..f5aa163d59a6e 100644 --- a/compiler/rustc_passes/src/debugger_visualizer.rs +++ b/compiler/rustc_passes/src/debugger_visualizer.rs @@ -1,9 +1,8 @@ //! Detecting usage of the `#[debugger_visualizer]` attribute. use rustc_ast::{ItemKind, ast}; +use rustc_attr_ir::{Attribute, AttributeKind, DebugVisualizer}; use rustc_attr_parsing::AttributeParser; -use rustc_hir::Attribute; -use rustc_hir::attrs::{AttributeKind, DebugVisualizer}; use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::query::{LocalCrate, Providers}; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs index 74cd94259f4b4..1f17edb3254e3 100644 --- a/compiler/rustc_passes/src/diagnostic_items.rs +++ b/compiler/rustc_passes/src/diagnostic_items.rs @@ -9,8 +9,9 @@ //! //! * Compiler internal types like `Ty` and `TyCtxt` -use rustc_hir::attrs::diagnostic_items::DiagnosticItems; -use rustc_hir::{CRATE_OWNER_ID, OwnerId, find_attr}; +use rustc_attr_ir::diagnostic_items::DiagnosticItems; +use rustc_attr_ir::find_attr; +use rustc_hir::{CRATE_OWNER_ID, OwnerId}; use rustc_middle::query::{LocalCrate, Providers}; use rustc_middle::ty::TyCtxt; use rustc_span::def_id::{DefId, LOCAL_CRATE}; diff --git a/compiler/rustc_passes/src/eii.rs b/compiler/rustc_passes/src/eii.rs index 05cb10e174d89..4daff2358e87f 100644 --- a/compiler/rustc_passes/src/eii.rs +++ b/compiler/rustc_passes/src/eii.rs @@ -3,8 +3,8 @@ use std::iter; +use rustc_attr_ir::{EiiDecl, EiiImpl}; use rustc_data_structures::fx::FxIndexMap; -use rustc_hir::attrs::{EiiDecl, EiiImpl}; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc_middle::diagnostics::DuplicateEiiImpls; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs index 68be74886a2e4..0306a0bc349af 100644 --- a/compiler/rustc_passes/src/lang_items.rs +++ b/compiler/rustc_passes/src/lang_items.rs @@ -9,9 +9,9 @@ use rustc_ast as ast; use rustc_ast::visit; +use rustc_attr_ir::lang_items::{GenericRequirement, LangItem, LanguageItems}; +use rustc_attr_ir::target::Target; use rustc_crate_store::ExternCrate; -use rustc_hir::Target; -use rustc_hir::attrs::lang_items::{GenericRequirement, LangItem, LanguageItems}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::middle::resolve::ResolverAstLowering; use rustc_middle::query::Providers; diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs index f73916d861f27..961d39ec8e5ca 100644 --- a/compiler/rustc_passes/src/layout_test.rs +++ b/compiler/rustc_passes/src/layout_test.rs @@ -1,8 +1,7 @@ use rustc_abi::{HasDataLayout, TargetDataLayout}; -use rustc_hir::attrs::RustcDumpLayoutKind; +use rustc_attr_ir::{RustcDumpLayoutKind, find_attr}; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; -use rustc_hir::find_attr; use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers}; use rustc_middle::ty::{self, Ty, TyCtxt, Unnormalized}; use rustc_span::{Span, span_bug}; diff --git a/compiler/rustc_passes/src/lib_features.rs b/compiler/rustc_passes/src/lib_features.rs index ceaad91d25982..2420d55545805 100644 --- a/compiler/rustc_passes/src/lib_features.rs +++ b/compiler/rustc_passes/src/lib_features.rs @@ -4,9 +4,8 @@ //! but are not declared in one single location (unlike lang features), which means we need to //! collect them instead. -use rustc_hir::attrs::AttributeKind; +use rustc_attr_ir::{Attribute, AttributeKind, StabilityLevel, StableSince}; use rustc_hir::intravisit::Visitor; -use rustc_hir::{Attribute, StabilityLevel, StableSince}; use rustc_middle::hir::nested_filter; use rustc_middle::middle::lib_features::{FeatureStability, LibFeatures}; use rustc_middle::query::{LocalCrate, Providers}; diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index b2535b4c4d9c0..1148aac51f3e8 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -4,17 +4,19 @@ use std::num::NonZero; use rustc_ast_lowering::stability::extern_abi_stability; +use rustc_attr_ir::{ + AttributeKind, ConstStability, DefaultBodyStability, DeprecatedSince, Stability, + StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER, find_attr, +}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::unord::{ExtendUnord, UnordMap, UnordSet}; use rustc_feature::{EnabledLangFeature, EnabledLibFeature, UNSTABLE_LANG_FEATURES}; -use rustc_hir::attrs::{AttributeKind, DeprecatedSince}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalModId}; use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{ - self as hir, AmbigArg, ConstStability, Constness, DefaultBodyStability, FieldDef, HirId, Item, - ItemKind, Path, Stability, StabilityLevel, StableSince, TraitRef, Ty, TyKind, UnstableReason, - UsePath, VERSION_PLACEHOLDER, Variant, find_attr, + self as hir, AmbigArg, Constness, FieldDef, HirId, Item, ItemKind, Path, TraitRef, Ty, TyKind, + UsePath, Variant, }; use rustc_lint_defs::builtin::{ DEPRECATED, DUPLICATE_FEATURES, INEFFECTIVE_UNSTABLE_REEXPORTS, diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs index e7042767f8bae..42e07bc0eaaee 100644 --- a/compiler/rustc_passes/src/weak_lang_items.rs +++ b/compiler/rustc_passes/src/weak_lang_items.rs @@ -1,8 +1,8 @@ //! Validity checking for weak lang items +use rustc_attr_ir::lang_items::{self, LangItem}; +use rustc_attr_ir::weak_lang_items::WEAK_LANG_ITEMS; use rustc_data_structures::fx::FxHashSet; -use rustc_hir::attrs::lang_items::{self, LangItem}; -use rustc_hir::attrs::weak_lang_items::WEAK_LANG_ITEMS; use rustc_middle::middle::lang_items::required; use rustc_middle::ty::TyCtxt; use rustc_structures::CrateType; diff --git a/compiler/rustc_resolve/Cargo.toml b/compiler/rustc_resolve/Cargo.toml index 19a4ee5a55ff7..a635f7853d971 100644 --- a/compiler/rustc_resolve/Cargo.toml +++ b/compiler/rustc_resolve/Cargo.toml @@ -13,6 +13,7 @@ pulldown-cmark = { version = "0.11", features = [ rustc_arena = { path = "../rustc_arena" } rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_attr_parsing = { path = "../rustc_attr_parsing" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 89ea973cb3ff8..ee35d23691628 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -2,11 +2,10 @@ use std::mem; use rustc_ast::visit::FnKind; use rustc_ast::*; -use rustc_attr_parsing as attr; +use rustc_attr_ir::target::Target; use rustc_attr_parsing::{AttributeParser, ShouldEmit}; use rustc_expand::expand::AstFragment; use rustc_hir as hir; -use rustc_hir::Target; use rustc_hir::def::DefKind; use rustc_hir::def::Namespace::{TypeNS, ValueNS}; use rustc_hir::def_id::LocalDefId; @@ -558,7 +557,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { let orig_in_attr = mem::replace(&mut self.invocation_parent.in_attr, true); match &attr.kind { AttrKind::Normal(normal) => { - if attr::is_builtin_attr(&normal.item) { + if rustc_attr_parsing::is_builtin_attr(&normal.item) { self.r .builtin_attrs .push((normal.item.path.segments[0].ident, self.parent_scope)); diff --git a/compiler/rustc_symbol_mangling/Cargo.toml b/compiler/rustc_symbol_mangling/Cargo.toml index bb79bb3ece781..1e078015257d7 100644 --- a/compiler/rustc_symbol_mangling/Cargo.toml +++ b/compiler/rustc_symbol_mangling/Cargo.toml @@ -8,6 +8,7 @@ edition = "2024" punycode = "0.4.0" rustc-demangle = "0.1.28" rustc_abi = { path = "../rustc_abi" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_hashes = { path = "../rustc_hashes" } rustc_hir = { path = "../rustc_hir" } diff --git a/compiler/rustc_symbol_mangling/src/test.rs b/compiler/rustc_symbol_mangling/src/test.rs index a4364cc20b68e..646a916fb5085 100644 --- a/compiler/rustc_symbol_mangling/src/test.rs +++ b/compiler/rustc_symbol_mangling/src/test.rs @@ -4,7 +4,8 @@ //! def-path. This is used for unit testing the code that generates //! paths etc in all kinds of annoying scenarios. -use rustc_hir::{CRATE_OWNER_ID, find_attr}; +use rustc_attr_ir::find_attr; +use rustc_hir::CRATE_OWNER_ID; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{GenericArgs, Instance, TyCtxt}; diff --git a/compiler/rustc_transmute/Cargo.toml b/compiler/rustc_transmute/Cargo.toml index 5da9435e77e63..55e2f7e99b869 100644 --- a/compiler/rustc_transmute/Cargo.toml +++ b/compiler/rustc_transmute/Cargo.toml @@ -6,8 +6,8 @@ edition = "2024" [dependencies] # tidy-alphabetical-start rustc_abi = { path = "../rustc_abi", optional = true } +rustc_attr_ir = { path = "../rustc_attr_ir", optional = true } rustc_data_structures = { path = "../rustc_data_structures" } -rustc_hir = { path = "../rustc_hir", optional = true } rustc_middle = { path = "../rustc_middle", optional = true } rustc_span = { path = "../rustc_span", optional = true } smallvec = "1.8.1" @@ -23,7 +23,7 @@ itertools = "0.15" # tidy-alphabetical-start rustc = [ "dep:rustc_abi", - "dep:rustc_hir", + "dep:rustc_attr_ir", "dep:rustc_middle", "dep:rustc_span", ] diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 53287dbe331ee..cb5a76b51df1b 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -103,7 +103,7 @@ pub enum Reason { #[cfg(feature = "rustc")] mod rustc { - use rustc_hir::attrs::lang_items::LangItem; + use rustc_attr_ir::lang_items::LangItem; use rustc_middle::ty::consts::ConstExt; use rustc_middle::ty::{Const, Region, Ty, TyCtxt}; diff --git a/compiler/rustc_ty_utils/Cargo.toml b/compiler/rustc_ty_utils/Cargo.toml index e6de7bd1fab24..5ac4d72a6c573 100644 --- a/compiler/rustc_ty_utils/Cargo.toml +++ b/compiler/rustc_ty_utils/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" # tidy-alphabetical-start itertools = "0.15" rustc_abi = { path = "../rustc_abi" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_hashes = { path = "../rustc_hashes" } diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 55140d2c5458d..bcba5839926db 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -2,7 +2,7 @@ use std::{assert_matches, iter}; use rustc_abi::Primitive::Pointer; use rustc_abi::{Align, BackendRepr, ExternAbi, PointerKind, Scalar, Size}; -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; use rustc_hir::{self as hir, find_attr}; use rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs; use rustc_middle::query::Providers; diff --git a/compiler/rustc_ty_utils/src/common_traits.rs b/compiler/rustc_ty_utils/src/common_traits.rs index 4d25a2886fa27..48e2a68bec7f6 100644 --- a/compiler/rustc_ty_utils/src/common_traits.rs +++ b/compiler/rustc_ty_utils/src/common_traits.rs @@ -1,6 +1,6 @@ //! Queries for checking whether a type implements one of a few common traits. -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::query::Providers; use rustc_middle::ty::{self, Ty, TyCtxt}; diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index f0f0a66a8eeba..9a41caafc6da6 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::lang_items::LangItem; use rustc_errors::ErrorGuaranteed; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_infer::infer::TyCtxtInferExt; diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index dee4b785e418d..43af74d10aba7 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -9,9 +9,9 @@ use rustc_abi::{ LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size, StructKind, TagEncoding, VariantIdx, Variants, WrappingRange, }; +use rustc_attr_ir::lang_items::LangItem; use rustc_hashes::Hash64; use rustc_hir as hir; -use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::find_attr; use rustc_index::{Idx as _, IndexVec}; use rustc_middle::query::Providers; diff --git a/compiler/rustc_ty_utils/src/structural_match.rs b/compiler/rustc_ty_utils/src/structural_match.rs index 85d13cfda743b..7dd596fa5bdfc 100644 --- a/compiler/rustc_ty_utils/src/structural_match.rs +++ b/compiler/rustc_ty_utils/src/structural_match.rs @@ -1,4 +1,4 @@ -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::query::Providers; use rustc_middle::ty::{self, Ty, TyCtxt, TypingMode}; diff --git a/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs b/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs index e3b1a05bda7dd..ff929df0acded 100644 --- a/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs +++ b/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs @@ -2,7 +2,7 @@ use super::DEPRECATED_SEMVER; use clippy_utils::diagnostics::span_lint; use clippy_utils::sym; use rustc_ast::{LitKind, MetaItemLit}; -use rustc_hir::VERSION_PLACEHOLDER; +use rustc_attr_ir::VERSION_PLACEHOLDER; use rustc_lint::EarlyContext; use rustc_span::Span; use semver::Version; diff --git a/src/tools/clippy/clippy_lints/src/missing_doc.rs b/src/tools/clippy/clippy_lints/src/missing_doc.rs index af2c84737c655..2ef893edd4236 100644 --- a/src/tools/clippy/clippy_lints/src/missing_doc.rs +++ b/src/tools/clippy/clippy_lints/src/missing_doc.rs @@ -1,11 +1,9 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint; use clippy_utils::{is_doc_hidden, is_from_proc_macro}; -use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::{AttrArgs, Attribute, AttributeKind}; use rustc_hir::def_id::LocalDefId; -use rustc_hir::{ - AttrArgs, Attribute, Body, BodyId, FieldDef, HirId, ImplItem, Item, ItemKind, Node, TraitItem, Variant, -}; +use rustc_hir::{Body, BodyId, FieldDef, HirId, ImplItem, Item, ItemKind, Node, TraitItem, Variant}; use rustc_lint::{LateContext, LateLintPass, impl_lint_pass}; use rustc_middle::middle::privacy::Level; use rustc_middle::ty::Visibility; diff --git a/tests/ui-fulldeps/internal-lints/find_attr.rs b/tests/ui-fulldeps/internal-lints/find_attr.rs index 90b9b96ba54ef..f2ee921c731f4 100644 --- a/tests/ui-fulldeps/internal-lints/find_attr.rs +++ b/tests/ui-fulldeps/internal-lints/find_attr.rs @@ -4,9 +4,9 @@ #![feature(rustc_private)] #![deny(rustc::bad_use_of_find_attr)] -extern crate rustc_hir; +extern crate rustc_attr_ir; -use rustc_hir::{attrs::AttributeKind, find_attr}; +use rustc_attr_ir::{AttributeKind, find_attr}; fn main() { let attrs = &[]; diff --git a/tests/ui-fulldeps/polymorphic-drop-glue.rs b/tests/ui-fulldeps/polymorphic-drop-glue.rs index 861c7c74b705c..4d85d342d7395 100644 --- a/tests/ui-fulldeps/polymorphic-drop-glue.rs +++ b/tests/ui-fulldeps/polymorphic-drop-glue.rs @@ -6,6 +6,7 @@ //@ ignore-backends: gcc #![feature(rustc_private)] +extern crate rustc_attr_ir; extern crate rustc_driver; extern crate rustc_hir; extern crate rustc_interface; @@ -16,7 +17,7 @@ extern crate rustc_span; use std::process::ExitCode; use rustc_driver::Compilation; -use rustc_hir::attrs::lang_items::LangItem; +use rustc_attr_ir::lang_items::LangItem; use rustc_hir::def::DefKind; use rustc_interface::interface::Compiler; use rustc_middle::ty::{self, TyCtxt};