Skip to content

Stable ICE with fieldless enums and dyn traits #83764

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

Closed
PatrickNorton opened this issue Apr 1, 2021 · 4 comments
Closed

Stable ICE with fieldless enums and dyn traits #83764

PatrickNorton opened this issue Apr 1, 2021 · 4 comments
Labels
A-layout Area: Memory layout of types 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

@PatrickNorton
Copy link

PatrickNorton commented Apr 1, 2021

Code

#![allow(dead_code)]

pub fn main() {
    // Instantiating Foo with a concrete type will not fail
    let _ = Foo::<dyn FooTrait>::new();
}

pub struct Foo<T: FooTrait + ?Sized> {
    base: FooBase,
    value: T,
}

impl<T: FooTrait + ?Sized> Foo<T> {
    pub fn new() -> Box<Foo<T>> {
        todo!()
    }
}

pub trait FooTrait {}

pub struct FooBase {
    cls: Bar,
}

// Bar *must* be a fieldless enum
pub enum Bar {}

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-apple-darwin
release: 1.51.0
LLVM version: 11.0.1

(also crashes on beta and nightly)

Error output

thread 'rustc' panicked at 'assertion failed: layout.abi.is_uninhabited()', compiler/rustc_middle/src/ty/layout.rs:228:21
Backtrace

   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:50:5
   3: rustc_middle::ty::layout::layout_raw
   4: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::layout_raw>::compute
   5: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   6: rustc_data_structures::stack::ensure_sufficient_stack
   7: rustc_query_system::query::plumbing::force_query_with_job
   8: rustc_query_system::query::plumbing::get_query_impl
   9: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  10: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::spanned_layout_of
  11: rustc_middle::ty::layout::<impl rustc_target::abi::TyAndLayoutMethods<C> for &rustc_middle::ty::TyS>::pointee_info_at
  12: rustc_middle::ty::layout::<impl rustc_target::abi::TyAndLayoutMethods<C> for &rustc_middle::ty::TyS>::pointee_info_at
  13: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal::{{closure}}::{{closure}}
  14: rustc_target::abi::call::ArgAbi<Ty>::new
  15: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  16: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold
  17: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  18: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal
  19: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
  20: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  22: rustc_codegen_llvm::base::compile_codegen_unit
  23: rustc_codegen_ssa::base::codegen_crate
  24: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  25: rustc_session::utils::<impl rustc_session::session::Session>::time
  26: rustc_interface::passes::QueryContext::enter
  27: rustc_interface::queries::Queries::ongoing_codegen
  28: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  29: rustc_span::with_source_map
  30: rustc_interface::interface::create_compiler_and_run
  31: rustc_span::with_session_globals

@PatrickNorton PatrickNorton 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 1, 2021
@jonas-schievink jonas-schievink added A-layout Area: Memory layout of types I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 1, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 1, 2021

Possible duplicate of #82954.

fanninpm added a commit to fanninpm/glacier that referenced this issue Apr 2, 2021
Possible duplicate.

Issue: rust-lang/rust#83764
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 2, 2021
@hameerabbasi
Copy link
Contributor

Bisected:

found 4 bors merge commits in the specified range
  commit[0] 2019-10-03UTC: Auto merge of #64938 - estebank:ice-ice-baby, r=matthewjasper
  commit[1] 2019-10-03UTC: Auto merge of #65076 - tmandry:rollup-ka7nzb6, r=tmandry
  commit[2] 2019-10-04UTC: Auto merge of #65087 - Centril:rollup-skxq0zr, r=Centril
  commit[3] 2019-10-04UTC: Auto merge of #64994 - GuillaumeGomez:fix-rustdoc-display-js-disabled, r=Mark-Simulacrum
ERROR: no commits between 032a53a06ce293571e51bbe621a5c480e8a28e95 and 2e7244807a7878f6eca3eb7d97ae9b413aa49014 within last 167 days

@apiraino
Copy link
Contributor

apiraino commented Apr 6, 2021

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 6, 2021
@Alexendoo
Copy link
Member

Fixed by #90854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Area: Memory layout of types 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

No branches or pull requests

8 participants