Skip to content

const_val_field on non-field #50706

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Thinkofname opened this issue May 13, 2018 · 2 comments · Fixed by #50690
Closed

const_val_field on non-field #50706

Thinkofname opened this issue May 13, 2018 · 2 comments · Fixed by #50690
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Thinkofname
Copy link

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.

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 13, 2018
@pietroalbini
Copy link
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

@pietroalbini pietroalbini added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 13, 2018
@pietroalbini
Copy link
Member

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

@nikomatsakis nikomatsakis added the P-high High priority label May 17, 2018
bors added a commit that referenced this issue May 19, 2018
Ensure that statics are always ByRef

Statics aren't values to be used, they are names for memory locations.

r? @eddyb

cc @Zoxc

fixes #50706
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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