Skip to content

Commit 96767a3

Browse files
committed
docs stderr | maybe-bounds.rs
1 parent 697afce commit 96767a3

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//! Test that ?Trait bounds are forbidden in supertraits and trait object types.
2+
//!
3+
//! While `?Sized` and other maybe bounds are allowed in type parameter bounds and where clauses,
4+
//! they are explicitly forbidden in certain syntactic positions:
5+
//! - As supertraits in trait definitions
6+
//! - In trait object type expressions
7+
//!
8+
//! See https://github.com/rust-lang/rust/issues/20503
9+
110
trait Tr: ?Sized {}
211
//~^ ERROR `?Trait` is not permitted in supertraits
312

tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: `?Trait` is not permitted in supertraits
2-
--> $DIR/maybe-bounds.rs:1:11
2+
--> $DIR/maybe-trait-bounds-forbidden-locations.rs:10:11
33
|
44
LL | trait Tr: ?Sized {}
55
| ^^^^^^
@@ -9,7 +9,7 @@ LL | trait Tr: ?Sized {}
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: `?Trait` is not permitted in trait object types
12-
--> $DIR/maybe-bounds.rs:4:20
12+
--> $DIR/maybe-trait-bounds-forbidden-locations.rs:13:20
1313
|
1414
LL | type A1 = dyn Tr + (?Sized);
1515
| ^^^^^^^^
@@ -18,7 +18,7 @@ LL | type A1 = dyn Tr + (?Sized);
1818
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1919

2020
error[E0658]: `?Trait` is not permitted in trait object types
21-
--> $DIR/maybe-bounds.rs:6:28
21+
--> $DIR/maybe-trait-bounds-forbidden-locations.rs:15:28
2222
|
2323
LL | type A2 = dyn for<'a> Tr + (?Sized);
2424
| ^^^^^^^^

0 commit comments

Comments
 (0)