summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-inherent-types
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/associated-inherent-types')
-rw-r--r--src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs10
-rw-r--r--src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr10
-rw-r--r--src/test/ui/associated-inherent-types/assoc-inherent-private.rs23
-rw-r--r--src/test/ui/associated-inherent-types/assoc-inherent-private.stderr21
-rw-r--r--src/test/ui/associated-inherent-types/assoc-inherent-unstable.rs6
-rw-r--r--src/test/ui/associated-inherent-types/assoc-inherent-unstable.stderr11
-rw-r--r--src/test/ui/associated-inherent-types/assoc-inherent-use.rs14
-rw-r--r--src/test/ui/associated-inherent-types/auxiliary/assoc-inherent-unstable.rs11
-rw-r--r--src/test/ui/associated-inherent-types/issue-104260.rs14
-rw-r--r--src/test/ui/associated-inherent-types/normalize-projection-0.rs22
-rw-r--r--src/test/ui/associated-inherent-types/normalize-projection-1.rs22
-rw-r--r--src/test/ui/associated-inherent-types/struct-generics.rs15
12 files changed, 179 insertions, 0 deletions
diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs
new file mode 100644
index 000000000..71f65b92e
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs
@@ -0,0 +1,10 @@
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct Foo;
+
+impl Foo {
+ type Baz; //~ ERROR associated type in `impl` without body
+}
+
+fn main() {}
diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr
new file mode 100644
index 000000000..387a5658d
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr
@@ -0,0 +1,10 @@
+error: associated type in `impl` without body
+ --> $DIR/assoc-inherent-no-body.rs:7:5
+ |
+LL | type Baz;
+ | ^^^^^^^^-
+ | |
+ | help: provide a definition for the type: `= <type>;`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-private.rs b/src/test/ui/associated-inherent-types/assoc-inherent-private.rs
new file mode 100644
index 000000000..531581954
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/assoc-inherent-private.rs
@@ -0,0 +1,23 @@
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+mod m {
+ pub struct T;
+ impl T {
+ type P = ();
+ }
+}
+type U = m::T::P; //~ ERROR associated type `P` is private
+
+mod n {
+ pub mod n {
+ pub struct T;
+ impl T {
+ pub(super) type P = bool;
+ }
+ }
+ type U = n::T::P;
+}
+type V = n::n::T::P; //~ ERROR associated type `P` is private
+
+fn main() {}
diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-private.stderr b/src/test/ui/associated-inherent-types/assoc-inherent-private.stderr
new file mode 100644
index 000000000..d67b45dae
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/assoc-inherent-private.stderr
@@ -0,0 +1,21 @@
+error[E0624]: associated type `P` is private
+ --> $DIR/assoc-inherent-private.rs:10:10
+ |
+LL | type P = ();
+ | ------ associated type defined here
+...
+LL | type U = m::T::P;
+ | ^^^^^^^ private associated type
+
+error[E0624]: associated type `P` is private
+ --> $DIR/assoc-inherent-private.rs:21:10
+ |
+LL | pub(super) type P = bool;
+ | ----------------- associated type defined here
+...
+LL | type V = n::n::T::P;
+ | ^^^^^^^^^^ private associated type
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0624`.
diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-unstable.rs b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.rs
new file mode 100644
index 000000000..34b4e47bf
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.rs
@@ -0,0 +1,6 @@
+// aux-crate:aux=assoc-inherent-unstable.rs
+// edition: 2021
+
+type Data = aux::Owner::Data; //~ ERROR use of unstable library feature 'data'
+
+fn main() {}
diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-unstable.stderr b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.stderr
new file mode 100644
index 000000000..c0be8bfd7
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/assoc-inherent-unstable.stderr
@@ -0,0 +1,11 @@
+error[E0658]: use of unstable library feature 'data'
+ --> $DIR/assoc-inherent-unstable.rs:4:13
+ |
+LL | type Data = aux::Owner::Data;
+ | ^^^^^^^^^^^^^^^^
+ |
+ = help: add `#![feature(data)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-use.rs b/src/test/ui/associated-inherent-types/assoc-inherent-use.rs
new file mode 100644
index 000000000..7ae425e2a
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/assoc-inherent-use.rs
@@ -0,0 +1,14 @@
+// check-pass
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct Foo;
+
+impl Foo {
+ type Bar = isize;
+}
+
+fn main() {
+ let x: Foo::Bar;
+ x = 0isize;
+}
diff --git a/src/test/ui/associated-inherent-types/auxiliary/assoc-inherent-unstable.rs b/src/test/ui/associated-inherent-types/auxiliary/assoc-inherent-unstable.rs
new file mode 100644
index 000000000..6b71ffc97
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/auxiliary/assoc-inherent-unstable.rs
@@ -0,0 +1,11 @@
+#![feature(staged_api)]
+#![feature(inherent_associated_types)]
+#![stable(feature = "main", since = "1.0.0")]
+
+#[stable(feature = "main", since = "1.0.0")]
+pub struct Owner;
+
+impl Owner {
+ #[unstable(feature = "data", issue = "none")]
+ pub type Data = ();
+}
diff --git a/src/test/ui/associated-inherent-types/issue-104260.rs b/src/test/ui/associated-inherent-types/issue-104260.rs
new file mode 100644
index 000000000..a73cd1775
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/issue-104260.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct Foo;
+
+impl Foo {
+ type Bar<T> = u8;
+}
+
+fn main() {
+ let a: Foo::Bar<()>;
+}
diff --git a/src/test/ui/associated-inherent-types/normalize-projection-0.rs b/src/test/ui/associated-inherent-types/normalize-projection-0.rs
new file mode 100644
index 000000000..50763ecdd
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/normalize-projection-0.rs
@@ -0,0 +1,22 @@
+// check-pass
+
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct S<T>(T);
+
+impl<T: O> S<T> {
+ type P = <T as O>::P;
+}
+
+trait O {
+ type P;
+}
+
+impl O for i32 {
+ type P = String;
+}
+
+fn main() {
+ let _: S<i32>::P = String::new();
+}
diff --git a/src/test/ui/associated-inherent-types/normalize-projection-1.rs b/src/test/ui/associated-inherent-types/normalize-projection-1.rs
new file mode 100644
index 000000000..2f7b2551a
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/normalize-projection-1.rs
@@ -0,0 +1,22 @@
+// check-pass
+
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct S;
+
+impl S {
+ type P<T: O> = <T as O>::P;
+}
+
+trait O {
+ type P;
+}
+
+impl O for i32 {
+ type P = String;
+}
+
+fn main() {
+ let _: S::P<i32> = String::new();
+}
diff --git a/src/test/ui/associated-inherent-types/struct-generics.rs b/src/test/ui/associated-inherent-types/struct-generics.rs
new file mode 100644
index 000000000..8952b3791
--- /dev/null
+++ b/src/test/ui/associated-inherent-types/struct-generics.rs
@@ -0,0 +1,15 @@
+// check-pass
+
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct S<T>(T);
+
+impl<T> S<T> {
+ type P = T;
+}
+
+fn main() {
+ type A = S<()>::P;
+ let _: A = ();
+}