// Test various places where relaxed bounds are not permitted. // // Relaxed bounds are only permitted inside impl-Trait, assoc ty item bounds and // on type params defined by the closest item. struct S1(T) where (T): ?Sized; //~ ERROR this relaxed bound is not permitted here struct S2(T) where u8: ?Sized; //~ ERROR this relaxed bound is not permitted here struct S3(T) where &'static T: ?Sized; //~ ERROR this relaxed bound is not permitted here trait Trait<'a> {} struct S4(T) where for<'a> T: ?Trait<'a>; //~^ ERROR this relaxed bound is not permitted here //~| ERROR bound modifier `?` can only be applied to `Sized` struct S5(*const T) where T: ?Trait<'static> + ?Sized; //~^ ERROR bound modifier `?` can only be applied to `Sized` impl S1 { fn f() where T: ?Sized {} //~ ERROR this relaxed bound is not permitted here } // Test associated type bounds (ATB). // issue: struct S6(T) where T: Iterator; //~ ERROR this relaxed bound is not permitted here trait Tr: ?Sized {} //~ ERROR relaxed bounds are not permitted in supertrait bounds // Test that relaxed `Sized` bounds are rejected in trait object types: type O1 = dyn Tr + ?Sized; //~ ERROR relaxed bounds are not permitted in trait object types type O2 = dyn ?Sized + ?Sized + Tr; //~^ ERROR relaxed bounds are not permitted in trait object types //~| ERROR relaxed bounds are not permitted in trait object types fn main() {}