-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I was not aware that Sized
is a default requirement for type parameters, so I was very confused why this code doesn't compile:
trait OopsSized<O /* missing : ?Sized */> {
fn foo(&self) -> Option<Box<O>>;
}
trait Unsized {}
struct Foo;
impl OopsSized<Unsized> for Foo {
fn foo(&self) -> Option<Box<Unsized>> {
None
}
}
I couldn't understand why compiler insists on having Sized
for the innermost type, if Box
doesn't care and makes the boxed type sized.
The current explanation for E0277 doesn't cover this case specifically, and it doesn't mention the unusual ?Sized
syntax. It'd help me if, for example, the hint:
note: required by
OopsSized
made implied defaults explicitly spelled out:
note: required by
OopsSized<O: Sized>
and/or hinted how to fix it:
note: required by
OopsSized
, becauseO
by default isSized
. TryO: ?Sized
.
najamelan and rwestphal
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.