summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-consts
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/associated-consts')
-rw-r--r--src/test/ui/associated-consts/defaults-cyclic-fail.stderr8
-rw-r--r--src/test/ui/associated-consts/defaults-not-assumed-fail.rs3
-rw-r--r--src/test/ui/associated-consts/defaults-not-assumed-fail.stderr28
-rw-r--r--src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr4
-rw-r--r--src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr4
-rw-r--r--src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr4
-rw-r--r--src/test/ui/associated-consts/issue-47814.rs14
-rw-r--r--src/test/ui/associated-consts/issue-47814.stderr14
-rw-r--r--src/test/ui/associated-consts/issue-58022.rs19
-rw-r--r--src/test/ui/associated-consts/issue-58022.stderr19
-rw-r--r--src/test/ui/associated-consts/issue-93835.rs8
-rw-r--r--src/test/ui/associated-consts/issue-93835.stderr65
12 files changed, 124 insertions, 66 deletions
diff --git a/src/test/ui/associated-consts/defaults-cyclic-fail.stderr b/src/test/ui/associated-consts/defaults-cyclic-fail.stderr
index c4cd9c2a4..a1483911b 100644
--- a/src/test/ui/associated-consts/defaults-cyclic-fail.stderr
+++ b/src/test/ui/associated-consts/defaults-cyclic-fail.stderr
@@ -1,14 +1,14 @@
error[E0391]: cycle detected when const-evaluating + checking `Tr::A`
- --> $DIR/defaults-cyclic-fail.rs:5:5
+ --> $DIR/defaults-cyclic-fail.rs:5:19
|
LL | const A: u8 = Self::B;
- | ^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^
|
note: ...which requires const-evaluating + checking `Tr::B`...
- --> $DIR/defaults-cyclic-fail.rs:8:5
+ --> $DIR/defaults-cyclic-fail.rs:8:19
|
LL | const B: u8 = Self::A;
- | ^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^
= note: ...which again requires const-evaluating + checking `Tr::A`, completing the cycle
note: cycle used when const-evaluating + checking `main::promoted[1]`
--> $DIR/defaults-cyclic-fail.rs:16:16
diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs
index 6762d7583..495dfb338 100644
--- a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs
+++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs
@@ -31,8 +31,7 @@ impl Tr for u32 {
fn main() {
assert_eq!(<() as Tr>::A, 255);
assert_eq!(<() as Tr>::B, 0); // causes the error above
- //~^ ERROR evaluation of constant value failed
- //~| ERROR erroneous constant used
+ //~^ constant
assert_eq!(<u8 as Tr>::A, 254);
assert_eq!(<u8 as Tr>::B, 255);
diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr
index aa130f438..fb7159e40 100644
--- a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr
+++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr
@@ -4,20 +4,36 @@ error[E0080]: evaluation of `<() as Tr>::B` failed
LL | const B: u8 = Self::A + 1;
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
-error[E0080]: evaluation of constant value failed
+note: erroneous constant used
--> $DIR/defaults-not-assumed-fail.rs:33:16
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
- | ^^^^^^^^^^^^^ referenced constant has errors
+ | ^^^^^^^^^^^^^
-error[E0080]: erroneous constant used
+note: erroneous constant used
--> $DIR/defaults-not-assumed-fail.rs:33:5
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: aborting due to 3 previous errors
+note: erroneous constant used
+ --> $DIR/defaults-not-assumed-fail.rs:33:5
+ |
+LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+note: erroneous constant used
+ --> $DIR/defaults-not-assumed-fail.rs:33:5
+ |
+LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr
index c8c57bccb..be5781761 100644
--- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr
+++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr
@@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
- --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
+ --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:27
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 11:19>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr
index 76ed8d4a6..8347b260b 100644
--- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr
+++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr
@@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
- --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
+ --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:30
|
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr
index 6a98f08f3..3955a3120 100644
--- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr
+++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr
@@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
- --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
+ --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:28
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
diff --git a/src/test/ui/associated-consts/issue-47814.rs b/src/test/ui/associated-consts/issue-47814.rs
new file mode 100644
index 000000000..a28b1c001
--- /dev/null
+++ b/src/test/ui/associated-consts/issue-47814.rs
@@ -0,0 +1,14 @@
+struct ArpIPv4<'a> {
+ s: &'a u8
+}
+
+impl<'a> ArpIPv4<'a> {
+ const LENGTH: usize = 20;
+
+ pub fn to_buffer() -> [u8; Self::LENGTH] {
+ //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants
+ unimplemented!()
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/associated-consts/issue-47814.stderr b/src/test/ui/associated-consts/issue-47814.stderr
new file mode 100644
index 000000000..2e4ddb811
--- /dev/null
+++ b/src/test/ui/associated-consts/issue-47814.stderr
@@ -0,0 +1,14 @@
+error: generic `Self` types are currently not permitted in anonymous constants
+ --> $DIR/issue-47814.rs:8:32
+ |
+LL | pub fn to_buffer() -> [u8; Self::LENGTH] {
+ | ^^^^
+ |
+note: not a concrete type
+ --> $DIR/issue-47814.rs:5:10
+ |
+LL | impl<'a> ArpIPv4<'a> {
+ | ^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/associated-consts/issue-58022.rs b/src/test/ui/associated-consts/issue-58022.rs
new file mode 100644
index 000000000..2a8a1eaa6
--- /dev/null
+++ b/src/test/ui/associated-consts/issue-58022.rs
@@ -0,0 +1,19 @@
+pub trait Foo: Sized {
+ const SIZE: usize;
+
+ fn new(slice: &[u8; Foo::SIZE]) -> Self;
+ //~^ ERROR: E0790
+}
+
+pub struct Bar<T: ?Sized>(T);
+
+impl Bar<[u8]> {
+ const SIZE: usize = 32;
+
+ fn new(slice: &[u8; Self::SIZE]) -> Self {
+ Foo(Box::new(*slice))
+ //~^ ERROR: expected function, tuple struct or tuple variant, found trait `Foo`
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/associated-consts/issue-58022.stderr b/src/test/ui/associated-consts/issue-58022.stderr
new file mode 100644
index 000000000..56d85c066
--- /dev/null
+++ b/src/test/ui/associated-consts/issue-58022.stderr
@@ -0,0 +1,19 @@
+error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type
+ --> $DIR/issue-58022.rs:4:25
+ |
+LL | const SIZE: usize;
+ | ------------------ `Foo::SIZE` defined here
+LL |
+LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
+ | ^^^^^^^^^ cannot refer to the associated constant of trait
+
+error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo`
+ --> $DIR/issue-58022.rs:14:9
+ |
+LL | Foo(Box::new(*slice))
+ | ^^^ not a function, tuple struct or tuple variant
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0423, E0790.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/src/test/ui/associated-consts/issue-93835.rs b/src/test/ui/associated-consts/issue-93835.rs
index 5c7b06598..b2a437fcb 100644
--- a/src/test/ui/associated-consts/issue-93835.rs
+++ b/src/test/ui/associated-consts/issue-93835.rs
@@ -1,9 +1,11 @@
+#![feature(type_ascription)]
+
fn e() {
- p:a<p:p<e=6>>
- //~^ ERROR comparison operators
+ type_ascribe!(p, a<p:p<e=6>>);
+ //~^ ERROR cannot find type `a` in this scope
//~| ERROR cannot find value
//~| ERROR associated const equality
- //~| ERROR associated const equality
+ //~| ERROR cannot find trait `p` in this scope
//~| ERROR associated type bounds
}
diff --git a/src/test/ui/associated-consts/issue-93835.stderr b/src/test/ui/associated-consts/issue-93835.stderr
index 0406a16a3..be0573a13 100644
--- a/src/test/ui/associated-consts/issue-93835.stderr
+++ b/src/test/ui/associated-consts/issue-93835.stderr
@@ -1,65 +1,40 @@
-error: comparison operators cannot be chained
- --> $DIR/issue-93835.rs:2:8
- |
-LL | fn e() {
- | - while parsing this struct
-LL | p:a<p:p<e=6>>
- | ^ ^
- |
- = help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
- = help: or use `(...)` if you meant to specify fn arguments
-
error[E0425]: cannot find value `p` in this scope
- --> $DIR/issue-93835.rs:2:5
- |
-LL | p:a<p:p<e=6>>
- | ^ not found in this scope
- |
-help: you might have meant to write a `struct` literal
- |
-LL ~ fn e() { SomeStruct {
-LL | p:a<p:p<e=6>>
- ...
-LL |
-LL ~ }}
+ --> $DIR/issue-93835.rs:4:19
|
-help: maybe you meant to write a path separator here
- |
-LL | p::a<p:p<e=6>>
- | ~~
-help: maybe you meant to write an assignment here
- |
-LL | let p:a<p:p<e=6>>
- | ~~~~~
+LL | type_ascribe!(p, a<p:p<e=6>>);
+ | ^ not found in this scope
-error[E0658]: associated const equality is incomplete
- --> $DIR/issue-93835.rs:2:13
+error[E0412]: cannot find type `a` in this scope
+ --> $DIR/issue-93835.rs:4:22
|
-LL | p:a<p:p<e=6>>
- | ^^^
+LL | type_ascribe!(p, a<p:p<e=6>>);
+ | ^ not found in this scope
+
+error[E0405]: cannot find trait `p` in this scope
+ --> $DIR/issue-93835.rs:4:26
|
- = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
- = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
+LL | type_ascribe!(p, a<p:p<e=6>>);
+ | ^ not found in this scope
error[E0658]: associated const equality is incomplete
- --> $DIR/issue-93835.rs:2:13
+ --> $DIR/issue-93835.rs:4:28
|
-LL | p:a<p:p<e=6>>
- | ^^^
+LL | type_ascribe!(p, a<p:p<e=6>>);
+ | ^^^
|
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
error[E0658]: associated type bounds are unstable
- --> $DIR/issue-93835.rs:2:9
+ --> $DIR/issue-93835.rs:4:24
|
-LL | p:a<p:p<e=6>>
- | ^^^^^^^^
+LL | type_ascribe!(p, a<p:p<e=6>>);
+ | ^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
error: aborting due to 5 previous errors
-Some errors have detailed explanations: E0425, E0658.
-For more information about an error, try `rustc --explain E0425`.
+Some errors have detailed explanations: E0405, E0412, E0425, E0658.
+For more information about an error, try `rustc --explain E0405`.