summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-04-16 09:56:37 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-04-16 09:58:08 +0000
commit4e7edf3684ac96f57f918afdb560c4af7afafb60 (patch)
treeead29391115561f2f8b85e083ab46b2868c16712
parentce1073ba9d894b2e351b2a85fcd39f2c99b78974 (diff)
Add tests.
-rw-r--r--tests/ui/impl-trait/issue-108591.rs30
-rw-r--r--tests/ui/impl-trait/issue-108592.rs21
-rw-r--r--tests/ui/impl-trait/issue-108592.stderr21
3 files changed, 72 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/issue-108591.rs b/tests/ui/impl-trait/issue-108591.rs
new file mode 100644
index 00000000000..6b9d14941f2
--- /dev/null
+++ b/tests/ui/impl-trait/issue-108591.rs
@@ -0,0 +1,30 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+struct MyTy<'a>(Vec<u8>, &'a ());
+
+impl MyTy<'_> {
+ fn one(&mut self) -> &mut impl Sized {
+ &mut self.0
+ }
+ fn two(&mut self) -> &mut (impl Sized + 'static) {
+ self.one()
+ }
+}
+
+type Opaque<'a> = impl Sized;
+fn define<'a>() -> Opaque<'a> {}
+
+fn test<'a>() {
+ None::<&'static Opaque<'a>>;
+}
+
+fn one<'a, 'b: 'b>() -> &'a impl Sized {
+ &()
+}
+fn two<'a, 'b>() {
+ one::<'a, 'b>();
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/issue-108592.rs b/tests/ui/impl-trait/issue-108592.rs
new file mode 100644
index 00000000000..58a0ed9bf1a
--- /dev/null
+++ b/tests/ui/impl-trait/issue-108592.rs
@@ -0,0 +1,21 @@
+// check-pass
+#![feature(type_alias_impl_trait)]
+
+fn opaque<'a: 'a>() -> impl Sized {}
+fn assert_static<T: 'static>(_: T) {}
+
+fn test_closure() {
+ let closure = |_| {
+ assert_static(opaque());
+ };
+ closure(&opaque());
+}
+
+type Opaque<'a> = impl Sized;
+fn define<'a>() -> Opaque<'a> {}
+
+fn test_tait(_: &Opaque<'_>) {
+ None::<&'static Opaque<'_>>;
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/issue-108592.stderr b/tests/ui/impl-trait/issue-108592.stderr
new file mode 100644
index 00000000000..3fbf0b266c3
--- /dev/null
+++ b/tests/ui/impl-trait/issue-108592.stderr
@@ -0,0 +1,21 @@
+error[E0428]: the name `test` is defined multiple times
+ --> $DIR/issue-108592.rs:17:1
+ |
+LL | fn test() {
+ | --------- previous definition of the value `test` here
+...
+LL | fn test(_: &Opaque<'_>) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ `test` redefined here
+ |
+ = note: `test` must be defined only once in the value namespace of this module
+
+error[E0601]: `main` function not found in crate `issue_108592`
+ --> $DIR/issue-108592.rs:20:2
+ |
+LL | }
+ | ^ consider adding a `main` function to `$DIR/issue-108592.rs`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0428, E0601.
+For more information about an error, try `rustc --explain E0428`.