about summary refs log tree commit diff
path: root/src/libsyntax/attr.rs
diff options
context:
space:
mode:
authorCameron Hart <cameron.hart@gmail.com>2017-03-25 19:00:49 +1100
committerCameron Hart <cameron.hart@gmail.com>2017-04-21 07:37:10 +1000
commit7971a47eff4b178ffe7c38c67b1926dacea4c0dd (patch)
treee13abfbdef80aa9a36dd5f58dc0d12f2985cedfb /src/libsyntax/attr.rs
parent4358e35fda66ab7a00215c7f9d50e7c6dc9b801b (diff)
downloadrust-7971a47eff4b178ffe7c38c67b1926dacea4c0dd.tar.gz
rust-7971a47eff4b178ffe7c38c67b1926dacea4c0dd.zip
Added feature gate, updated error messages and tests.
Diffstat (limited to 'src/libsyntax/attr.rs')
-rw-r--r--src/libsyntax/attr.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 442345ceb3c..82492d97627 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -972,19 +972,24 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
                 } else if let Some((name, value)) = item.name_value_literal() {
                     if name == "align" {
                         recognised = true;
-                        let mut valid_align = false;
+                        let mut align_error = None;
                         if let ast::LitKind::Int(align, ast::LitIntType::Unsuffixed) = value.node {
                             if align.is_power_of_two() {
                                 // rustc::ty::layout::Align restricts align to <= 32768
                                 if align <= 32768 {
                                     acc.push(ReprAlign(align as u16));
-                                    valid_align = true;
+                                } else {
+                                    align_error = Some("larger than 32768");
                                 }
+                            } else {
+                                align_error = Some("not a power of two");
                             }
+                        } else {
+                            align_error = Some("not an unsuffixed integer");
                         }
-                        if !valid_align {
+                        if let Some(align_error) = align_error {
                             span_err!(diagnostic, item.span, E0589,
-                                      "align representation must be a u16 power of two");
+                                      "invalid `repr(align)` attribute: {}", align_error);
                         }
                     }
                 }