Skip to content

Commit 2111525

Browse files
committed
Add test false-sealed-traits-note.rs
Signed-off-by: xizheyin <[email protected]>
1 parent c96a690 commit 2111525

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// when we impl TraitA for Struct, it can compile, we should not emit sealed traits note, see issue #143392
2+
3+
mod inner {
4+
pub trait TraitA {}
5+
6+
pub trait TraitB: TraitA {}
7+
}
8+
9+
struct Struct;
10+
11+
impl inner::TraitB for Struct {} //~ ERROR the trait bound `Struct: TraitA` is not satisfied [E0277]
12+
13+
fn main(){}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0277]: the trait bound `Struct: TraitA` is not satisfied
2+
--> $DIR/false-sealed-traits-note.rs:11:24
3+
|
4+
LL | impl inner::TraitB for Struct {}
5+
| ^^^^^^ the trait `TraitA` is not implemented for `Struct`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/false-sealed-traits-note.rs:4:5
9+
|
10+
LL | pub trait TraitA {}
11+
| ^^^^^^^^^^^^^^^^
12+
note: required by a bound in `TraitB`
13+
--> $DIR/false-sealed-traits-note.rs:6:23
14+
|
15+
LL | pub trait TraitB: TraitA {}
16+
| ^^^^^^ required by this bound in `TraitB`
17+
= note: `TraitB` is a "sealed trait", because to implement it you also need to implement `inner::TraitA`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
18+
19+
error: aborting due to 1 previous error
20+
21+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)