-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
(Anti-)regression between Rust 1.78.0 and Rust 1.79.0 with struct containing Cow<[Self]>
#129541
Comments
The code you show has |
Fixed. The gression did indeed happen for |
So I expect this code to compile, especially given that It would be interesting to know what specifically about #122493 caused this to compile, though I haven't looked at all about it. |
I think this is more about What I think happened is that I think some details in my explanation are wrong (particularly the last step?), because I'm not familiar enough with type checking in rustc; but. I do think that "not requiring |
This was properly fixed in #122791, which also landed in 1.78.0. That PR also allows this similar code to compile, which still fails after #122493: #[derive(Clone)]
struct Hello {
a: <[Hello] as ToOwned>::Owned,
} This happens, because normalizing
The Code in the OP compiles with just #122493, because that PR changed |
I think this has solved #100347 |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
#129541 (comment) this uncovers a case where we forget ambiguity. Even if we're able to use an ambiguous candidate to normalize, this should force the goal to be ambiguous. This currently fails with the new solver and should do so until we've changed our cycle handling. https://rust.godbolt.org/z/sYGY15Gv5 I don't fully understand why this happens and whether this hides a more serious issue. I want to look more deeply into the code once I am back home next week. Thanks @zachs18 for opening this issue and thanks @lukas-code for looking into this. |
I was actually hoping for unsized unions to remain possible, honestly, so I'm somewhat disappointed by this event being caused by #122493, since that makes it impossible to even explore adding such support without it then being a regression. |
Before #122493, unions would only be unsized if the last field was unsized, e.g. // This was unsized before.
union Foo {
a: (),
b: [u8],
}
// This was always sized.
union Bar {
a: [u8],
b: (),
} That's probably not the semantics that we want for unsized unions and the same can already be achieved with a sized union and a struct. So it seemed fine to me to remove this weird special case. I'm actually more concerned about the future of unsized enums now, because I thought we could just revert the relevant changes if they ever become a thing, but this issue shows that that's evidently not the case. |
I agree that that rule for unions seems like the wrong semantics! To be clear, I was hoping for something like this becoming possible: #[repr(C)]
union Varlena {
pack: (u8, [u8]),
full: (u32, [u8]),
} Which would be quite useful for binding against C code with various kinds of "we have enums at home" solutions. |
ah, this is #106040 😅 that's good as this issue is already known and something we'll have to handle regardless. |
Okay, so this issue contains 2 unintended changes:
I think these changes in behavior are acceptable and desirable. They will be automatically supported once we've implemented the new cycle semantics. I believe we were already forced to handle #106040 in the new solver even before #122791 made it easier to exploit. I propose that we accept this accidental stabilization (given that it's already stable since for 2 versions) and close this issue after adding regression tests. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#129542 (Add regression test for rust-lang#129541) - rust-lang#129755 (test: cross-edition metavar fragment specifiers) - rust-lang#130566 (Break up compiletest `runtest.rs` into smaller helper modules) - rust-lang#130585 (Add tidy check for rustdoc templates to ensure the whitespace characters are all stripped) - rust-lang#130605 (Fix feature name in test) - rust-lang#130607 ([Clippy] Remove final std paths for diagnostic item) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129542 - zachs18:cow-self-test, r=compiler-errors Add regression test for rust-lang#129541 (maybe?) closes rust-lang#129541 by adding a test that the code in question continues to compile.
please also add the 3 tests from #129541 (comment) |
@lcnr I think you link to the wrong comment? I think you mean "tests from issues referenced from #129541 (comment)" ? |
no, to close this issue I would like to also want the following tests from my FCP proposal to get added as regression tests: |
PR that adds those tests: #133467 |
I want to merge the failing test to also catch when its behavior changes, even if it goes from pass to fail. I want to make sure we realize that we accidentally stabilized something before it hits stable 😁 |
tests: Add recursive associated type bound regression tests Add regression tests for rust-lang#129541 as requested in rust-lang#129541 (comment). Closes rust-lang#129541 r? `@lcnr`
Rollup merge of rust-lang#133467 - Enselic:recurse-tests, r=lcnr tests: Add recursive associated type bound regression tests Add regression tests for rust-lang#129541 as requested in rust-lang#129541 (comment). Closes rust-lang#129541 r? ``@lcnr``
tests: Add regression test for self referential structs with cow as last field Making compilation pass for this code was retroactively stabilized via FCP in 1.79. The code does not compile in 1.78. See rust-lang#129541 for details. Closes rust-lang#107481
tests: Add regression test for self referential structs with cow as last field Making compilation pass for this code was retroactively stabilized via FCP in 1.79. The code does not compile in 1.78. See rust-lang#129541 for details. Closes rust-lang#107481
Rollup merge of rust-lang#133488 - Enselic:recurse-2, r=BoxyUwU tests: Add regression test for self referential structs with cow as last field Making compilation pass for this code was retroactively stabilized via FCP in 1.79. The code does not compile in 1.78. See rust-lang#129541 for details. Closes rust-lang#107481
Code
I tried this code:
I expected to see this happen: On 1.78 and below, this fails to compile with several E0277s (trait bound not satisfied)
full error message
Instead, this happened: On Rust 1.79 and above, it compiles without error
Version it didn't work on
It most recently didn't work on: Rust 1.78.0
Version with anti-regression
rustc --version --verbose
:Bisection:
searched nightlies: from nightly-2024-03-16 to nightly-2024-04-28
regressed nightly: nightly-2024-03-20
searched commit range: 3c85e56...a7e4de1
regressed commit: 196ff44
bisected with cargo-bisect-rustc v0.6.9
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cc @lukas-code The description of #122493 says "This should not make more or less code compile, but it can change error output in some rare cases."
Probably nothing to do but add a test to make sure this keeps compiling in the future?
The text was updated successfully, but these errors were encountered: