Skip to content
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

ICE with anonymous field and a derive in 1.80.1 but also checked on Godbolt's nightly compiler #131041

Closed
tialaramex opened this issue Sep 29, 2024 · 2 comments · Fixed by #131045
Labels
C-bug Category: This is a bug. F-unnamed_fields `#![feature(unnamed_fields)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tialaramex
Copy link
Contributor

Code

#[derive(Debug)]
pub struct Type
{
    _: u8,
}

Meta

rustc --version --verbose:

rustc 1.80.1 (3f5fd8dd4 2024-08-06) (Fedora 1.80.1-1.fc40)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.6

Error output

   Compiling ice20240929 v0.1.0 (/home/njl/src/ice20240929)
error[E0658]: unnamed fields are not yet fully implemented
 --> src/main.rs:4:5
  |
4 |     _: u8,
  |     ^
  |
  = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information

error[E0601]: `main` function not found in crate `ice20240929`
 --> src/main.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `src/main.rs`

error: struct with unnamed fields must have `#[repr(C)]` representation
 --> src/main.rs:2:1
  |
2 | pub struct Type
  | ^^^^^^^^^^^^^^^ struct `Type` defined here
  |
note: unnamed field defined here
 --> src/main.rs:4:5
  |
4 |     _: u8,
  |     ^^^^^
help: add `#[repr(C)]` to this struct
  |
2 + #[repr(C)]
3 | pub struct Type
  |

error: unnamed fields can only have struct or union types
 --> src/main.rs:4:5
  |
4 |     _: u8,
  |     ^^^^^

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect.rs:892:49:
expect Adt for unnamed field
stack backtrace:
   0:     0x7f8f73f4f135 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2a0cac5be5a8d820
   1:     0x7f8f73f9dafb - core::fmt::write::h17332d03f2f4f35b
   2:     0x7f8f73f4421f - <unknown>
   3:     0x7f8f73f4ef0e - <unknown>
   4:     0x7f8f73f51949 - <unknown>
   5:     0x7f8f73f516ea - std::panicking::default_hook::ha48f87b295834c46
   6:     0x7f8f74a5ec30 - <unknown>
   7:     0x7f8f73f5200b - std::panicking::rust_panic_with_hook::h4eeb081fd329f3e2
   8:     0x7f8f73f51d84 - <unknown>
   9:     0x7f8f73f4f5f9 - <unknown>
  10:     0x7f8f73f51ab7 - rust_begin_unwind
  11:     0x7f8f73f15a73 - core::panicking::panic_fmt::h755ac17b0b090cd9
  12:     0x7f8f73f15a3b - core::option::expect_failed::h27ffe2fb3bb55e8c
  13:     0x7f8f75f9d6c0 - rustc_hir_analysis[9a5fae5dc28e0e53]::collect::find_field
  14:     0x7f8f7710649f - <unknown>
  15:     0x7f8f771058b1 - <unknown>
  16:     0x7f8f754fc093 - <unknown>
  17:     0x7f8f7546323e - <unknown>
  18:     0x7f8f7544390f - <unknown>
  19:     0x7f8f7559f041 - <unknown>
  20:     0x7f8f760a1e57 - <unknown>
  21:     0x7f8f760603dc - <unknown>
  22:     0x7f8f7605d32d - <unknown>
  23:     0x7f8f7605fbc3 - <unknown>
  24:     0x7f8f7605d32d - <unknown>
  25:     0x7f8f7605fbc3 - <unknown>
  26:     0x7f8f760460fa - <unknown>
  27:     0x7f8f7605f589 - <unknown>
  28:     0x7f8f7605d32d - <unknown>
  29:     0x7f8f760d7b02 - <unknown>
  30:     0x7f8f7605d32d - <unknown>
  31:     0x7f8f7612c352 - <unknown>
  32:     0x7f8f76124081 - rustc_hir_typeck[30ee169b06768cb7]::typeck
  33:     0x7f8f768b6ad7 - <unknown>
  34:     0x7f8f75462850 - <unknown>
  35:     0x7f8f75450f11 - <unknown>
  36:     0x7f8f7556d828 - <unknown>
  37:     0x7f8f75fa8e3a - rustc_hir_analysis[9a5fae5dc28e0e53]::check_crate
  38:     0x7f8f76231b9e - rustc_interface[881e2d08a402e036]::passes::analysis
  39:     0x7f8f771081e7 - <unknown>
  40:     0x7f8f75461a4f - <unknown>
  41:     0x7f8f75417c08 - <unknown>
  42:     0x7f8f7555d394 - <unknown>
  43:     0x7f8f76e65fdc - <unknown>
  44:     0x7f8f76e63de7 - <unknown>
  45:     0x7f8f76e68a7a - <unknown>
  46:     0x7f8f73f5bfeb - <unknown>
  47:     0x7f8f73d796d7 - start_thread
  48:     0x7f8f73dfd60c - __clone3
  49:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.80.1 (3f5fd8dd4 2024-08-06) (Fedora 1.80.1-1.fc40) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [find_field] find the index of maybe nested field `_` in `Type`
#1 [typeck] type-checking `<impl at src/main.rs:1:10: 1:15>::fmt`
end of query stack
Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.
error: could not compile `ice20240929` (bin "ice20240929") due to 4 previous errors

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect.rs:892:49:
expect Adt for unnamed field

Backtrace

``` 0: 0x7f8f73f4f135 - ::fmt::h2a0cac5be5a8d820 1: 0x7f8f73f9dafb - core::fmt::write::h17332d03f2f4f35b 2: 0x7f8f73f4421f - 3: 0x7f8f73f4ef0e - 4: 0x7f8f73f51949 - 5: 0x7f8f73f516ea - std::panicking::default_hook::ha48f87b295834c46 6: 0x7f8f74a5ec30 - 7: 0x7f8f73f5200b - std::panicking::rust_panic_with_hook::h4eeb081fd329f3e2 8: 0x7f8f73f51d84 - 9: 0x7f8f73f4f5f9 - 10: 0x7f8f73f51ab7 - rust_begin_unwind 11: 0x7f8f73f15a73 - core::panicking::panic_fmt::h755ac17b0b090cd9 12: 0x7f8f73f15a3b - core::option::expect_failed::h27ffe2fb3bb55e8c 13: 0x7f8f75f9d6c0 - rustc_hir_analysis[9a5fae5dc28e0e53]::collect::find_field 14: 0x7f8f7710649f - 15: 0x7f8f771058b1 - 16: 0x7f8f754fc093 - 17: 0x7f8f7546323e - 18: 0x7f8f7544390f - 19: 0x7f8f7559f041 - 20: 0x7f8f760a1e57 - 21: 0x7f8f760603dc - 22: 0x7f8f7605d32d - 23: 0x7f8f7605fbc3 - 24: 0x7f8f7605d32d - 25: 0x7f8f7605fbc3 - 26: 0x7f8f760460fa - 27: 0x7f8f7605f589 - 28: 0x7f8f7605d32d - 29: 0x7f8f760d7b02 - 30: 0x7f8f7605d32d - 31: 0x7f8f7612c352 - 32: 0x7f8f76124081 - rustc_hir_typeck[30ee169b06768cb7]::typeck 33: 0x7f8f768b6ad7 - 34: 0x7f8f75462850 - 35: 0x7f8f75450f11 - 36: 0x7f8f7556d828 - 37: 0x7f8f75fa8e3a - rustc_hir_analysis[9a5fae5dc28e0e53]::check_crate 38: 0x7f8f76231b9e - rustc_interface[881e2d08a402e036]::passes::analysis 39: 0x7f8f771081e7 - 40: 0x7f8f75461a4f - 41: 0x7f8f75417c08 - 42: 0x7f8f7555d394 - 43: 0x7f8f76e65fdc - 44: 0x7f8f76e63de7 - 45: 0x7f8f76e68a7a - 46: 0x7f8f73f5bfeb - 47: 0x7f8f73d796d7 - start_thread 48: 0x7f8f73dfd60c - __clone3 49: 0x0 - ```

@tialaramex tialaramex added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 29, 2024
@tialaramex
Copy link
Contributor Author

The ICE does not happen if we don't use a derive, or if we give the field a real name

@clubby789 clubby789 added the F-unnamed_fields `#![feature(unnamed_fields)]` label Sep 29, 2024
@clubby789
Copy link
Contributor

Closing since this is a duplicate of #121263 (and related to #121299 and #121161) - the feature is currently up for discussion.

@clubby789 clubby789 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 30, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 11, 2024
…s, r=wesleywiser

Retire the `unnamed_fields` feature for now

`#![feature(unnamed_fields)]` was implemented in part in rust-lang#115131 and rust-lang#115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature.

However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly.

Fixes rust-lang#117942
Fixes rust-lang#121161
Fixes rust-lang#121263
Fixes rust-lang#121299
Fixes rust-lang#121722
Fixes rust-lang#121799
Fixes rust-lang#126969
Fixes rust-lang#131041

Tracking:
* rust-lang#49804

[^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields
[^2]: rust-lang#49804 (comment)
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 11, 2024
…s, r=wesleywiser

Retire the `unnamed_fields` feature for now

`#![feature(unnamed_fields)]` was implemented in part in rust-lang#115131 and rust-lang#115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature.

However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly.

Fixes rust-lang#117942
Fixes rust-lang#121161
Fixes rust-lang#121263
Fixes rust-lang#121299
Fixes rust-lang#121722
Fixes rust-lang#121799
Fixes rust-lang#126969
Fixes rust-lang#131041

Tracking:
* rust-lang#49804

[^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields
[^2]: rust-lang#49804 (comment)
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 18, 2024
…s, r=wesleywiser

Retire the `unnamed_fields` feature for now

`#![feature(unnamed_fields)]` was implemented in part in rust-lang#115131 and rust-lang#115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature.

However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly.

Fixes rust-lang#117942
Fixes rust-lang#121161
Fixes rust-lang#121263
Fixes rust-lang#121299
Fixes rust-lang#121722
Fixes rust-lang#121799
Fixes rust-lang#126969
Fixes rust-lang#131041

Tracking:
* rust-lang#49804

[^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields
[^2]: rust-lang#49804 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-unnamed_fields `#![feature(unnamed_fields)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants