diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 81c1560f18b..c5779dde499 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -82,17 +82,17 @@ fn eq_item(bytes: &[u8], item_id: int) -> bool { } fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc { - return maybe_find_item(item_id, items).get(); + match maybe_find_item(item_id, items) { + None => fail!("lookup_item: id not found: %d", item_id), + Some(d) => d + } } // Looks up an item in the given metadata and returns an ebml doc pointing // to the item data. fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc { let items = reader::get_doc(reader::Doc(data), tag_items); - match maybe_find_item(item_id, items) { - None => fail!("lookup_item: id not found: %d", item_id), - Some(d) => d - } + find_item(item_id, items) } #[deriving(Eq)] diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 7746c469f23..267eccbc397 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2316,59 +2316,59 @@ fn subtypes_require(cx: ctxt, seen: &mut ~[def_id], ::util::ppaux::ty_to_str(cx, ty)); let r = match get(ty).sty { - ty_nil | - ty_bot | - ty_bool | - ty_int(_) | - ty_uint(_) | - ty_float(_) | - ty_estr(_) | - ty_bare_fn(_) | - ty_closure(_) | - ty_infer(_) | - ty_err | - ty_param(_) | - ty_self(_) | - ty_type | - ty_opaque_box | - ty_opaque_closure_ptr(_) | - ty_evec(_, _) | - ty_unboxed_vec(_) => { - false - } - ty_box(ref mt) | - ty_uniq(ref mt) | - ty_rptr(_, ref mt) => { - return type_requires(cx, seen, r_ty, mt.ty); - } + ty_nil | + ty_bot | + ty_bool | + ty_int(_) | + ty_uint(_) | + ty_float(_) | + ty_estr(_) | + ty_bare_fn(_) | + ty_closure(_) | + ty_infer(_) | + ty_err | + ty_param(_) | + ty_self(_) | + ty_type | + ty_opaque_box | + ty_opaque_closure_ptr(_) | + ty_evec(_, _) | + ty_unboxed_vec(_) => { + false + } + ty_box(ref mt) | + ty_uniq(ref mt) | + ty_rptr(_, ref mt) => { + type_requires(cx, seen, r_ty, mt.ty) + } - ty_ptr(*) => { - false // unsafe ptrs can always be NULL - } + ty_ptr(*) => { + false // unsafe ptrs can always be NULL + } - ty_trait(_, _, _, _) => { - false - } + ty_trait(_, _, _, _) => { + false + } - ty_struct(ref did, _) if vec::contains(*seen, did) => { - false - } + ty_struct(ref did, _) if vec::contains(*seen, did) => { + false + } - ty_struct(did, ref substs) => { - seen.push(did); - let fields = struct_fields(cx, did, substs); - let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty)); - seen.pop(); - r - } + ty_struct(did, ref substs) => { + seen.push(did); + let fields = struct_fields(cx, did, substs); + let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty)); + seen.pop(); + r + } - ty_tup(ref ts) => { - ts.any(|t| type_requires(cx, seen, r_ty, *t)) - } + ty_tup(ref ts) => { + ts.any(|t| type_requires(cx, seen, r_ty, *t)) + } - ty_enum(ref did, _) if vec::contains(*seen, did) => { - false - } + ty_enum(ref did, _) if vec::contains(*seen, did) => { + false + } ty_enum(did, ref substs) => { seen.push(did); @@ -2392,8 +2392,8 @@ fn subtypes_require(cx: ctxt, seen: &mut ~[def_id], return r; } - let seen = @mut ~[]; - !subtypes_require(cx, seen, r_ty, r_ty) + let mut seen = ~[]; + !subtypes_require(cx, &mut seen, r_ty, r_ty) } pub fn type_structurally_contains(cx: ctxt, diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 002a6caf85c..474e93ed11a 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -772,7 +772,11 @@ fn binop(rdr: @mut StringReader, op: token::binop) -> token::Token { '/' => { return binop(rdr, token::SLASH); } '^' => { return binop(rdr, token::CARET); } '%' => { return binop(rdr, token::PERCENT); } - c => { rdr.fatal(fmt!("unknown start of token: %d", c as int)); } + c => { + // So the error span points to the unrecognized character + rdr.peek_span = codemap::mk_sp(rdr.last_pos, rdr.pos); + rdr.fatal(fmt!("unknown start of token: %d", c as int)); + } } }