about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-07-02 21:00:59 -0700
committerHuon Wilson <dbau.pp+github@gmail.com>2015-07-06 11:35:39 -0700
commit69d340a40d0ca37e91731026bd5d7041a145aa34 (patch)
tree9bc5d897b32355807db8a7b477d37ba7db0988cf /src/libsyntax
parentfe283b4067769a9bc653855842fd8279e95e1f3e (diff)
downloadrust-69d340a40d0ca37e91731026bd5d7041a145aa34.tar.gz
rust-69d340a40d0ca37e91731026bd5d7041a145aa34.zip
rustc: implement `unstable(issue = "nnn")`.
This takes an issue number and points people to it in the printed error
message. This commit does not make it an error to have no `issue` field.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/attr.rs68
1 files changed, 45 insertions, 23 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 3ee8ffe3636..84fea8415ee 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -375,6 +375,8 @@ pub struct Stability {
     // The reason for the current stability level. If deprecated, the
     // reason for deprecation.
     pub reason: Option<InternedString>,
+    // The relevant rust-lang issue
+    pub issue: Option<u32>
 }
 
 /// The available stability levels.
@@ -409,41 +411,54 @@ fn find_stability_generic<'a,
 
         used_attrs.push(attr);
 
-        let (feature, since, reason) = match attr.meta_item_list() {
+        let (feature, since, reason, issue) = match attr.meta_item_list() {
             Some(metas) => {
                 let mut feature = None;
                 let mut since = None;
                 let mut reason = None;
+                let mut issue = None;
                 for meta in metas {
-                    if meta.name() == "feature" {
-                        match meta.value_str() {
-                            Some(v) => feature = Some(v),
-                            None => {
-                                diagnostic.span_err(meta.span, "incorrect meta item");
-                                continue 'outer;
+                    match &*meta.name() {
+                        "feature" => {
+                            match meta.value_str() {
+                                Some(v) => feature = Some(v),
+                                None => {
+                                    diagnostic.span_err(meta.span, "incorrect meta item");
+                                    continue 'outer;
+                                }
                             }
                         }
-                    }
-                    if &meta.name()[..] == "since" {
-                        match meta.value_str() {
-                            Some(v) => since = Some(v),
-                            None => {
-                                diagnostic.span_err(meta.span, "incorrect meta item");
-                                continue 'outer;
+                        "since" => {
+                            match meta.value_str() {
+                                Some(v) => since = Some(v),
+                                None => {
+                                    diagnostic.span_err(meta.span, "incorrect meta item");
+                                    continue 'outer;
+                                }
                             }
                         }
-                    }
-                    if &meta.name()[..] == "reason" {
-                        match meta.value_str() {
-                            Some(v) => reason = Some(v),
-                            None => {
-                                diagnostic.span_err(meta.span, "incorrect meta item");
-                                continue 'outer;
+                        "reason" => {
+                            match meta.value_str() {
+                                Some(v) => reason = Some(v),
+                                None => {
+                                    diagnostic.span_err(meta.span, "incorrect meta item");
+                                    continue 'outer;
+                                }
+                            }
+                        }
+                        "issue" => {
+                            match meta.value_str().and_then(|s| s.parse().ok()) {
+                                Some(v) => issue = Some(v),
+                                None => {
+                                    diagnostic.span_err(meta.span, "incorrect meta item");
+                                    continue 'outer;
+                                }
                             }
                         }
+                        _ => {}
                     }
                 }
-                (feature, since, reason)
+                (feature, since, reason, issue)
             }
             None => {
                 diagnostic.span_err(attr.span(), "incorrect stability attribute type");
@@ -477,7 +492,8 @@ fn find_stability_generic<'a,
                 feature: feature.unwrap_or(intern_and_get_ident("bogus")),
                 since: since,
                 deprecated_since: None,
-                reason: reason
+                reason: reason,
+                issue: issue,
             });
         } else { // "deprecated"
             if deprecated.is_some() {
@@ -501,6 +517,12 @@ fn find_stability_generic<'a,
                                               either stable or unstable attribute");
             }
         }
+    } else if stab.as_ref().map_or(false, |s| s.level == Unstable && s.issue.is_none()) {
+        // non-deprecated unstable items need to point to issues.
+        // FIXME: uncomment this error
+        // diagnostic.span_err(item_sp,
+        //                     "non-deprecated unstable items need to point \
+        //                      to an issue with `issue = \"NNN\"`");
     }
 
     (stab, used_attrs)