diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-11-20 02:15:21 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-12-04 20:29:35 +0000 |
| commit | c6205055e085a1210c1503978225d34147a0d8bd (patch) | |
| tree | 478f64801bff49436a65db792b8af786e0bdc9ce /tests/ui/associated-consts | |
| parent | 490b2cc09860dd62a7595bb07364d71c12ce4e60 (diff) | |
| download | rust-c6205055e085a1210c1503978225d34147a0d8bd.tar.gz rust-c6205055e085a1210c1503978225d34147a0d8bd.zip | |
On `const` pattern errors, point at the `const` item definition
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"),
| ^^^^
```
Diffstat (limited to 'tests/ui/associated-consts')
| -rw-r--r-- | tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr index adc8f399207..5aef0fa414b 100644 --- a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr +++ b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr @@ -1,24 +1,44 @@ 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"), | ^^^^ error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:22:9 | +LL | pub trait Foo { + | ------------- +LL | const X: EFoo; + | ------------- constant defined here +... LL | B::X => println!("B::X"), | ^^^^ error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:30:9 | +LL | pub trait Foo { + | ------------- +LL | const X: EFoo; + | ------------- constant defined here +... LL | let A::X = arg; | ^^^^ error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:28:48 | +LL | pub trait Foo { + | ------------- +LL | const X: EFoo; + | ------------- constant defined here +... LL | pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) { | ^^^^ |
