diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 10 |
12 files changed, 44 insertions, 37 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index e6bbd45dae7..883020e637a 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -280,13 +280,13 @@ impl ToStr for AbiSet { #[test] fn lookup_Rust() { let abi = lookup("Rust"); - assert!(abi.is_some() && abi.get().data().name == "Rust"); + assert!(abi.is_some() && abi.unwrap().data().name == "Rust"); } #[test] fn lookup_cdecl() { let abi = lookup("cdecl"); - assert!(abi.is_some() && abi.get().data().name == "cdecl"); + assert!(abi.is_some() && abi.unwrap().data().name == "cdecl"); } #[test] diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index cf7a1e51798..435be3c71af 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -24,7 +24,7 @@ use extra::serialize::{Encodable, Decodable, Encoder, Decoder}; // table) and a SyntaxContext to track renaming and // macro expansion per Flatt et al., "Macros // That Work Together" -#[deriving(Clone, Eq, IterBytes)] +#[deriving(Clone, Eq, IterBytes, ToStr)] pub struct ident { name: Name, ctxt: SyntaxContext } /// Construct an identifier with the given name and an empty context: @@ -121,7 +121,7 @@ pub type CrateNum = int; pub type NodeId = int; -#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] +#[deriving(Clone, Eq, Encodable, Decodable, IterBytes, ToStr)] pub struct def_id { crate: CrateNum, node: NodeId, diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 5cba22a8e23..6b4da9671a9 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -466,11 +466,11 @@ pub fn node_id_to_str(map: map, id: NodeId, itr: @ident_interner) -> ~str { Some(&node_local(ident)) => { fmt!("local (id=%?, name=%s)", id, itr.get(ident.name)) } - Some(&node_block(_)) => { - fmt!("block") + Some(&node_block(ref block)) => { + fmt!("block %s (id=%?)", pprust::block_to_str(block, itr), id) } - Some(&node_struct_ctor(*)) => { - fmt!("struct_ctor") + Some(&node_struct_ctor(_, _, path)) => { + fmt!("struct_ctor %s (id=%?)", path_to_str(*path, itr), id) } } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 11d3740be3f..84e6544f780 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -410,7 +410,7 @@ impl IdVisitor { impl Visitor<()> for IdVisitor { fn visit_mod(@mut self, module: &_mod, - span: span, + _span: span, node_id: NodeId, env: ()) { (self.visit_callback)(node_id); diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index d1ddebfc347..d39cb2f507c 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -114,7 +114,7 @@ impl AttributeMethods for Attribute { /// non-sugared doc attributes.) pub fn desugar_doc(&self) -> Attribute { if self.node.is_sugared_doc { - let comment = self.value_str().get(); + let comment = self.value_str().unwrap(); let meta = mk_name_value_item_str(@"doc", strip_doc_comment_decoration(comment).to_managed()); mk_attr(meta) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 0da424ce54c..8c70f128d9a 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -369,12 +369,19 @@ impl CodeMap { return @FileLines {file: lo.file, lines: lines}; } - pub fn span_to_snippet(&self, sp: span) -> ~str { + pub fn span_to_snippet(&self, sp: span) -> Option<~str> { let begin = self.lookup_byte_offset(sp.lo); let end = self.lookup_byte_offset(sp.hi); - assert_eq!(begin.fm.start_pos, end.fm.start_pos); - return begin.fm.src.slice( - begin.pos.to_uint(), end.pos.to_uint()).to_owned(); + + // FIXME #8256: this used to be an assert but whatever precondition + // it's testing isn't true for all spans in the AST, so to allow the + // caller to not have to fail (and it can't catch it since the CodeMap + // isn't sendable), return None + if begin.fm.start_pos != end.fm.start_pos { + None + } else { + Some(begin.fm.src.slice( begin.pos.to_uint(), end.pos.to_uint()).to_owned()) + } } pub fn get_filemap(&self, filename: &str) -> @FileMap { diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 1dda2493da2..6ed5ca3e402 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -538,20 +538,20 @@ mod test { m.insert (@"def",@16); // FIXME: #4492 (ICE) assert_eq!(m.find(&@"abc"),Some(@15)); // .... assert_eq!(m.find(&@"def"),Some(@16)); - assert_eq!(*(m.find(&@"abc").get()),15); - assert_eq!(*(m.find(&@"def").get()),16); + assert_eq!(*(m.find(&@"abc").unwrap()),15); + assert_eq!(*(m.find(&@"def").unwrap()),16); let n = m.push_frame(); // old bindings are still present: - assert_eq!(*(n.find(&@"abc").get()),15); - assert_eq!(*(n.find(&@"def").get()),16); + assert_eq!(*(n.find(&@"abc").unwrap()),15); + assert_eq!(*(n.find(&@"def").unwrap()),16); n.insert (@"def",@17); // n shows the new binding - assert_eq!(*(n.find(&@"abc").get()),15); - assert_eq!(*(n.find(&@"def").get()),17); + assert_eq!(*(n.find(&@"abc").unwrap()),15); + assert_eq!(*(n.find(&@"def").unwrap()),17); // ... but m still has the old ones // FIXME: #4492: assert_eq!(m.find(&@"abc"),Some(@15)); // FIXME: #4492: assert_eq!(m.find(&@"def"),Some(@16)); - assert_eq!(*(m.find(&@"abc").get()),15); - assert_eq!(*(m.find(&@"def").get()),16); + assert_eq!(*(m.find(&@"abc").unwrap()),15); + assert_eq!(*(m.find(&@"def").unwrap()),16); } } diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index f5eb57c94b7..fb1e6bf1913 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -961,7 +961,7 @@ fn create_struct_pattern(cx: @ExtCtxt, let field_pats = do vec::build |push| { for (&pat, &(id, _)) in subpats.iter().zip(ident_expr.iter()) { // id is guaranteed to be Some - push(ast::field_pat { ident: id.get(), pat: pat }) + push(ast::field_pat { ident: id.unwrap(), pat: pat }) } }; cx.pat_struct(span, matching_path, field_pats) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index a6c5526b5a9..c7020b990bf 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1182,9 +1182,9 @@ mod test { let a2_name = intern("a2"); let renamer = new_ident_renamer(ast::ident{name:a_name,ctxt:empty_ctxt}, a2_name); - let renamed_ast = fun_to_ident_folder(renamer).fold_item(item_ast).get(); + let renamed_ast = fun_to_ident_folder(renamer).fold_item(item_ast).unwrap(); let resolver = new_ident_resolver(); - let resolved_ast = fun_to_ident_folder(resolver).fold_item(renamed_ast).get(); + let resolved_ast = fun_to_ident_folder(resolver).fold_item(renamed_ast).unwrap(); let resolved_as_str = pprust::item_to_str(resolved_ast, get_ident_interner()); assert_eq!(resolved_as_str,~"fn a2() -> int { let b = 13; b }"); diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 626a562b92c..71903b9aa02 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -31,7 +31,7 @@ pub fn expand_line(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "line!"); - let topmost = topmost_expn_info(cx.backtrace().get()); + let topmost = topmost_expn_info(cx.backtrace().unwrap()); let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); base::MRExpr(cx.expr_uint(topmost.call_site, loc.line)) @@ -42,7 +42,7 @@ pub fn expand_col(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "col!"); - let topmost = topmost_expn_info(cx.backtrace().get()); + let topmost = topmost_expn_info(cx.backtrace().unwrap()); let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); base::MRExpr(cx.expr_uint(topmost.call_site, loc.col.to_uint())) } @@ -54,7 +54,7 @@ pub fn expand_file(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "file!"); - let topmost = topmost_expn_info(cx.backtrace().get()); + let topmost = topmost_expn_info(cx.backtrace().unwrap()); let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); let filename = loc.file.name; base::MRExpr(cx.expr_str(topmost.call_site, filename)) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index afa2e7a5e42..a0932729930 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -691,7 +691,7 @@ impl Parser { */ let opt_abis = self.parse_opt_abis(); - let abis = opt_abis.get_or_default(AbiSet::Rust()); + let abis = opt_abis.unwrap_or_default(AbiSet::Rust()); let purity = self.parse_unsafety(); self.expect_keyword(keywords::Fn); let (decl, lifetimes) = self.parse_ty_fn_decl(); @@ -3326,7 +3326,7 @@ impl Parser { let ident = self.parse_ident(); let opt_bounds = self.parse_optional_ty_param_bounds(); // For typarams we don't care about the difference b/w "<T>" and "<T:>". - let bounds = opt_bounds.get_or_default(opt_vec::Empty); + let bounds = opt_bounds.unwrap_or_default(opt_vec::Empty); ast::TyParam { ident: ident, id: self.get_id(), bounds: bounds } } @@ -4196,7 +4196,7 @@ impl Parser { self.obsolete(*self.last_span, ObsoleteExternVisibility); } - let abis = opt_abis.get_or_default(AbiSet::C()); + let abis = opt_abis.unwrap_or_default(AbiSet::C()); let (inner, next) = self.parse_inner_attrs_and_next(); let m = self.parse_foreign_mod_items(sort, abis, next); @@ -4463,7 +4463,7 @@ impl Parser { if self.eat_keyword(keywords::Fn) { // EXTERN FUNCTION ITEM - let abis = opt_abis.get_or_default(AbiSet::C()); + let abis = opt_abis.unwrap_or_default(AbiSet::C()); let (ident, item_, extra_attrs) = self.parse_item_fn(extern_fn, abis); return iovi_item(self.mk_item(lo, self.last_span.hi, ident, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 174b0f8e451..f517179f603 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -874,7 +874,7 @@ pub fn print_attribute(s: @ps, attr: &ast::Attribute) { hardbreak_if_not_bol(s); maybe_print_comment(s, attr.span.lo); if attr.node.is_sugared_doc { - let comment = attr.value_str().get(); + let comment = attr.value_str().unwrap(); word(s.s, comment); } else { word(s.s, "#["); @@ -1085,7 +1085,7 @@ pub fn print_call_post(s: @ps, } if sugar != ast::NoSugar { nbsp(s); - match blk.get().node { + match blk.unwrap().node { // need to handle closures specifically ast::expr_do_body(e) => { end(s); // we close our head box; closure @@ -1095,7 +1095,7 @@ pub fn print_call_post(s: @ps, } _ => { // not sure if this can happen. - print_expr(s, blk.get()); + print_expr(s, blk.unwrap()); } } } @@ -1323,13 +1323,13 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { assert!(body.stmts.is_empty()); assert!(body.expr.is_some()); // we extract the block, so as not to create another set of boxes - match body.expr.get().node { + match body.expr.unwrap().node { ast::expr_block(ref blk) => { print_block_unclosed(s, blk); } _ => { // this is a bare expression - print_expr(s, body.expr.get()); + print_expr(s, body.expr.unwrap()); end(s); // need to close a box } } |
