diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-03-27 12:55:18 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-03-27 13:48:24 -0400 |
| commit | 772293a25120367bed984243fffd59fcb4b8cd80 (patch) | |
| tree | 722c5bb36b4f6932ed83dd37d4b80f1bb92fa0a6 /src/libsyntax | |
| parent | b93393e907eddab513fa2be541af4356b8203282 (diff) | |
| download | rust-772293a25120367bed984243fffd59fcb4b8cd80.tar.gz rust-772293a25120367bed984243fffd59fcb4b8cd80.zip | |
Fix pretty-printer test failure by carrying the bound lifetime names through
the types. Initially I thought it would be necessary to thread this data through not only the AST but the types themselves, but then I remembered that the pretty printer only cares about the AST. Regardless, I have elected to leave the changes to the types intact since they will eventually be needed. I left a few FIXMEs where it didn't seem worth finishing up since the code wasn't crucial yet.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 12 |
4 files changed, 13 insertions, 4 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6071cc643a3..9112e92df7e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -904,6 +904,7 @@ pub struct TyClosure { pub struct TyBareFn { purity: purity, abi: Abi, + lifetimes: OptVec<Lifetime>, decl: fn_decl } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 017e95ab4c1..9d4cf4e8939 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -615,6 +615,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ { } ty_bare_fn(ref f) => { ty_bare_fn(@TyBareFn { + lifetimes: f.lifetimes, purity: f.purity, abi: f.abi, decl: fold_fn_decl(&f.decl, fld) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 53d618e3340..c82151bb4a9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -363,10 +363,11 @@ pub impl Parser { let purity = self.parse_purity(); self.expect_keyword(&~"fn"); - let (decl, _) = self.parse_ty_fn_decl(); + let (decl, lifetimes) = self.parse_ty_fn_decl(); return ty_bare_fn(@TyBareFn { abi: RustAbi, purity: purity, + lifetimes: lifetimes, decl: decl }); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9a9834c488b..a6064b467b1 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -14,6 +14,7 @@ use ast::{RegionTyParamBound, TraitTyParamBound, required, provided}; use ast; use ast_util; use opt_vec::OptVec; +use opt_vec; use attr; use codemap::{CodeMap, BytePos}; use codemap; @@ -402,14 +403,18 @@ pub fn print_type(s: @ps, &&ty: @ast::Ty) { pclose(s); } ast::ty_bare_fn(f) => { + let generics = ast::Generics {lifetimes: copy f.lifetimes, + ty_params: opt_vec::Empty}; print_ty_fn(s, Some(f.abi), None, None, f.purity, ast::Many, &f.decl, None, - None, None); + Some(&generics), None); } ast::ty_closure(f) => { + let generics = ast::Generics {lifetimes: copy f.lifetimes, + ty_params: opt_vec::Empty}; print_ty_fn(s, None, Some(f.sigil), f.region, f.purity, f.onceness, &f.decl, None, - None, None); + Some(&generics), None); } ast::ty_path(path, _) => print_path(s, path, false), ast::ty_fixed_length_vec(ref mt, v) => { @@ -1923,7 +1928,8 @@ pub fn print_ty_fn(s: @ps, opt_region: Option<@ast::Lifetime>, purity: ast::purity, onceness: ast::Onceness, - decl: &ast::fn_decl, id: Option<ast::ident>, + decl: &ast::fn_decl, + id: Option<ast::ident>, generics: Option<&ast::Generics>, opt_self_ty: Option<ast::self_ty_>) { ibox(s, indent_unit); |
