Skip to content

Commit 5d10eb5

Browse files
committed
rename begin_panic
1 parent 7cd9505 commit 5d10eb5

32 files changed

+62
-54
lines changed

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,11 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
827827

828828
// At this point, we are calling a function, `callee`, whose `DefId` is known...
829829

830-
// `begin_panic` and `#[rustc_const_panic_str]` functions accept generic
830+
// `panic_with_payload` and `#[rustc_const_panic_str]` functions accept generic
831831
// types other than str. Check to enforce that only str can be used in
832832
// const-eval.
833833

834-
// const-eval of the `begin_panic` fn assumes the argument is `&str`
834+
// const-eval of the `panic_with_payload` fn assumes the argument is `&str`
835835
if tcx.is_lang_item(callee, LangItem::BeginPanic) {
836836
match args[0].node.ty(&self.ccx.body.local_decls, tcx).kind() {
837837
ty::Ref(_, ty, _) if ty.is_str() => {}

compiler/rustc_hir/src/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ language_item_table! {
320320
PanicAsyncGenFnResumedDrop, sym::panic_const_async_gen_fn_resumed_drop, panic_const_async_gen_fn_resumed_drop, Target::Fn, GenericRequirement::None;
321321
PanicGenFnNoneDrop, sym::panic_const_gen_fn_none_drop, panic_const_gen_fn_none_drop, Target::Fn, GenericRequirement::None;
322322
/// libstd panic entry point. Necessary for const eval to be able to catch it
323-
BeginPanic, sym::begin_panic, begin_panic_fn, Target::Fn, GenericRequirement::None;
323+
BeginPanic, sym::panic_with_payload, begin_panic_fn, Target::Fn, GenericRequirement::None;
324324

325325
// Lang items needed for `format_args!()`.
326326
FormatArgument, sym::format_argument, format_argument, Target::Struct, GenericRequirement::None;

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ symbols! {
550550
avx512f,
551551
await_macro,
552552
bang,
553-
begin_panic,
553+
panic_with_payload,
554554
bench,
555555
bevy_ecs,
556556
bikeshed_guaranteed_no_drop,

library/std/src/panic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ impl fmt::Display for PanicHookInfo<'_> {
215215
#[rustc_macro_transparency = "semitransparent"]
216216
pub macro panic_2015 {
217217
() => ({
218-
$crate::rt::begin_panic("explicit panic")
218+
$crate::rt::panic_with_payload("explicit panic")
219219
}),
220220
($msg:expr $(,)?) => ({
221-
$crate::rt::begin_panic($msg);
221+
$crate::rt::panic_with_payload($msg);
222222
}),
223223
// Special-case the single-argument case for const_panic.
224224
("{}", $arg:expr $(,)?) => ({
@@ -257,7 +257,7 @@ pub use crate::panicking::{set_hook, take_hook};
257257
#[track_caller]
258258
#[cfg_attr(not(test), rustc_diagnostic_item = "panic_any")]
259259
pub fn panic_any<M: 'static + Any + Send>(msg: M) -> ! {
260-
crate::panicking::begin_panic(msg);
260+
crate::panicking::panic_with_payload(msg);
261261
}
262262

263263
#[stable(feature = "catch_unwind", since = "1.9.0")]

library/std/src/panicking.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::{fmt, intrinsics, process, thread};
2929

3030
// This forces codegen of the function called by panic!() inside the std crate, rather than in
3131
// downstream crates. Primarily this is useful for rustc's codegen tests, which rely on noticing
32-
// complete removal of panic from generated IR. Since begin_panic is inline(never), it's only
32+
// complete removal of panic from generated IR. Since panic_with_payload is inline(never), it's only
3333
// codegen'd once per crate-graph so this pushes that to std rather than our codegen test crates.
3434
//
3535
// (See https://github.com/rust-lang/rust/pull/123244 for more info on why).
@@ -41,7 +41,7 @@ use crate::{fmt, intrinsics, process, thread};
4141
#[allow(dead_code)]
4242
#[used(compiler)]
4343
pub static EMPTY_PANIC: fn(&'static str) -> ! =
44-
begin_panic::<&'static str> as fn(&'static str) -> !;
44+
panic_with_payload::<&'static str> as fn(&'static str) -> !;
4545

4646
// Binary interface to the panic runtime that the standard library depends on.
4747
//
@@ -650,7 +650,7 @@ pub fn begin_panic_handler(info: &core::panic::PanicInfo<'_>) -> ! {
650650
fn take_box(&mut self) -> *mut (dyn Any + Send) {
651651
// We do two allocations here, unfortunately. But (a) they're required with the current
652652
// scheme, and (b) we don't handle panic + OOM properly anyway (see comment in
653-
// begin_panic below).
653+
// panic_with_payload below).
654654
let contents = mem::take(self.fill());
655655
Box::into_raw(Box::new(contents))
656656
}
@@ -717,15 +717,15 @@ pub fn begin_panic_handler(info: &core::panic::PanicInfo<'_>) -> ! {
717717
/// panic!() and assert!(). In particular, this is the only entry point that supports
718718
/// arbitrary payloads, not just format strings.
719719
#[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "none")]
720-
#[cfg_attr(not(any(test, doctest)), lang = "begin_panic")]
720+
#[cfg_attr(not(any(test, doctest)), lang = "panic_with_payload")]
721721
// lang item for CTFE panic support
722722
// never inline unless panic_immediate_abort to avoid code
723723
// bloat at the call sites as much as possible
724724
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold, optimize(size))]
725725
#[cfg_attr(feature = "panic_immediate_abort", inline)]
726726
#[track_caller]
727727
#[rustc_do_not_const_check] // hooked by const-eval
728-
pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
728+
pub const fn panic_with_payload<M: Any + Send>(msg: M) -> ! {
729729
if cfg!(feature = "panic_immediate_abort") {
730730
intrinsics::abort()
731731
}

library/std/src/rt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![allow(unused_macros)]
1818

1919
#[rustfmt::skip]
20-
pub use crate::panicking::{begin_panic, panic_count};
20+
pub use crate::panicking::{panic_with_payload, panic_count};
2121
pub use core::panicking::{panic_display, panic_fmt};
2222

2323
#[rustfmt::skip]

src/doc/rustc-dev-guide/src/compiler-debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ stack backtrace:
7171
2: std::panicking::default_hook::{{closure}}
7272
3: std::panicking::default_hook
7373
4: std::panicking::rust_panic_with_hook
74-
5: std::panicking::begin_panic
74+
5: std::panicking::panic_with_payload
7575
(~~~~ LINES REMOVED BY ME FOR BREVITY ~~~~)
7676
32: rustc_typeck::check_crate
7777
33: <std::thread::local::LocalKey<T>>::with

src/tools/clippy/clippy_lints/src/fallible_impl_from.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn lint_impl_body(cx: &LateContext<'_>, item_def_id: hir::OwnerId, impl_span: Sp
103103
{
104104
let impl_item_def_id = impl_item.def_id.expect_local();
105105

106-
// check the body for `begin_panic` or `unwrap`
106+
// check the body for `panic_with_payload` or `unwrap`
107107
let body = cx.tcx.hir_body_owned_by(impl_item_def_id);
108108
let mut fpu = FindPanicUnwrap {
109109
lcx: cx,

src/tools/rust-analyzer/bench_data/numerous_macro_rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ macro_rules! __ra_macro_fixture437 {($t : ty , $pmap : expr , $smap : expr )=
439439
macro_rules! __ra_macro_fixture438 {()=>{# [ inline ] fn is_ascii (& self )-> bool { self . is_ascii ()}# [ inline ] fn to_ascii_uppercase (& self )-> Self :: Owned { self . to_ascii_uppercase ()}# [ inline ] fn to_ascii_lowercase (& self )-> Self :: Owned { self . to_ascii_lowercase ()}# [ inline ] fn eq_ignore_ascii_case (& self , o : & Self )-> bool { self . eq_ignore_ascii_case ( o )}# [ inline ] fn make_ascii_uppercase (& mut self ){ self . make_ascii_uppercase (); }# [ inline ] fn make_ascii_lowercase (& mut self ){ self . make_ascii_lowercase (); }}; }
440440
macro_rules! __ra_macro_fixture439 {()=>($crate :: vec :: Vec :: new ()); ($elem : expr ; $n : expr )=>($crate :: vec :: from_elem ($elem , $n )); ($($x : expr ),+ $(,)?)=>(< [_]>:: into_vec ( box [$($x ),+])); }
441441
macro_rules! __ra_macro_fixture440 {($left : expr , $right : expr $(,)?)=>({ match (&$left , &$right ){( left_val , right_val )=>{ if ! (* left_val == * right_val ){ panic ! ( r#"assertion failed: `(left == right)`\n left: `{:?}`,\n right: `{:?}`"# , &* left_val , &* right_val )}}}}); ($left : expr , $right : expr , $($arg : tt )+)=>({ match (& ($left ), & ($right )){( left_val , right_val )=>{ if ! (* left_val == * right_val ){ panic ! ( r#"assertion failed: `(left == right)`\n left: `{:?}`,\n right: `{:?}`: {}"# , &* left_val , &* right_val , $crate :: format_args ! ($($arg )+))}}}}); }
442-
macro_rules! __ra_macro_fixture441 {()=>({$crate :: panic ! ( "explicit panic" )}); ($msg : expr $(,)?)=>({$crate :: rt :: begin_panic ($msg )}); ($fmt : expr , $($arg : tt )+)=>({$crate :: rt :: begin_panic_fmt (&$crate :: format_args ! ($fmt , $($arg )+))}); }
442+
macro_rules! __ra_macro_fixture441 {()=>({$crate :: panic ! ( "explicit panic" )}); ($msg : expr $(,)?)=>({$crate :: rt :: panic_with_payload ($msg )}); ($fmt : expr , $($arg : tt )+)=>({$crate :: rt :: begin_panic_fmt (&$crate :: format_args ! ($fmt , $($arg )+))}); }
443443
macro_rules! __ra_macro_fixture442 {($expression : expr , $($pattern : pat )|+ $(if $guard : expr )? $(,)?)=>{ match $expression {$($pattern )|+ $(if $guard )? => true , _ => false }}}
444444
macro_rules! __ra_macro_fixture443 {()=>{# [ inline ] fn load_consume (& self )-> Self :: Val { self . load ( Ordering :: Acquire )}}; }
445445
macro_rules! __ra_macro_fixture444 {($($tt : tt )*)=>{$($tt )* }}

src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
//! This attribute to tell the compiler about semi built-in std library
44
//! features, such as Fn family of traits.
55
use hir_expand::name::Name;
6-
use intern::{Symbol, sym};
6+
use intern::{sym, Symbol};
77
use rustc_hash::FxHashMap;
88
use triomphe::Arc;
99

1010
use crate::{
11-
AdtId, AssocItemId, AttrDefId, Crate, EnumId, EnumVariantId, FunctionId, ImplId, ModuleDefId,
12-
StaticId, StructId, TraitId, TypeAliasId, UnionId,
1311
db::DefDatabase,
1412
expr_store::path::Path,
1513
nameres::{assoc::TraitItems, crate_def_map},
14+
AdtId, AssocItemId, AttrDefId, Crate, EnumId, EnumVariantId, FunctionId, ImplId, ModuleDefId,
15+
StaticId, StructId, TraitId, TypeAliasId, UnionId,
1616
};
1717

1818
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -153,7 +153,11 @@ pub fn crate_lang_items(db: &dyn DefDatabase, krate: Crate) -> Option<Box<LangIt
153153
}
154154
}
155155

156-
if lang_items.items.is_empty() { None } else { Some(Box::new(lang_items)) }
156+
if lang_items.items.is_empty() {
157+
None
158+
} else {
159+
Some(Box::new(lang_items))
160+
}
157161
}
158162

159163
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
@@ -226,7 +230,11 @@ pub(crate) fn crate_notable_traits(db: &dyn DefDatabase, krate: Crate) -> Option
226230
}
227231
}
228232

229-
if traits.is_empty() { None } else { Some(traits.into_iter().collect()) }
233+
if traits.is_empty() {
234+
None
235+
} else {
236+
Some(traits.into_iter().collect())
237+
}
230238
}
231239

232240
pub enum GenericRequirement {
@@ -416,7 +424,7 @@ language_item_table! {
416424
PanicCannotUnwind, sym::panic_cannot_unwind, panic_cannot_unwind, Target::Fn, GenericRequirement::Exact(0);
417425
PanicNullPointerDereference, sym::panic_null_pointer_dereference, panic_null_pointer_dereference, Target::Fn, GenericRequirement::None;
418426
/// libstd panic entry point. Necessary for const eval to be able to catch it
419-
BeginPanic, sym::begin_panic, begin_panic_fn, Target::Fn, GenericRequirement::None;
427+
BeginPanic, sym::panic_with_payload, begin_panic_fn, Target::Fn, GenericRequirement::None;
420428

421429
// Lang items needed for `format_args!()`.
422430
FormatAlignment, sym::format_alignment, format_alignment, Target::Enum, GenericRequirement::None;

0 commit comments

Comments
 (0)