diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-07 17:26:58 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-07 17:26:58 -0800 |
| commit | 6e806bdefde91af102567ef4b5dbd3ccf0c5c2ec (patch) | |
| tree | b8627ad2c80976f618b661ec14695f6a322ad1b3 /src/libsyntax/std_inject.rs | |
| parent | f6a7dc5528a9a9ac36867bbca2a6044b7be5bce2 (diff) | |
| parent | 7d72719efc25c6cdb8963c187e93df646ba65245 (diff) | |
| download | rust-6e806bdefde91af102567ef4b5dbd3ccf0c5c2ec.tar.gz rust-6e806bdefde91af102567ef4b5dbd3ccf0c5c2ec.zip | |
rollup merge of #20721: japaric/snap
Conflicts: src/libcollections/vec.rs src/libcore/fmt/mod.rs src/librustc/lint/builtin.rs src/librustc/session/config.rs src/librustc_trans/trans/base.rs src/librustc_trans/trans/context.rs src/librustc_trans/trans/type_.rs src/librustc_typeck/check/_match.rs src/librustdoc/html/format.rs src/libsyntax/std_inject.rs src/libsyntax/util/interner.rs src/test/compile-fail/mut-pattern-mismatched.rs
Diffstat (limited to 'src/libsyntax/std_inject.rs')
| -rw-r--r-- | src/libsyntax/std_inject.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 8e1a5860259..1d8f62abc08 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -40,7 +40,7 @@ pub fn maybe_inject_prelude(krate: ast::Crate) -> ast::Crate { } fn use_std(krate: &ast::Crate) -> bool { - !attr::contains_name(krate.attrs.index(&FullRange), "no_std") + !attr::contains_name(&krate.attrs[], "no_std") } fn no_prelude(attrs: &[ast::Attribute]) -> bool { @@ -56,7 +56,7 @@ impl<'a> fold::Folder for StandardLibraryInjector<'a> { // The name to use in `extern crate "name" as std;` let actual_crate_name = match self.alt_std_name { - Some(ref s) => token::intern_and_get_ident(s.index(&FullRange)), + Some(ref s) => token::intern_and_get_ident(&s[]), None => token::intern_and_get_ident("std"), }; @@ -106,14 +106,27 @@ impl<'a> fold::Folder for PreludeInjector<'a> { // only add `use std::prelude::*;` if there wasn't a // `#![no_implicit_prelude]` at the crate level. // fold_mod() will insert glob path. - if !no_prelude(krate.attrs.index(&FullRange)) { + if !no_prelude(&krate.attrs[]) { + // only add `use std::prelude::*;` if there wasn't a + // `#![no_implicit_prelude]` at the crate level. + // fold_mod() will insert glob path. + let globs_attr = attr::mk_attr_inner(attr::mk_attr_id(), + attr::mk_list_item( + InternedString::new("feature"), + vec!( + attr::mk_word_item(InternedString::new("globs")), + ))); + // std_inject runs after feature checking so manually mark this attr + attr::mark_used(&globs_attr); + krate.attrs.push(globs_attr); + krate.module = self.fold_mod(krate.module); } krate } fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> { - if !no_prelude(item.attrs.index(&FullRange)) { + if !no_prelude(&item.attrs[]) { // only recur if there wasn't `#![no_implicit_prelude]` // on this item, i.e. this means that the prelude is not // implicitly imported though the whole subtree |
