Skip to content

Commit 5d52ef5

Browse files
Add tests and longer error explanation
1 parent 44c6861 commit 5d52ef5

File tree

5 files changed

+67
-3
lines changed

5 files changed

+67
-3
lines changed

src/libsyntax_ext/diagnostics.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -15,8 +15,31 @@
1515
// In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
1616
register_long_diagnostics! {
1717
E0660: r##"
18+
The argument to the `asm` macro is not well-formed.
19+
20+
Erroneous code example:
21+
22+
```compile_fail,E0660
23+
asm!("nop" "nop");
24+
```
25+
26+
Considering that this would be a long explanation, we instead recommend you to
27+
take a look at the unstable book:
28+
https://doc.rust-lang.org/unstable-book/language-features/asm.html
1829
"##,
1930

2031
E0661: r##"
32+
An invalid syntax was passed to the second argument of an `asm` macro line.
33+
34+
Erroneous code example:
35+
36+
```compile_fail,E0661
37+
let a;
38+
asm!("nop" : "r"(a));
39+
```
40+
41+
Considering that this would be a long explanation, we instead recommend you to
42+
take a look at the unstable book:
43+
https://doc.rust-lang.org/unstable-book/language-features/asm.html
2144
"##,
2245
}

src/test/compile-fail/issue-21045.rs renamed to src/test/ui/E0660.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
1011
#![feature(asm)]
1112

1213
fn main() {
1314
let a;
14-
asm!("nop" "nop"); //~ ERROR malformed inline assembly
15-
asm!("nop" "nop" : "=r"(a)); //~ ERROR malformed inline assembly
15+
asm!("nop" "nop");
16+
asm!("nop" "nop" : "=r"(a));
1617
}

src/test/ui/E0660.stderr

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0660]: malformed inline assembly
2+
--> $DIR/E0660.rs:15:5
3+
|
4+
LL | asm!("nop" "nop");
5+
| ^^^^^^^^^^^^^^^^^^
6+
7+
error[E0660]: malformed inline assembly
8+
--> $DIR/E0660.rs:16:5
9+
|
10+
LL | asm!("nop" "nop" : "=r"(a));
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0660`.

src/test/ui/E0661.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(asm)]
12+
13+
fn main() {
14+
let a;
15+
asm!("nop" : "r"(a));
16+
}

src/test/ui/E0661.stderr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0661]: output operand constraint lacks '=' or '+'
2+
--> $DIR/E0661.rs:15:18
3+
|
4+
LL | asm!("nop" : "r"(a));
5+
| ^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0661`.

0 commit comments

Comments
 (0)