summaryrefslogtreecommitdiffstats
path: root/tests/ui/auto-traits/typeck-default-trait-impl-precedence.rs
blob: 2bbe82270bd06a16c2d4732a74ae95fd6e14c93d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Test that declaring that `&T` is `Defaulted` if `T:Signed` implies
// that other `&T` is NOT `Defaulted` if `T:Signed` does not hold. In
// other words, the auto impl only applies if there are no existing
// impls whose types unify.

#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait Defaulted { }
impl<'a,T:Signed> Defaulted for &'a T { }
impl<'a,T:Signed> Defaulted for &'a mut T { }
fn is_defaulted<T:Defaulted>() { }

trait Signed { }
impl Signed for i32 { }

fn main() {
    is_defaulted::<&'static i32>();
    is_defaulted::<&'static u32>();
    //~^ ERROR `u32: Signed` is not satisfied
}