Skip to content

const_val_field on non-field #50706

Description

@Thinkofname

Compiler version: rustc 1.27.0-nightly (ff2ac35db 2018-05-12)

Stack trace:

thread 'main' panicked at 'const_val_field on non-field', libcore/option.rs:914:5
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:467
   6: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:350
   7: rust_begin_unwind
             at libstd/panicking.rs:328
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   9: core::option::expect_failed
             at libcore/option.rs:914
  10: rustc_mir::interpret::const_eval::const_val_field
  11: rustc_mir::hair::pattern::PatternContext::const_to_pat::{{closure}}
  12: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  13: rustc_mir::hair::pattern::PatternContext::const_to_pat
  14: rustc_mir::hair::pattern::PatternContext::lower_path
  15: rustc_mir::hair::pattern::PatternContext::lower_pattern
  16: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
  17: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  18: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  19: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
  20: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
  21: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
  22: rustc::session::Session::track_errors
  23: rustc_mir::hair::pattern::check_match::check_match
  24: rustc::dep_graph::graph::DepGraph::with_task_impl
  25: rustc::ty::context::tls::with_related_context
  26: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  27: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  28: rustc::hir::intravisit::Visitor::visit_nested_body
  29: rustc::hir::Crate::visit_all_item_likes
  30: rustc_mir::hair::pattern::check_match::check_crate
  31: rustc::util::common::time
  32: rustc::ty::context::tls::enter_context
  33: <std::thread::local::LocalKey<T>>::with
  34: rustc::ty::context::TyCtxt::create_and_enter
  35: rustc_driver::driver::compile_input
  36: rustc_driver::run_compiler_impl
  37: <scoped_tls::ScopedKey<T>>::set
  38: syntax::with_globals
  39: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  40: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  41: rustc_driver::run
  42: rustc_driver::main
  43: std::rt::lang_start::{{closure}}
  44: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  45: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  46: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  47: main
  48: __libc_start_main
  49: <unknown>
query stack during panic:
#0 [check_match] processing `Stat::from_index`
end of query stack

error: internal compiler error: unexpected panic

Code:

pub struct Stats;

#[derive(PartialEq, Eq)]
pub struct StatVariant {
    pub id: u8,
    _priv: (),
}

#[derive(PartialEq, Eq)]
pub struct Stat {
    pub variant: StatVariant,
    pub index: usize,
    _priv: (),
}

impl Stats {

    pub const TEST: StatVariant = StatVariant{id: 0, _priv: (),};
    #[allow(non_upper_case_globals)]
    pub const A: Stat = Stat{
         variant: Self::TEST,
         index: 0,
         _priv: (),};
}

impl Stat {
    pub fn from_index(variant: StatVariant, index: usize) -> Option<Stat> {
        let stat = Stat{variant, index, _priv: (),};
        match stat {
            Stats::A => Some(Stats::A),
            _ => None,
        }
    }
}

fn main() {

}

I tried to reduce it as it was originally generated by a macro, this is about as small as I could get it.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on May 13, 2018
  2. emilyalbini commented on May 13, 2018

    @emilyalbini
    Member

    Thanks for reporting this! This is indeed a regression from stable to nightly.

    A bisect points at #50249 as the cause of the regression. cc @oli-obk @Zoxc

  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on May 13, 2018
  4. emilyalbini commented on May 13, 2018

    @emilyalbini
    Member

    This also seems to be a different error than #50707, even if it's caused by the same PR.

  5. added a commit that references this issue on May 19, 2018
    5c3960c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions