]> git.lizzy.rs Git - rust.git/blob - tests/ui/trivial-bounds/trivial-bounds-leak.rs
Rollup merge of #106470 - ehuss:tidy-no-wasm, r=Mark-Simulacrum
[rust.git] / tests / ui / trivial-bounds / trivial-bounds-leak.rs
1 // Check that false bounds don't leak
2 #![feature(trivial_bounds)]
3
4 pub trait Foo {
5     fn test(&self);
6 }
7
8 fn return_str() -> str where str: Sized {
9     *"Sized".to_string().into_boxed_str()
10 }
11
12 fn cant_return_str() -> str { //~ ERROR
13     *"Sized".to_string().into_boxed_str()
14 }
15
16 fn my_function() where i32: Foo
17 {
18     3i32.test();
19     Foo::test(&4i32);
20     generic_function(5i32);
21 }
22
23 fn foo() {
24     3i32.test(); //~ ERROR
25     Foo::test(&4i32); //~ ERROR
26     generic_function(5i32); //~ ERROR
27 }
28
29 fn generic_function<T: Foo>(t: T) {}
30
31 fn main() {}