-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ?Sized bound to a supertrait listing in E0038 error documentation #65200
Conversation
This example failed to compile because of implicit `Sized` bound for `A` parameter that wasn't required by `Trait`.
Some changes occurred in diagnostic error codes |
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this is an improvement, but my understanding of what this example is intended to demonstrate might be incorrect.
I think this example is intended to demonstrate a failing example for this case - this is what the previous cases do, so changing this to a passing example might be not desirable.
As I understand it, this example attempts to demonstrate why a trait is no longer object-safe when it uses Self
in a supertrait listing:
When a trait Foo
has a supertrait Super<Self>
then that can make Foo
non-object-safe even if Super<T>
is object-safe. Suppose Super<T>
contains a method returning T
- and Super<T>
is still object-safe if it does - then when used as a supertrait (Super<Self>
), the subtrait would be not be object-safe as it would have a method returning a unknown type (this is the "Method references the Self
type in its parameters or return type" case from above).
I think the error's example is better suited to explaining that if it remains as a failing example than as a passing example, as in this PR.
That said, the next paragraph might be slightly incorrect as it references a "trait Foo" even though the example names the trait "Trait", so if you want to modify this PR to correct that instead, then that would be appreciated.
The first example is supposed to fail and is checked as such. |
Is this how the example is supposed to fail? trait Super<A> {}
trait Trait: Super<Self> {} Gives the following error:
Note that the error is not E0038, but rather E0277. The issue is that with There are two ways to fix that, one is to put |
But yeah, now that I'm checking there is something weird with the description, although I think it should be "trait |
I think it would probably be desirable for the example to error with the code that it is describing (that said, I don't maintain the error codes and the intent might just have been to have as simple an example as possible that explains the case).
I think that this slightly modified version of the example is probably what we're after. It shows that |
Yeah, I can add |
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks! @bors: r+ rollup |
📌 Commit 3f9d834 has been approved by |
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`.
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`.
Rollup of 16 pull requests Successful merges: - rust-lang#64337 (libstd: Fix typos in doc) - rust-lang#64986 (Function pointers as const generic arguments) - rust-lang#65048 (Added doc about behavior of extend on HashMap) - rust-lang#65191 (Add some regression tests) - rust-lang#65200 (Add ?Sized bound to a supertrait listing in E0038 error documentation) - rust-lang#65205 (Add long error explanation for E0568) - rust-lang#65240 (self-profiling: Add events for metadata loading (plus a small dep-tracking optimization)) - rust-lang#65248 (Suggest `if let` on `let` refutable binding) - rust-lang#65252 (expand: Simplify expansion of derives) - rust-lang#65263 (Deduplicate is_{freeze,copy,sized}_raw) - rust-lang#65265 (Cleanup librustc mir err codes) - rust-lang#65266 (Mark Path::join as must_use) - rust-lang#65276 (Don't cc rust-lang/compiler for toolstate changes) - rust-lang#65277 (Query generator kind for error reporting) - rust-lang#65283 (stability: Do not use `buffer_lint` after lowering to HIR) - rust-lang#65289 (Fix suggested bound addition diagnostic) Failed merges: r? @ghost
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`.
Rollup of 16 pull requests Successful merges: - rust-lang#64337 (libstd: Fix typos in doc) - rust-lang#64986 (Function pointers as const generic arguments) - rust-lang#65048 (Added doc about behavior of extend on HashMap) - rust-lang#65191 (Add some regression tests) - rust-lang#65200 (Add ?Sized bound to a supertrait listing in E0038 error documentation) - rust-lang#65205 (Add long error explanation for E0568) - rust-lang#65240 (self-profiling: Add events for metadata loading (plus a small dep-tracking optimization)) - rust-lang#65248 (Suggest `if let` on `let` refutable binding) - rust-lang#65252 (expand: Simplify expansion of derives) - rust-lang#65263 (Deduplicate is_{freeze,copy,sized}_raw) - rust-lang#65265 (Cleanup librustc mir err codes) - rust-lang#65266 (Mark Path::join as must_use) - rust-lang#65276 (Don't cc rust-lang/compiler for toolstate changes) - rust-lang#65277 (Query generator kind for error reporting) - rust-lang#65283 (stability: Do not use `buffer_lint` after lowering to HIR) - rust-lang#65289 (Fix suggested bound addition diagnostic) Failed merges: r? @ghost
Rollup of 11 pull requests Successful merges: - #64337 (libstd: Fix typos in doc) - #65048 (Added doc about behavior of extend on HashMap) - #65191 (Add some regression tests) - #65200 (Add ?Sized bound to a supertrait listing in E0038 error documentation) - #65205 (Add long error explanation for E0568) - #65263 (Deduplicate is_{freeze,copy,sized}_raw) - #65266 (Mark Path::join as must_use) - #65276 (Don't cc rust-lang/compiler for toolstate changes) - #65277 (Query generator kind for error reporting) - #65283 (stability: Do not use `buffer_lint` after lowering to HIR) - #65299 (Rollup of 16 pull requests) Failed merges: r? @ghost
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`.
Rollup of 15 pull requests Successful merges: - #64337 (libstd: Fix typos in doc) - #64986 (Function pointers as const generic arguments) - #65048 (Added doc about behavior of extend on HashMap) - #65191 (Add some regression tests) - #65200 (Add ?Sized bound to a supertrait listing in E0038 error documentation) - #65205 (Add long error explanation for E0568) - #65220 (Update LLVM for Emscripten exception handling support) - #65263 (Deduplicate is_{freeze,copy,sized}_raw) - #65266 (Mark Path::join as must_use) - #65276 (Don't cc rust-lang/compiler for toolstate changes) - #65277 (Query generator kind for error reporting) - #65283 (stability: Do not use `buffer_lint` after lowering to HIR) - #65289 (Fix suggested bound addition diagnostic) - #65310 (deriving: avoid dummy Span on an artificial `type_ident` path) - #65321 (Remove painful test that is not pulling its weight) Failed merges: r? @ghost
This example failed to compile because of implicit
Sized
bound forA
parameter that wasn't required byTrait
.