diff options
| author | Patrick Walton <[email protected]> | 2011-03-29 17:01:27 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-29 17:01:27 -0700 |
| commit | c67eb1a575dc09850c3b59ed15252db9cb451c11 (patch) | |
| tree | 7e0b534ff2f22bfe0e089f07d76a6aa906ddebd3 /src/comp/front/creader.rs | |
| parent | rustc: Tolerate def id tags inside module tags. Fixes metadata reading. (diff) | |
| download | rust-c67eb1a575dc09850c3b59ed15252db9cb451c11.tar.xz rust-c67eb1a575dc09850c3b59ed15252db9cb451c11.zip | |
rustc: Partially resolve external module imports
Diffstat (limited to 'src/comp/front/creader.rs')
| -rw-r--r-- | src/comp/front/creader.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/comp/front/creader.rs b/src/comp/front/creader.rs index 3b95b24f..35d10422 100644 --- a/src/comp/front/creader.rs +++ b/src/comp/front/creader.rs @@ -540,18 +540,15 @@ fn read_crates(session.session sess, // Crate metadata queries -fn lookup_def(session.session sess, &span sp, int cnum, vec[ast.ident] path) - -> ast.def { +fn lookup_def(session.session sess, int cnum, vec[ast.ident] path) + -> option.t[ast.def] { auto data = sess.get_external_crate(cnum); auto did; alt (resolve_path(path, data)) { case (rr_ok(?di)) { did = di; } case (rr_not_found(?prev, ?name)) { - sess.span_err(sp, - #fmt("unbound name '%s' (no item named '%s' found in '%s')", - _str.connect(path, "."), name, _str.connect(prev, "."))); - fail; + ret none[ast.def]; } } @@ -561,21 +558,24 @@ fn lookup_def(session.session sess, &span sp, int cnum, vec[ast.ident] path) did = tup(cnum, did._1); // FIXME: It'd be great if we had u8 char literals. - if (kind_ch == ('c' as u8)) { ret ast.def_const(did); } - else if (kind_ch == ('f' as u8)) { ret ast.def_fn(did); } - else if (kind_ch == ('y' as u8)) { ret ast.def_ty(did); } - else if (kind_ch == ('o' as u8)) { ret ast.def_obj(did); } - else if (kind_ch == ('t' as u8)) { ret ast.def_ty(did); } - else if (kind_ch == ('m' as u8)) { ret ast.def_mod(did); } - else if (kind_ch == ('n' as u8)) { ret ast.def_native_mod(did); } + auto def; + if (kind_ch == ('c' as u8)) { def = ast.def_const(did); } + else if (kind_ch == ('f' as u8)) { def = ast.def_fn(did); } + else if (kind_ch == ('y' as u8)) { def = ast.def_ty(did); } + else if (kind_ch == ('o' as u8)) { def = ast.def_obj(did); } + else if (kind_ch == ('t' as u8)) { def = ast.def_ty(did); } + else if (kind_ch == ('m' as u8)) { def = ast.def_mod(did); } + else if (kind_ch == ('n' as u8)) { def = ast.def_native_mod(did); } else if (kind_ch == ('v' as u8)) { auto tid = get_variant_tag_id(ebml_r); tid = tup(cnum, tid._1); - ret ast.def_variant(tid, did); + def = ast.def_variant(tid, did); + } else { + log #fmt("lookup_def(): unknown kind char: %d", kind_ch as int); + fail; } - log #fmt("lookup_def(): unknown kind char: %d", kind_ch as int); - fail; + ret some[ast.def](def); } fn get_type(session.session sess, ast.def_id def) -> ty.ty_params_and_ty { |