summaryrefslogtreecommitdiffstats
path: root/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs
blob: 7148f5d6da05b8abcdcad4f9d86c710b90468363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// run-pass

// Check that tautalogically false bounds are accepted, and are used
// in type inference.
#![feature(trivial_bounds)]
#![allow(unused)]

pub trait Foo {
    fn test(&self);
}

fn generic_function<X: Foo>(x: X) {}

enum E where i32: Foo { V } //~ WARNING trivial_bounds

struct S where i32: Foo; //~ WARNING trivial_bounds

trait T where i32: Foo {} //~ WARNING trivial_bounds

union U where i32: Foo { f: i32 } //~ WARNING trivial_bounds

type Y where i32: Foo = ();
//~^ WARNING type_alias_bounds
//~| WARNING trivial_bounds

impl Foo for () where i32: Foo { //~ WARNING trivial_bounds
    fn test(&self) {
        3i32.test();
        Foo::test(&4i32);
        generic_function(5i32);
    }
}

fn f() where i32: Foo { //~ WARNING trivial_bounds
    let s = S;
    3i32.test();
    Foo::test(&4i32);
    generic_function(5i32);
}

fn g() where &'static str: Foo { //~ WARNING trivial_bounds
    "Foo".test();
    Foo::test(&"Foo");
    generic_function("Foo");
}

trait A {}

impl A for i32 {}

struct Dst<X: ?Sized> {
    x: X,
}

struct TwoStrs(str, str) where str: Sized; //~ WARNING trivial_bounds

fn unsized_local() where for<'a> Dst<dyn A + 'a>: Sized { //~ WARNING trivial_bounds
    let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>);
}

fn return_str() -> str where str: Sized { //~ WARNING trivial_bounds
    *"Sized".to_string().into_boxed_str()
}

fn use_op(s: String) -> String where String: ::std::ops::Neg<Output=String> {
    //~^ WARNING trivial_bounds
    -s
}

fn use_for() where i32: Iterator { //~ WARNING trivial_bounds
    for _ in 2i32 {}
}

fn main() {}