add #[panic_handler]; deprecate #[panic_implementation]
This commit is contained in:
parent
e5284b0b57
commit
a774c81f98
41 changed files with 134 additions and 83 deletions
|
@ -293,7 +293,9 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// (To be) stable attribute for #[lang = "panic_impl"]
|
// (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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,9 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> {
|
||||||
if let Some(value) = attribute.value_str() {
|
if let Some(value) = attribute.value_str() {
|
||||||
return Some((value, attribute.span));
|
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))
|
return Some((Symbol::intern("panic_impl"), attribute.span))
|
||||||
} else if attribute.check_name("alloc_error_handler") {
|
} else if attribute.check_name("alloc_error_handler") {
|
||||||
return Some((Symbol::intern("oom"), attribute.span))
|
return Some((Symbol::intern("oom"), attribute.span))
|
||||||
|
|
|
@ -113,7 +113,7 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
!whitelisted(tcx, lang_items::$item) &&
|
!whitelisted(tcx, lang_items::$item) &&
|
||||||
items.$name().is_none() {
|
items.$name().is_none() {
|
||||||
if lang_items::$item == lang_items::PanicImplLangItem {
|
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"));
|
but not found"));
|
||||||
} else if lang_items::$item == lang_items::OomLangItem {
|
} else if lang_items::$item == lang_items::OomLangItem {
|
||||||
tcx.sess.err(&format!("`#[alloc_error_handler]` function required, \
|
tcx.sess.err(&format!("`#[alloc_error_handler]` function required, \
|
||||||
|
|
|
@ -1171,8 +1171,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
||||||
if !generics.params.is_empty() {
|
if !generics.params.is_empty() {
|
||||||
fcx.tcx.sess.span_err(
|
fcx.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
"`#[panic_implementation]` function should have no type \
|
"should have no type parameters",
|
||||||
parameters",
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,8 @@
|
||||||
#![feature(doc_alias)]
|
#![feature(doc_alias)]
|
||||||
#![feature(doc_keyword)]
|
#![feature(doc_keyword)]
|
||||||
#![feature(panic_info_message)]
|
#![feature(panic_info_message)]
|
||||||
#![feature(panic_implementation)]
|
#![cfg_attr(stage0, feature(panic_implementation))]
|
||||||
|
#![cfg_attr(not(stage0), feature(panic_handler))]
|
||||||
#![feature(non_exhaustive)]
|
#![feature(non_exhaustive)]
|
||||||
|
|
||||||
#![default_lib_allocator]
|
#![default_lib_allocator]
|
||||||
|
|
|
@ -319,7 +319,8 @@ pub fn panicking() -> bool {
|
||||||
|
|
||||||
/// Entry point of panic from the libcore crate.
|
/// Entry point of panic from the libcore crate.
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
#[panic_implementation]
|
#[cfg_attr(stage0, panic_implementation)]
|
||||||
|
#[cfg_attr(not(stage0), panic_handler)]
|
||||||
#[unwind(allowed)]
|
#[unwind(allowed)]
|
||||||
pub fn rust_begin_panic(info: &PanicInfo) -> ! {
|
pub fn rust_begin_panic(info: &PanicInfo) -> ! {
|
||||||
continue_panic_fmt(&info)
|
continue_panic_fmt(&info)
|
||||||
|
|
|
@ -472,8 +472,9 @@ declare_features! (
|
||||||
// Integer match exhaustiveness checking
|
// Integer match exhaustiveness checking
|
||||||
(active, exhaustive_integer_patterns, "1.30.0", Some(50907), None),
|
(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_implementation, "1.28.0", Some(44489), None),
|
||||||
|
(active, panic_handler, "1.30.0", Some(44489), None),
|
||||||
|
|
||||||
// #[doc(keyword = "...")]
|
// #[doc(keyword = "...")]
|
||||||
(active, doc_keyword, "1.28.0", Some(51315), None),
|
(active, doc_keyword, "1.28.0", Some(51315), None),
|
||||||
|
@ -1104,12 +1105,19 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
|
||||||
"infer 'static lifetime requirements",
|
"infer 'static lifetime requirements",
|
||||||
cfg_fn!(infer_static_outlives_requirements))),
|
cfg_fn!(infer_static_outlives_requirements))),
|
||||||
|
|
||||||
// RFC 2070
|
// RFC 2070 (deprecated attribute name)
|
||||||
("panic_implementation", Normal, Gated(Stability::Unstable,
|
("panic_implementation",
|
||||||
|
Normal, Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224"),
|
||||||
"panic_implementation",
|
"panic_implementation",
|
||||||
"#[panic_implementation] is an unstable feature",
|
"This attribute was renamed to `panic_handler`",
|
||||||
cfg_fn!(panic_implementation))),
|
cfg_fn!(panic_implementation))),
|
||||||
|
|
||||||
|
// RFC 2070
|
||||||
|
("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", Normal, Gated(Stability::Unstable,
|
||||||
"alloc_error_handler",
|
"alloc_error_handler",
|
||||||
"#[alloc_error_handler] is an unstable feature",
|
"#[alloc_error_handler] is an unstable feature",
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
// no-prefer-dynamic
|
// no-prefer-dynamic
|
||||||
|
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// 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)]
|
#![feature(lang_items)]
|
||||||
#![no_main]
|
#![no_main]
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// aux-build:some-panic-impl.rs
|
// aux-build:some-panic-impl.rs
|
||||||
|
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
@ -19,7 +19,7 @@ extern crate some_panic_impl;
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
//~^ error duplicate lang item found: `panic_impl`
|
//~^ error duplicate lang item found: `panic_impl`
|
||||||
loop {}
|
loop {}
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// aux-build:weak-lang-items.rs
|
// 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`
|
// error-pattern: language item required, but not found: `eh_personality`
|
||||||
// ignore-wasm32-bare compiled with panic=abort, personality not required
|
// ignore-wasm32-bare compiled with panic=abort, personality not required
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
|
|
||||||
#![crate_type = "bin"]
|
#![crate_type = "bin"]
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use core::alloc::Layout;
|
use core::alloc::Layout;
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(_: &PanicInfo) -> ! {
|
fn panic(_: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(panic_implementation, alloc_error_handler)]
|
#![feature(panic_handler, alloc_error_handler)]
|
||||||
#![crate_type = "cdylib"]
|
#![crate_type = "cdylib"]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ fn a(_: core::alloc::Layout) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn b(_: &core::panic::PanicInfo) -> ! {
|
fn b(_: &core::panic::PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
#![feature(alloc_error_handler, panic_implementation)]
|
#![feature(alloc_error_handler, panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
@ -24,5 +24,5 @@ fn oom(
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
#![feature(alloc_error_handler, panic_implementation)]
|
#![feature(alloc_error_handler, panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
@ -23,5 +23,5 @@ fn oom(
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
#![feature(alloc_error_handler, panic_implementation)]
|
#![feature(alloc_error_handler, panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
@ -21,5 +21,5 @@ fn oom() -> ! { //~ ERROR function should have one argument
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
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) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
11
src/test/ui/feature-gates/feature-gate-panic-handler.stderr
Normal file
11
src/test/ui/feature-gates/feature-gate-panic-handler.stderr
Normal file
|
@ -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`.
|
|
@ -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`.
|
|
|
@ -13,9 +13,9 @@
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![crate_type = "staticlib"]
|
#![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) -> ! {
|
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![crate_type = "staticlib"]
|
#![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) -> ! {
|
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
// no-prefer-dynamic
|
// no-prefer-dynamic
|
||||||
|
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(
|
fn panic(
|
||||||
info: PanicInfo, //~ ERROR argument should be `&PanicInfo`
|
info: PanicInfo, //~ ERROR argument should be `&PanicInfo`
|
||||||
) -> () //~ ERROR return type should be `!`
|
) -> () //~ ERROR return type should be `!`
|
|
@ -1,11 +1,11 @@
|
||||||
error: return type should be `!`
|
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 `!`
|
LL | ) -> () //~ ERROR return type should be `!`
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error: argument should be `&PanicInfo`
|
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`
|
LL | info: PanicInfo, //~ ERROR argument should be `&PanicInfo`
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(
|
fn panic(
|
||||||
info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo`
|
info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo`
|
||||||
) -> !
|
) -> !
|
|
@ -1,5 +1,5 @@
|
||||||
error: argument should be `&PanicInfo`
|
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`
|
LL | info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo`
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic() -> ! { //~ ERROR function should have one argument
|
fn panic() -> ! { //~ ERROR function should have one argument
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
error: function should have one argument
|
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 | / fn panic() -> ! { //~ ERROR function should have one argument
|
||||||
LL | | loop {}
|
LL | | loop {}
|
23
src/test/ui/panic-handler/panic-handler-bad-signature-4.rs
Normal file
23
src/test/ui/panic-handler/panic-handler-bad-signature-4.rs
Normal file
|
@ -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 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>(pi: &PanicInfo) -> ! {
|
||||||
|
//~^ ERROR should have no type parameters
|
||||||
|
loop {}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
error: should have no type parameters
|
||||||
|
--> $DIR/panic-handler-bad-signature-4.rs:20:1
|
||||||
|
|
|
||||||
|
LL | / fn panic<T>(pi: &PanicInfo) -> ! {
|
||||||
|
LL | | //~^ ERROR should have no type parameters
|
||||||
|
LL | | loop {}
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0152]: duplicate lang item found: `panic_impl`.
|
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 | / fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`.
|
||||||
LL | | loop {}
|
LL | | loop {}
|
||||||
|
@ -7,7 +7,7 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
|
|
||||||
note: first defined here.
|
note: first defined here.
|
||||||
--> $DIR/panic-implementation-duplicate.rs:21:1
|
--> $DIR/panic-handler-duplicate.rs:21:1
|
||||||
|
|
|
|
||||||
LL | / fn panic(info: &PanicInfo) -> ! {
|
LL | / fn panic(info: &PanicInfo) -> ! {
|
||||||
LL | | loop {}
|
LL | | loop {}
|
|
@ -13,11 +13,11 @@
|
||||||
|
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(no_core)]
|
#![feature(no_core)]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic() -> ! {
|
fn panic() -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
// error-pattern: duplicate lang item found: `panic_impl`.
|
// error-pattern: duplicate lang item found: `panic_impl`.
|
||||||
|
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
|
|
||||||
use std::panic::PanicInfo;
|
use std::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
fn panic(info: PanicInfo) -> ! {
|
fn panic(info: PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0152]: duplicate lang item found: `panic_impl`.
|
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 | / fn panic(info: PanicInfo) -> ! {
|
||||||
LL | | loop {}
|
LL | | loop {}
|
|
@ -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<T>(pi: &PanicInfo) -> ! {
|
|
||||||
LL | | //~^ ERROR `#[panic_implementation]` function should have no type parameters
|
|
||||||
LL | | loop {}
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -10,14 +10,15 @@
|
||||||
|
|
||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
|
|
||||||
|
#![deny(deprecated)]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_implementation)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_implementation]
|
||||||
fn panic<T>(pi: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
//~^ ERROR `#[panic_implementation]` function should have no type parameters
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -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
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(panic_implementation)]
|
#![feature(panic_handler)]
|
||||||
|
|
||||||
#[panic_implementation]
|
#[panic_handler]
|
||||||
pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {
|
pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {
|
||||||
|x: u8| x;
|
|x: u8| x;
|
||||||
loop {}
|
loop {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue