From 9e264137e9cececda98521bd411f3317c408a0ec Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 22 Oct 2021 15:55:56 -0300 Subject: [PATCH] Be sure that we do not allow too much --- .../coherence-overlap-trait-alias.rs | 20 +++++++++++++++++++ .../coherence-overlap-trait-alias.stderr | 16 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/ui/coherence/coherence-overlap-trait-alias.rs create mode 100644 src/test/ui/coherence/coherence-overlap-trait-alias.stderr diff --git a/src/test/ui/coherence/coherence-overlap-trait-alias.rs b/src/test/ui/coherence/coherence-overlap-trait-alias.rs new file mode 100644 index 000000000000..45b2f0863055 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-trait-alias.rs @@ -0,0 +1,20 @@ +#![feature(rustc_attrs)] +#![feature(trait_alias)] + +trait A {} +trait B {} +trait AB = A + B; + +impl A for u32 {} +impl B for u32 {} + +trait C {} +#[rustc_strict_coherence] +impl C for T {} +#[rustc_strict_coherence] +impl C for u32 {} +//~^ ERROR +// FIXME it's giving an ungreat error but unsure if we care given that it's using an internal rustc +// attribute and an artificial code path for testing purposes + +fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-trait-alias.stderr b/src/test/ui/coherence/coherence-overlap-trait-alias.stderr new file mode 100644 index 000000000000..e2e8ad54beb1 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-trait-alias.stderr @@ -0,0 +1,16 @@ +error[E0283]: type annotations needed + --> $DIR/coherence-overlap-trait-alias.rs:15:6 + | +LL | impl C for u32 {} + | ^ cannot infer type for type `u32` + | + = note: cannot satisfy `u32: C` +note: required by a bound in `C` + --> $DIR/coherence-overlap-trait-alias.rs:11:1 + | +LL | trait C {} + | ^^^^^^^ required by this bound in `C` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0283`.