rust/compiler
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
..
rustc Fix overcapturing, unsafe extern blocks, and new unsafe ops 2025-02-22 00:01:48 +00:00
rustc_abi Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, r=saethlin,traviscross 2025-02-23 02:44:18 -05:00
rustc_arena Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_ast Auto merge of #137517 - nnethercote:rm-NtPat-NtItem-NtStmt, r=petrochenkov 2025-02-28 21:32:39 +00:00
rustc_ast_ir Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_ast_lowering Rollup merge of #137771 - estebank:abi-sugg, r=compiler-errors 2025-03-01 05:49:56 +01:00
rustc_ast_passes Teach structured errors to display short Ty 2025-02-25 16:56:03 +00:00
rustc_ast_pretty Introduce AssocOp::Binary. 2025-02-27 09:53:17 +11:00
rustc_attr_data_structures Spruce up AttributeKind docs 2025-02-26 22:21:36 +00:00
rustc_attr_parsing Remove NtPath. 2025-02-28 08:42:14 +11:00
rustc_baked_icu_data Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_borrowck Rollup merge of #137201 - estebank:structured-errors-long-ty, r=oli-obk 2025-02-26 19:03:55 +01:00
rustc_builtin_macros switch #[cfg(not(llvm_enzyme))] to cfg!(llvm_enzyme) 2025-02-27 19:32:30 +05:30
rustc_codegen_cranelift Auto merge of #137608 - fmease:rollup-h4siso6, r=fmease 2025-02-25 19:36:17 +00:00
rustc_codegen_gcc Rollup merge of #137595 - folkertdev:remove-simd-pow-powi, r=RalfJung 2025-02-25 13:07:40 +01:00
rustc_codegen_llvm Auto merge of #137796 - jieyouxu:rollup-qt9yr1g, r=jieyouxu 2025-03-01 00:53:19 +00:00
rustc_codegen_ssa Auto merge of #137796 - jieyouxu:rollup-qt9yr1g, r=jieyouxu 2025-03-01 00:53:19 +00:00
rustc_const_eval Rollup merge of #136503 - estebank:const-panic, r=RalfJung 2025-03-01 11:33:57 +01:00
rustc_data_structures Rollup merge of #136579 - bjorn3:fix_thinvec_ext_ub, r=BoxyUwU 2025-02-27 08:56:36 +01:00
rustc_driver Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_driver_impl Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_error_codes Update E0133 docs for 2024 edition 2025-02-27 08:33:44 -08:00
rustc_error_messages Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_errors Fix rebase 2025-02-25 17:27:22 +00:00
rustc_expand Remove NtPath. 2025-02-28 08:42:14 +11:00
rustc_feature Rollup merge of #137489 - RalfJung:no-more-rustc_intrinsic_must_be_overridden, r=oli-obk 2025-02-24 19:21:47 -05:00
rustc_fluent_macro Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_fs_util Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_graphviz Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_hashes Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_hir Rollup merge of #137686 - nbdd0121:asm_const, r=compiler-errors 2025-03-01 05:49:52 +01:00
rustc_hir_analysis Rollup merge of #137686 - nbdd0121:asm_const, r=compiler-errors 2025-03-01 05:49:52 +01:00
rustc_hir_pretty Rollup merge of #137686 - nbdd0121:asm_const, r=compiler-errors 2025-03-01 05:49:52 +01:00
rustc_hir_typeck Rollup merge of #137686 - nbdd0121:asm_const, r=compiler-errors 2025-03-01 05:49:52 +01:00
rustc_incremental Change span field accesses to method calls 2025-02-24 14:22:31 +01:00
rustc_index Rollup merge of #136610 - Jarcho:range_idx, r=Noratrieb 2025-02-24 02:11:32 -05:00
rustc_index_macros Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_infer Use Binder<Vec<T>> instead of Vec<Binder<T>> in new solver 2025-02-26 17:32:26 +00:00
rustc_interface Auto merge of #137420 - matthiaskrgr:rollup-rr0q37f, r=matthiaskrgr 2025-02-22 13:32:44 +00:00
rustc_lexer Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
rustc_lint Rollup merge of #136424 - 11happy:overflow.hex.fix, r=fmease 2025-02-28 21:41:58 +08:00
rustc_lint_defs Introduce new-style attribute parsers for several attributes 2025-02-24 14:31:17 +01:00
rustc_llvm compiler: bump cc to 1.2.16 to fix x86 Windows jobs on newest Windows SDK 2025-02-28 21:10:21 +08:00
rustc_log Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_macros pretty print hir attributes 2025-02-24 14:31:19 +01:00
rustc_metadata Rollup merge of #137201 - estebank:structured-errors-long-ty, r=oli-obk 2025-02-26 19:03:55 +01:00
rustc_middle Rollup merge of #137689 - compiler-errors:coroutine, r=lcnr 2025-03-01 05:49:53 +01:00
rustc_mir_build Rollup merge of #137686 - nbdd0121:asm_const, r=compiler-errors 2025-03-01 05:49:52 +01:00
rustc_mir_dataflow Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
rustc_mir_transform Print out destructor 2025-02-26 19:03:29 +00:00
rustc_monomorphize Rollup merge of #137601 - davidtwco:deduplicate-type-has-metadata, r=fmease,bjorn3 2025-02-26 04:15:05 +01:00
rustc_next_trait_solver Rollup merge of #137689 - compiler-errors:coroutine, r=lcnr 2025-03-01 05:49:53 +01:00
rustc_parse Auto merge of #137517 - nnethercote:rm-NtPat-NtItem-NtStmt, r=petrochenkov 2025-02-28 21:32:39 +00:00
rustc_parse_format Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_passes require trait impls to have matching const stabilities as the traits 2025-02-27 04:56:27 +00:00
rustc_pattern_analysis Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
rustc_privacy Introduce new-style attribute parsers for several attributes 2025-02-24 14:31:17 +01:00
rustc_query_impl Introduce new parsing infrastructure and types for parsed attributes 2025-02-24 14:26:06 +01:00
rustc_query_system Introduce new parsing infrastructure and types for parsed attributes 2025-02-24 14:26:06 +01:00
rustc_resolve Rollup merge of #137686 - nbdd0121:asm_const, r=compiler-errors 2025-03-01 05:49:52 +01:00
rustc_sanitizers Introduce new-style attribute parsers for several attributes 2025-02-24 14:31:17 +01:00
rustc_serialize rename sub_ptr 😅 2025-02-23 23:11:00 +07:00
rustc_session Teach structured errors to display short Ty 2025-02-25 16:56:03 +00:00
rustc_smir change smir attributes getters to only support tool attributes 2025-02-24 14:31:19 +01:00
rustc_span Auto merge of #137608 - fmease:rollup-h4siso6, r=fmease 2025-02-25 19:36:17 +00:00
rustc_symbol_mangling Introduce new-style attribute parsers for several attributes 2025-02-24 14:31:17 +01:00
rustc_target Rollup merge of #137370 - RalfJung:x86-abi-fallback, r=SparrowLii 2025-02-25 13:07:23 +01:00
rustc_trait_selection Rollup merge of #137689 - compiler-errors:coroutine, r=lcnr 2025-03-01 05:49:53 +01:00
rustc_traits Rollup merge of #137333 - compiler-errors:edition-2024-fresh, r=Nadrieril 2025-02-22 11:36:43 +01:00
rustc_transmute Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_ty_utils Rollup merge of #137770 - compiler-errors:unsafe-binder-sized-crit, r=oli-obk 2025-02-28 22:29:56 +08:00
rustc_type_ir Rollup merge of #137689 - compiler-errors:coroutine, r=lcnr 2025-03-01 05:49:53 +01:00
rustc_type_ir_macros Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
stable_mir change smir attributes getters to only support tool attributes 2025-02-24 14:31:19 +01:00