]> git.lizzy.rs Git - rust.git/commitdiff
Add tests and longer error explanation
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 26 Mar 2018 20:04:27 +0000 (22:04 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 14 Apr 2018 15:25:35 +0000 (17:25 +0200)
src/libsyntax_ext/diagnostics.rs
src/test/compile-fail/issue-21045.rs [deleted file]
src/test/ui/E0660.rs [new file with mode: 0644]
src/test/ui/E0660.stderr [new file with mode: 0644]
src/test/ui/E0661.rs [new file with mode: 0644]
src/test/ui/E0661.stderr [new file with mode: 0644]

index e247a22aeb073b373a2a62c56b6b17c8bf5de5b8..a840c0392e9fe7cc663fd1a9bc85814a4bb4f98d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
 // In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
 register_long_diagnostics! {
 E0660: r##"
+The argument to the `asm` macro is not well-formed.
+
+Erroneous code example:
+
+```compile_fail,E0660
+asm!("nop" "nop");
+```
+
+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
 "##,
 
 E0661: r##"
+An invalid syntax was passed to the second argument of an `asm` macro line.
+
+Erroneous code example:
+
+```compile_fail,E0661
+let a;
+asm!("nop" : "r"(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
 "##,
 }
diff --git a/src/test/compile-fail/issue-21045.rs b/src/test/compile-fail/issue-21045.rs
deleted file mode 100644 (file)
index 134240f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-#![feature(asm)]
-
-fn main() {
-    let a;
-    asm!("nop" "nop"); //~ ERROR malformed inline assembly
-    asm!("nop" "nop" : "=r"(a)); //~ ERROR malformed inline assembly
-}
diff --git a/src/test/ui/E0660.rs b/src/test/ui/E0660.rs
new file mode 100644 (file)
index 0000000..dbea0c8
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(asm)]
+
+fn main() {
+    let a;
+    asm!("nop" "nop");
+    asm!("nop" "nop" : "=r"(a));
+}
diff --git a/src/test/ui/E0660.stderr b/src/test/ui/E0660.stderr
new file mode 100644 (file)
index 0000000..0ef8fc4
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0660]: malformed inline assembly
+  --> $DIR/E0660.rs:15:5
+   |
+LL |     asm!("nop" "nop");
+   |     ^^^^^^^^^^^^^^^^^^
+
+error[E0660]: malformed inline assembly
+  --> $DIR/E0660.rs:16:5
+   |
+LL |     asm!("nop" "nop" : "=r"(a));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0660`.
diff --git a/src/test/ui/E0661.rs b/src/test/ui/E0661.rs
new file mode 100644 (file)
index 0000000..be932a0
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(asm)]
+
+fn main() {
+    let a;
+    asm!("nop" : "r"(a));
+}
diff --git a/src/test/ui/E0661.stderr b/src/test/ui/E0661.stderr
new file mode 100644 (file)
index 0000000..90aeca5
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0661]: output operand constraint lacks '=' or '+'
+  --> $DIR/E0661.rs:15:18
+   |
+LL |     asm!("nop" : "r"(a));
+   |                  ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0661`.