rust/tests/ui/trivial-bounds/trivial-bounds-inconsistent.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
1.6 KiB
Rust
Raw Normal View History

2018-05-06 21:54:00 +00:00
// 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
2018-05-06 21:54:00 +00:00
struct S where i32: Foo; //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
trait T where i32: Foo {} //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
union U where i32: Foo { f: i32 } //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
type Y where i32: Foo = ();
//~^ WARNING type_alias_bounds
//~| WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
impl Foo for () where i32: Foo { //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
fn test(&self) {
3i32.test();
Foo::test(&4i32);
generic_function(5i32);
}
}
fn f() where i32: Foo { //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
let s = S;
3i32.test();
Foo::test(&4i32);
generic_function(5i32);
}
fn g() where &'static str: Foo { //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
"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
2018-05-06 21:54:00 +00:00
fn unsized_local() where for<'a> Dst<dyn A + 'a>: Sized { //~ WARNING trivial_bounds
2019-05-28 18:46:13 +00:00
let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>);
2018-05-06 21:54:00 +00:00
}
fn return_str() -> str where str: Sized { //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
*"Sized".to_string().into_boxed_str()
}
fn use_op(s: String) -> String where String: ::std::ops::Neg<Output=String> {
//~^ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
-s
}
fn use_for() where i32: Iterator { //~ WARNING trivial_bounds
2018-05-06 21:54:00 +00:00
for _ in 2i32 {}
}
fn main() {}