Add tests.
This commit is contained in:
parent
ce1073ba9d
commit
4e7edf3684
30
tests/ui/impl-trait/issue-108591.rs
Normal file
30
tests/ui/impl-trait/issue-108591.rs
Normal 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() {}
|
21
tests/ui/impl-trait/issue-108592.rs
Normal file
21
tests/ui/impl-trait/issue-108592.rs
Normal 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() {}
|
21
tests/ui/impl-trait/issue-108592.stderr
Normal file
21
tests/ui/impl-trait/issue-108592.stderr
Normal 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`.
|
Loading…
Reference in New Issue
Block a user