about summary refs log tree commit diff
path: root/src/libsyntax_ext
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-05-14 20:17:21 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-05-15 14:29:57 +0200
commit30d950231e430d3fc4f6e27f6ebb47e8056dc3f7 (patch)
tree594f03ee9fa45fe37fbee1b430a659cba7d418ef /src/libsyntax_ext
parentcb1ce7ddf8e791faddc9760ca505d513ce1c00c9 (diff)
downloadrust-30d950231e430d3fc4f6e27f6ebb47e8056dc3f7.tar.gz
rust-30d950231e430d3fc4f6e27f6ebb47e8056dc3f7.zip
Add missing error codes in libsyntax-ext asm
Diffstat (limited to 'src/libsyntax_ext')
-rw-r--r--src/libsyntax_ext/asm.rs9
-rw-r--r--src/libsyntax_ext/diagnostics.rs52
2 files changed, 58 insertions, 3 deletions
diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs
index e1eabc5cb01..369c5b1ff60 100644
--- a/src/libsyntax_ext/asm.rs
+++ b/src/libsyntax_ext/asm.rs
@@ -179,9 +179,11 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
                     let (constraint, _str_style) = panictry!(p.parse_str());
 
                     if constraint.as_str().starts_with("=") {
-                        cx.span_err(p.prev_span, "input operand constraint contains '='");
+                        span_err_if_not_stage0!(cx, p.prev_span, E0662,
+                                                "input operand constraint contains '='");
                     } else if constraint.as_str().starts_with("+") {
-                        cx.span_err(p.prev_span, "input operand constraint contains '+'");
+                        span_err_if_not_stage0!(cx, p.prev_span, E0663,
+                                                "input operand constraint contains '+'");
                     }
 
                     panictry!(p.expect(&token::OpenDelim(token::Paren)));
@@ -203,7 +205,8 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
                     if OPTIONS.iter().any(|&opt| s == opt) {
                         cx.span_warn(p.prev_span, "expected a clobber, found an option");
                     } else if s.as_str().starts_with("{") || s.as_str().ends_with("}") {
-                        cx.span_err(p.prev_span, "clobber should not be surrounded by braces");
+                        span_err_if_not_stage0!(cx, p.prev_span, E0664,
+                                                "clobber should not be surrounded by braces");
                     }
 
                     clobs.push(s);
diff --git a/src/libsyntax_ext/diagnostics.rs b/src/libsyntax_ext/diagnostics.rs
index a840c0392e9..33ae24c37e5 100644
--- a/src/libsyntax_ext/diagnostics.rs
+++ b/src/libsyntax_ext/diagnostics.rs
@@ -42,4 +42,56 @@ Considering that this would be a long explanation, we instead recommend you to
 take a look at the unstable book:
 https://doc.rust-lang.org/unstable-book/language-features/asm.html
 "##,
+
+E0662: r##"
+An invalid input operand constraint was passed to the `asm` macro (third line).
+
+Erroneous code example:
+
+```compile_fail,E0662
+asm!("xor %eax, %eax"
+     :
+     : "=test"("a")
+    );
+```
+
+Considering that this would be a long explanation, we instead recommend you to
+take a look at the unstable book:
+https://doc.rust-lang.org/unstable-book/language-features/asm.html
+"##,
+
+E0663: r##"
+An invalid input operand constraint was passed to the `asm` macro (third line).
+
+Erroneous code example:
+
+```compile_fail,E0663
+asm!("xor %eax, %eax"
+     :
+     : "+test"("a")
+    );
+```
+
+Considering that this would be a long explanation, we instead recommend you to
+take a look at the unstable book:
+https://doc.rust-lang.org/unstable-book/language-features/asm.html
+"##,
+
+E0664: r##"
+A clobber was surrounded by braces in the `asm` macro.
+
+Erroneous code example:
+
+```compile_fail,E0663
+asm!("mov $$0x200, %eax"
+     :
+     :
+     : "{eax}"
+    );
+```
+
+Considering that this would be a long explanation, we instead recommend you to
+take a look at the unstable book:
+https://doc.rust-lang.org/unstable-book/language-features/asm.html
+"##,
 }