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 with const generics over a &'static str #67883

Closed
snf opened this issue Jan 5, 2020 · 0 comments · Fixed by #68143
Closed

ICE with const generics over a &'static str #67883

snf opened this issue Jan 5, 2020 · 0 comments · Fixed by #68143
Labels
C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@snf
Copy link
Contributor

snf commented Jan 5, 2020

This seems to be similar to #60813 and #60814 but with a different stacktrace

#![feature(const_generics)]

struct Caca<const A: &'static str> {
    s: String
}

impl<const A: &str> Default for Caca<A> {
    fn default() -> Self {
        let a = Self::A;
        Self {
            s: A.to_string()
        }
    }
}

fn main() {
    println!("Hello, world!");
}

Stacktrace:

warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> 1.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default

error: internal compiler error: src/librustc/ty/subst.rs:496: Region parameter out of range when substituting in region '_ (root type=Some(&str)) (index=0)

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:854:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1057
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:195
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:215
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:476
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::span_bug
  14: rustc_errors::Handler::span_bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::span_bug_fmt
  20: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_region
  21: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
  22: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty
  23: rustc_typeck::check::FnCtxt::instantiate_value_path
  24: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  25: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  26: rustc::ty::context::tls::with_context::{{closure}}
  27: rustc_typeck::check::typeck_tables_of
  28: rustc::ty::query::__query_compute::typeck_tables_of
  29: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  30: rustc::dep_graph::graph::DepGraph::with_task_impl
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  32: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  33: rustc_typeck::check::typeck_item_bodies
  34: rustc::ty::query::__query_compute::typeck_item_bodies
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: rustc_typeck::check_crate
  38: rustc_interface::passes::analysis
  39: rustc::ty::query::__query_compute::analysis
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  42: rustc::ty::context::tls::enter_global
  43: rustc_interface::interface::run_compiler_in_existing_thread_pool
  44: std::thread::local::LocalKey<T>::with
  45: scoped_tls::ScopedKey<T>::set
  46: syntax::with_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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0-nightly (ed33453a3 2019-12-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck_tables_of] processing `<Caca<A> as std::default::Default>::{{constant}}#0`
#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

@Centril Centril added F-const_generics `#![feature(const_generics)]` 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. P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. labels Jan 5, 2020
@JohnTitor JohnTitor added the C-bug Category: This is a bug. label Jan 5, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 5, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jan 13, 2020
…ifetime, r=petrochenkov

Forbid elided lifetimes within const generic parameter types

Disallows `fn foo<const T: &u32>()`, the lifetime must be explicitly given, i.e. `fn foo<const T: &'static u32>()`.

Fixes rust-lang#67883
@bors bors closed this as completed in d7e5992 Jan 14, 2020
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-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
4 participants