1
Fork 0

Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-se

panic_str only exists for the migration to 2021 panic macros

The only caller is `expect_failed`, which is already a cold inline(never) function, so inlining into that function should be fine. (And indeed `panic_str` was `#[inline]` anyway.)

The existence of panic_str risks someone calling it when they should call `panic` instead, and I can't see a reason why this footgun should exist.

I also extended the comment in `panic` to explain why it needs a `'static` string -- I know I've wondered about this in the past and it took me quite a while to understand.
This commit is contained in:
Matthias Krüger 2024-04-23 12:10:25 +02:00 committed by GitHub
commit 72e8fb4268
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 25 additions and 18 deletions

View file

@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for NonPanicFmt {
if Some(def_id) == cx.tcx.lang_items().begin_panic_fn()
|| Some(def_id) == cx.tcx.lang_items().panic_fn()
|| f_diagnostic_name == Some(sym::panic_str)
|| f_diagnostic_name == Some(sym::panic_str_2015)
{
if let Some(id) = f.span.ctxt().outer_expn_data().macro_def_id {
if matches!(