Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created April 29, 2014 09:06
Show Gist options
  • Save fjolnir/11394712 to your computer and use it in GitHub Desktop.
Save fjolnir/11394712 to your computer and use it in GitHub Desktop.
extern crate libc;
use libc::uintptr_t;
type Sel = libc::uintptr_t;
enum ObjcObject {}
type Class<'a> = &'a ObjcObject;
type Id<'a> = &'a ObjcObject;
type NSObjectClass<'a> = Class<'a>;
type NSObject<'a> = Id<'a>;
type NSStringClass<'a> = NSObjectClass<'a>;
type NSString<'a> = NSObject<'a>;
#[link(name = "Foundation", kind = "framework")]
extern "C" {
fn sel_registerName(sel: *libc::c_char) -> Sel;
fn objc_msgSend(object: Id, sel: Sel, ...) -> Id;
#[link_name="OBJC_CLASS_$_NSString"]
static NSStringKlass:ObjcObject;
}
static NSString:NSStringClass<'static> = &NSStringKlass; // Crashes rustc
fn main() { unsafe {
// let NSString:NSStringClass = &NSStringKlass; // This works fine
}
@fjolnir
Copy link
Author

fjolnir commented Apr 29, 2014

error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'expected item, found foreign item NSStringKlass::NSStringKlass (id=62)', /private/tmp/rust-nFr6/src/libsyntax/ast_map.rs:264
stack backtrace:
   1:        0x1108034b4 - rt::backtrace::imp::write::h9c3ff5de79b059e17Ca::v0.11.pre
   2:        0x11076548e - rt::unwind::begin_unwind_inner::h0d3658714eee3acddda::v0.11.pre
   3:        0x110764947 - rt::unwind::begin_unwind_fmt::he12c67654d9a0b0anca::v0.11.pre
   4:        0x10ff31ec0 - ast_map::Map::expect_item::h8f81eced621bb26e4fw::v0.11.pre
   5:        0x10e2381b2 - middle::check_const::CheckItemRecursionVisitor<'a>.Visitor<(*>::visit_expr::h4378512bd031f7cdZkw::v0.11.pre
   6:        0x10e238247 - middle::check_const::CheckItemRecursionVisitor<'a>.Visitor<(*>::visit_expr::h4378512bd031f7cdZkw::v0.11.pre
   7:        0x10e2370e0 - middle::check_const::CheckItemRecursionVisitor<'a>.Visitor<(*>::visit_item::hc9ac90e3563e19c14jw::v0.11.pre
   8:        0x10e23260e - middle::check_const::check_item::hcda3355090cb445738v::v0.11.pre
   9:        0x10e235461 - middle::check_const::check_crate::h27f6e2fe428221e1E8v::v0.11.pre
  10:        0x10e217e7f - util::common::time::h207654785007433334::v0.11.pre
  11:        0x10e631055 - driver::driver::phase_3_run_analysis_passes::h3ac561bcfae0e017TCf::v0.11.pre
  12:        0x10e636fb2 - driver::driver::compile_input::h0773f5d7411f7dafG2f::v0.11.pre
  13:        0x10e65cce2 - run_compiler::hcc52bab246c245c1xzn::v0.11.pre
  14:        0x10e670b5d - main_args::closure.91449
  15:        0x10e66eef2 - monitor::closure.91324
  16:        0x10e66aa3b - task::TaskBuilder::try::closure.91090
  17:        0x10de0f7cc - task::spawn_opts::closure.7106
  18:        0x1107fe5b8 - rt::task::Task::run::closure.40133
  19:        0x11080821c - rust_try
  20:        0x1107fe437 - rt::task::Task::run::h6c169d6ad97226e3N37::v0.11.pre
  21:        0x10de0f64f - task::spawn_opts::closure.7078
  22:        0x110801e86 - rt::thread::thread_start::h0b9fd93cd0f6cdad0I8::v0.11.pre
  23:     0x7fff8e990899 - _pthread_body
  24:     0x7fff8e99072a - _pthread_struct_init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment