about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorcgswords <cameronswords@gmail.com>2016-07-17 21:45:06 -0700
committercgswords <cameronswords@gmail.com>2016-07-25 14:27:10 -0700
commit5553901146fa80c652abdc514b38360a0ae7418d (patch)
tree722ec8d11d396c7a65fd3617d3a3c0d47ed8f234 /src
parenta5e5ea1646367b82864af3a2a508993d76b792af (diff)
downloadrust-5553901146fa80c652abdc514b38360a0ae7418d.tar.gz
rust-5553901146fa80c652abdc514b38360a0ae7418d.zip
Adressed PR comments.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/lint/context.rs18
-rw-r--r--src/librustc_driver/lib.rs9
-rw-r--r--src/librustc_incremental/assert_dep_graph.rs8
-rw-r--r--src/librustc_lint/builtin.rs8
-rw-r--r--src/librustdoc/clean/mod.rs22
-rw-r--r--src/libsyntax/attr.rs21
-rw-r--r--src/libsyntax_pos/lib.rs4
7 files changed, 30 insertions, 60 deletions
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs
index 0a1e7005f9f..27e1d0520dc 100644
--- a/src/librustc/lint/context.rs
+++ b/src/librustc/lint/context.rs
@@ -367,18 +367,18 @@ pub fn gather_attr(attr: &ast::Attribute)
 
     let meta = &attr.node.value;
     let metas = if let Some(metas) = meta.meta_item_list() {
-                    metas
-                } else {
-                    out.push(Err(meta.span));
-                    return out;
-                };
+        metas
+    } else {
+        out.push(Err(meta.span));
+        return out;
+    };
 
     for meta in metas {
         out.push(if meta.is_word() {
-                     Ok((meta.name().clone(), level, meta.span))
-                 } else {
-                     Err(meta.span)
-                 });
+            Ok((meta.name().clone(), level, meta.span))
+        } else {
+            Err(meta.span)
+        });
     }
 
     out
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 9df1dea4567..07a2605026a 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -395,10 +395,9 @@ fn check_cfg(sopts: &config::Options,
     for item in sopts.cfg.iter() {
         if item.is_meta_item_list() {
             saw_invalid_predicate = true;
-            saw_invalid_predicate = true;
             handler.emit(&MultiSpan::new(),
                          &format!("invalid predicate in --cfg command line argument: `{}`",
-                                  pred),
+                                  item.name()),
                             errors::Level::Fatal);
         }
     }
@@ -651,10 +650,8 @@ impl RustcDefaultCalls {
                         if cfg.is_word() {
                             println!("{}", cfg.name());
                         } else if cfg.is_value_str() {
-                            let rhs = cfg.value_str();
-                            match rhs {
-                                Some(s) => println!("{}=\"{}\"", cfg.name(), s),
-                                None => continue,
+                            if let Some(s) = cfg.value_str() {
+                                println!("{}=\"{}\"", cfg.name(), s);
                             }
                         } else if cfg.is_meta_item_list() {
                             // Right now there are not and should not be any
diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs
index 0d327414c8f..774c5ca6d6b 100644
--- a/src/librustc_incremental/assert_dep_graph.rs
+++ b/src/librustc_incremental/assert_dep_graph.rs
@@ -114,9 +114,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
                         id = Some(meta_item.name().clone());
                     } else {
                         // FIXME better-encapsulate meta_item (don't directly access `node`)
-                        self.tcx.sess.span_err(
-                            meta_item.span(),
-                            &format!("unexpected meta-item {:?}", meta_item.node));
+                        span_bug!(meta_item.span(), "unexpected meta-item {:?}", meta_item.node)
                     }
                 }
                 let id = id.unwrap_or(InternedString::new(ID));
@@ -133,9 +131,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
                         id = Some(meta_item.name().clone());
                     } else {
                         // FIXME better-encapsulate meta_item (don't directly access `node`)
-                        self.tcx.sess.span_err(
-                            meta_item.span(),
-                            &format!("unexpected meta-item {:?}", meta_item.node));
+                        span_bug!(meta_item.span(), "unexpected meta-item {:?}", meta_item.node)
                     }
                 }
                 let dep_node = match dep_node_interned {
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index a498004b390..7547e28625c 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -298,13 +298,7 @@ impl MissingDoc {
             }
         }
 
-        let has_doc = attrs.iter().any(|a| {
-            if a.is_value_str() && a.name() == "doc" {
-                true
-            } else {
-                false
-            }
-        });
+        let has_doc = attrs.iter().any(|a| a.is_value_str() && a.name() == "doc");
         if !has_doc {
             cx.span_lint(MISSING_DOCS, sp,
                          &format!("missing documentation for {}", desc));
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 8d69c55ecf1..6883c22d675 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -504,7 +504,7 @@ impl Clean<Attribute> for ast::MetaItem {
             NameValue(self.name().to_string(), v.to_string())
         } else { // must be a list
             let l = self.meta_item_list().unwrap();
-              List(self.name().to_string(), l.clean(cx))
+            List(self.name().to_string(), l.clean(cx))
        }
     }
 }
@@ -2589,26 +2589,6 @@ impl ToSource for syntax_pos::Span {
     }
 }
 
-// fn lit_to_string(lit: &ast::Lit) -> String {
-//     match lit.node {
-//         ast::LitKind::Str(ref st, _) => st.to_string(),
-//         ast::LitKind::ByteStr(ref data) => format!("{:?}", data),
-//         ast::LitKind::Byte(b) => {
-//             let mut res = String::from("b'");
-//             for c in (b as char).escape_default() {
-//                 res.push(c);
-//             }
-//             res.push('\'');
-//             res
-//         },
-//         ast::LitKind::Char(c) => format!("'{}'", c),
-//         ast::LitKind::Int(i, _t) => i.to_string(),
-//         ast::LitKind::Float(ref f, _t) => f.to_string(),
-//         ast::LitKind::FloatUnsuffixed(ref f) => f.to_string(),
-//         ast::LitKind::Bool(b) => b.to_string(),
-//     }
-// }
-
 fn name_from_pat(p: &hir::Pat) -> String {
     use rustc::hir::*;
     debug!("Trying to get a name from pattern: {:?}", p);
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 8bd3f5195cc..b622f6861b3 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -94,10 +94,16 @@ pub trait AttrMetaMethods {
 
     /// Indicates if the attribute is a Word.
     fn is_word(&self) -> bool;
+
     /// Indicates if the attribute is a Value String.
-    fn is_value_str(&self) -> bool;
+    fn is_value_str(&self) -> bool {
+        self.value_str().is_some()
+    }
+
     /// Indicates if the attribute is a Meta-Item List.
-    fn is_meta_item_list(&self) -> bool;
+    fn is_meta_item_list(&self) -> bool {
+        self.meta_item_list().is_some()
+    }
 
     fn span(&self) -> Span;
 }
@@ -119,9 +125,6 @@ impl AttrMetaMethods for Attribute {
     }
 
     fn is_word(&self) -> bool { self.meta().is_word() }
-    fn is_value_str(&self) -> bool { self.meta().is_value_str() }
-
-    fn is_meta_item_list(&self) -> bool { self.meta().is_meta_item_list() }
 
     fn span(&self) -> Span { self.meta().span }
 }
@@ -161,10 +164,6 @@ impl AttrMetaMethods for MetaItem {
         }
     }
 
-    fn is_value_str(&self) -> bool { self.value_str().is_some() }
-
-    fn is_meta_item_list(&self) -> bool { self.meta_item_list().is_some() }
-
     fn span(&self) -> Span { self.span }
 }
 
@@ -240,7 +239,7 @@ pub fn mk_word_item(name: InternedString) -> P<MetaItem> {
 
 pub fn mk_spanned_name_value_item(sp: Span, name: InternedString, value: ast::Lit)
                           -> P<MetaItem> {
-    P(respan(sp,MetaItemKind::NameValue(name, value)))
+    P(respan(sp, MetaItemKind::NameValue(name, value)))
 }
 
 pub fn mk_spanned_list_item(sp: Span, name: InternedString, items: Vec<P<MetaItem>>)
@@ -249,7 +248,7 @@ pub fn mk_spanned_list_item(sp: Span, name: InternedString, items: Vec<P<MetaIte
 }
 
 pub fn mk_spanned_word_item(sp: Span, name: InternedString) -> P<MetaItem> {
-    P(respan(sp,MetaItemKind::Word(name)))
+    P(respan(sp, MetaItemKind::Word(name)))
 }
 
 
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index c96be8fec2b..b1ec7fd0ab8 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -254,6 +254,10 @@ pub const NO_EXPANSION: ExpnId = ExpnId(!0);
 // For code appearing from the command line
 pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(!1);
 
+// For code generated by a procedural macro, without knowing which
+// Used in `qquote!`
+pub const PROC_EXPN: ExpnId = ExpnId(!2);
+
 impl ExpnId {
     pub fn from_u32(id: u32) -> ExpnId {
         ExpnId(id)