rust/tests/ui/inline-const
Matthias Krüger f012947bf0
Rollup merge of #136503 - estebank:const-panic, r=RalfJung
Tweak output of const panic diagnostic

### Shorten span of panic failures in const context

Previously, we included a redundant prefix on the panic message and a postfix of the location of the panic. The prefix didn't carry any additional information beyond "something failed", and the location of the panic is redundant with the diagnostic's span, which gets printed out even if its code is not shown.

```
error[E0080]: evaluation of constant value failed
--> $DIR/assert-type-intrinsics.rs:11:9
   |
LL |         MaybeUninit::<!>::uninit().assume_init();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ panic: aborted execution: attempted to instantiate uninhabited type `!`
```

```
error[E0080]: evaluation of `Fail::<i32>::C` failed
--> $DIR/collect-in-dead-closure.rs:9:19
   |
LL |     const C: () = panic!();
   |                   ^^^^^^^^ explicit panic
   |
   = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited.rs:87:9
   |
LL |         assert!(false);
   |         ^^^^^^^^^^^^^^ assertion failed: false
   |
   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
```

### Remove duplicated span from const eval frame list

When the primary span for a const error is the same as the first frame in the const error report, skip it.

```
error[E0080]: evaluation of constant value failed
  --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24
   |
LL | const _CONST: &[u8] = &f(&[], |_| {});
   |                        ^^^^^^^^^^^^^^ explicit panic
   |
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>`
  --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5
   |
LL |     panic!()
   |     ^^^^^^^^ the failure occurred here
   = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
```
instead of
```
error[E0080]: evaluation of constant value failed
--> $DIR/issue-88434-removal-index-should-be-less.rs:10:5
   |
LL |     panic!()
   |     ^^^^^^^^ explicit panic
   |
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>`
--> $DIR/issue-88434-removal-index-should-be-less.rs:10:5
   |
LL |     panic!()
   |     ^^^^^^^^
note: inside `_CONST`
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:24
   |
LL | const _CONST: &[u8] = &f(&[], |_| {});
   |                        ^^^^^^^^^^^^^^
   = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant encountered
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:23
   |
LL | const _CONST: &[u8] = &f(&[], |_| {});
   |                       ^^^^^^^^^^^^^^^
```

r? ``@oli-obk``
2025-03-01 11:33:57 +01:00
..
break-inside-inline-const-issue-128604.rs Don't Suggest Labeling const and unsafe Blocks 2024-08-06 14:50:09 -04:00
break-inside-inline-const-issue-128604.stderr Don't Suggest Labeling const and unsafe Blocks 2024-08-06 14:50:09 -04:00
collect-scopes-in-pat.rs Fix test directives that were accidentally ignored 2025-02-27 13:22:16 +00:00
const-block-pat-liveness.rs tests: ui/inline-consts: add issue number to a test, rename other tests from a_b_c to a-b-c 2024-11-16 13:09:10 +01:00
const-expr-array-init.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-basic.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-generic-err2.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-generic-err2.stderr Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-generic-err.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-generic-err.stderr Shorten span of panic failures in const context 2025-02-28 16:28:41 +00:00
const-expr-generic.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-inference.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-lifetime-err.rs stabilize const_mut_refs 2024-09-15 09:51:32 +02:00
const-expr-lifetime-err.stderr best_blame_constraint: don't filter constraints by sup SCC 2025-01-06 16:08:29 -08:00
const-expr-lifetime.rs stabilize const_mut_refs 2024-09-15 09:51:32 +02:00
const-expr-macro.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-expr-reference.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
const-match-pat-generic.rs review comments: reword messages and simplify logic 2024-12-04 20:49:05 +00:00
const-match-pat-generic.stderr review comments: reword messages and simplify logic 2024-12-04 20:49:05 +00:00
const-match-pat-inference.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
const-match-pat-lifetime-err.rs stabilize const_mut_refs 2024-09-15 09:51:32 +02:00
const-match-pat-lifetime-err.stderr best_blame_constraint: don't filter constraints by sup SCC 2025-01-06 16:08:29 -08:00
const-match-pat-lifetime.rs stabilize const_mut_refs 2024-09-15 09:51:32 +02:00
const-match-pat-range.rs Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
const-match-pat.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cross-const-control-flow-125846.rs tests: ui/inline-consts: add issue number to a test, rename other tests from a_b_c to a-b-c 2024-11-16 13:09:10 +01:00
cross-const-control-flow-125846.stderr Show diff suggestion format on verbose replacement 2025-02-10 20:21:39 +00:00
elided-lifetime-being-infer-vars.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
expr-unsafe-err.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
expr-unsafe-err.stderr Fix tests and bless 2024-04-24 13:12:33 +01:00
expr-unsafe.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
expr-unsafe.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
expr-with-block-err.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
expr-with-block-err.stderr Fix tests and bless 2024-04-24 13:12:33 +01:00
expr-with-block.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
instance-doesnt-depend-on-type.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
interpolated.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
macro-with-const.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
pat-match-fndef.rs #![feature(inline_const_pat)] is no longer incomplete 2024-02-01 10:27:54 +00:00
pat-match-fndef.stderr Specify type kind of constant that can't be used in patterns 2024-12-04 20:29:36 +00:00
pat-unsafe-err.rs #![feature(inline_const_pat)] is no longer incomplete 2024-02-01 10:27:54 +00:00
pat-unsafe-err.stderr #![feature(inline_const_pat)] is no longer incomplete 2024-02-01 10:27:54 +00:00
pat-unsafe.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
pat-unsafe.stderr #![feature(inline_const_pat)] is no longer incomplete 2024-02-01 10:27:54 +00:00
promotion.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
promotion.stderr Fix tests and bless 2024-04-24 13:12:33 +01:00
referencing-local-variables.rs tests: ui/inline-consts: add issue number to a test, rename other tests from a_b_c to a-b-c 2024-11-16 13:09:10 +01:00
referencing-local-variables.stderr tests: ui/inline-consts: add issue number to a test, rename other tests from a_b_c to a-b-c 2024-11-16 13:09:10 +01:00
required-const.rs Fix tests and bless 2024-04-24 13:12:33 +01:00
required-const.stderr Shorten span of panic failures in const context 2025-02-28 16:28:41 +00:00
uninit-local.rs tests: ui/inline-consts: add issue number to a test, rename other tests from a_b_c to a-b-c 2024-11-16 13:09:10 +01:00
uninit-local.stderr tests: ui/inline-consts: add issue number to a test, rename other tests from a_b_c to a-b-c 2024-11-16 13:09:10 +01:00
using-late-bound-from-closure.rs Add test 2024-08-08 00:41:39 +08:00
using-late-bound-from-closure.stderr Add test 2024-08-08 00:41:39 +08:00