diff options
| author | bors <bors@rust-lang.org> | 2016-11-21 08:08:47 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-21 08:08:47 -0600 |
| commit | ebec55406ba94faf8b2cd23b27a8f74df97d1ca4 (patch) | |
| tree | 446c06caed20d58ba039ba0e7739a89a136e74aa /src/libsyntax/ext/source_util.rs | |
| parent | 59b87b3975c97820b32ba6ebee8eac2a13ab883b (diff) | |
| parent | a8e86f0f816c9666915c73e80969dbf85a5afd56 (diff) | |
| download | rust-ebec55406ba94faf8b2cd23b27a8f74df97d1ca4.tar.gz rust-ebec55406ba94faf8b2cd23b27a8f74df97d1ca4.zip | |
Auto merge of #37824 - jseyfried:symbols, r=eddyb
Clean up `ast::Attribute`, `ast::CrateConfig`, and string interning This PR - removes `ast::Attribute_` (changing `Attribute` from `Spanned<Attribute_>` to a struct), - moves a `MetaItem`'s name from the `MetaItemKind` variants to a field of `MetaItem`, - avoids needlessly wrapping `ast::MetaItem` with `P`, - moves string interning into `syntax::symbol` (`ast::Name` is a reexport of `symbol::Symbol` for now), - replaces `InternedString` with `Symbol` in the AST, HIR, and various other places, and - refactors `ast::CrateConfig` from a `Vec` to a `HashSet`. r? @eddyb
Diffstat (limited to 'src/libsyntax/ext/source_util.rs')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index bda84cdaf39..320d49b6463 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -17,6 +17,7 @@ use parse::token; use parse; use print::pprust; use ptr::P; +use symbol::Symbol; use tokenstream; use util::small_vector::SmallVector; @@ -60,15 +61,13 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) let topmost = cx.expansion_cause(); let loc = cx.codemap().lookup_char_pos(topmost.lo); - let filename = token::intern_and_get_ident(&loc.file.name); - base::MacEager::expr(cx.expr_str(topmost, filename)) + base::MacEager::expr(cx.expr_str(topmost, Symbol::intern(&loc.file.name))) } pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'static> { let s = pprust::tts_to_string(tts); - base::MacEager::expr(cx.expr_str(sp, - token::intern_and_get_ident(&s[..]))) + base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&s))) } pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) @@ -77,9 +76,7 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) let mod_path = &cx.current_expansion.module.mod_path; let string = mod_path.iter().map(|x| x.to_string()).collect::<Vec<String>>().join("::"); - base::MacEager::expr(cx.expr_str( - sp, - token::intern_and_get_ident(&string[..]))) + base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&string))) } /// include! : parse the given file as an expr @@ -144,10 +141,9 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenT // Add this input file to the code map to make it available as // dependency information let filename = format!("{}", file.display()); - let interned = token::intern_and_get_ident(&src[..]); cx.codemap().new_filemap_and_lines(&filename, None, &src); - base::MacEager::expr(cx.expr_str(sp, interned)) + base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&src))) } Err(_) => { cx.span_err(sp, |
