about summary refs log tree commit diff
path: root/tests/ui/associated-consts
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-11-20 03:08:52 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-12-04 20:29:36 +0000
commit87ddc1ea33edbe1be119d73e57c2783940e797fe (patch)
tree1078cb612921aa307c2700910e38c4441beccbd8 /tests/ui/associated-consts
parentc0f00086f85ae1fff34dd2daf6a11850e5bfc2f0 (diff)
downloadrust-87ddc1ea33edbe1be119d73e57c2783940e797fe.tar.gz
rust-87ddc1ea33edbe1be119d73e57c2783940e797fe.zip
Point at generic param through which a const is used in a pattern
```
error[E0158]: constant pattern depends on a generic parameter, which is not allowed
  --> $DIR/associated-const-type-parameter-pattern.rs:20:9
   |
LL | pub trait Foo {
   | -------------
LL |     const X: EFoo;
   |     ------------- constant defined here
...
LL | pub fn test<A: Foo, B: Foo>(arg: EFoo) {
   |             - constant depends on this generic param
LL |     match arg {
LL |         A::X => println!("A::X"),
   |         ^^^^ `const` depends on a generic parameter
```
Diffstat (limited to 'tests/ui/associated-consts')
-rw-r--r--tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr27
1 files changed, 19 insertions, 8 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 5aef0fa414b..455831e8401 100644
--- a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr
+++ b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr
@@ -1,4 +1,4 @@
-error[E0158]: constant pattern depends on a generic parameter
+error[E0158]: constant pattern depends on a generic parameter, which is not allowed
   --> $DIR/associated-const-type-parameter-pattern.rs:20:9
    |
 LL | pub trait Foo {
@@ -6,10 +6,13 @@ LL | pub trait Foo {
 LL |     const X: EFoo;
    |     ------------- constant defined here
 ...
+LL | pub fn test<A: Foo, B: Foo>(arg: EFoo) {
+   |             - constant depends on this generic param
+LL |     match arg {
 LL |         A::X => println!("A::X"),
-   |         ^^^^
+   |         ^^^^ `const` depends on a generic parameter
 
-error[E0158]: constant pattern depends on a generic parameter
+error[E0158]: constant pattern depends on a generic parameter, which is not allowed
   --> $DIR/associated-const-type-parameter-pattern.rs:22:9
    |
 LL | pub trait Foo {
@@ -17,10 +20,13 @@ LL | pub trait Foo {
 LL |     const X: EFoo;
    |     ------------- constant defined here
 ...
+LL | pub fn test<A: Foo, B: Foo>(arg: EFoo) {
+   |                     - constant depends on this generic param
+...
 LL |         B::X => println!("B::X"),
-   |         ^^^^
+   |         ^^^^ `const` depends on a generic parameter
 
-error[E0158]: constant pattern depends on a generic parameter
+error[E0158]: constant pattern depends on a generic parameter, which is not allowed
   --> $DIR/associated-const-type-parameter-pattern.rs:30:9
    |
 LL | pub trait Foo {
@@ -28,10 +34,13 @@ 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) {
+   |                     - constant depends on this generic param
+LL |
 LL |     let A::X = arg;
-   |         ^^^^
+   |         ^^^^ `const` depends on a generic parameter
 
-error[E0158]: constant pattern depends on a generic parameter
+error[E0158]: constant pattern depends on a generic parameter, which is not allowed
   --> $DIR/associated-const-type-parameter-pattern.rs:28:48
    |
 LL | pub trait Foo {
@@ -40,7 +49,9 @@ LL |     const X: EFoo;
    |     ------------- constant defined here
 ...
 LL | pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
-   |                                                ^^^^
+   |                     -                          ^^^^ `const` depends on a generic parameter
+   |                     |
+   |                     constant depends on this generic param
 
 error: aborting due to 4 previous errors