Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rust
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: Manishearth/rust
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: alloc-error-handler
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 1 commit
  • 12 files changed
  • 1 contributor

Commits on Apr 23, 2023

  1. Copy the full SHA
    bdd480a View commit details
13 changes: 13 additions & 0 deletions compiler/rustc_builtin_macros/src/alloc_error_handler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::Span;

pub fn expand(
_ecx: &mut ExtCtxt<'_>,
_span: Span,
_meta_item: &rustc_ast::MetaItem,
item: Annotatable,
) -> Vec<Annotatable> {

vec![item.clone()]
}

2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ use rustc_expand::proc_macro::BangProcMacro;
use rustc_fluent_macro::fluent_messages;
use rustc_span::symbol::sym;

mod alloc_error_handler;
mod assert;
mod cfg;
mod cfg_accessible;
@@ -103,6 +104,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
}

register_attr! {
alloc_error_handler: alloc_error_handler::expand,
bench: test::expand_bench,
cfg_accessible: cfg_accessible::Expander,
cfg_eval: cfg_eval::expand,
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
@@ -291,6 +291,8 @@ declare_features! (
(active, abi_x86_interrupt, "1.17.0", Some(40180), None),
/// Allows additional const parameter types, such as `&'static str` or user defined types
(incomplete, adt_const_params, "1.56.0", Some(95174), None),
/// Deprecated feature; exists for smooth transitions
(active, alloc_error_handler, "1.29.0", Some(51540), None),
/// Allows trait methods with arbitrary self types.
(active, arbitrary_self_types, "1.23.0", Some(44874), None),
/// Allows using `const` operands in inline assembly.
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
@@ -47,8 +47,6 @@ declare_features! (

(removed, advanced_slice_patterns, "1.0.0", Some(62254), None,
Some("merged into `#![feature(slice_patterns)]`")),
/// Allows defining an `#[alloc_error_handler]`.
(removed, alloc_error_handler, "CURRENT_RUSTC_VERSION", Some(51540), None, Some("now handled by panic handler")),
(removed, allocator, "1.0.0", None, None, None),
/// Allows a test to fail without failing the whole suite.
(removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")),
9 changes: 9 additions & 0 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
@@ -1531,6 +1531,15 @@ pub(crate) mod builtin {
/* compiler built-in */
}

/// Deprecated attribute for functionality now handled by panic_handler
#[unstable(feature = "alloc_error_handler", issue = "51540")]
#[deprecated(since = "1.71", note = "Please use #[panic_handler] instead")]
#[allow_internal_unstable(rustc_attrs)]
#[rustc_builtin_macro]
pub macro alloc_error_handler($item:item) {
/* compiler built-in */
}

/// Keeps the item it's applied to if the passed path is accessible, and removes it otherwise.
#[unstable(
feature = "cfg_accessible",
3 changes: 2 additions & 1 deletion library/core/src/prelude/v1.rs
Original file line number Diff line number Diff line change
@@ -76,7 +76,8 @@ pub use crate::macros::builtin::{RustcDecodable, RustcEncodable};
// Do not `doc(no_inline)` so that they become doc items on their own
// (no public module for them to be re-exported from).
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
pub use crate::macros::builtin::{bench, derive, global_allocator, test, test_case};
#[allow(deprecated)]
pub use crate::macros::builtin::{alloc_error_handler, bench, derive, global_allocator, test, test_case};

#[unstable(feature = "derive_const", issue = "none")]
pub use crate::macros::builtin::derive_const;
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
@@ -236,6 +236,7 @@
//
// Language features:
// tidy-alphabetical-start
#![feature(alloc_error_handler)]
#![feature(allocator_internals)]
#![feature(allow_internal_unsafe)]
#![feature(allow_internal_unstable)]
3 changes: 2 additions & 1 deletion library/std/src/prelude/v1.rs
Original file line number Diff line number Diff line change
@@ -60,7 +60,8 @@ pub use core::prelude::v1::{RustcDecodable, RustcEncodable};
// Do not `doc(no_inline)` so that they become doc items on their own
// (no public module for them to be re-exported from).
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
pub use core::prelude::v1::{bench, derive, global_allocator, test, test_case};
#[allow(deprecated)]
pub use core::prelude::v1::{alloc_error_handler, bench, derive, global_allocator, test, test_case};

#[unstable(feature = "derive_const", issue = "none")]
pub use core::prelude::v1::derive_const;
13 changes: 13 additions & 0 deletions tests/ui/alloc-error/alloc-error-handler-deprecated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![feature(alloc_error_handler)]
#![deny(deprecated)]


extern crate alloc;
use alloc::layout::Layout;

#[alloc_error_handler]
fn alloc_error(_l: Layout) -> ! {
loop {}
}

fn main() {}
21 changes: 21 additions & 0 deletions tests/ui/alloc-error/alloc-error-handler-deprecated.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0432]: unresolved import `alloc::layout`
--> $DIR/alloc-error-handler-deprecated.rs:6:12
|
LL | use alloc::layout::Layout;
| ^^^^^^ could not find `layout` in `alloc`

error: use of deprecated macro `alloc_error_handler`: Please use #[panic_handler] instead
--> $DIR/alloc-error-handler-deprecated.rs:8:3
|
LL | #[alloc_error_handler]
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/alloc-error-handler-deprecated.rs:2:9
|
LL | #![deny(deprecated)]
| ^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0432`.
16 changes: 16 additions & 0 deletions tests/ui/feature-gates/feature-gate-alloc-error-handler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// compile-flags:-C panic=abort

#![no_std]
#![no_main]

use core::alloc::Layout;

#[alloc_error_handler] //~ ERROR use of unstable library feature 'alloc_error_handler'
fn oom(info: Layout) -> ! {
loop {}
}

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
loop {}
}
20 changes: 20 additions & 0 deletions tests/ui/feature-gates/feature-gate-alloc-error-handler.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0658]: use of unstable library feature 'alloc_error_handler'
--> $DIR/feature-gate-alloc-error-handler.rs:8:3
|
LL | #[alloc_error_handler]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #51540 <https://github.com/rust-lang/rust/issues/51540> for more information
= help: add `#![feature(alloc_error_handler)]` to the crate attributes to enable

warning: use of deprecated macro `alloc_error_handler`: Please use #[panic_handler] instead
--> $DIR/feature-gate-alloc-error-handler.rs:8:3
|
LL | #[alloc_error_handler]
| ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.