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 when attempting to explicitly type function pointer variable #24322

Closed
maghoff opened this issue Apr 11, 2015 · 3 comments
Closed

ICE when attempting to explicitly type function pointer variable #24322

maghoff opened this issue Apr 11, 2015 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@maghoff
Copy link

maghoff commented Apr 11, 2015

I get an internal compiler error on the input detailed below.

I tried this code:

struct B;

impl B {
    fn func(&self) { }
}

fn main() {
    let x:&fn(&B) = &B::func;
}

I expected to see this happen: Maybe it should work like let x = &B::func, but I'm guessing that I have some error here. I get an error message when I try a variant of the above;

fn main() {
    let y = &B::func;
    let z:&fn(&B) = y;
}

This gives me the compile time error:

bug.rs:10:18: 10:19 error: mismatched types:
 expected `&fn(&B)`,
    found `&fn(&B) {B::func}`
(expected fn pointer,
    found fn item) [E0308]
bug.rs:10       let z:&fn(&B) = y;
                                ^
error: aborting due to previous error

Instead, this happened:

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: 4 }, false), last_private: LastMod(AllPublic), depth: 1 }', /build/buildd/rust-nightly-201504110408~93f7fe3~utopic/src/librustc/middle/def.rs:80

Meta

rustc --version --verbose:

rustc 1.0.0-dev (built 2015-04-11)
binary: rustc
commit-hash: unknown
commit-date: unknown
build-date: 2015-04-11
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev

From the rust-nightly package here: https://launchpad.net/~hansjorg/+archive/ubuntu/rust

Backtrace:

Running RUST_BACKTRACE=1 rustc bug.rs gives me only this output:

Illegal instruction
@maghoff
Copy link
Author

maghoff commented Apr 11, 2015

I attempted a small search for similar issues, but didn't quite know what to look for. In any event, I was unable to identify a duplicate :)

I am currently trying to build rustc from source to see if I will be able to get a backtrace that way.

@maghoff maghoff changed the title "internal compiler error" when attempting to explicitly type function pointer variable ICE when attempting to explicitly type function pointer variable Apr 11, 2015
@maghoff
Copy link
Author

maghoff commented Apr 11, 2015

I have now been able to try with a locally compiled rustc:

rustc --version --verbose:

rustc 1.0.0-dev (3a8275397 2015-04-11) (built 2015-04-11)
binary: rustc
commit-hash: 3a8275397a156b17331e16393e5e1ba89ab4de3f
commit-date: 2015-04-11
build-date: 2015-04-11
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev

Backtrace:

stack backtrace:
   1:     0x7fe588440779 - sys::backtrace::write::h1fb912b6242676e13JC
   2:     0x7fe588465067 - panicking::on_panic::h49b58f19dee2b6499aJ
   3:     0x7fe5883aefb2 - rt::unwind::begin_unwind_inner::h954a8c2d8b458b8ehQI
   4:     0x7fe5883af27f - rt::unwind::begin_unwind_fmt::h8142be88e287f416VOI
   5:     0x7fe5863bcfe0 - middle::ty::resolve_expr::h468519011c7f5a2dsB6
   6:     0x7fe58650e2b1 - middle::ty::expr_kind::h13d00213be0997d6yD6
   7:     0x7fe58650e07a - middle::ty::expr_is_lval::he8576d1b1ffb6fb6vC6
   8:     0x7fe587245c60 - check::check_expr_with_unifier::h1234167007494092036
   9:     0x7fe58726c89b - check::check_decl_local::h66808f8a0a45231fHjs
  10:     0x7fe5872125b1 - check::check_block_with_expected::h8460ca5f594c8570Nps
  11:     0x7fe5871f6196 - check::check_fn::hd5196d54a6852698Abo
  12:     0x7fe58720df97 - check::check_bare_fn::h0073eb2d0e87712990n
  13:     0x7fe587207b58 - check::check_item::hef34ffea35346370Ujo
  14:     0x7fe5872cefb6 - check_crate::closure.36498
  15:     0x7fe5872ca3f0 - check_crate::h679eb3dc01c34e66zxC
  16:     0x7fe588ab8938 - driver::phase_3_run_analysis_passes::h7b112f16caf4f0fcpGa
  17:     0x7fe588a99a05 - driver::compile_input::hb07383d8b05653e9Qba
  18:     0x7fe588b586e1 - run_compiler::hd11be756ecff4a4dL4b
  19:     0x7fe588b56332 - boxed::F.FnBox<A>::call_box::h9743051768958258733
  20:     0x7fe588b55869 - rt::unwind::try::try_fn::h3770862294174962809
  21:     0x7fe5884e55f8 - rust_try_inner
  22:     0x7fe5884e55e5 - rust_try
  23:     0x7fe588b55b18 - boxed::F.FnBox<A>::call_box::h17316511360530184554
  24:     0x7fe5884529e1 - sys::thread::create::thread_start::h14fabfa97526362frLH
  25:     0x7fe582ddd0a4 - start_thread
  26:     0x7fe588018cfc - __clone
  27:                0x0 - <unknown>

@maghoff
Copy link
Author

maghoff commented Apr 11, 2015

This issue may be related to a similar issue I also bumped into: #24327

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 11, 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

2 participants