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 when passing slice with const eval length to method #54038

Closed
XOSplicer opened this issue Sep 7, 2018 · 3 comments
Closed

ICE when passing slice with const eval length to method #54038

XOSplicer opened this issue Sep 7, 2018 · 3 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-const-eval Area: Constant evaluation (MIR interpretation) A-typesystem Area: The type system 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@XOSplicer
Copy link

XOSplicer commented Sep 7, 2018

I tried this code:

struct Foo<'a> {
    data: &'a [u8],
}

impl<'a> Foo<'a> {
    const LEN: usize = 4;
    fn bar(buf: &mut [u8; Self::LEN]) {
        unimplemented!()
    }
}

I expected a successful compile, however rustc panicked.
Without the lifetime annotation (only struct Foo;) the panic does not happen and it compiles successfully.

Meta

rust version: rustc 1.28.0 (9634041 2018-07-30) running on x86_64-unknown-linux-gnu

playground link: https://play.rust-lang.org/?gist=4f897c3fc9de85f853b16cc0a8c2b562&version=stable&mode=debug&edition=2015

Backtrace:

   Compiling playground v0.0.1 (file:///playground)
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Some(NodeId(13))`,
 right: `None`: free_scope: DefId(0/0:4 ~ playground[a256]::{{impl}}[0]) not recognized by the region scope tree for None / Some(DefId(0/0:6 ~ playground[a256]::{{impl}}[0]::bar[0]))', librustc/middle/region.rs:734:13
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:515
   6: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:426
   7: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:413
   8: rustc::middle::region::ScopeTree::early_free_scope
   9: rustc::middle::free_region::RegionRelations::is_subregion_of
  10: rustc::infer::lexical_region_resolve::resolve
  11: rustc::infer::InferCtxt::resolve_regions_and_report_errors_inner
  12: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_expr
  13: rustc::ty::context::tls::with_related_context
  14: rustc::infer::InferCtxtBuilder::enter
  15: rustc_typeck::check::typeck_tables_of
  16: rustc::ty::query::__query_compute::typeck_tables_of
  17: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
  18: rustc::dep_graph::graph::DepGraph::with_task_impl
  19: rustc::ty::context::tls::with_related_context
  20: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  21: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  22: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  23: rustc_mir::interpret::const_eval::const_eval_provider
  24: rustc::ty::query::__query_compute::const_eval
  25: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
  26: rustc::dep_graph::graph::DepGraph::with_task_impl
  27: rustc::ty::context::tls::with_related_context
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  30: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
  31: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  32: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  33: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  34: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  35: <rustc_data_structures::accumulate_vec::AccumulateVec<A> as core::iter::traits::FromIterator<<A as rustc_data_structures::array_vec::Array>::Element>>::from_iter
  36: rustc::ty::fold::TypeFoldable::fold_with
  37: rustc::traits::project::normalize
  38: rustc::infer::InferCtxt::partially_normalize_associated_types_in
  39: rustc::ty::context::tls::with_related_context
  40: rustc::infer::InferCtxtBuilder::enter
  41: rustc_typeck::check::wfcheck::check_associated_item
  42: rustc_typeck::check::wfcheck::check_impl_item
  43: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::check_impl_item_well_formed<'tcx>>::compute
  44: rustc::dep_graph::graph::DepGraph::with_task_impl
  45: rustc::ty::context::tls::with_related_context
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
  49: rustc::hir::Crate::visit_all_item_likes
  50: rustc::session::Session::track_errors
  51: rustc::util::common::time
  52: rustc_typeck::check_crate
  53: rustc::ty::context::tls::enter_context
  54: <std::thread::local::LocalKey<T>>::with
  55: rustc::ty::context::TyCtxt::create_and_enter
  56: rustc_driver::driver::compile_input
  57: rustc_driver::run_compiler_with_pool
  58: <scoped_tls::ScopedKey<T>>::set
  59: syntax::with_globals
  60: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  61: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  62: rustc_driver::run
  63: rustc_driver::main
  64: std::rt::lang_start::{{closure}}
  65: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  66: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  67: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  68: main
  69: __libc_start_main
  70: <unknown>
query stack during panic:
#0 [typeck_tables_of] processing `Foo::bar::{{constant}}`
#1 [const_eval] const-evaluating `Foo::bar::{{constant}}`
#2 [check_impl_item_well_formed] processing `Foo::bar`
end of query stack

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.28.0 (9634041f0 2018-07-30) 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.
@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-const-eval Area: Constant evaluation (MIR interpretation) WG-compiler-const labels Sep 7, 2018
@oli-obk oli-obk self-assigned this Jan 28, 2019
@oli-obk oli-obk added A-typesystem Area: The type system A-associated-items Area: Associated items (types, constants & functions) and removed A-const-eval Area: Constant evaluation (MIR interpretation) labels Mar 12, 2019
@oli-obk oli-obk removed their assignment Mar 12, 2019
@estebank estebank added the A-const-eval Area: Constant evaluation (MIR interpretation) label May 8, 2019
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@XOSplicer
Copy link
Author

The provided code example still does not compile successfully with rustc 1.40.0

@oli-obk
Copy link
Contributor

oli-obk commented Dec 22, 2019

This is basically #43408

Self is an implicit generic parameter in impl blocks

@oli-obk
Copy link
Contributor

oli-obk commented May 8, 2020

I'm closing this as a duplicate, as tracking it separately doesn't give us any benefit until the root issue has been fixed (which will likely just fix this one, too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-const-eval Area: Constant evaluation (MIR interpretation) A-typesystem Area: The type system 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) ❄️ 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

6 participants