diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-01-10 17:20:07 -0800 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-02 01:44:48 +1100 |
| commit | a0646ae3a496819fe69eec3ee74f4422c0619218 (patch) | |
| tree | cabb5d727ae8ed585d4d6c80361f8488d9956083 /src/libsyntax | |
| parent | 8e52b85d5a6f6e3aaa2f15d7c1e907d0ce8589ee (diff) | |
| download | rust-a0646ae3a496819fe69eec3ee74f4422c0619218.tar.gz rust-a0646ae3a496819fe69eec3ee74f4422c0619218.zip | |
libsyntax: De-`@str` `to_source`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 425ac8865b2..71879fc2f1e 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -66,133 +66,134 @@ pub mod rt { pub trait ToSource { // Takes a thing and generates a string containing rust code for it. - fn to_source(&self) -> @str; + fn to_source(&self) -> ~str; } impl ToSource for ast::Ident { - fn to_source(&self) -> @str { - ident_to_str(self) + fn to_source(&self) -> ~str { + let this = get_ident(self.name); + this.get().to_owned() } } impl ToSource for @ast::Item { - fn to_source(&self) -> @str { - pprust::item_to_str(*self, get_ident_interner()).to_managed() + fn to_source(&self) -> ~str { + pprust::item_to_str(*self, get_ident_interner()) } } impl<'a> ToSource for &'a [@ast::Item] { - fn to_source(&self) -> @str { - self.map(|i| i.to_source()).connect("\n\n").to_managed() + fn to_source(&self) -> ~str { + self.map(|i| i.to_source()).connect("\n\n") } } impl ToSource for ast::Ty { - fn to_source(&self) -> @str { - pprust::ty_to_str(self, get_ident_interner()).to_managed() + fn to_source(&self) -> ~str { + pprust::ty_to_str(self, get_ident_interner()) } } impl<'a> ToSource for &'a [ast::Ty] { - fn to_source(&self) -> @str { - self.map(|i| i.to_source()).connect(", ").to_managed() + fn to_source(&self) -> ~str { + self.map(|i| i.to_source()).connect(", ") } } impl ToSource for Generics { - fn to_source(&self) -> @str { - pprust::generics_to_str(self, get_ident_interner()).to_managed() + fn to_source(&self) -> ~str { + pprust::generics_to_str(self, get_ident_interner()) } } impl ToSource for @ast::Expr { - fn to_source(&self) -> @str { - pprust::expr_to_str(*self, get_ident_interner()).to_managed() + fn to_source(&self) -> ~str { + pprust::expr_to_str(*self, get_ident_interner()) } } impl ToSource for ast::Block { - fn to_source(&self) -> @str { - pprust::block_to_str(self, get_ident_interner()).to_managed() + fn to_source(&self) -> ~str { + pprust::block_to_str(self, get_ident_interner()) } } impl<'a> ToSource for &'a str { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitStr( token::intern_and_get_ident(*self), ast::CookedStr)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for int { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for i8 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI8)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for i16 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI16)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for i32 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI32)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for i64 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI64)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for uint { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for u8 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU8)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for u16 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU16)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for u32 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU32)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } impl ToSource for u64 { - fn to_source(&self) -> @str { + fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU64)); - pprust::lit_to_str(&lit).to_managed() + pprust::lit_to_str(&lit) } } @@ -202,7 +203,7 @@ pub mod rt { ($t:ty) => ( impl ToTokens for $t { fn to_tokens(&self, cx: &ExtCtxt) -> ~[TokenTree] { - cx.parse_tts(self.to_source()) + cx.parse_tts(self.to_source().to_managed()) } } ) @@ -212,7 +213,7 @@ pub mod rt { ($t:ty) => ( impl<'a> ToTokens for $t { fn to_tokens(&self, cx: &ExtCtxt) -> ~[TokenTree] { - cx.parse_tts(self.to_source()) + cx.parse_tts(self.to_source().to_managed()) } } ) |
