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

Compiler panic: "Path not fully resolved" when passing reference to impl function #22933

Closed
michaelbeaumont opened this issue Mar 1, 2015 · 8 comments · Fixed by #34365
Closed
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@michaelbeaumont
Copy link

I'm getting a compiler error about a "path not fully resolved":

thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTy(DefId { krate: 0, node: 204 }, false), last_private: LastMod(AllPublic), depth: 1 }'

I tried this code:

fn is_whitespace(c: char) -> bool {
    c == ' ' || c == '\n'
}

fn consume_whitespace(&mut self) -> Parse<()> {
    //Ok(())
    self.consume_while(&(CNFParser::is_whitespace))
}

fn consume_while(&mut self, p: &Fn(char) -> bool) -> Parse<()> {
    while p(self.token) {
        let take = self.take();
        if take.is_err() { return take }
    }
    Ok(())
}    

I expected to see this happen:
the code should compile, it did somewhere after 1.0 alpha and stopped in the last week (I think)

Instead, this happened:
I got this unexpected panic. It has something to do with passing the reference to CNFParser::is_whitespace

Meta

rustc --version --verbose:

    rustc 1.0.0-nightly (890293655 2015-02-28) (built 2015-03-01)
    binary: rustc
    commit-hash: 890293655251c372ea99694c0c9f0795e2663286
    commit-date: 2015-02-28
    build-date: 2015-03-01
    host: x86_64-unknown-linux-gnu
    release: 1.0.0-nightly

Backtrace:

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: 204 }, false), last_private: LastMod(AllPublic), depth: 1 }', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/middle/def.rs:79

stack backtrace:
   1:         0xde628c4f - sys::backtrace::write::hb08af03691eab78a5kA
   2:         0xde651782 - panicking::on_panic::h37164609ca1c02afBnJ
   3:         0xde59163a - rt::unwind::begin_unwind_inner::h24d5e7492198457b43I
   4:         0xde591d24 - rt::unwind::begin_unwind_fmt::hee1a09c48e390d87H2I
   5:         0xdc4856b1 - middle::ty::resolve_expr::h65338d27a12ebb460A6
   6:         0xdc5eac40 - middle::ty::expr_kind::hcac269a238fc506fAC6
   7:         0xdc5eaf7b - middle::ty::expr_kind::hcac269a238fc506fAC6
   8:         0xdc5ea94a - middle::ty::expr_is_lval::h485f36669a19d1a13B6
   9:         0xdd3bee84 - check::check_expr_with_unifier::h329803007416623423
  10:         0xdd3983a8 - check::check_argument_types::h6d28a2012d7e49afNsp
  11:         0xdd399d34 - check::check_method_argument_types::hf1decc93718710207pp
  12:         0xdd3cc071 - check::check_expr_with_unifier::check_method_call::hb126ebcd08adeb94z4p
  13:         0xdd3d6ae2 - check::check_expr_with_unifier::h8581770403589055324
  14:         0xdd3ad396 - check::check_block_with_expected::haa14a0695c08d2a6V0r
  15:         0xdd3908d5 - check::check_fn::ha741703a74959edd8kn
  16:         0xdd3aa0d2 - check::check_bare_fn::hdc3a9af5b372582fOan
  17:         0xdd3adbbb - check::check_method_body::h49a550c880bfd87dnIn
  18:         0xdd3a3864 - check::check_item::h203d9fc30afbd381stn
  19:         0xdd3a85c2 - visit::walk_item::h11360223606861997271
  20:         0xdd46df2e - check_crate::closure.35032
  21:         0xdd469207 - check_crate::h6ce4a57b1730f0fdDXB
  22:         0xdeca908e - driver::phase_3_run_analysis_passes::h55e7e7af941f4089xFa
  23:         0xdec8e411 - driver::compile_input::hee81c045ab46c74fIba
  24:         0xded58e6e - run_compiler::h875c1e123fe4ae2cF5b
  25:         0xded56a1c - thunk::F.Invoke<A, R>::invoke::h12424714292252424185
  26:         0xded55770 - rt::unwind::try::try_fn::h4021821266450575721
  27:         0xde6bcfe8 - rust_try_inner
  28:         0xde6bcfd5 - rust_try
  29:         0xded55e5c - thunk::F.Invoke<A, R>::invoke::h8199562432922027576
  30:         0xde63d2d5 - sys::thread::thread_start::h1b1bb1e7ac08d3a6yRE
  31:         0xd8378373 - start_thread
  32:         0xde21927c - __clone
  33:         0xffffffff - <unknown>
@kmcallister kmcallister added A-resolve Area: Name/path resolution done by `rustc_resolve` specifically I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Mar 2, 2015
@ahwatts
Copy link

ahwatts commented Mar 13, 2015

I'm also getting this error, but with an enum that depends on previous enum values, if the named value doesn't exist. Note that Delicious::PIE doesn't exist; it should be Delicious::Pie. If I fix that error, this compiles fine.

// test.rs
enum Delicious {
    Pie      = 0x1,
    Apple    = 0x2,
    ApplePie = Delicious::Apple as isize | Delicious::PIE as isize,
}

Compiling it:

$ RUST_BACKTRACE=1 rustc --crate-type=lib test.rs
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 }, true), last_private: LastMod(AllPublic), depth: 1 }', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc/middle/def.rs:79

stack backtrace:
   1:        0x10863226d - sys::backtrace::write::h4102628905e599dfKDA
   2:        0x10865bc34 - panicking::on_panic::hc3e357b7ac1634e3MsJ
   3:        0x10858d279 - rt::unwind::begin_unwind_inner::h53ac351c4bf63bfaibJ
   4:        0x10858d6fe - rt::unwind::begin_unwind_fmt::had971e57ff3bf48aT9I
   5:        0x1057a0fd0 - middle::const_eval::eval_const_expr_partial::hd2bf46b839f7abc47lh
   6:        0x10579f0dd - middle::const_eval::eval_const_expr_partial::hd2bf46b839f7abc47lh
   7:        0x10579f5f3 - middle::const_eval::eval_const_expr_partial::hd2bf46b839f7abc47lh
   8:        0x10595dc94 - iter::Map<I, F>.Iterator::next::h5439266479542136741
   9:        0x1057b7007 - middle::ty::enum_variants::h533e784536d4c911iP7
  10:        0x105955c9b - middle::ty::type_is_c_like_enum::h1ce3cb9b64f503a3co6
  11:        0x104f2c5fc - check::check_cast::hfe487139a864af4aPao
  12:        0x104f690b1 - check::check_expr_with_unifier::h10849947522957101540
  13:        0x104f3a892 - check::check_expr_with_unifier::check_binop::h7f85f182a25c1bd9Xgq
  14:        0x104f51da9 - check::check_expr_with_unifier::h10953368268981294451
  15:        0x104f70809 - check::check_const_with_ty::hf19906d71ca9eb4ez9r
  16:        0x104f1d66a - check::check_item::hd818d764a5174b83zun
  17:        0x104fdff92 - check_crate::closure.35673
  18:        0x104fdbb40 - check_crate::hf2d34adf6a37b8a3hfC
  19:        0x104d2ccba - driver::phase_3_run_analysis_passes::hc0848bc6836a8617mGa
  20:        0x104d11fb3 - driver::compile_input::hb5f376d824cdbd3fNba
  21:        0x104ddfbe6 - run_compiler::h771e8a13e5d39fa8G6b
  22:        0x104ddd2d0 - thunk::F.Invoke<A, R>::invoke::h7762305853454838659
  23:        0x104ddbe0f - rt::unwind::try::try_fn::h12334561919016735610
  24:        0x1086d5ca8 - rust_try_inner
  25:        0x1086d5c95 - rust_try
  26:        0x104ddc62f - thunk::F.Invoke<A, R>::invoke::h11009727036119889909
  27:        0x1086473e2 - sys::thread::thread_start::h45ac84d363b9c45b32E
  28:     0x7fff95f7a267 - _pthread_body
  29:     0x7fff95f7a1e4 - _pthread_start

UPDATE: rustc --version is rustc 1.0.0-nightly (270a677d4 2015-03-07) (built 2015-03-07)

@lynks--
Copy link

lynks-- commented Mar 24, 2015

Same issue, when calling contains() on a HashSet<Enum>.

thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTy(DefId { krate: 16, node: 3687 }, true), last_private: LastMod(AllPublic), depth: 1 }', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/middle/def.rs:79
stack backtrace:
1: 0x7effa1e76b84 - sys::backtrace::write::h5e3efc31357524bax4C
2: 0x7effa1e9f528 - panicking::on_panic::ha90a3694573d0234cjJ
3: 0x7effa1dd2b0c - rt::unwind::begin_unwind_inner::hed207b77c3567743tZI
4: 0x7effa1dd2ef1 - rt::unwind::begin_unwind_fmt::hc68cf3a549295d5e4XI
5: 0x7eff9fd2e8b0 - middle::ty::resolve_expr::h86c09f0a5295954abL4
6: 0x7eff9febe3c2 - middle::ty::expr_kind::h310bb33d94f05b53LM4
7: 0x7eff9febe0ea - middle::ty::expr_is_lval::hc7f63c6be56af2cfeM4
8: 0x7effa0bff595 - check::check_expr_with_unifier::h9359096955431801547
9: 0x7effa0bd7c08 - check::check_argument_types::h8d5e6036623af320aAp
10: 0x7effa0bd9476 - check::check_method_argument_types::h5ff1f83bdc232e04uxp
11: 0x7effa0c0bcfc - check::check_expr_with_unifier::check_method_call::h8586fa7476f34d654bq
12: 0x7effa0c10577 - check::check_expr_with_unifier::h9680945807954801565
13: 0x7effa0c0aa88 - check::check_expr_with_unifier::check_then_else::h7cf11a86c99e36a3Zeq
14: 0x7effa0c16a0f - check::check_expr_with_unifier::h5228973384822829375
15: 0x7effa0beca77 - check::check_block_with_expected::h48654249dc75ee7bq8r
16: 0x7effa0bcf359 - check::check_fn::hf00168574636b371ssn
17: 0x7effa0be93ce - check::check_bare_fn::h4aeaf589451764bd8hn
18: 0x7effa0bed216 - check::check_method_body::h3743f47dc0cb6141RPn
19: 0x7effa0be6052 - check::check_item::h8c63c985a80d6d6cMAn
20: 0x7effa0cb4787 - check_crate::closure.35943
21: 0x7effa0caf4ca - check_crate::h4c34ce3ed2b7e6ceIhC
22: 0x7effa24c44c8 - driver::phase_3_run_analysis_passes::h66fdf3bbde068e6asGa
23: 0x7effa24aadb4 - driver::compile_input::hbb0d45c147e0b714Rba
24: 0x7effa2562822 - run_compiler::h7d24915e61095736v2b
25: 0x7effa25605f3 - thunk::F.Invoke<A, R>::invoke::h119471990717082172
26: 0x7effa255fa89 - rt::unwind::try::try_fn::h7237081841665992942
27: 0x7effa1f15358 - rust_try_inner
28: 0x7effa1f15345 - rust_try
29: 0x7effa255fdac - thunk::F.Invoke<A, R>::invoke::h12484507958770312030
30: 0x7effa1e8bb18 - sys::thread::create::thread_start::h05349c15f3b249d8oUH
31: 0x7eff9bd7d373 - start_thread
32: 0x7effa1a4a27c - __clone
33: 0x0 -

@nham
Copy link
Contributor

nham commented May 10, 2015

I am also getting 'path not fully resolved', with this code:

//use std::u8;
const FOO: [u32; u8::MIN as usize] = [];
fn main() {}

Backtrace:

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: DefPrimTy(TyUint(u8)), last_private: LastMod(AllPublic), depth: 1 }', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/middle/def.rs:81

stack backtrace:
   1:     0x7fef208d95a9 - sys::backtrace::write::h602e10b8f312e9d3uhs
   2:     0x7fef208e1529 - panicking::on_panic::h7ec3fe45867bef8cxXw
   3:     0x7fef208a1702 - rt::unwind::begin_unwind_inner::hf035f7930114ad73HCw
   4:     0x7fef208a24a7 - rt::unwind::begin_unwind_fmt::hedeb5f4f1f270aabNBw
   5:     0x7fef1e566f4e - middle::const_eval::eval_const_expr_partial::h6bbfeed9b465166aQii
   6:     0x7fef1e5646e3 - middle::const_eval::eval_const_expr_partial::h6bbfeed9b465166aQii
   7:     0x7fef1fd94395 - astconv::ast_ty_to_ty::h3ba2c06d5e12ed37cXv
   8:     0x7fef1fe12ea9 - collect::type_scheme_of_item::h8830d9c9c58170aeYry
   9:     0x7fef1fe0b51a - collect::convert_typed_item::had5b9e2e37f2991fBwy
  10:     0x7fef1fdf2e34 - collect::convert_item::hf1bc7731f28083aaZFx
  11:     0x7fef1fe385c7 - check_crate::closure.38744
  12:     0x7fef1fe3659b - check_crate::ha4b79837beadc77cQHC
  13:     0x7fef20e2f238 - driver::phase_3_run_analysis_passes::h20da97b9b20a51aetGa
  14:     0x7fef20e1003c - driver::compile_input::h67ec65619cbee40aQba
  15:     0x7fef20ec9c81 - run_compiler::h248a70f938b953f865b
  16:     0x7fef20ec74d2 - boxed::F.FnBox<A>::call_box::h6589873407031420697
  17:     0x7fef20ec6a99 - rt::unwind::try::try_fn::h13793979998646453366
  18:     0x7fef20959828 - rust_try_inner
  19:     0x7fef20959815 - rust_try
  20:     0x7fef20ec6d34 - boxed::F.FnBox<A>::call_box::h12061239028765835470
  21:     0x7fef208e02c1 - sys::thread::Thread::new::thread_start::h8f6e6836281b1b4f3Iv
  22:     0x7fef1a638373 - start_thread
  23:     0x7fef2053127c - clone
  24:                0x0 - <unknown>

rustc version is rustc 1.1.0-nightly (dc630d01e 2015-05-09) (built 2015-05-10)

@diogovk
Copy link

diogovk commented Jun 9, 2015

I think I have the same problem with the code in the gist:
https://gist.github.com/diogovk/706633eff291227b8e37

@arielb1
Copy link
Contributor

arielb1 commented Jun 21, 2015

This issue mixes the expr_is_lval issue (#23173) with several associated const issues (which I think are duplicates - cc @quantheory for that).

@quantheory
Copy link
Contributor

At least @nham's example is another case of #25145, i.e. we can't evaluated associated constants in array sizes in collect. Note also #22519, which is related (I was trying to deal with that, but I've been stalled for a couple of weeks).

The example from @ahwatts is actually new to me. Without delving too deeply yet, I think that there must be a missing check for ty_err somewhere. When I try to compile it, the method resolution code gives this (correct, if somewhat unexpected) error:

test_argl.rs:10:44: 10:58 error: no associated item named `PIE` found for type `Delicious` in the current scope
test_argl.rs:10     ApplePie = Delicious::Apple as isize | Delicious::PIE as isize,

But then we end up panicking during check_casts anyway.

@diogovk's issue is #23173 (@arielb1 got it right, but made a typo). Note also #25757 and #24322 for the function pointer issues.

@arielb1
Copy link
Contributor

arielb1 commented Jun 21, 2015

Isn't it nice when several distinct errors get the same issue?

@quantheory
Copy link
Contributor

I created #26483 for the C-like enum variant issue. The others already have open issues, so perhaps this should just be closed as a duplicate now?

bors added a commit that referenced this issue Jul 9, 2016
Some more pattern cleanup and bugfixing

The next part of #34095

The most significant fixed mistake is definitions for partially resolved associated types not being updated after full resolution.
```
fn f<T: Fn()>(arg: T::Output) { .... } // <- the definition of T::Output was not updated in def_map
```
For this reason unstable associated types of stable traits, like `FnOnce::Output`, could be used in stable code when written in unqualified form. Now they are properly checked, this is a **[breaking-change]** (pretty minor one, but a crater run would be nice). The fix is not to use unstable library features in stable code, alternatively `FnOnce::Output` can be stabilized.

Besides that, paths in struct patterns and expressions `S::A { .. }` are now fully resolved as associated types. Such types cannot be identified as structs at the moment, i.e. the change doesn't make previously invalid code valid, but it improves error diagnostics.

Other changes: `Def::Err` is supported better (less chances for ICEs for erroneous code), some incorrect error messages are corrected, some duplicated error messages are not reported, ADT definitions are now available through constructor IDs, everything else is cleanup and code audit.

Fixes #34209
Closes #22933 (adds tests)

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants