From a774c81f9855f75a1a86f71a851b373d2178d9e9 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 23 Aug 2018 00:40:32 +0200 Subject: [PATCH 1/4] add #[panic_handler]; deprecate #[panic_implementation] --- src/librustc/middle/dead.rs | 4 +++- src/librustc/middle/lang_items.rs | 4 +++- src/librustc/middle/weak_lang_items.rs | 2 +- src/librustc_typeck/check/mod.rs | 3 +-- src/libstd/lib.rs | 3 ++- src/libstd/panicking.rs | 3 ++- src/libsyntax/feature_gate.rs | 18 +++++++++++---- .../compile-fail/auxiliary/some-panic-impl.rs | 4 ++-- ...on-missing.rs => panic-handler-missing.rs} | 2 +- ...tation-twice.rs => panic-handler-twice.rs} | 4 ++-- src/test/compile-fail/weak-lang-item.rs | 2 +- src/test/run-make-fulldeps/issue-51671/app.rs | 4 ++-- .../panic-impl-provider.rs | 4 ++-- .../run-make/wasm-symbols-not-exported/bar.rs | 4 ++-- .../alloc-error-handler-bad-signature-1.rs | 4 ++-- .../alloc-error-handler-bad-signature-2.rs | 4 ++-- .../alloc-error-handler-bad-signature-3.rs | 4 ++-- ...ation.rs => feature-gate-panic-handler.rs} | 2 +- .../feature-gate-panic-handler.stderr | 11 +++++++++ .../feature-gate-panic-implementation.stderr | 11 --------- .../ui/missing/missing-alloc_error_handler.rs | 4 ++-- src/test/ui/missing/missing-allocator.rs | 4 ++-- .../auxiliary/some-panic-impl.rs | 4 ++-- .../panic-handler-bad-signature-1.rs} | 4 ++-- .../panic-handler-bad-signature-1.stderr} | 4 ++-- .../panic-handler-bad-signature-2.rs} | 4 ++-- .../panic-handler-bad-signature-2.stderr} | 2 +- .../panic-handler-bad-signature-3.rs} | 4 ++-- .../panic-handler-bad-signature-3.stderr} | 2 +- .../panic-handler-bad-signature-4.rs | 23 +++++++++++++++++++ .../panic-handler-bad-signature-4.stderr | 11 +++++++++ .../panic-handler-duplicate.rs} | 4 ++-- .../panic-handler-duplicate.stderr} | 4 ++-- .../panic-handler-requires-panic-info.rs} | 4 ++-- .../panic-handler-requires-panic-info.stderr} | 0 .../panic-handler-std.rs} | 4 ++-- .../panic-handler-std.stderr} | 2 +- ...anic-implementation-bad-signature-4.stderr | 11 --------- ....rs => panic-implementation-deprecated.rs} | 7 +++--- .../panic-implementation-deprecated.stderr | 14 +++++++++++ src/test/ui/panic_implementation-closures.rs | 4 ++-- 41 files changed, 134 insertions(+), 83 deletions(-) rename src/test/compile-fail/{panic-implementation-missing.rs => panic-handler-missing.rs} (87%) rename src/test/compile-fail/{panic-implementation-twice.rs => panic-handler-twice.rs} (92%) rename src/test/ui/feature-gates/{feature-gate-panic-implementation.rs => feature-gate-panic-handler.rs} (85%) create mode 100644 src/test/ui/feature-gates/feature-gate-panic-handler.stderr delete mode 100644 src/test/ui/feature-gates/feature-gate-panic-implementation.stderr rename src/test/ui/{panic-implementation => panic-handler}/auxiliary/some-panic-impl.rs (91%) rename src/test/ui/{panic-implementation/panic-implementation-bad-signature-1.rs => panic-handler/panic-handler-bad-signature-1.rs} (92%) rename src/test/ui/{panic-implementation/panic-implementation-bad-signature-1.stderr => panic-handler/panic-handler-bad-signature-1.stderr} (71%) rename src/test/ui/{panic-implementation/panic-implementation-bad-signature-2.rs => panic-handler/panic-handler-bad-signature-2.rs} (91%) rename src/test/ui/{panic-implementation/panic-implementation-bad-signature-2.stderr => panic-handler/panic-handler-bad-signature-2.stderr} (77%) rename src/test/ui/{panic-implementation/panic-implementation-bad-signature-3.rs => panic-handler/panic-handler-bad-signature-3.rs} (91%) rename src/test/ui/{panic-implementation/panic-implementation-bad-signature-3.stderr => panic-handler/panic-handler-bad-signature-3.stderr} (77%) create mode 100644 src/test/ui/panic-handler/panic-handler-bad-signature-4.rs create mode 100644 src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr rename src/test/ui/{panic-implementation/panic-implementation-duplicate.rs => panic-handler/panic-handler-duplicate.rs} (92%) rename src/test/ui/{panic-implementation/panic-implementation-duplicate.stderr => panic-handler/panic-handler-duplicate.stderr} (80%) rename src/test/ui/{panic-implementation/panic-implementation-requires-panic-info.rs => panic-handler/panic-handler-requires-panic-info.rs} (92%) rename src/test/ui/{panic-implementation/panic-implementation-requires-panic-info.stderr => panic-handler/panic-handler-requires-panic-info.stderr} (100%) rename src/test/ui/{panic-implementation/panic-implementation-std.rs => panic-handler/panic-handler-std.rs} (91%) rename src/test/ui/{panic-implementation/panic-implementation-std.stderr => panic-handler/panic-handler-std.stderr} (86%) delete mode 100644 src/test/ui/panic-implementation/panic-implementation-bad-signature-4.stderr rename src/test/ui/panic-implementation/{panic-implementation-bad-signature-4.rs => panic-implementation-deprecated.rs} (82%) create mode 100644 src/test/ui/panic-implementation/panic-implementation-deprecated.stderr diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index ba04842ac7c0a..30701654f299d 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -293,7 +293,9 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt, } // (To be) stable attribute for #[lang = "panic_impl"] - if attr::contains_name(attrs, "panic_implementation") { + if attr::contains_name(attrs, "panic_implementation") || + attr::contains_name(attrs, "panic_handler") + { return true; } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 8c300a0aba0ec..d92f856fa4dbf 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -185,7 +185,9 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> { if let Some(value) = attribute.value_str() { return Some((value, attribute.span)); } - } else if attribute.check_name("panic_implementation") { + } else if attribute.check_name("panic_implementation") || + attribute.check_name("panic_handler") + { return Some((Symbol::intern("panic_impl"), attribute.span)) } else if attribute.check_name("alloc_error_handler") { return Some((Symbol::intern("oom"), attribute.span)) diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index e8431ce3e109b..bfc27e3b5806c 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -113,7 +113,7 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, !whitelisted(tcx, lang_items::$item) && items.$name().is_none() { if lang_items::$item == lang_items::PanicImplLangItem { - tcx.sess.err(&format!("`#[panic_implementation]` function required, \ + tcx.sess.err(&format!("`#[panic_handler]` function required, \ but not found")); } else if lang_items::$item == lang_items::OomLangItem { tcx.sess.err(&format!("`#[alloc_error_handler]` function required, \ diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index db4dda0da5b4e..4fe0212ce366b 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1171,8 +1171,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, - "`#[panic_implementation]` function should have no type \ - parameters", + "should have no type parameters", ); } } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index ade297219d221..b20c51d823e9a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -310,7 +310,8 @@ #![feature(doc_alias)] #![feature(doc_keyword)] #![feature(panic_info_message)] -#![feature(panic_implementation)] +#![cfg_attr(stage0, feature(panic_implementation))] +#![cfg_attr(not(stage0), feature(panic_handler))] #![feature(non_exhaustive)] #![default_lib_allocator] diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 862f0fd71b0a3..6eb2db8e63bfe 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -319,7 +319,8 @@ pub fn panicking() -> bool { /// Entry point of panic from the libcore crate. #[cfg(not(test))] -#[panic_implementation] +#[cfg_attr(stage0, panic_implementation)] +#[cfg_attr(not(stage0), panic_handler)] #[unwind(allowed)] pub fn rust_begin_panic(info: &PanicInfo) -> ! { continue_panic_fmt(&info) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 1ffb6e55f06e3..04066f687fc7b 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -472,8 +472,9 @@ declare_features! ( // Integer match exhaustiveness checking (active, exhaustive_integer_patterns, "1.30.0", Some(50907), None), - // #[panic_implementation] + // RFC 2070: #[panic_implementation] / #[panic_handler] (active, panic_implementation, "1.28.0", Some(44489), None), + (active, panic_handler, "1.30.0", Some(44489), None), // #[doc(keyword = "...")] (active, doc_keyword, "1.28.0", Some(51315), None), @@ -1104,11 +1105,18 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "infer 'static lifetime requirements", cfg_fn!(infer_static_outlives_requirements))), + // RFC 2070 (deprecated attribute name) + ("panic_implementation", + Normal, Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224"), + "panic_implementation", + "This attribute was renamed to `panic_handler`", + cfg_fn!(panic_implementation))), + // RFC 2070 - ("panic_implementation", Normal, Gated(Stability::Unstable, - "panic_implementation", - "#[panic_implementation] is an unstable feature", - cfg_fn!(panic_implementation))), + ("panic_handler", Normal, Gated(Stability::Unstable, + "panic_handler", + "#[panic_handler] is an unstable feature", + cfg_fn!(panic_handler))), ("alloc_error_handler", Normal, Gated(Stability::Unstable, "alloc_error_handler", diff --git a/src/test/compile-fail/auxiliary/some-panic-impl.rs b/src/test/compile-fail/auxiliary/some-panic-impl.rs index db16ac325ac59..e3b4fba176e3c 100644 --- a/src/test/compile-fail/auxiliary/some-panic-impl.rs +++ b/src/test/compile-fail/auxiliary/some-panic-impl.rs @@ -11,12 +11,12 @@ // no-prefer-dynamic #![crate_type = "rlib"] -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_std] use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic(info: &PanicInfo) -> ! { loop {} } diff --git a/src/test/compile-fail/panic-implementation-missing.rs b/src/test/compile-fail/panic-handler-missing.rs similarity index 87% rename from src/test/compile-fail/panic-implementation-missing.rs rename to src/test/compile-fail/panic-handler-missing.rs index b11081a3e3bbe..d17c19b4c1308 100644 --- a/src/test/compile-fail/panic-implementation-missing.rs +++ b/src/test/compile-fail/panic-handler-missing.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: `#[panic_implementation]` function required, but not found +// error-pattern: `#[panic_handler]` function required, but not found #![feature(lang_items)] #![no_main] diff --git a/src/test/compile-fail/panic-implementation-twice.rs b/src/test/compile-fail/panic-handler-twice.rs similarity index 92% rename from src/test/compile-fail/panic-implementation-twice.rs rename to src/test/compile-fail/panic-handler-twice.rs index 78dc545c036f8..6c9515ca90994 100644 --- a/src/test/compile-fail/panic-implementation-twice.rs +++ b/src/test/compile-fail/panic-handler-twice.rs @@ -10,7 +10,7 @@ // aux-build:some-panic-impl.rs -#![feature(panic_implementation)] +#![feature(panic_handler)] #![feature(lang_items)] #![no_std] #![no_main] @@ -19,7 +19,7 @@ extern crate some_panic_impl; use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic(info: &PanicInfo) -> ! { //~^ error duplicate lang item found: `panic_impl` loop {} diff --git a/src/test/compile-fail/weak-lang-item.rs b/src/test/compile-fail/weak-lang-item.rs index 42972c40674b6..493c708018177 100644 --- a/src/test/compile-fail/weak-lang-item.rs +++ b/src/test/compile-fail/weak-lang-item.rs @@ -9,7 +9,7 @@ // except according to those terms. // aux-build:weak-lang-items.rs -// error-pattern: `#[panic_implementation]` function required, but not found +// error-pattern: `#[panic_handler]` function required, but not found // error-pattern: language item required, but not found: `eh_personality` // ignore-wasm32-bare compiled with panic=abort, personality not required diff --git a/src/test/run-make-fulldeps/issue-51671/app.rs b/src/test/run-make-fulldeps/issue-51671/app.rs index 453602b800b5e..e980b12039e96 100644 --- a/src/test/run-make-fulldeps/issue-51671/app.rs +++ b/src/test/run-make-fulldeps/issue-51671/app.rs @@ -10,14 +10,14 @@ #![crate_type = "bin"] #![feature(lang_items)] -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_main] #![no_std] use core::alloc::Layout; use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic(_: &PanicInfo) -> ! { loop {} } diff --git a/src/test/run-make-fulldeps/panic-impl-transitive/panic-impl-provider.rs b/src/test/run-make-fulldeps/panic-impl-transitive/panic-impl-provider.rs index 46cdf2e2fa55e..065b2b6bf18fa 100644 --- a/src/test/run-make-fulldeps/panic-impl-transitive/panic-impl-provider.rs +++ b/src/test/run-make-fulldeps/panic-impl-transitive/panic-impl-provider.rs @@ -9,12 +9,12 @@ // except according to those terms. #![crate_type = "rlib"] -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_std] use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic(info: &PanicInfo) -> ! { loop {} } diff --git a/src/test/run-make/wasm-symbols-not-exported/bar.rs b/src/test/run-make/wasm-symbols-not-exported/bar.rs index 979ec44b04077..061280779b0cf 100644 --- a/src/test/run-make/wasm-symbols-not-exported/bar.rs +++ b/src/test/run-make/wasm-symbols-not-exported/bar.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(panic_implementation, alloc_error_handler)] +#![feature(panic_handler, alloc_error_handler)] #![crate_type = "cdylib"] #![no_std] @@ -39,7 +39,7 @@ fn a(_: core::alloc::Layout) -> ! { loop {} } -#[panic_implementation] +#[panic_handler] fn b(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs index e398f16a065bd..0a54ae8341bbf 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.rs @@ -10,7 +10,7 @@ // compile-flags:-C panic=abort -#![feature(alloc_error_handler, panic_implementation)] +#![feature(alloc_error_handler, panic_handler)] #![no_std] #![no_main] @@ -24,5 +24,5 @@ fn oom( loop {} } -#[panic_implementation] +#[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs index 4fee9d27e5175..b33d82cd55008 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.rs @@ -10,7 +10,7 @@ // compile-flags:-C panic=abort -#![feature(alloc_error_handler, panic_implementation)] +#![feature(alloc_error_handler, panic_handler)] #![no_std] #![no_main] @@ -23,5 +23,5 @@ fn oom( loop {} } -#[panic_implementation] +#[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs index 828a78055d5f2..0e102dd08ea5d 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs @@ -10,7 +10,7 @@ // compile-flags:-C panic=abort -#![feature(alloc_error_handler, panic_implementation)] +#![feature(alloc_error_handler, panic_handler)] #![no_std] #![no_main] @@ -21,5 +21,5 @@ fn oom() -> ! { //~ ERROR function should have one argument loop {} } -#[panic_implementation] +#[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/feature-gates/feature-gate-panic-implementation.rs b/src/test/ui/feature-gates/feature-gate-panic-handler.rs similarity index 85% rename from src/test/ui/feature-gates/feature-gate-panic-implementation.rs rename to src/test/ui/feature-gates/feature-gate-panic-handler.rs index ae9fbc7b13bd5..fd16268ef8b4e 100644 --- a/src/test/ui/feature-gates/feature-gate-panic-implementation.rs +++ b/src/test/ui/feature-gates/feature-gate-panic-handler.rs @@ -15,7 +15,7 @@ use core::panic::PanicInfo; -#[panic_implementation] //~ ERROR #[panic_implementation] is an unstable feature (see issue #44489) +#[panic_handler] //~ ERROR #[panic_handler] is an unstable feature (see issue #44489) fn panic(info: &PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/feature-gates/feature-gate-panic-handler.stderr b/src/test/ui/feature-gates/feature-gate-panic-handler.stderr new file mode 100644 index 0000000000000..9680a240a9925 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-panic-handler.stderr @@ -0,0 +1,11 @@ +error[E0658]: #[panic_handler] is an unstable feature (see issue #44489) + --> $DIR/feature-gate-panic-handler.rs:18:1 + | +LL | #[panic_handler] //~ ERROR #[panic_handler] is an unstable feature (see issue #44489) + | ^^^^^^^^^^^^^^^^ + | + = help: add #![feature(panic_handler)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr b/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr deleted file mode 100644 index f99228bef1d62..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: #[panic_implementation] is an unstable feature (see issue #44489) - --> $DIR/feature-gate-panic-implementation.rs:18:1 - | -LL | #[panic_implementation] //~ ERROR #[panic_implementation] is an unstable feature (see issue #44489) - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(panic_implementation)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/missing/missing-alloc_error_handler.rs b/src/test/ui/missing/missing-alloc_error_handler.rs index 3842d48f8fab1..1096027c8dc0b 100644 --- a/src/test/ui/missing/missing-alloc_error_handler.rs +++ b/src/test/ui/missing/missing-alloc_error_handler.rs @@ -13,9 +13,9 @@ #![no_std] #![crate_type = "staticlib"] -#![feature(panic_implementation, alloc_error_handler, alloc)] +#![feature(panic_handler, alloc_error_handler, alloc)] -#[panic_implementation] +#[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/missing/missing-allocator.rs b/src/test/ui/missing/missing-allocator.rs index c949dcb635aad..f4331c4b99480 100644 --- a/src/test/ui/missing/missing-allocator.rs +++ b/src/test/ui/missing/missing-allocator.rs @@ -13,9 +13,9 @@ #![no_std] #![crate_type = "staticlib"] -#![feature(panic_implementation, alloc_error_handler, alloc)] +#![feature(panic_handler, alloc_error_handler, alloc)] -#[panic_implementation] +#[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/panic-implementation/auxiliary/some-panic-impl.rs b/src/test/ui/panic-handler/auxiliary/some-panic-impl.rs similarity index 91% rename from src/test/ui/panic-implementation/auxiliary/some-panic-impl.rs rename to src/test/ui/panic-handler/auxiliary/some-panic-impl.rs index db16ac325ac59..e3b4fba176e3c 100644 --- a/src/test/ui/panic-implementation/auxiliary/some-panic-impl.rs +++ b/src/test/ui/panic-handler/auxiliary/some-panic-impl.rs @@ -11,12 +11,12 @@ // no-prefer-dynamic #![crate_type = "rlib"] -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_std] use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic(info: &PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-1.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-1.rs similarity index 92% rename from src/test/ui/panic-implementation/panic-implementation-bad-signature-1.rs rename to src/test/ui/panic-handler/panic-handler-bad-signature-1.rs index fec11fdbd7ba1..cc7e337fc9e65 100644 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-1.rs +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-1.rs @@ -10,13 +10,13 @@ // compile-flags:-C panic=abort -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_std] #![no_main] use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic( info: PanicInfo, //~ ERROR argument should be `&PanicInfo` ) -> () //~ ERROR return type should be `!` diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-1.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr similarity index 71% rename from src/test/ui/panic-implementation/panic-implementation-bad-signature-1.stderr rename to src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr index 0e020fbc78b81..5771f4277b46d 100644 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-1.stderr +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr @@ -1,11 +1,11 @@ error: return type should be `!` - --> $DIR/panic-implementation-bad-signature-1.rs:22:6 + --> $DIR/panic-handler-bad-signature-1.rs:22:6 | LL | ) -> () //~ ERROR return type should be `!` | ^^ error: argument should be `&PanicInfo` - --> $DIR/panic-implementation-bad-signature-1.rs:21:11 + --> $DIR/panic-handler-bad-signature-1.rs:21:11 | LL | info: PanicInfo, //~ ERROR argument should be `&PanicInfo` | ^^^^^^^^^ diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-2.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-2.rs similarity index 91% rename from src/test/ui/panic-implementation/panic-implementation-bad-signature-2.rs rename to src/test/ui/panic-handler/panic-handler-bad-signature-2.rs index 2a628c05699cc..ec698903c846e 100644 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-2.rs +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-2.rs @@ -10,13 +10,13 @@ // compile-flags:-C panic=abort -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_std] #![no_main] use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic( info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo` ) -> ! diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-2.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr similarity index 77% rename from src/test/ui/panic-implementation/panic-implementation-bad-signature-2.stderr rename to src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr index 71ed1efdcf2b8..4823f8a2781b0 100644 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-2.stderr +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr @@ -1,5 +1,5 @@ error: argument should be `&PanicInfo` - --> $DIR/panic-implementation-bad-signature-2.rs:21:11 + --> $DIR/panic-handler-bad-signature-2.rs:21:11 | LL | info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo` | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-3.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-3.rs similarity index 91% rename from src/test/ui/panic-implementation/panic-implementation-bad-signature-3.rs rename to src/test/ui/panic-handler/panic-handler-bad-signature-3.rs index 29337025b7076..585716c7c7569 100644 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-3.rs +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-3.rs @@ -10,13 +10,13 @@ // compile-flags:-C panic=abort -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_std] #![no_main] use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic() -> ! { //~ ERROR function should have one argument loop {} } diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-3.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr similarity index 77% rename from src/test/ui/panic-implementation/panic-implementation-bad-signature-3.stderr rename to src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr index 3fd29bcd3e998..0eb0d4e10004b 100644 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-3.stderr +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr @@ -1,5 +1,5 @@ error: function should have one argument - --> $DIR/panic-implementation-bad-signature-3.rs:20:1 + --> $DIR/panic-handler-bad-signature-3.rs:20:1 | LL | / fn panic() -> ! { //~ ERROR function should have one argument LL | | loop {} diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-4.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-4.rs new file mode 100644 index 0000000000000..9cda37f27b332 --- /dev/null +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-4.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(panic_handler)] +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(pi: &PanicInfo) -> ! { + //~^ ERROR should have no type parameters + loop {} +} diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr new file mode 100644 index 0000000000000..a61b9b3743c7d --- /dev/null +++ b/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr @@ -0,0 +1,11 @@ +error: should have no type parameters + --> $DIR/panic-handler-bad-signature-4.rs:20:1 + | +LL | / fn panic(pi: &PanicInfo) -> ! { +LL | | //~^ ERROR should have no type parameters +LL | | loop {} +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/panic-implementation/panic-implementation-duplicate.rs b/src/test/ui/panic-handler/panic-handler-duplicate.rs similarity index 92% rename from src/test/ui/panic-implementation/panic-implementation-duplicate.rs rename to src/test/ui/panic-handler/panic-handler-duplicate.rs index 017113af409bb..7d7fe251869f1 100644 --- a/src/test/ui/panic-implementation/panic-implementation-duplicate.rs +++ b/src/test/ui/panic-handler/panic-handler-duplicate.rs @@ -11,13 +11,13 @@ // compile-flags:-C panic=abort #![feature(lang_items)] -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_std] #![no_main] use core::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic(info: &PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/panic-implementation/panic-implementation-duplicate.stderr b/src/test/ui/panic-handler/panic-handler-duplicate.stderr similarity index 80% rename from src/test/ui/panic-implementation/panic-implementation-duplicate.stderr rename to src/test/ui/panic-handler/panic-handler-duplicate.stderr index d553c02379c37..d8afaa27e2662 100644 --- a/src/test/ui/panic-implementation/panic-implementation-duplicate.stderr +++ b/src/test/ui/panic-handler/panic-handler-duplicate.stderr @@ -1,5 +1,5 @@ error[E0152]: duplicate lang item found: `panic_impl`. - --> $DIR/panic-implementation-duplicate.rs:26:1 + --> $DIR/panic-handler-duplicate.rs:26:1 | LL | / fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`. LL | | loop {} @@ -7,7 +7,7 @@ LL | | } | |_^ | note: first defined here. - --> $DIR/panic-implementation-duplicate.rs:21:1 + --> $DIR/panic-handler-duplicate.rs:21:1 | LL | / fn panic(info: &PanicInfo) -> ! { LL | | loop {} diff --git a/src/test/ui/panic-implementation/panic-implementation-requires-panic-info.rs b/src/test/ui/panic-handler/panic-handler-requires-panic-info.rs similarity index 92% rename from src/test/ui/panic-implementation/panic-implementation-requires-panic-info.rs rename to src/test/ui/panic-handler/panic-handler-requires-panic-info.rs index 597f44d98326d..ec68a414f54d5 100644 --- a/src/test/ui/panic-implementation/panic-implementation-requires-panic-info.rs +++ b/src/test/ui/panic-handler/panic-handler-requires-panic-info.rs @@ -13,11 +13,11 @@ #![feature(lang_items)] #![feature(no_core)] -#![feature(panic_implementation)] +#![feature(panic_handler)] #![no_core] #![no_main] -#[panic_implementation] +#[panic_handler] fn panic() -> ! { loop {} } diff --git a/src/test/ui/panic-implementation/panic-implementation-requires-panic-info.stderr b/src/test/ui/panic-handler/panic-handler-requires-panic-info.stderr similarity index 100% rename from src/test/ui/panic-implementation/panic-implementation-requires-panic-info.stderr rename to src/test/ui/panic-handler/panic-handler-requires-panic-info.stderr diff --git a/src/test/ui/panic-implementation/panic-implementation-std.rs b/src/test/ui/panic-handler/panic-handler-std.rs similarity index 91% rename from src/test/ui/panic-implementation/panic-implementation-std.rs rename to src/test/ui/panic-handler/panic-handler-std.rs index f25cd3605c1dd..7cbe0a35baed8 100644 --- a/src/test/ui/panic-implementation/panic-implementation-std.rs +++ b/src/test/ui/panic-handler/panic-handler-std.rs @@ -10,11 +10,11 @@ // error-pattern: duplicate lang item found: `panic_impl`. -#![feature(panic_implementation)] +#![feature(panic_handler)] use std::panic::PanicInfo; -#[panic_implementation] +#[panic_handler] fn panic(info: PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/panic-implementation/panic-implementation-std.stderr b/src/test/ui/panic-handler/panic-handler-std.stderr similarity index 86% rename from src/test/ui/panic-implementation/panic-implementation-std.stderr rename to src/test/ui/panic-handler/panic-handler-std.stderr index 5016d502cee31..c34a993e2c5e3 100644 --- a/src/test/ui/panic-implementation/panic-implementation-std.stderr +++ b/src/test/ui/panic-handler/panic-handler-std.stderr @@ -1,5 +1,5 @@ error[E0152]: duplicate lang item found: `panic_impl`. - --> $DIR/panic-implementation-std.rs:18:1 + --> $DIR/panic-handler-std.rs:18:1 | LL | / fn panic(info: PanicInfo) -> ! { LL | | loop {} diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-4.stderr b/src/test/ui/panic-implementation/panic-implementation-bad-signature-4.stderr deleted file mode 100644 index 362be2fc3b91e..0000000000000 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-4.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: `#[panic_implementation]` function should have no type parameters - --> $DIR/panic-implementation-bad-signature-4.rs:20:1 - | -LL | / fn panic(pi: &PanicInfo) -> ! { -LL | | //~^ ERROR `#[panic_implementation]` function should have no type parameters -LL | | loop {} -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/panic-implementation/panic-implementation-bad-signature-4.rs b/src/test/ui/panic-implementation/panic-implementation-deprecated.rs similarity index 82% rename from src/test/ui/panic-implementation/panic-implementation-bad-signature-4.rs rename to src/test/ui/panic-implementation/panic-implementation-deprecated.rs index d5f942ba2d62f..c4bec01f6af61 100644 --- a/src/test/ui/panic-implementation/panic-implementation-bad-signature-4.rs +++ b/src/test/ui/panic-implementation/panic-implementation-deprecated.rs @@ -10,14 +10,15 @@ // compile-flags:-C panic=abort +#![deny(deprecated)] #![feature(panic_implementation)] #![no_std] -#![no_main] use core::panic::PanicInfo; #[panic_implementation] -fn panic(pi: &PanicInfo) -> ! { - //~^ ERROR `#[panic_implementation]` function should have no type parameters +fn panic(info: &PanicInfo) -> ! { loop {} } + +fn main() {} diff --git a/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr b/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr new file mode 100644 index 0000000000000..43f51447ac46e --- /dev/null +++ b/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr @@ -0,0 +1,14 @@ +error: use of deprecated attribute `panic_implementation`: This attribute was renamed to `panic_handler`. See https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224 + --> $DIR/panic-implementation-deprecated.rs:19:1 + | +LL | #[panic_implementation] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: lint level defined here + --> $DIR/panic-implementation-deprecated.rs:13:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/panic_implementation-closures.rs b/src/test/ui/panic_implementation-closures.rs index 4fa9a639928f9..6642db6ee76bf 100644 --- a/src/test/ui/panic_implementation-closures.rs +++ b/src/test/ui/panic_implementation-closures.rs @@ -12,9 +12,9 @@ #![crate_type = "rlib"] #![no_std] -#![feature(panic_implementation)] +#![feature(panic_handler)] -#[panic_implementation] +#[panic_handler] pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { |x: u8| x; loop {} From ca03f86aadbcd79129fce8d29bf7dff68c778a81 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 23 Aug 2018 13:52:43 +0200 Subject: [PATCH 2/4] fix tidy --- src/libsyntax/feature_gate.rs | 10 +++++---- .../feature-gate-panic-implementation.rs | 21 +++++++++++++++++++ .../feature-gate-panic-implementation.stderr | 11 ++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/feature-gates/feature-gate-panic-implementation.rs create mode 100644 src/test/ui/feature-gates/feature-gate-panic-implementation.stderr diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 04066f687fc7b..db4bd29c4b72b 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1107,10 +1107,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG // RFC 2070 (deprecated attribute name) ("panic_implementation", - Normal, Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224"), - "panic_implementation", - "This attribute was renamed to `panic_handler`", - cfg_fn!(panic_implementation))), + Normal, + Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/44489\ + #issuecomment-415140224"), + "panic_implementation", + "This attribute was renamed to `panic_handler`", + cfg_fn!(panic_implementation))), // RFC 2070 ("panic_handler", Normal, Gated(Stability::Unstable, diff --git a/src/test/ui/feature-gates/feature-gate-panic-implementation.rs b/src/test/ui/feature-gates/feature-gate-panic-implementation.rs new file mode 100644 index 0000000000000..84e5f302c1676 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-panic-implementation.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_implementation] //~ ERROR This attribute was renamed to `panic_handler` (see issue #44489) +fn panic(info: &PanicInfo) -> ! { + loop {} +} diff --git a/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr b/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr new file mode 100644 index 0000000000000..926a49ae83199 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr @@ -0,0 +1,11 @@ +error[E0658]: This attribute was renamed to `panic_handler` (see issue #44489) + --> $DIR/feature-gate-panic-implementation.rs:18:1 + | +LL | #[panic_implementation] //~ ERROR This attribute was renamed to `panic_handler` (see issue #44489) + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(panic_implementation)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. From 363db147042bbb1461071b27c43bb9ab405943c8 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 23 Aug 2018 21:43:55 +0200 Subject: [PATCH 3/4] fix new ui test --- src/test/ui/consts/const-eval/const_panic_libcore_main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.rs b/src/test/ui/consts/const-eval/const_panic_libcore_main.rs index c66e1fe4bf5a9..f5e5f9778faed 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_main.rs +++ b/src/test/ui/consts/const-eval/const_panic_libcore_main.rs @@ -10,7 +10,7 @@ #![crate_type = "bin"] #![feature(lang_items)] -#![feature(panic_implementation)] +#![feature(panic_handler)] #![feature(const_panic)] #![no_main] #![no_std] @@ -31,7 +31,7 @@ fn eh() {} #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {} -#[panic_implementation] +#[panic_handler] fn panic(_info: &PanicInfo) -> ! { loop {} } From 40a38b01641d453a7b0f4d6af853d06b8cfef161 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 23 Aug 2018 21:44:45 +0200 Subject: [PATCH 4/4] update the unstable book --- src/doc/unstable-book/src/language-features/used.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/used.md b/src/doc/unstable-book/src/language-features/used.md index c3b7f2e41e15b..d49271382b604 100644 --- a/src/doc/unstable-book/src/language-features/used.md +++ b/src/doc/unstable-book/src/language-features/used.md @@ -87,7 +87,7 @@ This condition can be met using `#[used]` and `#[link_section]` plus a linker script. ``` rust,ignore -#![feature(panic_implementation)] +#![feature(panic_handler)] #![feature(used)] #![no_main] #![no_std] @@ -102,8 +102,8 @@ extern "C" fn reset_handler() -> ! { #[used] static RESET_HANDLER: extern "C" fn() -> ! = reset_handler; -#[panic_implementation] -fn panic_impl(info: &PanicInfo) -> ! { +#[panic_handler] +fn panic(info: &PanicInfo) -> ! { loop {} } ```