Skip to content

Commit 980a95d

Browse files
authored
Rollup merge of rust-lang#65200 - xfix:patch-20, r=GuillaumeGomez
Add ?Sized bound to a supertrait listing in E0038 error documentation This example failed to compile because of implicit `Sized` bound for `A` parameter that wasn't required by `Trait`.
2 parents 6f6e42c + 3f9d834 commit 980a95d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustc/error_codes.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ trait Foo {
259259
This is similar to the second sub-error, but subtler. It happens in situations
260260
like the following:
261261
262-
```compile_fail
263-
trait Super<A> {}
262+
```compile_fail,E0038
263+
trait Super<A: ?Sized> {}
264264
265265
trait Trait: Super<Self> {
266266
}
@@ -270,17 +270,21 @@ struct Foo;
270270
impl Super<Foo> for Foo{}
271271
272272
impl Trait for Foo {}
273+
274+
fn main() {
275+
let x: Box<dyn Trait>;
276+
}
273277
```
274278
275279
Here, the supertrait might have methods as follows:
276280
277281
```
278-
trait Super<A> {
279-
fn get_a(&self) -> A; // note that this is object safe!
282+
trait Super<A: ?Sized> {
283+
fn get_a(&self) -> &A; // note that this is object safe!
280284
}
281285
```
282286
283-
If the trait `Foo` was deriving from something like `Super<String>` or
287+
If the trait `Trait` was deriving from something like `Super<String>` or
284288
`Super<T>` (where `Foo` itself is `Foo<T>`), this is okay, because given a type
285289
`get_a()` will definitely return an object of that type.
286290

0 commit comments

Comments
 (0)