rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.87k stars 12.77k forks source link

ICE when attempting to borrow non-existent item associated with type for argument #27486

Closed ghost closed 9 years ago

ghost commented 9 years ago

The following code generates an internal compiler error:

struct Mozilla;

fn some_function(c: &Mozilla) {}

fn main() {
    some_function(&Mozilla::PHANTOM);
}

As far as I can tell:

rustc --version --verbose:

rustc 1.1.0 (35ceea399 2015-06-19)
binary: rustc
commit-hash: 35ceea3997c79a3b7562e89b462ab76af5b86b22
commit-date: 2015-06-19
host: x86_64-unknown-linux-gnu
release: 1.1.0

Backtrace

   Compiling second v0.1.0 (file:///home/adam/Programming/second)
     Running `rustc src/main.rs --crate-name second --crate-type bin -g --out-dir /home/adam/Programming/second/target/debug --emit=dep-info,link -L dependency=/home/adam/Programming/second/target/debug -L dependency=/home/adam/Programming/second/target/debug/deps`
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 }', /home/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/middle/def.rs:81

stack backtrace:
   1:     0x7facee46f529 - sys::backtrace::write::ha3b8868b13c6f5b594r
   2:     0x7facee477449 - panicking::on_panic::h0d4f0a7bb69824a9iJw
   3:     0x7facee438242 - rt::unwind::begin_unwind_inner::h6eae1ff9ccde81e1sow
   4:     0x7facee438fd7 - rt::unwind::begin_unwind_fmt::h1b64aa0dc7f97d91ynw
   5:     0x7facec473ed0 - middle::ty::resolve_expr::h72b5364125980b45V06
   6:     0x7facec5d16e4 - middle::ty::expr_kind::hedcc55e2b5ee13ab126
   7:     0x7facec5d14aa - middle::ty::expr_is_lval::hf1e1ed08fa8bcc2eY16
   8:     0x7facedc4742d - check::check_expr_with_unifier::h4257573379042224009
   9:     0x7facedc20948 - check::check_argument_types::ha9fd2f8e49d9e327BRp
  10:     0x7facedc1e529 - check::callee::confirm_builtin_call::hc307de1b89ed714bJRl
  11:     0x7facedc1ceac - check::callee::check_call::hc957c6523e65be6erIl
  12:     0x7facedc77b8d - check::check_expr_with_unifier::h2987789444823915436
  13:     0x7facedc35ec9 - check::check_block_with_expected::hac66c275a3b7f7a1D4r
  14:     0x7facedc1ac36 - check::check_fn::h64547069f38145a6gFn
  15:     0x7facedc30ec7 - check::check_bare_fn::h1be3d74a49bbd12cTun
  16:     0x7facedc2efc2 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h95962c6c6f459570Wrn
  17:     0x7facedcef5da - check_crate::closure.38929
  18:     0x7facedce904c - check_crate::h8ed0000b4b6dbbd2sJC
  19:     0x7facee9bf1ef - driver::phase_3_run_analysis_passes::h9b9e8dc3e9bbf431tGa
  20:     0x7facee9a306c - driver::compile_input::h6e596544d26b4394Qba
  21:     0x7faceea59041 - run_compiler::haa6c0289fab7415475b
  22:     0x7faceea56892 - boxed::F.FnBox<A>::call_box::h10721825727138786690
  23:     0x7faceea55e59 - rt::unwind::try::try_fn::h6014602198652783625
  24:     0x7facee4efb58 - rust_try_inner
  25:     0x7facee4efb45 - rust_try
  26:     0x7faceea560f4 - boxed::F.FnBox<A>::call_box::h5510246712457526188
  27:     0x7facee4761e1 - sys::thread::Thread::new::thread_start::h11fbc90f6ba541f9zvv
  28:     0x7face8d00181 - start_thread
  29:     0x7facee0b847c - __clone
  30:                0x0 - <unknown>

Could not compile `second`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name second --crate-type bin -g --out-dir /home/adam/Programming/second/target/debug --emit=dep-info,link -L dependency=/home/adam/Programming/second/target/debug -L dependency=/home/adam/Programming/second/target/debug/deps` (exit code: 101)
mitaa commented 9 years ago

Doesn't ICE on playpen beta and nightly

<anon>:6:20: 6:36 error: no associated item named `PHANTOM` found for type `Mozilla` in the current scope
<anon>:6     some_function(&Mozilla::PHANTOM);
                            ^~~~~~~~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101
Aatch commented 9 years ago

This bug is fixed in beta + nightly, so I'm closing.