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_trait_selection/src/traits/object_safety.rs: the type [type error] has an unknown layout while computing layout for type ... #78372

Closed
chengniansun opened this issue Oct 25, 2020 · 0 comments · Fixed by #78422
Assignees
Labels
C-bug Category: This is a bug. F-dispatch_from_dyn `#![feature(dispatch_from_dyn)]` 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

@chengniansun
Copy link

Code

use std::ops::DispatchFromDyn;
struct Smaht<T, MISC>(PhantomData);
impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
trait Foo: X<u32> {}
trait X<T> {
    fn foo(self: Smaht<Self, T>);
}
trait Marker {}
impl Marker for Foo {}

Meta

rustc --version --verbose:

binary: rustc
commit-hash: ffa2e7ae8fbf9badc035740db949b9dae271c29f
commit-date: 2020-10-24
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

Error output

error[E0412]: cannot find type `PhantomData` in this scope
 --> reduced_mutant.rs:2:23
  |
2 | struct Smaht<T, MISC>(PhantomData);
  |                       ^^^^^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 | use std::marker::PhantomData;
  |

error[E0412]: cannot find type `U` in this scope
 --> reduced_mutant.rs:3:31
  |
3 | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
  |      -                        ^ help: a type parameter with a similar name exists: `T`
  |      |
  |      similarly named type parameter `T` defined here

error[E0412]: cannot find type `MISC` in this scope
 --> reduced_mutant.rs:3:34
  |
3 | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
  |       -                          ^^^^ not found in this scope
  |       |
  |       help: you might be missing a type parameter: `, MISC`

warning: trait objects without an explicit `dyn` are deprecated
 --> reduced_mutant.rs:9:17
  |
9 | impl Marker for Foo {}
  |                 ^^^ help: use `dyn`: `dyn Foo`
  |
  = note: `#[warn(bare_trait_objects)]` on by default

error[E0601]: `main` function not found in crate `reduced_mutant`
 --> reduced_mutant.rs:1:1
  |
1 | / use std::ops::DispatchFromDyn;
2 | | struct Smaht<T, MISC>(PhantomData);
3 | | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
4 | | trait Foo: X<u32> {}
... |
8 | | trait Marker {}
9 | | impl Marker for Foo {}
  | |______________________^ consider adding a `main` function to `reduced_mutant.rs`

error[E0658]: use of unstable library feature 'dispatch_from_dyn'
 --> reduced_mutant.rs:1:5
  |
1 | use std::ops::DispatchFromDyn;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(dispatch_from_dyn)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'dispatch_from_dyn'
 --> reduced_mutant.rs:3:9
  |
3 | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(dispatch_from_dyn)]` to the crate attributes to enable

error: internal compiler error: compiler/rustc_trait_selection/src/traits/object_safety.rs:469:33: error: the type `[type error]` has an unknown layout
 while computing layout for type Smaht<(), T>

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945: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.49.0-nightly (ffa2e7ae8 2020-10-24) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [object_safety_violations] determine object safety of trait `Foo`
#1 [coherent_trait] coherence checking all impls of trait `Marker`
end of query stack
error: aborting due to 7 previous errors; 1 warning emitted

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

error: internal compiler error: compiler/rustc_trait_selection/src/traits/object_safety.rs:469:33: error: the type `[type error]` has an unknown layout
 while computing layout for type Smaht<(), T>

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::bug_fmt
   8: rustc_trait_selection::traits::object_safety::virtual_call_violation_for_method::{{closure}}
   9: rustc_trait_selection::traits::object_safety::virtual_call_violation_for_method
  10: rustc_trait_selection::traits::object_safety::object_safety_violation_for_method
  11: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
  12: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
  13: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  14: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
  15: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  16: rustc_middle::arena::Arena::alloc_from_iter
  17: rustc_trait_selection::traits::object_safety::object_safety_violations
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::get_query_impl
  21: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::is_object_safe
  22: rustc_typeck::coherence::coherent_trait
  23: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::coherent_trait>::compute
  24: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  25: rustc_data_structures::stack::ensure_sufficient_stack
  26: rustc_query_system::query::plumbing::get_query_impl
  27: rustc_query_system::query::plumbing::ensure_query_impl
  28: rustc_session::session::Session::track_errors
  29: rustc_typeck::check_crate
  30: rustc_interface::passes::analysis
  31: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  33: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  34: rustc_query_system::query::plumbing::get_query_impl
  35: rustc_interface::passes::QueryContext::enter
  36: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  37: rustc_span::with_source_map
  38: rustc_interface::interface::create_compiler_and_run
  39: 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.49.0-nightly (ffa2e7ae8 2020-10-24) running on x86_64-unknown-linux-gnu

NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses

@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 Oct 25, 2020
@jonas-schievink jonas-schievink added the F-dispatch_from_dyn `#![feature(dispatch_from_dyn)]` label Oct 25, 2020
@chengniansun chengniansun changed the title ICE: ompiler/rustc_trait_selection/src/traits/object_safety.rs: the type [type error] has an unknown layout while computing layout for type ... ICE: compiler/rustc_trait_selection/src/traits/object_safety.rs: the type [type error] has an unknown layout while computing layout for type ... Oct 25, 2020
@estebank estebank self-assigned this Oct 26, 2020
@bors bors closed this as completed in 7fa9e39 Oct 30, 2020
Dylan-DPC-zz referenced this issue in Dylan-DPC-zz/rust Mar 21, 2021
…chenkov

Move some tests to more reasonable directories - 5

cc rust-lang#73494

Threshold is 0.95. Next time I promise I will take a look into the special/misclassified directories.

- [issues/issue-23208.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-23208.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/23208)</sup>: associated-types 0.951
- [weird-exprs.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/weird-exprs.rs) <sup>unknown</sup>: destructuring-assignment 0.958
- [issues/issue-1701.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-1701.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/1701)</sup>: structs-enums 0.974
- [issues/issue-48508-aux.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-48508-aux.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/48508)</sup>: numbers-arithmetic 0.991
- [fn_must_use.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/fn_must_use.rs) <sup>unknown</sup>: lint 1.000
- [mir_check_nonconst.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/mir_check_nonconst.rs) <sup>unknown</sup>: consts 1.002
- [issues/issue-52060.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-52060.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/52060)</sup>: consts 1.017
- [issues/issue-45729-unsafe-in-generator.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-45729-unsafe-in-generator.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/45729)</sup>: generator 1.024
- [issues/issue-10392.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-10392.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/10392)</sup>: pattern 1.039
- [no-implicit-prelude.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/no-implicit-prelude.rs) <sup>unknown</sup>: resolve 1.071
- [issues/issue-68000-unicode-ident-after-missing-comma.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/68000)</sup>: parser 1.079
- [shadow.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/shadow.rs) <sup>unknown</sup>: binding 1.099
- [issues/issue-65611.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-65611.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/65611)</sup>: consts 1.139
- [concat-rpass.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/concat-rpass.rs) <sup>unknown</sup>: macros 1.194
- [issues/issue-31597.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-31597.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/31597)</sup>: associated-types 1.195
- [issues/issue-78372.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-78372.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/78372)</sup>: resolve 1.426
- [impl-trait-in-bindings-issue-73003.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-trait-in-bindings-issue-73003.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/73003)</sup>: impl-trait 1.471
- [impl-trait-in-bindings.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-trait-in-bindings.rs) <sup>unknown</sup>: impl-trait 2.500

r? `@petrochenkov`
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-dispatch_from_dyn `#![feature(dispatch_from_dyn)]` 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.

3 participants