Skip to content

Commit c8f6e03

Browse files
committed
Add regression test
1 parent bd12986 commit c8f6e03

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

Diff for: tests/ui/wf/conflicting-impls.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ edition: 2021
2+
3+
struct Ty;
4+
5+
impl TryFrom<Ty> for u8 {
6+
type Error = Ty;
7+
fn try_from(_: Ty) -> Result<Self, Self::Error> {
8+
//~^ ERROR type annotations needed
9+
loop {}
10+
}
11+
}
12+
13+
impl TryFrom<Ty> for u8 {
14+
//~^ ERROR conflicting implementations of trait
15+
type Error = Ty;
16+
fn try_from(_: Ty) -> Result<Self, Self::Error> {
17+
//~^ ERROR type annotations needed
18+
loop {}
19+
}
20+
}
21+
22+
fn main() {}

Diff for: tests/ui/wf/conflicting-impls.stderr

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
error[E0119]: conflicting implementations of trait `TryFrom<Ty>` for type `u8`
2+
--> $DIR/conflicting-impls.rs:12:1
3+
|
4+
LL | impl TryFrom<Ty> for u8 {
5+
| ----------------------- first implementation here
6+
...
7+
LL | impl TryFrom<Ty> for u8 {
8+
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8`
9+
10+
error[E0282]: type annotations needed
11+
--> $DIR/conflicting-impls.rs:7:5
12+
|
13+
LL | fn try_from(_: Ty) -> Result<Self, Self::Error> {
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
15+
|
16+
note: the requirement `_ <: _` appears on the `impl`'s method `try_from` but not on the corresponding trait's method
17+
--> $SRC_DIR/core/src/convert/mod.rs:LL:COL
18+
|
19+
= note: in this trait
20+
::: $SRC_DIR/core/src/convert/mod.rs:LL:COL
21+
|
22+
= note: this trait's method doesn't have the requirement `_ <: _`
23+
24+
error[E0282]: type annotations needed
25+
--> $DIR/conflicting-impls.rs:14:5
26+
|
27+
LL | fn try_from(_: Ty) -> Result<Self, Self::Error> {
28+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
29+
|
30+
note: the requirement `_ <: _` appears on the `impl`'s method `try_from` but not on the corresponding trait's method
31+
--> $SRC_DIR/core/src/convert/mod.rs:LL:COL
32+
|
33+
= note: in this trait
34+
::: $SRC_DIR/core/src/convert/mod.rs:LL:COL
35+
|
36+
= note: this trait's method doesn't have the requirement `_ <: _`
37+
38+
error: aborting due to 3 previous errors
39+
40+
Some errors have detailed explanations: E0119, E0282.
41+
For more information about an error, try `rustc --explain E0119`.

0 commit comments

Comments
 (0)