about summary refs log tree commit diff
path: root/tests/ui/generic-const-items
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-05-23 20:05:28 +0200
committerLeón Orell Valerian Liehr <me@fmease.dev>2024-05-24 00:42:32 +0200
commit39d9b840bbd2ed663241f4800f4d07b7950df46f (patch)
treebf9bd5b2015c5e202b5e59e3ca81c9671e3e9454 /tests/ui/generic-const-items
parent24afa42a90eb035e24e5dcffbc538fb96277e3a3 (diff)
downloadrust-39d9b840bbd2ed663241f4800f4d07b7950df46f.tar.gz
rust-39d9b840bbd2ed663241f4800f4d07b7950df46f.zip
Handle trait/impl GAC mismatches when inferring missing/placeholder types
Diffstat (limited to 'tests/ui/generic-const-items')
-rw-r--r--tests/ui/generic-const-items/assoc-const-missing-type.rs4
-rw-r--r--tests/ui/generic-const-items/assoc-const-missing-type.stderr26
2 files changed, 25 insertions, 5 deletions
diff --git a/tests/ui/generic-const-items/assoc-const-missing-type.rs b/tests/ui/generic-const-items/assoc-const-missing-type.rs
index 80f282ea134..93160f0b575 100644
--- a/tests/ui/generic-const-items/assoc-const-missing-type.rs
+++ b/tests/ui/generic-const-items/assoc-const-missing-type.rs
@@ -5,6 +5,7 @@
 
 trait Trait {
     const K<T>: T;
+    const Q<'a>: &'a str;
 }
 
 impl Trait for () {
@@ -12,6 +13,9 @@ impl Trait for () {
     //~^ ERROR missing type for `const` item
     //~| ERROR mismatched types
     //~| ERROR mismatched types
+    const Q = "";
+    //~^ ERROR missing type for `const` item
+    //~| ERROR lifetime parameters or bounds on const `Q` do not match the trait declaration
 }
 
 fn main() {}
diff --git a/tests/ui/generic-const-items/assoc-const-missing-type.stderr b/tests/ui/generic-const-items/assoc-const-missing-type.stderr
index 158e9a068f6..6f35c0958d4 100644
--- a/tests/ui/generic-const-items/assoc-const-missing-type.stderr
+++ b/tests/ui/generic-const-items/assoc-const-missing-type.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/assoc-const-missing-type.rs:11:18
+  --> $DIR/assoc-const-missing-type.rs:12:18
    |
 LL |     const K<T> = ();
    |             -    ^^ expected type parameter `T`, found `()`
@@ -10,13 +10,28 @@ LL |     const K<T> = ();
                    found unit type `()`
 
 error: missing type for `const` item
-  --> $DIR/assoc-const-missing-type.rs:11:15
+  --> $DIR/assoc-const-missing-type.rs:12:15
    |
 LL |     const K<T> = ();
    |               ^ help: provide a type for the associated constant: `()`
 
+error[E0195]: lifetime parameters or bounds on const `Q` do not match the trait declaration
+  --> $DIR/assoc-const-missing-type.rs:16:12
+   |
+LL |     const Q<'a>: &'a str;
+   |            ---- lifetimes in impl do not match this const in trait
+...
+LL |     const Q = "";
+   |            ^ lifetimes do not match const in trait
+
+error: missing type for `const` item
+  --> $DIR/assoc-const-missing-type.rs:16:12
+   |
+LL |     const Q = "";
+   |            ^ help: provide a type for the associated constant: `: &str`
+
 error[E0308]: mismatched types
-  --> $DIR/assoc-const-missing-type.rs:11:18
+  --> $DIR/assoc-const-missing-type.rs:12:18
    |
 LL |     const K<T> = ();
    |             -    ^^ expected type parameter `T`, found `()`
@@ -27,6 +42,7 @@ LL |     const K<T> = ();
                    found unit type `()`
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
-error: aborting due to 3 previous errors
+error: aborting due to 5 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
+Some errors have detailed explanations: E0195, E0308.
+For more information about an error, try `rustc --explain E0195`.