2020-02-20 03:19:48 -06:00
|
|
|
error: requires at least a template string argument
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:11:9
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!();
|
2021-10-14 13:28:28 -05:00
|
|
|
| ^^^^^^
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
error: asm template must be a string literal
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:13:14
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!(foo);
|
|
|
|
| ^^^
|
|
|
|
|
|
|
|
error: expected token: `,`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:15:19
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}" foo);
|
|
|
|
| ^^^ expected `,`
|
|
|
|
|
2021-07-29 06:43:26 -05:00
|
|
|
error: expected operand, clobber_abi, options, or additional template string
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:17:20
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", foo);
|
2021-07-29 06:43:26 -05:00
|
|
|
| ^^^ expected operand, clobber_abi, options, or additional template string
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
error: expected `(`, found `foo`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:19:23
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", in foo);
|
|
|
|
| ^^^ expected `(`
|
|
|
|
|
|
|
|
error: expected `)`, found `foo`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:21:27
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", in(reg foo));
|
|
|
|
| ^^^ expected `)`
|
|
|
|
|
|
|
|
error: expected expression, found end of macro arguments
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:23:27
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", in(reg));
|
|
|
|
| ^ expected expression
|
|
|
|
|
|
|
|
error: expected register class or explicit register
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:25:26
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", inout(=) foo => bar);
|
|
|
|
| ^
|
|
|
|
|
|
|
|
error: expected expression, found end of macro arguments
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:27:37
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", inout(reg) foo =>);
|
|
|
|
| ^ expected expression
|
|
|
|
|
|
|
|
error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:29:32
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", in(reg) foo => bar);
|
|
|
|
| ^^ expected one of 7 possible tokens
|
|
|
|
|
2022-02-28 18:54:28 -06:00
|
|
|
error: expected a path for argument to `sym`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:31:24
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{}", sym foo + bar);
|
|
|
|
| ^^^^^^^^^
|
|
|
|
|
2021-08-29 19:23:33 -05:00
|
|
|
error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:33:26
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("", options(foo));
|
2021-08-29 19:23:33 -05:00
|
|
|
| ^^^ expected one of 10 possible tokens
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
error: expected one of `)` or `,`, found `foo`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:35:32
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("", options(nomem foo));
|
|
|
|
| ^^^ expected one of `)` or `,`
|
|
|
|
|
2021-08-29 19:23:33 -05:00
|
|
|
error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo`
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:37:33
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("", options(nomem, foo));
|
2021-08-29 19:23:33 -05:00
|
|
|
| ^^^ expected one of 10 possible tokens
|
2020-02-20 03:19:48 -06:00
|
|
|
|
2021-10-14 02:23:09 -05:00
|
|
|
error: at least one abi must be provided as an argument to `clobber_abi`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:44:30
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
2021-10-14 02:23:09 -05:00
|
|
|
LL | asm!("", clobber_abi());
|
|
|
|
| ^
|
|
|
|
|
|
|
|
error: expected string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:46:30
|
2021-10-14 02:23:09 -05:00
|
|
|
|
|
2021-07-29 06:43:26 -05:00
|
|
|
LL | asm!("", clobber_abi(foo));
|
|
|
|
| ^^^ not a string literal
|
|
|
|
|
2021-10-14 02:23:09 -05:00
|
|
|
error: expected one of `)` or `,`, found `foo`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:48:34
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi("C" foo));
|
2021-10-14 02:23:09 -05:00
|
|
|
| ^^^ expected one of `)` or `,`
|
2021-07-29 06:43:26 -05:00
|
|
|
|
2021-10-14 02:23:09 -05:00
|
|
|
error: expected string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:50:35
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi("C", foo));
|
2021-10-14 02:23:09 -05:00
|
|
|
| ^^^ not a string literal
|
2021-07-29 06:43:26 -05:00
|
|
|
|
2023-06-15 16:45:53 -05:00
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:52:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(1));
|
|
|
|
| ^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:54:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(()));
|
|
|
|
| ^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:56:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(uwu));
|
|
|
|
| ^^^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:58:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi({}));
|
|
|
|
| ^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:60:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(loop {}));
|
|
|
|
| ^^^^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:62:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(if));
|
|
|
|
| ^^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:64:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(do));
|
|
|
|
| ^^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:66:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(<));
|
|
|
|
| ^ not a string literal
|
|
|
|
|
|
|
|
error: expected string literal
|
|
|
|
--> $DIR/parse-error.rs:68:30
|
|
|
|
|
|
|
|
|
LL | asm!("", clobber_abi(.));
|
|
|
|
| ^ not a string literal
|
|
|
|
|
2020-02-20 03:19:48 -06:00
|
|
|
error: duplicate argument named `a`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:76:36
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{a}", a = const foo, a = const bar);
|
|
|
|
| ------------- ^^^^^^^^^^^^^ duplicate argument
|
|
|
|
| |
|
|
|
|
| previously here
|
|
|
|
|
|
|
|
error: argument never used
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:76:36
|
2020-02-20 03:19:48 -06:00
|
|
|
|
|
|
|
|
LL | asm!("{a}", a = const foo, a = const bar);
|
|
|
|
| ^^^^^^^^^^^^^ argument never used
|
2020-06-10 19:27:48 -05:00
|
|
|
|
|
|
|
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
|
2020-02-20 03:19:48 -06:00
|
|
|
|
2021-07-29 06:43:26 -05:00
|
|
|
error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:82:29
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
|
|
|
|
LL | asm!("", options(), "");
|
2021-07-29 06:43:26 -05:00
|
|
|
| ^^ expected one of 9 possible tokens
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
2021-07-29 06:43:26 -05:00
|
|
|
error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:84:33
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
|
|
|
|
LL | asm!("{}", in(reg) foo, "{}", out(reg) foo);
|
2021-07-29 06:43:26 -05:00
|
|
|
| ^^^^ expected one of 9 possible tokens
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
|
|
|
error: asm template must be a string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:86:14
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
|
|
|
|
LL | asm!(format!("{{{}}}", 0), in(reg) foo);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2021-02-13 13:52:25 -06:00
|
|
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
|
|
|
error: asm template must be a string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:88:21
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
|
|
|
|
LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2021-02-13 13:52:25 -06:00
|
|
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
asm: Allow multiple template strings; interpret them as newline-separated
Allow the `asm!` macro to accept a series of template arguments, and
interpret them as if they were concatenated with a '\n' between them.
This allows writing an `asm!` where each line of assembly appears in a
separate template string argument.
This syntax makes it possible for rustfmt to reliably format and indent
each line of assembly, without risking changes to the inside of a
template string. It also avoids the complexity of having the user
carefully format and indent a multi-line string (including where to put
the surrounding quotes), and avoids the extra indentation and lines of a
call to `concat!`.
For example, rewriting the second example from the [blog post on the new
inline assembly
syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html)
using multiple template strings:
```rust
fn main() {
let mut bits = [0u8; 64];
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!(
" popcnt {popcnt}, {v}",
"2:",
" blsi rax, {v}",
" jz 1f",
" xor {v}, rax",
" tzcnt rax, rax",
" stosb",
" jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
inout("rdi") bits.as_mut_ptr() => _,
);
}
println!("bits of {}: {:?}", value, &bits[0..popcnt]);
}
}
```
Note that all the template strings must appear before all other
arguments; you cannot, for instance, provide a series of template
strings intermixed with the corresponding operands.
In order to get srcloc mappings right for macros that generate
multi-line string literals, create one line_span for each
line in the string literal, each pointing to the macro.
Make `rustc_parse_format::Parser::curarg` `pub`, so that we can
propagate it from one template string argument to the next.
2020-06-15 01:33:55 -05:00
|
|
|
|
2021-08-21 09:47:24 -05:00
|
|
|
error: _ cannot be used for input operands
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:90:28
|
2021-08-21 09:47:24 -05:00
|
|
|
|
|
|
|
|
LL | asm!("{}", in(reg) _);
|
|
|
|
| ^
|
|
|
|
|
|
|
|
error: _ cannot be used for input operands
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:92:31
|
2021-08-21 09:47:24 -05:00
|
|
|
|
|
|
|
|
LL | asm!("{}", inout(reg) _);
|
|
|
|
| ^
|
|
|
|
|
|
|
|
error: _ cannot be used for input operands
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:94:35
|
2021-08-21 09:47:24 -05:00
|
|
|
|
|
|
|
|
LL | asm!("{}", inlateout(reg) _);
|
|
|
|
| ^
|
|
|
|
|
2021-04-13 12:11:11 -05:00
|
|
|
error: requires at least a template string argument
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:101:1
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!();
|
2021-10-14 13:28:28 -05:00
|
|
|
| ^^^^^^^^^^^^^
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
error: asm template must be a string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:103:13
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!(FOO);
|
|
|
|
| ^^^
|
|
|
|
|
|
|
|
error: expected token: `,`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:105:18
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{}" FOO);
|
|
|
|
| ^^^ expected `,`
|
|
|
|
|
|
|
|
error: expected operand, options, or additional template string
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:107:19
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{}", FOO);
|
|
|
|
| ^^^ expected operand, options, or additional template string
|
|
|
|
|
|
|
|
error: expected expression, found end of macro arguments
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:109:24
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{}", const);
|
|
|
|
| ^ expected expression
|
|
|
|
|
|
|
|
error: expected one of `,`, `.`, `?`, or an operator, found `FOO`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:111:30
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{}", const(reg) FOO);
|
|
|
|
| ^^^ expected one of `,`, `.`, `?`, or an operator
|
|
|
|
|
2022-08-01 23:25:45 -05:00
|
|
|
error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:113:25
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", options(FOO));
|
2022-08-01 23:25:45 -05:00
|
|
|
| ^^^ expected one of `)`, `att_syntax`, or `raw`
|
2021-04-13 12:11:11 -05:00
|
|
|
|
2022-08-01 23:25:45 -05:00
|
|
|
error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:115:25
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", options(nomem FOO));
|
2022-08-01 23:25:45 -05:00
|
|
|
| ^^^^^ expected one of `)`, `att_syntax`, or `raw`
|
2021-04-13 12:11:11 -05:00
|
|
|
|
2022-08-01 23:25:45 -05:00
|
|
|
error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:117:25
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", options(nomem, FOO));
|
2022-08-01 23:25:45 -05:00
|
|
|
| ^^^^^ expected one of `)`, `att_syntax`, or `raw`
|
2021-04-13 12:11:11 -05:00
|
|
|
|
2021-07-29 06:43:26 -05:00
|
|
|
error: expected string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:120:29
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", clobber_abi(FOO));
|
|
|
|
| ^^^ not a string literal
|
|
|
|
|
2021-10-14 02:23:09 -05:00
|
|
|
error: expected one of `)` or `,`, found `FOO`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:122:33
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", clobber_abi("C" FOO));
|
2021-10-14 02:23:09 -05:00
|
|
|
| ^^^ expected one of `)` or `,`
|
2021-07-29 06:43:26 -05:00
|
|
|
|
2021-10-14 02:23:09 -05:00
|
|
|
error: expected string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:124:34
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", clobber_abi("C", FOO));
|
2021-10-14 02:23:09 -05:00
|
|
|
| ^^^ not a string literal
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
error: `clobber_abi` cannot be used with `global_asm!`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:126:19
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{}", clobber_abi("C"), const FOO);
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
2022-12-15 22:20:34 -06:00
|
|
|
error: `clobber_abi` cannot be used with `global_asm!`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:128:28
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", options(), clobber_abi("C"));
|
2022-12-15 22:20:34 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^
|
2021-07-29 06:43:26 -05:00
|
|
|
|
2022-12-15 22:20:34 -06:00
|
|
|
error: `clobber_abi` cannot be used with `global_asm!`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:130:30
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{}", options(), clobber_abi("C"), const FOO);
|
2022-12-15 22:20:34 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^
|
2021-07-29 06:43:26 -05:00
|
|
|
|
2021-10-14 02:23:09 -05:00
|
|
|
error: `clobber_abi` cannot be used with `global_asm!`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:132:17
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", clobber_abi("C"), clobber_abi("C"));
|
2021-10-14 02:23:09 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
|
2021-07-29 06:43:26 -05:00
|
|
|
|
2021-04-13 12:11:11 -05:00
|
|
|
error: duplicate argument named `a`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:134:35
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
|
|
|
| ------------- ^^^^^^^^^^^^^ duplicate argument
|
|
|
|
| |
|
|
|
|
| previously here
|
|
|
|
|
|
|
|
error: argument never used
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:134:35
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
|
|
|
| ^^^^^^^^^^^^^ argument never used
|
|
|
|
|
|
|
|
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
|
|
|
|
|
2022-02-28 18:54:28 -06:00
|
|
|
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:137:28
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("", options(), "");
|
2022-02-28 18:54:28 -06:00
|
|
|
| ^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
|
2021-04-13 12:11:11 -05:00
|
|
|
|
2022-02-28 18:54:28 -06:00
|
|
|
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"`
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:139:30
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{}", const FOO, "{}", const FOO);
|
2022-02-28 18:54:28 -06:00
|
|
|
| ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
error: asm template must be a string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:141:13
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!(format!("{{{}}}", 0), const FOO);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2021-05-13 17:09:54 -05:00
|
|
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
error: asm template must be a string literal
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:143:20
|
2021-04-13 12:11:11 -05:00
|
|
|
|
|
|
|
|
LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2021-05-13 17:09:54 -05:00
|
|
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
2021-04-13 12:11:11 -05:00
|
|
|
|
2021-04-05 23:50:55 -05:00
|
|
|
error[E0435]: attempt to use a non-constant value in a constant
|
2021-12-09 18:15:33 -06:00
|
|
|
--> $DIR/parse-error.rs:39:37
|
2021-04-05 23:50:55 -05:00
|
|
|
|
|
|
|
|
LL | let mut foo = 0;
|
2022-01-15 15:22:22 -06:00
|
|
|
| ----------- help: consider using `const` instead of `let`: `const foo`
|
2021-04-05 23:50:55 -05:00
|
|
|
...
|
|
|
|
LL | asm!("{}", options(), const foo);
|
|
|
|
| ^^^ non-constant value
|
|
|
|
|
|
|
|
error[E0435]: attempt to use a non-constant value in a constant
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:71:44
|
2021-07-29 06:43:26 -05:00
|
|
|
|
|
|
|
|
LL | let mut foo = 0;
|
2022-01-15 15:22:22 -06:00
|
|
|
| ----------- help: consider using `const` instead of `let`: `const foo`
|
2021-07-29 06:43:26 -05:00
|
|
|
...
|
|
|
|
LL | asm!("{}", clobber_abi("C"), const foo);
|
|
|
|
| ^^^ non-constant value
|
|
|
|
|
|
|
|
error[E0435]: attempt to use a non-constant value in a constant
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:74:55
|
2022-12-15 22:20:34 -06:00
|
|
|
|
|
|
|
|
LL | let mut foo = 0;
|
|
|
|
| ----------- help: consider using `const` instead of `let`: `const foo`
|
|
|
|
...
|
|
|
|
LL | asm!("{}", options(), clobber_abi("C"), const foo);
|
|
|
|
| ^^^ non-constant value
|
|
|
|
|
|
|
|
error[E0435]: attempt to use a non-constant value in a constant
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:76:31
|
2021-04-05 23:50:55 -05:00
|
|
|
|
|
|
|
|
LL | let mut foo = 0;
|
2022-01-15 15:22:22 -06:00
|
|
|
| ----------- help: consider using `const` instead of `let`: `const foo`
|
2021-04-05 23:50:55 -05:00
|
|
|
...
|
|
|
|
LL | asm!("{a}", a = const foo, a = const bar);
|
|
|
|
| ^^^ non-constant value
|
|
|
|
|
|
|
|
error[E0435]: attempt to use a non-constant value in a constant
|
2023-06-15 16:45:53 -05:00
|
|
|
--> $DIR/parse-error.rs:76:46
|
2021-04-05 23:50:55 -05:00
|
|
|
|
|
|
|
|
LL | let mut bar = 0;
|
2022-01-15 15:22:22 -06:00
|
|
|
| ----------- help: consider using `const` instead of `let`: `const bar`
|
2021-04-05 23:50:55 -05:00
|
|
|
...
|
|
|
|
LL | asm!("{a}", a = const foo, a = const bar);
|
|
|
|
| ^^^ non-constant value
|
|
|
|
|
2023-06-15 16:45:53 -05:00
|
|
|
error: aborting due to 63 previous errors
|
2020-02-20 03:19:48 -06:00
|
|
|
|
2021-04-05 23:50:55 -05:00
|
|
|
For more information about this error, try `rustc --explain E0435`.
|