rust/tests/ui/infinite
Esteban Küber 7d4d09eeeb 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();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: 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!();
   |                   ^^^^^^^^ evaluation panicked: 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:41:9
   |
LL |         assert!(false);
   |         ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false
   |
   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
```

---

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(&[], |_| {});
   |                        ^^^^^^^^^^^^^^ evaluation panicked: 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)
```

---

Revert order of constant evaluation errors

Point at the code the user wrote first and std functions last.

```
error[E0080]: evaluation of constant value failed
  --> $DIR/const-errs-dont-conflict-103369.rs:5:25
   |
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
   |                         ^^^^^^^^ evaluation panicked: Some error occurred
   |
note: called from `my_fn`
  --> $DIR/const-errs-dont-conflict-103369.rs:10:5
   |
LL |     panic!("Some error occurred");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = 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/const-errs-dont-conflict-103369.rs:10:5
   |
LL |     panic!("Some error occurred");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Some error occurred
   |
note: called from `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}`
  --> $DIR/const-errs-dont-conflict-103369.rs:5:25
   |
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
   |                         ^^^^^^^^
   = 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)
```
2025-02-28 16:28:41 +00:00
..
auxiliary only query params_in_repr if def kind is adt 2024-10-02 17:36:31 +08:00
infinite-alias.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
infinite-alias.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
infinite-assoc.rs only query params_in_repr if def kind is adt 2024-10-02 17:36:31 +08:00
infinite-assoc.stderr Show diff suggestion format on verbose replacement 2025-02-10 20:21:39 +00:00
infinite-autoderef.rs change error messages to be incorrect, but more helpful 2024-02-22 18:18:33 +01:00
infinite-autoderef.stderr change error messages to be incorrect, but more helpful 2024-02-22 18:18:33 +01:00
infinite-instantiation-struct-tail-ice-114484.rs normalize long-type.txt in tests 2025-01-30 17:10:19 +00:00
infinite-instantiation-struct-tail-ice-114484.stderr normalize long-type.txt in tests 2025-01-30 17:10:19 +00:00
infinite-instantiation.rs normalize long-type.txt in tests 2025-01-30 17:10:19 +00:00
infinite-instantiation.stderr normalize long-type.txt in tests 2025-01-30 17:10:19 +00:00
infinite-macro-expansion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
infinite-macro-expansion.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
infinite-recursion-const-fn.rs Shorten span of panic failures in const context 2025-02-28 16:28:41 +00:00
infinite-recursion-const-fn.stderr Shorten span of panic failures in const context 2025-02-28 16:28:41 +00:00
infinite-struct.rs Automatically taint InferCtxt when errors are emitted 2024-06-26 16:01:45 +00:00
infinite-struct.stderr Automatically taint InferCtxt when errors are emitted 2024-06-26 16:01:45 +00:00
infinite-tag-type-recursion.rs Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
infinite-tag-type-recursion.stderr Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
infinite-trait-alias-recursion.rs Use trait definition cycle detection for trait alias definitions, too 2025-01-09 08:49:39 +00:00
infinite-trait-alias-recursion.stderr Use trait definition cycle detection for trait alias definitions, too 2025-01-09 08:49:39 +00:00
infinite-type-alias-mutual-recursion.feature.stderr overflow errors: change source to a concrete enum 2024-02-22 17:43:57 +01:00
infinite-type-alias-mutual-recursion.gated.stderr Merge collect_mod_item_types query into check_well_formed 2024-03-07 14:26:31 +00:00
infinite-type-alias-mutual-recursion.rs overflow errors: change source to a concrete enum 2024-02-22 17:43:57 +01:00
infinite-vec-type-recursion.feature.stderr overflow errors: change source to a concrete enum 2024-02-22 17:43:57 +01:00
infinite-vec-type-recursion.gated.stderr Merge collect_mod_item_types query into check_well_formed 2024-03-07 14:26:31 +00:00
infinite-vec-type-recursion.rs overflow errors: change source to a concrete enum 2024-02-22 17:43:57 +01:00
issue-41731-infinite-macro-print.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-41731-infinite-macro-print.stderr Add spacing information to delimiters. 2023-12-11 09:36:40 +11:00
issue-41731-infinite-macro-println.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-41731-infinite-macro-println.stderr Add spacing information to delimiters. 2023-12-11 09:36:40 +11:00