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

match of associated_const from const_fn #27430

Closed
Johnson-A opened this issue Jul 31, 2015 · 2 comments
Closed

match of associated_const from const_fn #27430

Johnson-A opened this issue Jul 31, 2015 · 2 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Johnson-A
Copy link

I am using an associated constant in a match pattern. The associated constant was initiated with a const function. https://play.rust-lang.org/?gist=0a3ce02daba0b2226cac&version=nightly

#![feature(associated_consts, const_fn)]
struct A(u32);

impl A {
    const fn new() -> A { A(0) }
    const TEST: A = A::new();
}

fn main() {
    match A(1) {
        A::TEST => (),
        _ => ()
    }
}

I would expect this to work but instead I get a compile error.

Version:
rustc 1.3.0-nightly (4d52d7c 2015-07-30)
binary: rustc
commit-hash: 4d52d7c
commit-date: 2015-07-30
host: x86_64-apple-darwin
release: 1.3.0-nightly

Backtrace:
thread 'rustc' panicked at 'internal error: entered unreachable code', ../src/librustc/middle/const_eval.rs:303

stack backtrace:
1: 0x11045b775 - sys::backtrace::write::h00f40a024c5fc864Ovs
2: 0x11046487e - panicking::on_panic::h0e43a2acb42d44b6wWw
3: 0x11041e342 - rt::unwind::begin_unwind_inner::ha56aa2c668bd1b81HEw
4: 0x10d1d3046 - rt::unwind::begin_unwind::h5600055422857985838
5: 0x10d34d4ec - middle::const_eval::const_expr_to_pat::hb3e6bc475d6b1549byj
6: 0x10d34474f - middle::check_match::StaticInliner<'a, 'tcx>.Folder::fold_pat::h89405171f869c1bdPWh
7: 0x10d3442e5 - iter::Map<I, F>.Iterator::next::h8976116763720396864
8: 0x10d3406c0 - middle::check_match::check_expr::h0dc9e986b4200cebTyh
9: 0x10d3400ae - middle::check_match::check_expr::h0dc9e986b4200cebTyh
10: 0x10d342deb - middle::check_match::check_fn::hb4a13b41d8a3214fUKi
11: 0x10d343da6 - visit::walk_impl_item::h16511485676432689156
12: 0x10d34345e - visit::walk_item::h16706684038497946513
13: 0x10d3431de - visit::walk_item::h16706684038497946513
14: 0x10d342f4a - middle::check_match::check_crate::h6da5404894312007xyh
15: 0x10c8de265 - driver::phase_3_run_analysis_passes::closure.16497
16: 0x10c8daf8c - middle::ty::ctxt<'tcx>::create_and_enter::h15699848509377711113
17: 0x10c8d6066 - driver::phase_3_run_analysis_passes::h8204244616204611716
18: 0x10c8bbf5c - driver::compile_input::h15546a0a04ea3d9bTba
19: 0x10c99f960 - run_compiler::hba01dad9ef72ac1bA7b
20: 0x10c99d3f0 - boxed::F.FnBox::call_box::h17305433943357537886
21: 0x10c99cc67 - rt::unwind::try::try_fn::h14437690116303608274
22: 0x11046432f - __rust_try_inner
23: 0x11046436a - __rust_try
24: 0x11044dd15 - rt::unwind::try::inner_try::h7ac3b4630cf0a4afAAw
25: 0x10c99cea9 - boxed::F.FnBox::call_box::h6665094899717926123
26: 0x11046330d - sys::thread::Thread::new::thread_start::h22fe824ce7ac562bbZv
27: 0x7fff9ad42267 - _pthread_body
28: 0x7fff9ad421e4 - _pthread_start

@Aatch Aatch added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Aug 2, 2015
@apasel422
Copy link
Contributor

Still an issue.

@nagisa nagisa added the A-associated-items Area: Associated items (types, constants & functions) label May 16, 2016
@Mark-Simulacrum
Copy link
Member

This no longer ICEs, and I don't think that tracking the unimplemented constant evaluation makes sense--having a specific tracking issue for that won't make it get implemented, it'll come with miri's merge into rustc.

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) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants