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

Unexpected Panic in Compiler When Referencing Function in const Initializer #25757

Closed
zrneely opened this issue May 24, 2015 · 2 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@zrneely
Copy link

zrneely commented May 24, 2015

When I tried to compile my project, rustc panicked.

I put together a playpen that reproduces the issue (on stable, beta, or nightly, in debug or release mode), but I'm not sure where exactly the issue stems from. Side note - I was experimenting with macros for the first time, so the code is probably pretty bad anyway.

http://is.gd/EsBJsA

Here's the backtrace from my actual project:

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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTy(DefId { krate: 0, node: 1986 }, false), last_private: LastMod(All
Public), depth: 1 }', /home/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/middle/def.rs:80

stack backtrace:
   1:     0x7f7c27880449 - sys::backtrace::write::hbc46dc0cfb3b9537d4r
   2:     0x7f7c27888156 - panicking::on_panic::h74d3c14d86c58ac8jrw
   3:     0x7f7c2784b462 - rt::unwind::begin_unwind_inner::h382cea404b11eb00t6v
   4:     0x7f7c2784c10c - rt::unwind::begin_unwind_fmt::h5c14cfc30901d9d274v
   5:     0x7f7c2587c710 - middle::ty::resolve_expr::h624bd395eab0f46apA6
   6:     0x7f7c259dba24 - middle::ty::expr_kind::h42a59d6cf4de6fb1vC6
   7:     0x7f7c259db7ea - middle::ty::expr_is_lval::hf75f64ec2e4f01a7sB6
   8:     0x7f7c266ff7e0 - check::check_expr_with_unifier::h16758040784423113870
   9:     0x7f7c26703595 - check::check_expr_with_unifier::h14796100913847929148
  10:     0x7f7c267232da - check::check_const_with_ty::hd1e9965599ee588c70r
  11:     0x7f7c266c17d2 - check::check_item_type::hf5c3369181584636ePn
  12:     0x7f7c266c5c02 - visit::walk_item::h932162154766316786
  13:     0x7f7c2678b652 - check_crate::closure.38028
  14:     0x7f7c26786a30 - check_crate::h22dcd95e17a2d96dXcC
  15:     0x7f7c27dc4cc8 - driver::phase_3_run_analysis_passes::h43926ceca86caa9fnGa
  16:     0x7f7c27da5dc5 - driver::compile_input::hb78754f2f33c01efQba
  17:     0x7f7c27e674d1 - run_compiler::h258d36d5501c1cdfz4b
  18:     0x7f7c27e65122 - boxed::F.FnBox<A>::call_box::h7239693171334256553
  19:     0x7f7c27e64659 - rt::unwind::try::try_fn::h14329119008520845439
  20:     0x7f7c278faac8 - rust_try_inner
  21:     0x7f7c278faab5 - rust_try
  22:     0x7f7c27e64908 - boxed::F.FnBox<A>::call_box::h17332056298259451807
  23:     0x7f7c27887041 - sys::thread::create::thread_start::h490278b5c3c0b49faqv
  24:     0x7f7c221036a9 - start_thread
  25:     0x7f7c274d8eec - clone
  26:                0x0 - <unknown>
@shepmaster
Copy link
Member

Inlining the code so it doesn't get lost

macro_rules! get_method {
    ( $x: ident ) => {
        &Foo::$x
    };
}

struct Foo {
    a: u32
}

impl Foo {
    fn x(&mut self) {
        self.a = 5;
    }
}

const FUNC: &'static FnMut(&mut Foo) -> () = get_method!(x);

fn main() {}

@zrneely
Copy link
Author

zrneely commented May 25, 2015

Update: it appears this bug is unrelated to macros, as it still occurs in the following code:

struct Foo {
    a: u32
}

impl Foo {
    fn x(&mut self) {
        self.a = 5;
    }
}

const FUNC: &'static FnMut(&mut Foo) -> () = &Foo::x;

fn main() {}

Is this intended to be possible?

@zrneely zrneely changed the title Unexpected Panic in Compiler When Calling Macro in const Initializer Unexpected Panic in Compiler When Referencing Function in const Initializer May 25, 2015
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 25, 2015
arielb1 pushed a commit to arielb1/rust that referenced this issue Jun 21, 2015
Previously it also tried to find out the best way to translate the
expression, which could ICE during type-checking.

Fixes rust-lang#23173
Fixes rust-lang#24322
Fixes rust-lang#25757
bors added a commit that referenced this issue Jun 21, 2015
Previously it also tried to find out the best way to translate the
expression, which could ICE during type-checking.

Fixes #23173
Fixes #24322
Fixes #25757

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants