Centralize emitting an error in `const_to_pat` so that all errors from that evaluating a `const` in a pattern can add addditional information. With this, now point at the `const` item's definition:
```
error[E0158]: constant pattern depends on a generic parameter
--> $DIR/associated-const-type-parameter-pattern.rs:20:9
|
LL | pub trait Foo {
| -------------
LL | const X: EFoo;
| ------------- constant defined here
...
LL | A::X => println!("A::X"),
| ^^^^
```
12 lines
343 B
Plaintext
12 lines
343 B
Plaintext
error: cannot use unsized non-slice type `Username` in constant patterns
|
|
--> $DIR/issue-87046.rs:28:13
|
|
|
|
|
LL | pub const ROOT_USER: &Username = Username::from_str("root");
|
|
| ------------------------------ constant defined here
|
|
...
|
|
LL | ROOT_USER => true,
|
|
| ^^^^^^^^^
|
|
|
|
error: aborting due to 1 previous error
|
|
|