diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-10-11 15:09:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-11 15:09:47 -0700 |
| commit | 6687edcbef063cb2a6ff414cfa3754139905b79e (patch) | |
| tree | 4a3a954f145e41f4c6ee93d468682c08ab91799a /src | |
| parent | 728adc446ce55571ac100dac5e8184b692218b8b (diff) | |
| parent | 3f9d834fb3c32b67a5f368c8265a9ca6d83de7c3 (diff) | |
| download | rust-6687edcbef063cb2a6ff414cfa3754139905b79e.tar.gz rust-6687edcbef063cb2a6ff414cfa3754139905b79e.zip | |
Rollup merge of #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`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/error_codes.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index e208e25f6ea..50b6ef57b55 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -259,8 +259,8 @@ trait Foo { This is similar to the second sub-error, but subtler. It happens in situations like the following: -```compile_fail -trait Super<A> {} +```compile_fail,E0038 +trait Super<A: ?Sized> {} trait Trait: Super<Self> { } @@ -270,17 +270,21 @@ struct Foo; impl Super<Foo> for Foo{} impl Trait for Foo {} + +fn main() { + let x: Box<dyn Trait>; +} ``` Here, the supertrait might have methods as follows: ``` -trait Super<A> { - fn get_a(&self) -> A; // note that this is object safe! +trait Super<A: ?Sized> { + fn get_a(&self) -> &A; // note that this is object safe! } ``` -If the trait `Foo` was deriving from something like `Super<String>` or +If the trait `Trait` was deriving from something like `Super<String>` or `Super<T>` (where `Foo` itself is `Foo<T>`), this is okay, because given a type `get_a()` will definitely return an object of that type. |
