Skip to content

Commit e148520

Browse files
Commit some new solver tests
1 parent d962ea5 commit e148520

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// check-pass
2+
// compile-flags: -Ztrait-solver=next
3+
4+
use std::error::Error;
5+
6+
fn main() -> Result<(), Box<dyn Error>> {
7+
let x: i32 = parse()?;
8+
Ok(())
9+
}
10+
11+
trait Parse {}
12+
13+
impl Parse for i32 {}
14+
15+
#[derive(Debug)]
16+
struct ParseError;
17+
18+
impl std::fmt::Display for ParseError {
19+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20+
write!(f, "ParseError")
21+
}
22+
}
23+
24+
impl Error for ParseError {}
25+
26+
fn parse<T: Parse>() -> Result<T, ParseError> {
27+
todo!()
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// compile-flags: -Ztrait-solver=next
2+
// known-bug: unknown
3+
4+
trait Test {
5+
type Assoc;
6+
}
7+
8+
fn transform<T: Test>(x: T) -> T::Assoc {
9+
todo!()
10+
}
11+
12+
impl Test for i32 {
13+
type Assoc = i32;
14+
}
15+
16+
impl Test for String {
17+
type Assoc = String;
18+
}
19+
20+
fn main() {
21+
let mut x = Default::default();
22+
x = transform(x);
23+
x = 1i32;
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/equating-projection-cyclically.rs:22:19
3+
|
4+
LL | x = transform(x);
5+
| ^ expected inferred type, found associated type
6+
|
7+
= note: expected type `_`
8+
found associated type `<_ as Test>::Assoc`
9+
= help: consider constraining the associated type `<_ as Test>::Assoc` to `_`
10+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)