forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-fn-with-lifetime.rs
More file actions
47 lines (34 loc) · 865 Bytes
/
Copy pathtest-fn-with-lifetime.rs
File metadata and controls
47 lines (34 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// compile-flags: --test
// Issue #55228
#![feature(termination_trait_lib)]
use std::process::Termination;
#[test]
fn unit_1() -> Result<(), &'static str> { // this is OK
Ok(())
}
#[test]
fn unit_2<'a>() -> Result<(), &'a str> { // also OK
Ok(())
}
#[test]
fn unit_3<T: Termination>() -> Result<(), T> { // nope (how would this get monomorphized?)
//~^ ERROR return value of functions used as tests must either be `()` or implement
Ok(())
}
struct Quux;
trait Bar {
type Baz;
fn rah(&self) -> Self::Baz;
}
impl Bar for Quux {
type Baz = String;
fn rah(&self) -> Self::Baz {
"rah".to_owned()
}
}
#[test]
fn unit_4<T: Bar<Baz = String>>() -> <T as Bar>::Baz { // also nope
//~^ ERROR return value of functions used as tests must either be `()` or implement
let q = Quux{};
<Quux as Bar>::rah(&q)
}