rust/tests/ui/transmutability
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
..
abstraction safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
alignment Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
arrays TL note: current means target 2024-09-20 10:02:14 -07:00
enums Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
malformed-program-gracefulness transmutability: fix ICE when passing wrong ADT to ASSUME 2025-02-08 05:44:29 +01:00
primitives safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
references Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
safety safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
structs safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
unions safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
assoc-bound.rs TransmuteFrom: Gracefully handle unnormalized types and normalization errors 2024-10-01 20:52:17 +00:00
assoc-bound.stderr Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
dont-assume-err-is-yes-issue-126377.rs Fix transmute goal 2024-10-19 18:07:35 +00:00
dont-assume-err-is-yes-issue-126377.stderr Fix transmute goal 2024-10-19 18:07:35 +00:00
issue-101739-1.rs Re-enable ConstArgKind::Path lowering by default 2024-09-12 13:56:01 -04:00
issue-101739-1.stderr Re-enable ConstArgKind::Path lowering by default 2024-09-12 13:56:01 -04:00
issue-101739-2.rs Re-enable ConstArgKind::Path lowering by default 2024-09-12 13:56:01 -04:00
issue-101739-2.stderr Re-enable ConstArgKind::Path lowering by default 2024-09-12 13:56:01 -04:00
issue-110467.rs safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
issue-110892.rs safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
issue-110892.stderr safe transmute: revise safety analysis 2024-02-27 16:22:32 +00:00
maybeuninit.rs safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
maybeuninit.stderr safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
region-infer.rs safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
region-infer.stderr safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
transmute-padding-ice.rs safe transmute: Rename BikeshedIntrinsicFrom to TransmuteFrom 2024-08-27 14:05:54 +00:00
uninhabited.rs fix safe-transmute handling of enums 2024-12-01 18:28:04 +01:00
uninhabited.stderr Shorten span of panic failures in const context 2025-02-28 16:28:41 +00:00