From c305473d3c60d5b4590ef8c715468f718a7aad8f Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 20 May 2014 00:07:24 -0700 Subject: [PATCH] Add AttrId to Attribute_ --- src/librustc/back/svh.rs | 7 ++++- src/librustc/front/std_inject.rs | 11 ++++--- src/librustc/front/test.rs | 3 +- src/librustc/metadata/decoder.rs | 1 + src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/trans/base.rs | 5 +-- src/libsyntax/ast.rs | 4 +++ src/libsyntax/attr.rs | 36 ++++++++++++++++++---- src/libsyntax/ext/build.rs | 6 ++-- src/libsyntax/ext/deriving/clone.rs | 3 +- src/libsyntax/ext/deriving/cmp/eq.rs | 3 +- src/libsyntax/ext/deriving/cmp/ord.rs | 3 +- src/libsyntax/ext/deriving/cmp/totaleq.rs | 5 +-- src/libsyntax/ext/deriving/cmp/totalord.rs | 3 +- src/libsyntax/ext/deriving/default.rs | 3 +- src/libsyntax/ext/deriving/generic/mod.rs | 2 ++ src/libsyntax/ext/deriving/hash.rs | 3 +- src/libsyntax/ext/deriving/primitive.rs | 3 +- src/libsyntax/ext/deriving/zero.rs | 3 +- src/libsyntax/ext/expand.rs | 2 ++ src/libsyntax/ext/format.rs | 7 +++-- src/libsyntax/fold.rs | 1 + src/libsyntax/parse/attr.rs | 8 ++++- 23 files changed, 94 insertions(+), 30 deletions(-) diff --git a/src/librustc/back/svh.rs b/src/librustc/back/svh.rs index 489722aa13f..9ad653498ba 100644 --- a/src/librustc/back/svh.rs +++ b/src/librustc/back/svh.rs @@ -91,7 +91,12 @@ pub fn calculate(krate: &ast::Crate) -> Svh { // types and then use hash_content. But, since all crate // attributes should appear near beginning of the file, it is // not such a big deal to be sensitive to their spans for now. - krate.attrs.hash(&mut state); + // + // We hash only the MetaItems instead of the entire Attribute + // to avoid hashing the AttrId + for attr in krate.attrs.iter() { + attr.node.value.hash(&mut state); + } let hash = state.result(); return Svh { diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index efaeeaa5575..e380af7a4f0 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -78,7 +78,7 @@ fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate { with_version("std"), ast::DUMMY_NODE_ID), attrs: vec!( - attr::mk_attr_outer(attr::mk_list_item( + attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_list_item( InternedString::new("phase"), vec!( attr::mk_word_item(InternedString::new("syntax")), @@ -110,7 +110,8 @@ fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate { // Add it during the prelude injection instead. // Add #![feature(phase)] here, because we use #[phase] on extern crate std. - let feat_phase_attr = attr::mk_attr_inner(attr::mk_list_item( + let feat_phase_attr = attr::mk_attr_inner(attr::mk_attr_id(), + attr::mk_list_item( InternedString::new("feature"), vec![attr::mk_word_item(InternedString::new("phase"))], )); @@ -138,7 +139,8 @@ fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate { // This must happen here and not in StandardLibraryInjector because this // fold happens second. - let no_std_attr = attr::mk_attr_inner(attr::mk_word_item(InternedString::new("no_std"))); + let no_std_attr = attr::mk_attr_inner(attr::mk_attr_id(), + attr::mk_word_item(InternedString::new("no_std"))); krate.attrs.push(no_std_attr); if !no_prelude(krate.attrs.as_slice()) { @@ -146,7 +148,8 @@ fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate { // `#![no_implicit_prelude]` at the crate level. // fold_mod() will insert glob path. - let globs_attr = attr::mk_attr_inner(attr::mk_list_item( + 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")), diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index e7a5aeb9ef5..d5e9192cd74 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -341,7 +341,8 @@ pub fn main() { // This attribute tells resolve to let us call unexported functions let resolve_unexported_str = InternedString::new("!resolve_unexported"); let resolve_unexported_attr = - attr::mk_attr_inner(attr::mk_word_item(resolve_unexported_str)); + attr::mk_attr_inner(attr::mk_attr_id(), + attr::mk_word_item(resolve_unexported_str)); let item = ast::Item { ident: token::str_to_ident("__test"), diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index b3ef888c0b4..77c3d43bc09 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1056,6 +1056,7 @@ fn get_attributes(md: ebml::Doc) -> Vec { attrs.push( codemap::Spanned { node: ast::Attribute_ { + id: attr::mk_attr_id(), style: ast::AttrOuter, value: meta_item, is_sugared_doc: false, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index a0742669cc0..a06c6e59ea1 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1436,7 +1436,7 @@ fn synthesize_crate_attrs(ecx: &EncodeContext, fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute { assert!(!ecx.link_meta.crateid.name.is_empty()); - attr::mk_attr_inner( + attr::mk_attr_inner(attr::mk_attr_id(), attr::mk_name_value_item_str( InternedString::new("crate_id"), token::intern_and_get_ident(ecx.link_meta diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 43f3442ec47..4b769a5fdae 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -228,8 +228,9 @@ fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str, did: ast::De let f = decl_rust_fn(ccx, fn_ty, name); csearch::get_item_attrs(&ccx.sess().cstore, did, |meta_items| { - set_llvm_fn_attrs(meta_items.iter().map(|&x| attr::mk_attr_outer(x)) - .collect::>().as_slice(), f) + set_llvm_fn_attrs(meta_items.iter().map(|&x| { + attr::mk_attr_outer(attr::mk_attr_id(), x) + }).collect::>().as_slice(), f) }); ccx.externs.borrow_mut().insert(name.to_strbuf(), f); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index d4c01746098..e77d1faf05d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1024,9 +1024,13 @@ pub enum AttrStyle { AttrInner, } +#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] +pub struct AttrId(pub uint); + // doc-comments are promoted to attributes that have is_sugared_doc = true #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] pub struct Attribute_ { + pub id: AttrId, pub style: AttrStyle, pub value: @MetaItem, pub is_sugared_doc: bool, diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 77c335b8936..83ac2c08efb 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -11,7 +11,7 @@ // Functions dealing with attributes and meta items use ast; -use ast::{Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList}; +use ast::{AttrId, Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList}; use codemap::{Span, Spanned, spanned, dummy_spanned}; use codemap::BytePos; use diagnostic::SpanHandler; @@ -22,6 +22,18 @@ use collections::HashSet; +local_data_key!(used_attrs: HashSet) + +pub fn mark_used(attr: &Attribute) { + let mut used = used_attrs.replace(None).unwrap_or_else(|| HashSet::new()); + used.insert(attr.node.id); + used_attrs.replace(Some(used)); +} + +pub fn is_used(attr: &Attribute) -> bool { + used_attrs.get().map_or(false, |used| used.contains(&attr.node.id)) +} + pub trait AttrMetaMethods { // This could be changed to `fn check_name(&self, name: InternedString) -> // bool` which would facilitate a side table recording which @@ -127,9 +139,9 @@ fn desugar_doc(&self) -> Attribute { token::intern_and_get_ident(strip_doc_comment_decoration( comment.get()).as_slice())); if self.node.style == ast::AttrOuter { - mk_attr_outer(meta) + mk_attr_outer(self.node.id, meta) } else { - mk_attr_inner(meta) + mk_attr_inner(self.node.id, meta) } } else { *self @@ -158,9 +170,18 @@ pub fn mk_word_item(name: InternedString) -> @MetaItem { @dummy_spanned(MetaWord(name)) } +local_data_key!(next_attr_id: uint) + +pub fn mk_attr_id() -> AttrId { + let id = next_attr_id.replace(None).unwrap_or(0); + next_attr_id.replace(Some(id + 1)); + AttrId(id) +} + /// Returns an inner attribute with the given value. -pub fn mk_attr_inner(item: @MetaItem) -> Attribute { +pub fn mk_attr_inner(id: AttrId, item: @MetaItem) -> Attribute { dummy_spanned(Attribute_ { + id: id, style: ast::AttrInner, value: item, is_sugared_doc: false, @@ -168,19 +189,22 @@ pub fn mk_attr_inner(item: @MetaItem) -> Attribute { } /// Returns an outer attribute with the given value. -pub fn mk_attr_outer(item: @MetaItem) -> Attribute { +pub fn mk_attr_outer(id: AttrId, item: @MetaItem) -> Attribute { dummy_spanned(Attribute_ { + id: id, style: ast::AttrOuter, value: item, is_sugared_doc: false, }) } -pub fn mk_sugared_doc_attr(text: InternedString, lo: BytePos, hi: BytePos) +pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos, + hi: BytePos) -> Attribute { let style = doc_comment_style(text.get()); let lit = spanned(lo, hi, ast::LitStr(text, ast::CookedStr)); let attr = Attribute_ { + id: id, style: style, value: @spanned(lo, hi, MetaNameValue(InternedString::new("doc"), lit)), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 3c7415ae0e9..44c177d19ca 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -231,7 +231,7 @@ fn item_ty_poly(&self, generics: Generics) -> @ast::Item; fn item_ty(&self, span: Span, name: Ident, ty: P) -> @ast::Item; - fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute; + fn attribute(&self, id: AttrId, sp: Span, mi: @ast::MetaItem) -> ast::Attribute; fn meta_word(&self, sp: Span, w: InternedString) -> @ast::MetaItem; fn meta_list(&self, @@ -925,8 +925,10 @@ fn item_ty(&self, span: Span, name: Ident, ty: P) -> @ast::Item { self.item_ty_poly(span, name, ty, ast_util::empty_generics()) } - fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute { + fn attribute(&self, id: ast::AttrId, sp: Span, mi: @ast::MetaItem) + -> ast::Attribute { respan(sp, ast::Attribute_ { + id: id, style: ast::AttrOuter, value: mi, is_sugared_doc: false, diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 89c94891b33..73bfe9c27b6 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use attr; use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; @@ -21,7 +22,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt, item: @Item, push: |@Item|) { let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); let trait_def = TraitDef { span: span, attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 92b3788c247..31d6fcb9d6f 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -9,6 +9,7 @@ // except according to those terms. use ast::{MetaItem, Item, Expr}; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -34,7 +35,7 @@ fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { macro_rules! md ( ($name:expr, $f:ident) => { { let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); MethodDef { name: $name, generics: LifetimeBounds::empty(), diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index dd2f90cfa5f..3d79de4feb1 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -10,6 +10,7 @@ use ast; use ast::{MetaItem, Item, Expr}; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -24,7 +25,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, macro_rules! md ( ($name:expr, $op:expr, $equal:expr) => { { let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); MethodDef { name: $name, generics: LifetimeBounds::empty(), diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index b76caccffec..42bbf8e415a 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -9,6 +9,7 @@ // except according to those terms. use ast::{MetaItem, Item, Expr}; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -37,8 +38,8 @@ fn cs_total_eq_assert(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @E let inline = cx.meta_word(span, InternedString::new("inline")); let hidden = cx.meta_word(span, InternedString::new("hidden")); let doc = cx.meta_list(span, InternedString::new("doc"), vec!(hidden)); - let attrs = vec!(cx.attribute(span, inline), - cx.attribute(span, doc)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline), + cx.attribute(attr::mk_attr_id(), span, doc)); let trait_def = TraitDef { span: span, attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 3ca4f9e2862..6413bdab344 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -10,6 +10,7 @@ use ast; use ast::{MetaItem, Item, Expr}; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -24,7 +25,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt, item: @Item, push: |@Item|) { let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); let trait_def = TraitDef { span: span, attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index c225906ed2b..a0499a2cc1e 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -9,6 +9,7 @@ // except according to those terms. use ast::{MetaItem, Item, Expr}; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -21,7 +22,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt, item: @Item, push: |@Item|) { let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); let trait_def = TraitDef { span: span, attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 0875daddc0f..28595fecd89 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -182,6 +182,7 @@ fn eq(&self, other: &int) -> bool { use ast; use ast::{P, EnumDef, Expr, Ident, Generics, StructDef}; use ast_util; +use attr; use attr::AttrMetaMethods; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -427,6 +428,7 @@ fn create_derived_impl(&self, self_ty_params.into_vec()), None); let attr = cx.attribute( + attr::mk_attr_id(), self.span, cx.meta_word(self.span, InternedString::new("automatically_derived"))); diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index 3e6b8d522d4..8b368968f49 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -10,6 +10,7 @@ use ast; use ast::{MetaItem, Item, Expr, MutMutable}; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -37,7 +38,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, Path::new(vec!("std", "hash", "sip", "SipState"))) }; let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); let hash_trait_def = TraitDef { span: span, attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 5066a395b41..e3621b51c4d 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -10,6 +10,7 @@ use ast::{MetaItem, Item, Expr}; use ast; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -22,7 +23,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, item: @Item, push: |@Item|) { let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); let trait_def = TraitDef { span: span, attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 449851dd3ea..c60cdab9099 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -9,6 +9,7 @@ // except according to those terms. use ast::{MetaItem, Item, Expr}; +use attr; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -21,7 +22,7 @@ pub fn expand_deriving_zero(cx: &mut ExtCtxt, item: @Item, push: |@Item|) { let inline = cx.meta_word(span, InternedString::new("inline")); - let attrs = vec!(cx.attribute(span, inline)); + let attrs = vec!(cx.attribute(attr::mk_attr_id(), span, inline)); let trait_def = TraitDef { span: span, attributes: Vec::new(), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 989d0a463c3..83118df5e65 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -972,6 +972,7 @@ mod test { use super::*; use ast; use ast::{Attribute_, AttrOuter, MetaWord}; + use attr; use codemap; use codemap::Spanned; use ext::base::{CrateLoader, MacroCrate}; @@ -1103,6 +1104,7 @@ fn make_dummy_attr(s: &str) -> ast::Attribute { Spanned { span:codemap::DUMMY_SP, node: Attribute_ { + id: attr::mk_attr_id(), style: AttrOuter, value: @Spanned { node: MetaWord(token::intern_and_get_ident(s)), diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index ad4b798cfe5..c3b3c4eed57 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -10,6 +10,7 @@ use ast; use ast::P; +use attr; use codemap::{Span, respan}; use ext::base::*; use ext::base; @@ -382,7 +383,8 @@ fn static_attrs(&self) -> Vec { .meta_word(self.fmtsp, InternedString::new( "address_insignificant")); - let unnamed = self.ecx.attribute(self.fmtsp, unnamed); + let unnamed = self.ecx.attribute(attr::mk_attr_id(), self.fmtsp, + unnamed); // Do not warn format string as dead code let dead_code = self.ecx.meta_word(self.fmtsp, @@ -390,7 +392,8 @@ fn static_attrs(&self) -> Vec { let allow_dead_code = self.ecx.meta_list(self.fmtsp, InternedString::new("allow"), vec!(dead_code)); - let allow_dead_code = self.ecx.attribute(self.fmtsp, allow_dead_code); + let allow_dead_code = self.ecx.attribute(attr::mk_attr_id(), self.fmtsp, + allow_dead_code); return vec!(unnamed, allow_dead_code); } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 9813e12de01..ae5cf550bb9 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -360,6 +360,7 @@ fn fold_attribute_(at: Attribute, fld: &mut T) -> Attribute { Spanned { span: fld.new_span(at.span), node: ast::Attribute_ { + id: at.node.id, style: at.node.style, value: fold_meta_item_(at.node.value, fld), is_sugared_doc: at.node.is_sugared_doc diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 89d1b8f9342..e86dcb3d311 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use attr; use ast; use codemap::{spanned, Spanned, mk_sp, Span}; use parse::common::*; //resolve bug? @@ -39,6 +40,7 @@ fn parse_outer_attributes(&mut self) -> Vec { } token::DOC_COMMENT(s) => { let attr = ::attr::mk_sugared_doc_attr( + attr::mk_attr_id(), self.id_to_interned_str(s), self.span.lo, self.span.hi @@ -101,6 +103,7 @@ fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute { return Spanned { span: span, node: ast::Attribute_ { + id: attr::mk_attr_id(), style: style, value: value, is_sugared_doc: false @@ -132,7 +135,10 @@ fn parse_inner_attrs_and_next(&mut self) // we need to get the position of this token before we bump. let Span { lo, hi, .. } = self.span; self.bump(); - ::attr::mk_sugared_doc_attr(self.id_to_interned_str(s), lo, hi) + ::attr::mk_sugared_doc_attr(attr::mk_attr_id(), + self.id_to_interned_str(s), + lo, + hi) } _ => { break;