Description
When compiling this file:
// cargo.rs - Rust package manager
use rustc;
use std;
import rustc::syntax::{ast, codemap, visit};
import rustc::syntax::parse::parser;
import std::io;
import std::option;
import std::option::{none, some};
import std::run;
import std::str;
import std::tempfile;
import std::vec;
type pkg = {
name: str,
vers: str,
uuid: str,
desc: option::t,
sigs: option::t
};
fn load_link(mis: [@ast::meta_item]) -> (option::t,
option::t,
option::t) {
let name = none;
let vers = none;
let uuid = none;
for a: @ast::meta_item in mis {
alt a.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v {
"name" { name = some(s); }
"vers" { vers = some(s); }
"uuid" { uuid = some(s); }
_ { }
}
}
}
}
(name, vers, uuid)
}
fn load_pkg(filename: str) -> option::t {
let sess = @{cm: codemap::new_codemap(), mutable next_id: 0};
let c = parser::parse_crate_from_crate_file(filename, [], sess);
let name = none;
let vers = none;
let uuid = none;
let desc = none;
let sigs = none;
for a in c.node.attrs {
alt a.node.value.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v {
"desc" { desc = some(v); }
"sigs" { sigs = some(v); }
_ { }
}
}
ast::meta_list(v, mis) {
if v == "link" {
let (n, v, u) = load_link(mis);
name = n;
vers = v;
uuid = u;
}
}
}
}
alt (name, vers, uuid) {
(some(name0), some(vers0), some(uuid0)) {
some({
name: name0,
vers: vers0,
uuid: uuid0,
desc: desc,
sigs: sigs})
}
_ { ret none; }
}
}
fn print(s: str) {
io::stdout().write_line(s);
}
fn rest(s: str, start: uint) -> str {
if (start >= str::char_len(s)) {
""
} else {
str::char_slice(s, start, str::char_len(s))
}
}
fn install_file(path: str) -> option::t {
let wd = tempfile::mkdtemp("/tmp/cargo-work-", "");
ret wd;
}
fn cmd_install(argv: [str]) {
// cargo install
if vec::len(argv) < 3u {
cmd_usage();
ret;
}
let wd = if str::starts_with(argv[2], "file:") {
let path = rest(argv[2], 5u);
install_file(path)
} else {
none
};
}
fn cmd_usage() {
print("Usage: cargo [args...]");
}
fn main(argv: [str]) {
if vec::len(argv) < 2u {
cmd_usage();
ret;
}
alt argv[1] {
"usage" { cmd_usage(); }
_ { cmd_usage(); }
}
}
rustc crashes with the following error:
rust: upcall fail 'option none', src/lib/option.rs:34
rust: domain main @0x8f923a8 root task failed
Stack:
(gdb) bt
#0 upcall_fail (expr=0x837c570 "option none", file=0xf7f973e0 "src/lib/option.rs", line=34) at ./src/rt/rust_upcall.cpp:53
#1 0xf7f61bc4 in option::get::_2ea22c2ffe2384d0 () from /home/elly/a/rust/bin/../lib/libruststd.so
#2 0x0822574b in metadata::decoder::find_item::_df242c5c5051a8b3 ()
#3 0x08226deb in metadata::decoder::get_tag_variants::_a147d42fcea1fece ()
#4 0x082311c1 in metadata::csearch::get_tag_variants::_18f59da87adf6916 ()
#5 0x080f7a5b in middle::ty::tag_variants::_18f59da87adf6916 ()
#6 0x080e8a10 in middle::ty::type_structurally_contains::_5a6771941682f311 ()
#7 0x080e8bfb in middle::ty::type_structurally_contains::_5a6771941682f311 ()
#8 0x0806c667 in middle::trans::type_of_tag::_d41e55581ccd235a ()
#9 0x0806b4e9 in middle::trans::type_of_inner::_678082fcd324de96 ()
#10 0x0806bf39 in middle::trans::type_of_inner::_678082fcd324de96 ()
#11 0x0806b5a2 in middle::trans::type_of_inner::_678082fcd324de96 ()
#12 0x0806bdd7 in middle::trans::type_of_inner::_678082fcd324de96 ()
#13 0x0806bf39 in middle::trans::type_of_inner::_678082fcd324de96 ()
#14 0x0806bf39 in middle::trans::type_of_inner::_678082fcd324de96 ()
#15 0x0806b5a2 in middle::trans::type_of_inner::_678082fcd324de96 ()
#16 0x0806aeb0 in middle::trans::type_of_fn::_d546d6649fd77fad ()
#17 0x0806b344 in middle::trans::type_of_fn_from_ty::_c0eca63f47c43ab2 ()
#18 0x0806cab8 in middle::trans::type_of_ty_param_kinds_and_ty::_d6a7c6299c526e8f ()
#19 0x080906f6 in middle::trans::trans_external_path::_d1bfcf047562eb25 ()
#20 0x0809089b in middle::trans::lval_static_fn::_34da57b3cef2e8a6 ()
#21 0x08091722 in middle::trans::trans_var::_38a25ca0d46df44c ()
#22 0x08091537 in middle::trans::trans_path::_98b23f9ac5482cf2 ()
#23 0x08094548 in middle::trans::trans_callee::_acc25ceeb7639915 ()
#24 0x0809bb9d in middle::trans::trans_call::_8aa26f246483f45f ()
#25 0x080a0f81 in middle::trans::trans_expr::_bbcb02f4ad1ad745 ()
#26 0x0809fa86 in middle::trans::trans_temp_lval::_9abb497e3b8a2055 ()
#27 0x080a65b0 in middle::trans::init_local::_256ad881e86d4c2b ()
#28 0x080a7434 in middle::trans::trans_stmt::_457fb41f6733c9bd ()
#29 0x080a9078 in middle::trans::trans_block_dps::_5ed1d37c9b98c619 ()
#30 0x080abfeb in middle::trans::trans_closure::_3958e2a05ee91aa3 ()
#31 0x080ac1ca in middle::trans::trans_fn::_96b3ab2d545d6b67 ()
#32 0x080b1bf6 in middle::trans::trans_item::_5a8088de146f21ea ()
#33 0x080bcf28 in middle::trans::trans_crate::_4a38809211c9d6da ()
#34 0x0829537b in driver::rustc::compile_input::thunk9032 ()
#35 0x082330f9 in driver::rustc::time::_3e691b2a4ba58aee ()
#36 0x0823553e in driver::rustc::compile_input::_9ae791233473dfb5 ()
#37 0x0823e323 in driver::rustc::main::_cd8b8c8185af3dee ()
#38 0x0823e9ef in _rust_main ()
#39 0xf6ed47b4 in task_start_wrapper (a=0xf6bc9088) at ./src/rt/rust_task.cpp:180
#40 0xdeadbeef in ?? ()
#41 0xf6bc9088 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)