* The phrasing "only does something for" made sense back when this diagnostic was a (hard) warning. Now however, it's simply a hard error and thus completely rules out "doing something". * The primary message was way too long * The new wording more closely mirrors the wording we use for applying other bound modifiers (like `const` and `async`) to incompatible traits. * "all other traits are not bound by default" is no longer accurate under Sized Hierarchy. E.g., traits and assoc tys are (currently) bounded by `MetaSized` by default but can't be relaxed using `?MetaSized` (instead, you relax it by adding `PointeeSized`). * I've decided against adding any diagnositic notes or suggestions for now like "trait `Trait` can't be relaxed as it's not bound by default" which would be incorrect for `MetaSized` and assoc tys as mentioned above) or "consider changing `?MetaSized` to `PointeeSized`" as the Sized Hierarchy impl is still WIP)
21 lines
835 B
Rust
21 lines
835 B
Rust
// Regression test for issue #87199, where attempting to relax a bound
|
|
// other than the only supported `?Sized` would still cause the compiler
|
|
// to assume that the `Sized` bound was relaxed.
|
|
|
|
//@ check-fail
|
|
|
|
// Check that these function definitions only emit warnings, not errors
|
|
fn arg<T: ?Send>(_: T) {}
|
|
//~^ ERROR: bound modifier `?` can only be applied to `Sized`
|
|
fn ref_arg<T: ?Send>(_: &T) {}
|
|
//~^ ERROR: bound modifier `?` can only be applied to `Sized`
|
|
fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
|
|
//~^ ERROR: bound modifier `?` can only be applied to `Sized`
|
|
//~| ERROR: bound modifier `?` can only be applied to `Sized`
|
|
|
|
// Check that there's no `?Sized` relaxation!
|
|
fn main() {
|
|
ref_arg::<i32>(&5);
|
|
ref_arg::<[i32]>(&[5]);
|
|
//~^ ERROR the size for values of type `[i32]` cannot be known
|
|
}
|