about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-11-18 01:02:19 +0000
committerbors <bors@rust-lang.org>2014-11-18 01:02:19 +0000
commit9c96a79a74f10bed18b031ce0ac4126c56d6cfb3 (patch)
tree42a980b8b8b145b37aae79c28c7540f8a7eec8d0 /src/libsyntax
parent336349c93207d792587eb0b5258b29da6ec0db8a (diff)
parent330a1afae84c7bea583907e5b1f02448a4c7bc20 (diff)
downloadrust-9c96a79a74f10bed18b031ce0ac4126c56d6cfb3.tar.gz
rust-9c96a79a74f10bed18b031ce0ac4126c56d6cfb3.zip
auto merge of #19049 : jakub-/rust/roll-up, r=alexcrichton
r? @alexcrichton
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostics/registry.rs2
-rw-r--r--src/libsyntax/ext/asm.rs4
-rw-r--r--src/libsyntax/ext/format.rs6
-rw-r--r--src/libsyntax/feature_gate.rs4
-rw-r--r--src/libsyntax/parse/parser.rs13
-rw-r--r--src/libsyntax/print/pprust.rs2
-rw-r--r--src/libsyntax/util/interner.rs20
7 files changed, 36 insertions, 15 deletions
diff --git a/src/libsyntax/diagnostics/registry.rs b/src/libsyntax/diagnostics/registry.rs
index 71d82a41f38..4caef247aeb 100644
--- a/src/libsyntax/diagnostics/registry.rs
+++ b/src/libsyntax/diagnostics/registry.rs
@@ -20,6 +20,6 @@ impl Registry {
     }
 
     pub fn find_description(&self, code: &str) -> Option<&'static str> {
-        self.descriptions.find_equiv(code).map(|desc| *desc)
+        self.descriptions.get(code).map(|desc| *desc)
     }
 }
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index 8027d9bfd8a..d04144ef26e 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -97,8 +97,8 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                     // cannot be shared with any other operand (usually when
                     // a register is clobbered early.)
                     let output = match constraint.get().slice_shift_char() {
-                        (Some('='), _) => None,
-                        (Some('+'), operand) => {
+                        Some(('=', _)) => None,
+                        Some(('+', operand)) => {
                             Some(token::intern_and_get_ident(format!(
                                         "={}",
                                         operand).as_slice()))
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index 9a9724de8fb..f1b92b4d6bc 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -144,7 +144,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool,
             let name = interned_name.get();
             p.expect(&token::Eq);
             let e = p.parse_expr();
-            match names.find_equiv(name) {
+            match names.get(name) {
                 None => {}
                 Some(prev) => {
                     ecx.span_err(e.span,
@@ -366,7 +366,7 @@ impl<'a, 'b> Context<'a, 'b> {
                 self.ecx.expr_path(path)
             }
             parse::CountIsName(n) => {
-                let i = match self.name_positions.find_equiv(n) {
+                let i = match self.name_positions.get(n) {
                     Some(&i) => i,
                     None => 0, // error already emitted elsewhere
                 };
@@ -410,7 +410,7 @@ impl<'a, 'b> Context<'a, 'b> {
                     // Named arguments are converted to positional arguments at
                     // the end of the list of arguments
                     parse::ArgumentNamed(n) => {
-                        let i = match self.name_positions.find_equiv(n) {
+                        let i = match self.name_positions.get(n) {
                             Some(&i) => i,
                             None => 0, // error already emitted elsewhere
                         };
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 0178566fb06..0c31e9ae01d 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -182,6 +182,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
                                   "`#[thread_local]` is an experimental feature, and does not \
                                   currently handle destructors. There is no corresponding \
                                   `#[task_local]` mapping to the task model");
+            } else if attr.name().equiv(&("linkage")) {
+                self.gate_feature("linkage", i.span,
+                                  "the `linkage` attribute is experimental \
+                                   and not portable across platforms")
             }
         }
         match i.node {
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 5c95c369f94..98479d65cbb 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1232,7 +1232,8 @@ impl<'a> Parser<'a> {
     {
         if self.eat(&token::Lt) {
             if lifetime_defs.is_empty() {
-                self.warn("deprecated syntax, use `for` keyword now");
+                self.warn("deprecated syntax; use the `for` keyword now \
+                            (e.g. change `fn<'a>` to `for<'a> fn`)");
                 let lifetime_defs = self.parse_lifetime_defs();
                 self.expect_gt();
                 lifetime_defs
@@ -5178,7 +5179,15 @@ impl<'a> Parser<'a> {
             if self.eat(&token::OpenDelim(token::Brace)) {
                 // Parse a struct variant.
                 all_nullary = false;
-                kind = StructVariantKind(self.parse_struct_def());
+                let start_span = self.span;
+                let struct_def = self.parse_struct_def();
+                if struct_def.fields.len() == 0 {
+                    self.span_err(start_span,
+                        format!("unit-like struct variant should be written \
+                                 without braces, as `{},`",
+                                token::get_ident(ident)).as_slice());
+                }
+                kind = StructVariantKind(struct_def);
             } else if self.token == token::OpenDelim(token::Paren) {
                 all_nullary = false;
                 let arg_tys = self.parse_enum_variant_seq(
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 390a5cc68d3..81f3d977e13 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1855,7 +1855,7 @@ impl<'a> State<'a> {
                 try!(self.commasep(Inconsistent, a.outputs.as_slice(),
                                    |s, &(ref co, ref o, is_rw)| {
                     match co.get().slice_shift_char() {
-                        (Some('='), operand) if is_rw => {
+                        Some(('=', operand)) if is_rw => {
                             try!(s.print_string(format!("+{}", operand).as_slice(),
                                                 ast::CookedStr))
                         }
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs
index 08ada3e4435..ede967bba25 100644
--- a/src/libsyntax/util/interner.rs
+++ b/src/libsyntax/util/interner.rs
@@ -14,9 +14,9 @@
 
 use ast::Name;
 
+use std::borrow::BorrowFrom;
 use std::collections::HashMap;
 use std::cell::RefCell;
-use std::cmp::Equiv;
 use std::fmt;
 use std::hash::Hash;
 use std::rc::Rc;
@@ -75,9 +75,10 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
         (*vect).len()
     }
 
-    pub fn find_equiv<Sized? Q: Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> {
+    pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+    where Q: BorrowFrom<T> + Eq + Hash {
         let map = self.map.borrow();
-        match (*map).find_equiv(val) {
+        match (*map).get(val) {
             Some(v) => Some(*v),
             None => None,
         }
@@ -117,6 +118,12 @@ impl fmt::Show for RcStr {
     }
 }
 
+impl BorrowFrom<RcStr> for str {
+    fn borrow_from(owned: &RcStr) -> &str {
+        owned.string.as_slice()
+    }
+}
+
 impl RcStr {
     pub fn new(string: &str) -> RcStr {
         RcStr {
@@ -149,7 +156,7 @@ impl StrInterner {
 
     pub fn intern(&self, val: &str) -> Name {
         let mut map = self.map.borrow_mut();
-        match map.find_equiv(val) {
+        match map.get(val) {
             Some(&idx) => return idx,
             None => (),
         }
@@ -195,8 +202,9 @@ impl StrInterner {
         self.vect.borrow().len()
     }
 
-    pub fn find_equiv<Sized? Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> {
-        match (*self.map.borrow()).find_equiv(val) {
+    pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+    where Q: BorrowFrom<RcStr> + Eq + Hash {
+        match (*self.map.borrow()).get(val) {
             Some(v) => Some(*v),
             None => None,
         }