]> git.proxmox.com Git - rustc.git/blob - tests/ui/unsized-locals/unsized-exprs-rpass.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / unsized-locals / unsized-exprs-rpass.rs
1 // run-pass
2 #![allow(incomplete_features, unused_braces, unused_parens)]
3 #![feature(unsized_tuple_coercion, unsized_locals, unsized_fn_params)]
4
5 struct A<X: ?Sized>(#[allow(unused_tuple_struct_fields)] X);
6
7 fn udrop<T: ?Sized>(_x: T) {}
8 fn foo() -> Box<[u8]> {
9 Box::new(*b"foo")
10 }
11 fn tfoo() -> Box<(i32, [u8])> {
12 Box::new((42, *b"foo"))
13 }
14 fn afoo() -> Box<A<[u8]>> {
15 Box::new(A(*b"foo"))
16 }
17
18 impl std::ops::Add<i32> for A<[u8]> {
19 type Output = ();
20 fn add(self, _rhs: i32) -> Self::Output {}
21 }
22
23 fn main() {
24 udrop::<[u8]>(loop {
25 break *foo();
26 });
27 udrop::<[u8]>(if true { *foo() } else { *foo() });
28 udrop::<[u8]>({ *foo() });
29 udrop::<[u8]>((*foo()));
30 udrop::<[u8]>((*tfoo()).1);
31 *afoo() + 42;
32 udrop as fn([u8]);
33 }