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: compiler/rustc_middle/src/ty/layout.rs:370:17: univariant: field comes after unsized field #84108

Closed
chengniansun opened this issue Apr 11, 2021 · 5 comments · Fixed by #84262
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

chengniansun commented Apr 11, 2021

The bug should be different from #61335, as the stack traces are different.

Code

static NONE: (AsRef<OsStr>, u8);

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (a836d9b64 2021-04-10)
binary: rustc
commit-hash: a836d9b6413d9d593be6c09463ff8c4c70e56599
commit-date: 2021-04-10
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

error: free static item without body
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | static NONE: (AsRef<OsStr>, u8);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
  |                                |
  |                                help: provide a definition for the static: `= <expr>;`

error[E0412]: cannot find type `OsStr` in this scope
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:21
  |
1 | static NONE: (AsRef<OsStr>, u8);
  |                     ^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 | use std::ffi::OsStr;
  |

warning: trait objects without an explicit `dyn` are deprecated
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:15
  |
1 | static NONE: (AsRef<OsStr>, u8);
  |               ^^^^^^^^^^^^ help: use `dyn`: `dyn AsRef<OsStr>`
  |
  = note: `#[warn(bare_trait_objects)]` on by default

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | static NONE: (AsRef<OsStr>, u8);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:370:17: univariant: field #2 of `(dyn AsRef<[type error]>, u8)` comes after unsized field

thread 'rustc' panicked at 'Box<Any>', /rustc/a836d9b6413d9d593be6c09463ff8c4c70e56599/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: 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.53.0-nightly (a836d9b64 2021-04-10) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_raw] computing layout of `(dyn std::convert::AsRef<[type error]>, u8)`
#1 [check_mod_item_types] checking item types in top-level module
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0412, E0601.
For more information about an error, try `rustc --explain E0412`.
Backtrace

error: free static item without body
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | static NONE: (AsRef<OsStr>, u8);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
  |                                |
  |                                help: provide a definition for the static: `= <expr>;`

error[E0412]: cannot find type `OsStr` in this scope
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:21
  |
1 | static NONE: (AsRef<OsStr>, u8);
  |                     ^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 | use std::ffi::OsStr;
  |

warning: trait objects without an explicit `dyn` are deprecated
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:15
  |
1 | static NONE: (AsRef<OsStr>, u8);
  |               ^^^^^^^^^^^^ help: use `dyn`: `dyn AsRef<OsStr>`
  |
  = note: `#[warn(bare_trait_objects)]` on by default

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | static NONE: (AsRef<OsStr>, u8);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:370:17: univariant: field #2 of `(dyn AsRef<[type error]>, u8)` comes after unsized field

thread 'rustc' panicked at 'Box<Any>', /rustc/a836d9b6413d9d593be6c09463ff8c4c70e56599/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::univariant_uninterned
   8: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_raw_uncached
   9: rustc_middle::ty::layout::layout_raw
  10: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::layout_raw>::compute
  11: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  12: rustc_data_structures::stack::ensure_sufficient_stack
  13: rustc_query_system::query::plumbing::force_query_with_job
  14: rustc_query_system::query::plumbing::get_query_impl
  15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_raw
  16: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  17: rustc_typeck::check::check::check_static_inhabited
  18: rustc_typeck::check::check::check_item_type
  19: rustc_middle::hir::map::Map::visit_item_likes_in_module
  20: rustc_typeck::check::check::check_mod_item_types
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  22: rustc_query_system::query::plumbing::force_query_with_job
  23: rustc_query_system::query::plumbing::get_query_impl
  24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  25: rustc_session::utils::<impl rustc_session::session::Session>::time
  26: rustc_typeck::check_crate
  27: rustc_interface::passes::analysis
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::force_query_with_job
  31: rustc_query_system::query::plumbing::get_query_impl
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  33: rustc_interface::passes::QueryContext::enter
  34: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  35: rustc_span::with_source_map
  36: rustc_interface::interface::create_compiler_and_run
  37: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: 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.53.0-nightly (a836d9b64 2021-04-10) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_raw] computing layout of `(dyn std::convert::AsRef<[type error]>, u8)`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0412, E0601.
For more information about an error, try `rustc --explain E0412`.

@chengniansun chengniansun 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 Apr 11, 2021
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 11, 2021
@hameerabbasi
Copy link
Contributor

Bisected:

********************************************************************************
Regression in nightly-2020-10-27
********************************************************************************

fetching https://static.rust-lang.org/dist/2020-10-26/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-10-26: 40 B / 40 B [===============] 100.00 % 814.97 KB/s converted 2020-10-26 to 4760b8fb886a3702ae11bfa7868d495b2675b5ed
fetching https://static.rust-lang.org/dist/2020-10-27/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-10-27: 40 B / 40 B [=================] 100.00 % 1.02 MB/s converted 2020-10-27 to fd542592f08ca0d1f7255600115c2eafdf6b5da7
looking for regression commit between 2020-10-26 and 2020-10-27
opening existing repository at "rust.git"
refreshing repository
fetching (via local git) commits from 4760b8fb886a3702ae11bfa7868d495b2675b5ed to fd542592f08ca0d1f7255600115c2eafdf6b5da7
opening existing repository at "rust.git"
refreshing repository
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 11 bors merge commits in the specified range
  commit[0] 2020-10-25UTC: Auto merge of #78179 - RalfJung:miri-comments, r=oli-obk
  commit[1] 2020-10-25UTC: Auto merge of #78015 - ssomers:btree_merge_mergers, r=Mark-Simulacrum
  commit[2] 2020-10-26UTC: Auto merge of #77283 - estebank:if-let-sugg, r=Mark-Simulacrum
  commit[3] 2020-10-26UTC: Auto merge of #78387 - Dylan-DPC:rollup-ch0st6z, r=Dylan-DPC
  commit[4] 2020-10-26UTC: Auto merge of #75728 - nagisa:improve_align_offset_2, r=Mark-Simulacrum
  commit[5] 2020-10-26UTC: Auto merge of #78324 - RalfJung:uninhabited-statics, r=oli-obk
  commit[6] 2020-10-26UTC: Auto merge of #78196 - pietroalbini:shipped-files, r=Mark-Simulacrum
  commit[7] 2020-10-26UTC: Auto merge of #78395 - RalfJung:miri, r=RalfJung
  commit[8] 2020-10-26UTC: Auto merge of #77975 - bjorn3:cg_clif_subtree3, r=Mark-Simulacrum
  commit[9] 2020-10-26UTC: Auto merge of #68965 - eddyb:mir-inline-scope, r=nagisa,oli-obk
  commit[10] 2020-10-26UTC: Auto merge of #77187 - TimDiekmann:box-alloc, r=Amanieu
ERROR: no commits between 4760b8fb886a3702ae11bfa7868d495b2675b5ed and fd542592f08ca0d1f7255600115c2eafdf6b5da7 within last 167 days

@camelid
Copy link
Member

camelid commented Apr 12, 2021

Weirdly, the ICE only happens when you don't import OsStr. I.e., this ICEs:

static NONE: (dyn AsRef<OsStr>, u8) = ("hello", 42);

but this gives an appropriate unsized field error:

use std::ffi::OsStr;
static NONE: (dyn AsRef<OsStr>, u8) = ("hello", 42);

@estebank
Copy link
Contributor

The error happens when a [type error] is involved, which makes the sizedness check for dyn AsRef not to be evaluated. A way to side-step the issue is to change

to be is !sized && !ty.references_error() {

@camelid camelid self-assigned this Apr 14, 2021
@apiraino
Copy link
Contributor

Assigning priority as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 14, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Apr 16, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Apr 16, 2021
camelid added a commit to camelid/rust that referenced this issue Apr 16, 2021
Based on estebank's [comment], except I used `delay_span_bug` because it
should work in more cases, and I think it expresses its intent more
clearly.

[comment]: rust-lang#84108 (comment)
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 19, 2021
@chengniansun
Copy link
Author

A potential duplicate.

Code

static FOO: (PartialEq<Item>, u32);

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (cc77ba46f 2021-06-03)
binary: rustc
commit-hash: cc77ba46fcb2d288aa01554b48cd586c5827c3dd
commit-date: 2021-06-03
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

error: free static item without body
 --> mutant.rs:1:1
  |
1 | static FOO: (PartialEq<Item>, u32);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
  |                                   |
  |                                   help: provide a definition for the static: `= <expr>;`

error[E0412]: cannot find type `Item` in this scope
 --> mutant.rs:1:24
  |
1 | static FOO: (PartialEq<Item>, u32);
  |                        ^^^^ not found in this scope

warning: trait objects without an explicit `dyn` are deprecated
 --> mutant.rs:1:14
  |
1 | static FOO: (PartialEq<Item>, u32);
  |              ^^^^^^^^^^^^^^^ help: use `dyn`: `dyn PartialEq<Item>`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
  = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

error[E0601]: `main` function not found in crate `mutant`
 --> mutant.rs:1:1
  |
1 | static FOO: (PartialEq<Item>, u32);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `mutant.rs`

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:370:17: univariant: field #2 of `(dyn PartialEq<[type error]>, u32)` comes after unsized field

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:1007:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: 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.54.0-nightly (cc77ba46f 2021-06-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_raw] computing layout of `(dyn std::cmp::PartialEq<[type error]>, u32)`
#1 [check_mod_item_types] checking item types in top-level module
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0412, E0601.
For more information about an error, try `rustc --explain E0412`.
Backtrace

error: free static item without body
 --> mutant.rs:1:1
  |
1 | static FOO: (PartialEq<Item>, u32);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
  |                                   |
  |                                   help: provide a definition for the static: `= <expr>;`

error[E0412]: cannot find type `Item` in this scope
 --> mutant.rs:1:24
  |
1 | static FOO: (PartialEq<Item>, u32);
  |                        ^^^^ not found in this scope

warning: trait objects without an explicit `dyn` are deprecated
 --> mutant.rs:1:14
  |
1 | static FOO: (PartialEq<Item>, u32);
  |              ^^^^^^^^^^^^^^^ help: use `dyn`: `dyn PartialEq<Item>`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
  = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

error[E0601]: `main` function not found in crate `mutant`
 --> mutant.rs:1:1
  |
1 | static FOO: (PartialEq<Item>, u32);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `mutant.rs`

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:370:17: univariant: field #2 of `(dyn PartialEq<[type error]>, u32)` comes after unsized field

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:1007:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::univariant_uninterned
   8: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_raw_uncached
   9: rustc_middle::ty::layout::layout_raw
  10: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::layout_raw>::compute
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_raw
  13: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  14: rustc_typeck::check::check::check_static_inhabited
  15: rustc_typeck::check::check::check_item_type
  16: rustc_middle::hir::map::Map::visit_item_likes_in_module
  17: rustc_typeck::check::check::check_mod_item_types
  18: rustc_query_system::query::plumbing::get_query_impl
  19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  20: rustc_session::utils::<impl rustc_session::session::Session>::time
  21: rustc_typeck::check_crate
  22: rustc_interface::passes::analysis
  23: rustc_query_system::query::plumbing::get_query_impl
  24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  25: rustc_interface::passes::QueryContext::enter
  26: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: 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.54.0-nightly (cc77ba46f 2021-06-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_raw] computing layout of `(dyn std::cmp::PartialEq<[type error]>, u32)`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0412, E0601.
For more information about an error, try `rustc --explain E0412`.

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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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.

8 participants