From 58089717b9f824ff278e37c4b1f29e7dc1fa47a9 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Tue, 8 Oct 2019 12:19:00 +0200 Subject: [PATCH 1/3] 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`. --- src/librustc/error_codes.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index 502172db91c9b..2de9cb5e9fb61 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 {} +``` +trait Super {} trait Trait: Super { } @@ -275,8 +275,8 @@ impl Trait for Foo {} Here, the supertrait might have methods as follows: ``` -trait Super { - fn get_a(&self) -> A; // note that this is object safe! +trait Super { + fn get_a(&self) -> &A; // note that this is object safe! } ``` From 7dc4bf4f935a929d1a9b8beb5d72ae1daa117f34 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Wed, 9 Oct 2019 01:03:56 +0200 Subject: [PATCH 2/3] Change incorrect trait name in E0038 error documentation --- src/librustc/error_codes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index 2de9cb5e9fb61..caa7282c701cf 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -280,7 +280,7 @@ trait Super { } ``` -If the trait `Foo` was deriving from something like `Super` or +If the trait `Trait` was deriving from something like `Super` or `Super` (where `Foo` itself is `Foo`), this is okay, because given a type `get_a()` will definitely return an object of that type. From 3f9d834fb3c32b67a5f368c8265a9ca6d83de7c3 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Wed, 9 Oct 2019 12:33:24 +0200 Subject: [PATCH 3/3] Add failing example for Self in supertrait listing in E0038 documentation --- src/librustc/error_codes.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index caa7282c701cf..f3f1c9c6c7de4 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -259,7 +259,7 @@ trait Foo { This is similar to the second sub-error, but subtler. It happens in situations like the following: -``` +```compile_fail,E0038 trait Super {} trait Trait: Super { @@ -270,6 +270,10 @@ struct Foo; impl Super for Foo{} impl Trait for Foo {} + +fn main() { + let x: Box; +} ``` Here, the supertrait might have methods as follows: