]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/attr.rs
rollup merge of #21438: taralx/kill-racycell
[rust.git] / src / libsyntax / attr.rs
index 68bbde35ae61560d39c977fe84d3f9d5184a8b55..8f58b7694b6fb3763a7318517ede958544052433 100644 (file)
@@ -28,6 +28,7 @@
 use std::cell::{RefCell, Cell};
 use std::collections::BitvSet;
 use std::collections::HashSet;
+use std::fmt;
 
 thread_local! { static USED_ATTRS: RefCell<BitvSet> = RefCell::new(BitvSet::new()) }
 
@@ -97,7 +98,7 @@ fn value_str(&self) -> Option<InternedString> {
 
     fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]> {
         match self.node {
-            MetaList(_, ref l) => Some(l.index(&FullRange)),
+            MetaList(_, ref l) => Some(&l[]),
             _ => None
         }
     }
@@ -135,8 +136,8 @@ fn with_desugared_doc<T, F>(&self, f: F) -> T where
             let comment = self.value_str().unwrap();
             let meta = mk_name_value_item_str(
                 InternedString::new("doc"),
-                token::intern_and_get_ident(strip_doc_comment_decoration(
-                        comment.get()).index(&FullRange)));
+                token::intern_and_get_ident(&strip_doc_comment_decoration(
+                        comment.get())[]));
             if self.node.style == ast::AttrOuter {
                 f(&mk_attr_outer(self.node.id, meta))
             } else {
@@ -169,7 +170,7 @@ pub fn mk_word_item(name: InternedString) -> P<MetaItem> {
     P(dummy_spanned(MetaWord(name)))
 }
 
-thread_local! { static NEXT_ATTR_ID: Cell<uint> = Cell::new(0) }
+thread_local! { static NEXT_ATTR_ID: Cell<usize> = Cell::new(0) }
 
 pub fn mk_attr_id() -> AttrId {
     let id = NEXT_ATTR_ID.with(|slot| {
@@ -296,9 +297,9 @@ pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr {
             }
             MetaList(ref n, ref items) if *n == "inline" => {
                 mark_used(attr);
-                if contains_name(items.index(&FullRange), "always") {
+                if contains_name(&items[], "always") {
                     InlineAlways
-                } else if contains_name(items.index(&FullRange), "never") {
+                } else if contains_name(&items[], "never") {
                     InlineNever
                 } else {
                     InlineHint
@@ -357,6 +358,12 @@ pub enum StabilityLevel {
     Locked
 }
 
+impl fmt::String for StabilityLevel {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::Show::fmt(self, f)
+    }
+}
+
 pub fn find_stability_generic<'a,
                               AM: AttrMetaMethods,
                               I: Iterator<Item=&'a AM>>
@@ -396,7 +403,7 @@ pub fn require_unique_names(diagnostic: &SpanHandler, metas: &[P<MetaItem>]) {
 
         if !set.insert(name.clone()) {
             diagnostic.span_fatal(meta.span,
-                                  format!("duplicate meta item `{}`", name).index(&FullRange));
+                                  &format!("duplicate meta item `{}`", name)[]);
         }
     }
 }
@@ -457,8 +464,10 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
         "u32" => Some(UnsignedInt(ast::TyU32)),
         "i64" => Some(SignedInt(ast::TyI64)),
         "u64" => Some(UnsignedInt(ast::TyU64)),
-        "int" => Some(SignedInt(ast::TyI)),
-        "uint" => Some(UnsignedInt(ast::TyU)),
+        "int" => Some(SignedInt(ast::TyIs(true))),
+        "uint" => Some(UnsignedInt(ast::TyUs(true))),
+        "isize" => Some(SignedInt(ast::TyIs(false))),
+        "usize" => Some(UnsignedInt(ast::TyUs(false))),
         _ => None
     }
 }
@@ -502,7 +511,7 @@ fn is_ffi_safe(self) -> bool {
             SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) |
             SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) |
             SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true,
-            SignedInt(ast::TyI) | UnsignedInt(ast::TyU) => false
+            SignedInt(ast::TyIs(_)) | UnsignedInt(ast::TyUs(_)) => false
         }
     }
 }