about summary refs log tree commit diff
path: root/tests/ui/trait-bounds/fix-dyn-sized-fn-param-sugg.rs
blob: 1aa36207bc3ea25bd07e18f0c749c5bfadf2d245 (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
// Test that we emit a correct structured suggestions for dynamically sized ("maybe unsized")
// function parameters.
// We used to emit a butchered suggestion if duplicate relaxed `Sized` bounds were present.
// issue: <https://github.com/rust-lang/rust/issues/127441>.

use std::fmt::Debug;

fn foo1<T: ?Sized>(a: T) {}
//~^ ERROR the size for values of type `T` cannot be known at compilation time

fn foo2<T: ?Sized + ?Sized>(a: T) {}
//~^ ERROR duplicate relaxed `Sized` bounds
//~| ERROR the size for values of type `T` cannot be known at compilation time

fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
//~^ ERROR duplicate relaxed `Sized` bounds
//~| ERROR the size for values of type `T` cannot be known at compilation time

fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
//~^ ERROR duplicate relaxed `Sized` bounds
//~| ERROR the size for values of type `T` cannot be known at compilation time

fn foo5(_: impl ?Sized) {}
//~^ ERROR the size for values of type `impl ?Sized` cannot be known at compilation time

fn foo6(_: impl ?Sized + ?Sized) {}
//~^ ERROR duplicate relaxed `Sized` bounds
//~| ERROR the size for values of type `impl ?Sized + ?Sized` cannot be known at compilation tim

fn foo7(_: impl ?Sized + ?Sized + Debug) {}
//~^ ERROR duplicate relaxed `Sized` bounds
//~| ERROR the size for values of type `impl ?Sized + ?Sized + Debug` cannot be known at compilation time

fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
//~^ ERROR duplicate relaxed `Sized` bounds
//~| ERROR the size for values of type `impl ?Sized + Debug + ?Sized` cannot be known at compilation time

fn main() {}