Skip to content

Commit 340737d

Browse files
committed
Add coherence leak check test for impls with no higher ranked types
1 parent ae2fdfa commit 340737d

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
3+
trait Trait<'a> {}
4+
5+
impl Trait<'static> for u8 {}
6+
7+
impl Trait<'_> for (u8,) {}
8+
impl<T> Trait<'_> for (T,) where T: for<'a> Trait<'a> {}
9+
//~^ WARN conflicting implementations of trait `Trait<'_>` for type `(u8,)`
10+
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
11+
12+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: conflicting implementations of trait `Trait<'_>` for type `(u8,)`
2+
--> $DIR/coherence-free-regions.rs:8:1
3+
|
4+
LL | impl Trait<'_> for (u8,) {}
5+
| ------------------------ first implementation here
6+
LL | impl<T> Trait<'_> for (T,) where T: for<'a> Trait<'a> {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8,)`
8+
|
9+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
10+
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
11+
= note: `#[warn(coherence_leak_check)]` on by default
12+
13+
warning: 1 warning emitted
14+

0 commit comments

Comments
 (0)