Repository: rust
Issue: weird output in E0080 diagnostic
Labels: A-diagnostics,T-compiler

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.

If you cannot produce a minimal reproduction case (something that would work in
isolation), please provide the steps or even link to a repository that causes
the problematic output to occur.
-->

Given the following code: <!-- Please provide a link to play.rust-lang.org -->
`./src/test/ui/consts/invalid-union.rs`
```rust
// Check that constants with interior mutability inside unions are rejected
// during validation.
//
// Note that this test case relies on undefined behaviour to construct a
// constant with interior mutability that is "invisible" to the static checks.
// If for some reason this approach no longer works, it is should be fine to
// remove the test case.
//
// build-fail
// stderr-per-bitwidth
#![feature(const_mut_refs)]

use std::cell::Cell;
use std::mem::ManuallyDrop;

#[repr(C)]
struct S {
    x: u32,
    y: E,
}

#[repr(u32)]
enum E {
    A,
    B(U)
}

union U {
    cell: ManuallyDrop<Cell<u32>>,
}

const C: S = {
    let s = S { x: 0, y: E::A };
    // Go through an &u32 reference which is definitely not allowed to mutate anything.
    let p = &s.x as *const u32 as *mut u32;
    // Change enum tag to E::B.
    unsafe { *p.add(1) = 1 };
    s
};

fn main() { //~ ERROR it is undefined behavior to use this value
    let _: &'static _ = &C; //~ ERROR erroneous constant used
    //~^ WARN this was previously accepted
}
```
Full output:
````
warning: variant `B` is never constructed
  --> ./src/test/ui/consts/invalid-union.rs:25:5
   |
23 | enum E {
   |      - variant in this enum
24 |     A,
25 |     B(U)
   |     ^
   |
   = note: `#[warn(dead_code)]` on by default

warning: field `cell` is never read
  --> ./src/test/ui/consts/invalid-union.rs:29:5
   |
28 | union U {
   |       - field in this union
29 |     cell: ManuallyDrop<Cell<u32>>,
   |     ^^^^

error[E0080]: it is undefined behavior to use this value
  --> ./src/test/ui/consts/invalid-union.rs:41:1
   |
41 | fn main() { //~ ERROR it is undefined behavior to use this value
   | ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
   |
   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
   = note: the raw bytes of the constant (size: 8, align: 8) {
               ╾───────alloc7────────╼                         │ ╾──────╼
           }

error: erroneous constant used
  --> ./src/test/ui/consts/invalid-union.rs:42:25
   |
42 |     let _: &'static _ = &C; //~ ERROR erroneous constant used
   |                         ^^ referenced constant has errors
   |
   = note: `#[deny(const_err)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to 2 previous errors; 2 warnings emitted
````


I am curious about the E0080, what is this ------alloc7------ supposed to tell me...? :sweat_smile: 
Loos like some mangled diagram?
````
error[E0080]: it is undefined behavior to use this value
  --> ./src/test/ui/consts/invalid-union.rs:41:1
   |
41 | fn main() { //~ ERROR it is undefined behavior to use this value
   | ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
   |
   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
   = note: the raw bytes of the constant (size: 8, align: 8) {
               ╾───────alloc7────────╼                         │ ╾──────╼
           }
````