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

Const generic ICE without feature specified #60263

Closed
DutchGhost opened this issue Apr 25, 2019 · 4 comments · Fixed by #60277
Closed

Const generic ICE without feature specified #60263

DutchGhost opened this issue Apr 25, 2019 · 4 comments · Fixed by #60277
Labels
A-const-generics Area: const generics (parameters and arguments) 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.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Apr 25, 2019

The following ICE's on nightly only:

use std::marker::PhantomData;

struct B<const I: u8>;

impl B<0> {
    fn bug() -> Self {
        panic!()
    }
}

Notice I didn't specify the #![feature(const_generics)] feature

Backtrace:

Compiling playground v0.0.1 (/playground)
error[E0658]: const generics are unstable
  --> src/lib.rs:23:16
   |
23 | struct B<const I: u8>;
   |                ^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/44580
   = help: add #![feature(const_generics)] to the crate attributes to enable

warning: unused import: `std::marker::PhantomData`
  --> src/lib.rs:21:5
   |
21 | use std::marker::PhantomData;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

thread 'rustc' panicked at 'not yet implemented', src/librustc/ty/relate.rs:707:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   6: std::panicking::begin_panic
   7: <rustc::ty::subst::Kind as rustc::ty::relate::Relate>::relate
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
   9: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  10: <core::result::Result<T,E> as rustc::ty::context::InternIteratorElement<T,R>>::intern_with
  11: <rustc::infer::combine::Generalizer as rustc::ty::relate::TypeRelation>::relate_item_substs
  12: rustc::ty::relate::super_relate_tys
  13: <rustc::infer::combine::Generalizer as rustc::ty::relate::TypeRelation>::tys
  14: rustc::infer::combine::CombineFields::instantiate
  15: <rustc::infer::sub::Sub as rustc::ty::relate::TypeRelation>::tys
  16: rustc::infer::InferCtxt::commit_if_ok
  17: rustc::infer::InferCtxt::commit_if_ok
  18: rustc_typeck::check::coercion::Coerce::coerce_unsized
  19: rustc::infer::InferCtxt::commit_if_ok
  20: rustc_typeck::check::coercion::Coerce::coerce
  21: rustc::infer::InferCtxt::commit_if_ok
  22: rustc_typeck::check::coercion::<impl rustc_typeck::check::FnCtxt>::try_coerce
  23: rustc_typeck::check::coercion::CoerceMany<E>::coerce_inner
  24: rustc_typeck::check::FnCtxt::check_block_with_expected
  25: rustc_typeck::check::FnCtxt::check_expr_kind
  26: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  27: rustc_typeck::check::FnCtxt::check_block_with_expected
  28: rustc_typeck::check::FnCtxt::check_expr_kind
  29: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  30: rustc_typeck::check::FnCtxt::check_return_expr
  31: rustc_typeck::check::check_fn
  32: rustc::ty::context::GlobalCtxt::enter_local
  33: rustc_typeck::check::typeck_tables_of
  34: rustc::ty::query::__query_compute::typeck_tables_of
  35: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  38: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  39: rustc_typeck::check::typeck_item_bodies
  40: rustc::ty::query::__query_compute::typeck_item_bodies
  41: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_item_bodies>::compute
  42: rustc::dep_graph::graph::DepGraph::with_task_impl
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  44: rustc::util::common::time
  45: rustc_typeck::check_crate
  46: rustc_interface::passes::analysis
  47: rustc::ty::query::__query_compute::analysis
  48: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
  50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  51: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  52: rustc_interface::passes::create_global_ctxt::{{closure}}
  53: rustc_interface::passes::BoxedGlobalCtxt::enter
  54: rustc_interface::interface::run_compiler_in_existing_thread_pool
  55: std::thread::local::LocalKey<T>::with
  56: scoped_tls::ScopedKey<T>::set
  57: syntax::with_globals
query stack during panic:
#0 [typeck_tables_of] processing `B::<_>::bug`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

error: internal compiler error: unexpected panic

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.36.0-nightly (e305df184 2019-04-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

@jonas-schievink jonas-schievink 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 25, 2019
@petrochenkov
Copy link
Contributor

In general, presence or absence of #![feature(X)] shouldn't affect compiler's behavior in any way beside reporting the "feature X is unstable" error, so ICEs like this need to fixed unconditionally.

@hellow554
Copy link
Contributor

hellow554 commented Apr 25, 2019

Strongly related (not sure why two issues though) with #60264 and therefore with #60147 and #57272

@petrochenkov I already pinged you in #60147 (comment) because of this ;)

@DutchGhost
Copy link
Contributor Author

DutchGhost commented Apr 25, 2019

Strongly related (not sure why two issues though) with #60264 and therefore with #60147 and #57272

2 issue's because the ICE messages are different, sorry for the confusion!
To clearify, on both issue's there are 2 things wrong:

  • Being able to get the ICE's, without specifying the feature
  • The ICE's themselves (Which was likely to happen, given the incompleteness. Consider these as test-cases, or something :) )

@varkor
Copy link
Member

varkor commented May 2, 2019

This should be fixed on the next nightly, but #60277 will add a regression test for it.

@varkor varkor removed their assignment May 2, 2019
@varkor varkor added the A-const-generics Area: const generics (parameters and arguments) label May 2, 2019
bors added a commit that referenced this issue May 7, 2019
Don't ICE when relating const type args

Fix #60263.

r? @varkor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants