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

Rustc panicked when init undefined field #38311

Closed
sunchao opened this issue Dec 12, 2016 · 1 comment · Fixed by #38375
Closed

Rustc panicked when init undefined field #38311

sunchao opened this issue Dec 12, 2016 · 1 comment · Fixed by #38375
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@sunchao
Copy link

sunchao commented Dec 12, 2016

When building the following code:

struct S<'a> {
  a: &'a str
}

impl<'a> S<'a> {
  pub fn new(input: &'a str) -> S<'a> {
    S {
      a: input,
      b: &char
    }
  }
}

RUST_BACKTRACE=1 cargo build returns the following error message, which actually indicates the error, but also has a internal compiler error:

error[E0560]: struct `S<'_>` has no field named `b`
  --> src/main.rs:11:7
   |
11 |       b: &char
   |       ^^ `S<'_>` does not have this field

error: internal compiler error: ../src/librustc_typeck/check/mod.rs:4396: unexpected definition: PrimTy(TyChar)

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 'Box<Any>', ../src/librustc_errors/lib.rs:423
stack backtrace:
   1:        0x104bd2f7a - std::sys::imp::backtrace::tracing::imp::write::hbea47d9dd19b523c
   2:        0x104be026f - std::panicking::default_hook::{{closure}}::h6875a2976258b020
   3:        0x104bdfe1d - std::panicking::default_hook::h88ffbc5922643264
   4:        0x104be0736 - std::panicking::rust_panic_with_hook::hc790e47d4ecc86cd
   5:        0x1049a683a - std::panicking::begin_panic::h264cdc75d51b518b
   6:        0x1049b94c4 - rustc_errors::Handler::bug::h620f7270292f0095
   7:        0x101573c5c - rustc::session::opt_span_bug_fmt::{{closure}}::h4a9b70c3df8b4b3a
   8:        0x101573a69 - rustc::session::opt_span_bug_fmt::h7d83586c6e2c7ae6
   9:        0x1015735ea - rustc::session::bug_fmt::he2d2f00a4afa9d1e
  10:        0x100db178d - rustc_typeck::check::FnCtxt::instantiate_value_path::h4229ac945aebfa55
  11:        0x100d9fc31 - rustc_typeck::check::FnCtxt::check_expr_kind::hfeeca7568cc99087
  12:        0x100d9e86d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h5d7f5141d7386bb8
  13:        0x100da266a - rustc_typeck::check::FnCtxt::check_expr_kind::hfeeca7568cc99087
  14:        0x100d9e86d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h5d7f5141d7386bb8
  15:        0x100d9c7fc - rustc_typeck::check::FnCtxt::check_expr_struct_fields::h834dbf10da936de9
  16:        0x100da180d - rustc_typeck::check::FnCtxt::check_expr_kind::hfeeca7568cc99087
  17:        0x100d9e86d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h5d7f5141d7386bb8
  18:        0x100db04ae - rustc_typeck::check::FnCtxt::check_block_with_expected::he90dd72b6855e5e4
  19:        0x100d9ed93 - rustc_typeck::check::FnCtxt::check_expr_kind::hfeeca7568cc99087
  20:        0x100d9e86d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h5d7f5141d7386bb8
  21:        0x100d85663 - rustc_typeck::check::check_fn::h96bd864b4d4fc711
  22:        0x100d841f7 - rustc_typeck::check::check_bare_fn::h87386ea43f4e272e
  23:        0x100d8705c - rustc_typeck::check::check_item_body::h1e039ede2f960fb9
  24:        0x100d81dad - rustc_typeck::check::check_item_bodies::hd22adb7703cc56d7
  25:        0x100def9de - rustc_typeck::check_crate::h92f6bdfe03b6afba
  26:        0x10038a4d0 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::hd97ec26bf3a98036
  27:        0x100372404 - rustc_driver::driver::phase_3_run_analysis_passes::h6d446abb74c09795
  28:        0x10036286a - rustc_driver::driver::compile_input::h8e119234b60571d5
  29:        0x1003a9a4b - rustc_driver::run_compiler::h57c4f233cd1a0c04
  30:        0x1002c8088 - std::panicking::try::do_call::hf679f17bf3b43b0b
  31:        0x104be2cea - __rust_maybe_catch_panic
  32:        0x1002eb18f - <F as alloc::boxed::FnBox<A>>::call_box::h21b5b32059700da6
  33:        0x104bdf3b4 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  34:     0x7fffe5876aaa - _pthread_body
  35:     0x7fffe58769f6 - _pthread_start

My rustc --version --verbose output:

rustc 1.15.0-nightly (daf8c1dfc 2016-12-05)
binary: rustc
commit-hash: daf8c1dfce3b448fc581cc319f64632ec22bd0e1
commit-date: 2016-12-05
host: x86_64-apple-darwin
release: 1.15.0-nightly
LLVM version: 3.9
@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 12, 2016
@petrochenkov
Copy link
Contributor

Duplicate of #38155, fixed in #38154

bors added a commit that referenced this issue Dec 15, 2016
Fix regression in resolution of primitive types

Fix often encountered ICE.
Extracted from #38154
Fixes #38155, fixes #38188, fixes #38277, fixes #38280, fixes #38292, fixes #38311, fixes #38344, fixes #38363, fixes #38372 (duplicates)

r? @jseyfried or @eddyb or @nrc
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

Successfully merging a pull request may close this issue.

3 participants