Add tests.

This commit is contained in:
Camille GILLOT 2023-04-16 09:56:37 +00:00
parent ce1073ba9d
commit 4e7edf3684
3 changed files with 72 additions and 0 deletions

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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`.