![](/style/images/good.png)
![](/style/images/bad.png)
More deriving on packed structs by nnethercote · Pull Request #104429 · rust-lan...
source link: https://github.com/rust-lang/rust/pull/104429
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Conversation
added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Collaborator
rustbot commented Nov 15, 2022
Some changes occurred to MIR optimizations |
Contributor
Author
nnethercote commented Nov 15, 2022
Note that the first three commits are from #104391, and have already been approved. @RalfJung: even though you don't know the deriving code, there is enough stuff in this PR that you do know about (e.g. |
Contributor
Author
nnethercote commented Nov 15, 2022
@bors try |
Contributor
bors commented Nov 15, 2022
Contributor
bors commented Nov 15, 2022
|
// This one is fine because it's not packed. |
||
#[derive(Debug, Default)] |
||
struct Y(usize); |
||
// This one has an error because `Y` doesn't impl `Copy`. |
||
// Note: there is room for improvement in the error message. |
Yes there is indeed.^^ I noticed some other derive
get really nice error messages but I have no idea how they do that. I suspect it is related to these AssertParamIs
things?
// This one is an error because `Box<u32>` doesn't impl `Copy`. |
||
let x: Foo<NonCopy> = Foo(NonCopy, NonCopy, NonCopy); |
||
_ = x.clone(); |
||
//~^ ERROR the method `clone` exists for struct `Foo<NonCopy>`, but its trait bounds were not satisfied |
This is where I wonder how we can best document this. Users might be surprised here that Clone
doesn't work since they did derive(Clone)
and all fields are Clone
...
Member
RalfJung commented Nov 15, 2022
I looked at the testcases only; there are some more that should be added:
Looks like we don't even have a test for generic+associated without The changes in check_packed_ref are fine, too. I'll hand over review of the actual implementation to someone else, don't have the time to dig into the derive code currently, sorry. r? compiler |
Contributor
Author
nnethercote commented Nov 16, 2022
@bors try |
Contributor
bors commented Nov 16, 2022
Contributor
bors commented Nov 16, 2022
|
Contributor
Author
nnethercote commented Nov 16, 2022
@craterbot check |
Collaborator
craterbot commented Nov 16, 2022
|
added S-waiting-on-crater Status: Waiting on a crater run to be completed.
and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
labels
Collaborator
craterbot commented Nov 16, 2022
|
Collaborator
craterbot commented Nov 17, 2022
|
This comment has been minimized.
Contributor
Author
nnethercote commented Nov 24, 2022
@RalfJung: I have added the lint. Could you check it, make sure it all looks reasonable? Grep for |
This comment has been minimized.
force-pushed the more-deriving-on-packed-structs
branch
2 times, most recently
from
987e0ce
to
67b9ce9
Compare
Contributor
Author
nnethercote commented Nov 24, 2022
On the suggestion of @Nilstrieb, I renamed the lint. Search now for |
Member
RalfJung commented Nov 26, 2022
Yeah, the lint looks good to me. :) |
Member
joshtriplett commented Dec 6, 2022
We discussed this in today's @rust-lang/lang meeting. Because this breaks multiple existing crates (even though some of them have been fixed), we'd like to see this done over an edition boundary. This doesn't seem like something so urgent that it can't wait for Rust 2024, to avoid a breaking change. |
Contributor
tmandry commented Dec 6, 2022
@nnethercote This comment (also in the commit description) are very helpful but difficult to find; could you please make it more easily discoverable from the PR description? |
@joshtriplett so what is the plan then for #102513? That got approved by t-lang, but seems hard to land without landing this one here first (on all editions). Also AFAIK the policy for edition changes requires warnings or even fixes from the previous edition. That does not seem possible with reasonable effort here. |
@tmandry: Sorry this was hard to navigate. The comment you mentioned is a good overview, but unfortunately it omitted one important detail. This other comment, addressed to @rust-lang/lang, mentions this important detail:
(I have linked to the latter comment in the description.) If you only saw the former comment, you'd think that this PR makes the language nicer, at the cost of breaking a handful of obscure crates. If you see the latter comment, it's more obvious that this PR does that, while also unbreaking the winapi-0.2 crate, which has been broken by the ongoing work to disallow unaligned references. I suspect that the amount of unbreaking caused by this PR in the crate ecosystem is significant, more so than the breaking caused by this PR, though @RalfJung would know for sure. If the lang-team considered this, that's fine, I just want to make sure it wasn't overlooked because it's an important point and the structure of this PR's comments means it would have been easy to overlook. |
@nnethercote That this unbreaks any crates was not something we were clear on, no. I'll leave this nominated for consideration. |
Contributor
Author
nnethercote commented Dec 7, 2022
Great, thanks. Sorry again for the lack of clarity. |
Member
RalfJung commented Dec 7, 2022
Was the issue that the nomination comment I wrote was not clear enough, or that you did not see the nomination comment? (Just trying to figure out how to avoid such misunderstandings in the future. So far writing a comment addressed at the team when adding the nomination label worked fine and I thought that was the recommended process.)
|
Contributor
bors commented Dec 8, 2022
|
Contributor
tmandry commented Dec 13, 2022
@RalfJung I'd say it's a bit of both. One of the issues (at least for me) was that it took some digging to find the comment because of how GH hides comments in long threads. If I were to suggest a change here, it would be to edit the PR description to link directly to comments about nominations in PRs with long threads. Maybe we/I could also be more diligent in looking for that comment first, but not every nominated PR has one. We did eventually see it, but it also wasn't immediately clear that this unbroke things. Your comment linked to an issue that I think implies this, and references the fact at the very end, but on the kind of skim that tends to happen during t-lang meetings it definitely doesn't jump out. (Again, we might've figured this out if we'd spent more time looking at your comment, but we spent more time looking around for other details about the PR before finding it.) Hopefully this is helpful in some way. It's definitely just incremental changes that could improve things a bit, nothing groundbreaking :). And thanks to you and @nnethercote for clarifying! |
It's still useful feedback, thanks. :) Writing these nomination comments is not easy, so at last I know one more potential pitfall now. The biggest problem however is as usual that I have all the context in my head, so it is hard to remember all the things I need to explain to someone who hasn't spent all that time thinking about the issue already... (like in this case, the relation to #102513 and that this helps unbreak things) I have updated the nomination comment, and it is linked directly from the PR description now. |
Contributor
bors commented Dec 20, 2022
|
Contributor
nikomatsakis commented Dec 20, 2022
We discussed this in the lang-team meeting, taking into account the fact that this unbreaks a bunch of crates (notably winapi), as well as Ralf's comment about the general incoherence of the current rules. Meeting consensus was that, even though this is a breaking change, we should... @rfcbot fcp merge ...because:
|
rfcbot commented Dec 20, 2022 •
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), 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. |
added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised.
and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
labels
rfcbot commented Dec 20, 2022
|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
No milestone
Successfully merging this pull request may close these issues.
None yet
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK