Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport an explicit annotation for marker traits #53693
Conversation
rust-highfive
assigned
nikomatsakis
Aug 25, 2018
rust-highfive
added
the
S-waiting-on-review
label
Aug 25, 2018
scottmcm
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Aug 25, 2018
scottmcm
force-pushed the
scottmcm:marker-trait-attribute
branch
3 times, most recently
from
3ed26ac
to
a8b137f
Aug 25, 2018
rust-lang
deleted a comment from
rust-highfive
Aug 25, 2018
scottmcm
force-pushed the
scottmcm:marker-trait-attribute
branch
from
ca490fe
to
fcd94f9
Aug 25, 2018
rust-lang
deleted a comment from
rust-highfive
Aug 25, 2018
scottmcm
changed the title
[WIP] Support an explicit annotation for marker traits
Support an explicit annotation for marker traits
Aug 26, 2018
This comment has been minimized.
This comment has been minimized.
|
I think this is functional and sound, but it's missing the "this trait would be impossible to implement" error when defining a trait without default implementations for its items. I'd appreciate advice on where that should go, as well as any other feedback on how I've been going about this. |
scottmcm
requested a review
from
eddyb
Aug 26, 2018
scottmcm
referenced this pull request
Aug 26, 2018
Open
Tracking issue for allowing overlapping implementations for marker trait #29864
This comment has been minimized.
This comment has been minimized.
|
@scottmcm this is confusing to me. I thought a marker trait had no items -- not "items with defaults". |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis See #29864 (comment) for some context. But yes, it's an extension beyond the RFC, so I'm fine not implementing that for now. I do still need advice on where to put the "has no items" valuation check, though. (Once I know where I can figure out how to get the item list.) |
This comment has been minimized.
This comment has been minimized.
|
@scottmcm I see. That seems like an ok extension, actually, but in that case I don't know what this is referring to...
...oh, I see, I thought you meant some fancy check designed to prove that the trait is imposible to implement. But actually you just mean that you want to report an error if you label a trait as In that case, I think we should do that .. hmm .. either in WF or in coherence. Coherence seems like -- today -- it is focused on checking properties of impls so maybe wfcheck would be a better place. Basically extending this function: rust/src/librustc_typeck/check/wfcheck.rs Lines 305 to 311 in 70a21e8 We should probably do a quick lang-team FCP here too. |
nikomatsakis
added
the
T-lang
label
Aug 27, 2018
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp merge This PR modifies the special treatment of marker traits in two ways. First, you have to declare the traits explicitly, by writing Seems reasonable to me. |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Aug 27, 2018
•
|
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams:
Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
proposed-final-comment-period
disposition-merge
labels
Aug 27, 2018
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern vague I'm I'm not so convinced that redefining marker trait to include traits with default items and then adding additional checks that those are never overriden is a good idea. It comes at a nontrivial cost of complexity for users in terms of understanding the meaning and mechanics of both default methods and marker traits. The motivation doesn't seem that strong to me. |
rfcbot
added
proposed-final-comment-period
disposition-merge
labels
Aug 27, 2018
This comment has been minimized.
This comment has been minimized.
|
I very much agree that the incoherency should be opt-in rather than be implicit. However; this was not discussed in the RFC (unless I somehow missed that but I did look at every comment...) and this could use some more elaborate and detailed justification. @rfcbot concern needs-rfc In addition; I am not so sure about the concrete syntax here. The choice of using an attribute rather than some keyword as a prefix to the trait (e.g. @rfcbot concern concrete-syntax |
rfcbot
added
proposed-final-comment-period
disposition-merge
labels
Aug 27, 2018
This comment has been minimized.
This comment has been minimized.
|
To elaborate a bit: I'm fine with landing this PR and using |
This comment has been minimized.
This comment has been minimized.
|
I agree with @Centril and @withoutboats - this seems like a big change and marker traits with default methods adds considerably to the complexity of the feature, as well as making |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Sep 17, 2018
|
|
rfcbot
removed
the
proposed-final-comment-period
label
Sep 17, 2018
nikomatsakis
added
the
relnotes
label
Sep 17, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors r- |
bors
added
S-waiting-on-author
and removed
S-waiting-on-team
labels
Sep 17, 2018
scottmcm
added some commits
Aug 25, 2018
scottmcm
force-pushed the
scottmcm:marker-trait-attribute
branch
from
c991f11
to
3932249
Sep 20, 2018
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Ok, how about something like this:
But both features continue to work and are unstable, so it's surprising to me that we'd relnote them at all. |
scottmcm
added
S-waiting-on-review
and removed
S-waiting-on-author
labels
Sep 22, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r+ I'm not sure if we usually relnote unstable features. Seems like a nice thing to do. |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Sep 24, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Sep 25, 2018
This comment has been minimized.
This comment has been minimized.
|
|
scottmcm commentedAug 25, 2018
•
edited
From the tracking issue for rust-lang/rfcs#1268:
This PR allows you to put
#[marker]on a trait, at which point:All of the trait's items must have defaultsr? @nikomatsakis