rust/src/test/pretty
Josh Triplett 1078b6f942 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 12:35:27 -07:00
..
auxiliary Remove licenses 2018-12-25 21:08:33 -07:00
asm.pp asm: Allow multiple template strings; interpret them as newline-separated 2020-06-15 12:35:27 -07:00
asm.rs asm: Allow multiple template strings; interpret them as newline-separated 2020-06-15 12:35:27 -07:00
ast-stmt-expr-attr.rs ast_stmt_expr_attr -> pretty & ui tests 2019-12-20 22:53:40 +01:00
attr-derive.rs Remove licenses 2018-12-25 21:08:33 -07:00
attr-fn-inner.rs Introduce #[rustc_dummy] attribute and use it in tests 2019-06-08 23:55:25 +03:00
attr-literals.rs Update pretty tests 2020-03-17 20:58:31 +01:00
attr-tokens-raw-ident.rs pprust: Do not convert attributes into MetaItems for printing 2019-07-15 12:42:07 +03:00
auto-trait.rs Remove licenses 2018-12-25 21:08:33 -07:00
blank-lines.rs Remove licenses 2018-12-25 21:08:33 -07:00
block-comment-multiple-asterisks.rs Remove licenses 2018-12-25 21:08:33 -07:00
block-comment-trailing-whitespace.rs Remove licenses 2018-12-25 21:08:33 -07:00
block-comment-trailing-whitespace2.rs Remove licenses 2018-12-25 21:08:33 -07:00
block-comment-wchar.pp pprust: Do not print spaces before some tokens 2019-08-25 21:23:17 +03:00
block-comment-wchar.rs Remove licenses 2018-12-25 21:08:33 -07:00
block-disambig.rs Remove licenses 2018-12-25 21:08:33 -07:00
cast-lt.pp pprust: Fix formatting regressions from the previous commits 2019-07-15 12:42:07 +03:00
cast-lt.rs Remove licenses 2018-12-25 21:08:33 -07:00
closure-reform-pretty.rs Remove licenses 2018-12-25 21:08:33 -07:00
delimited-token-groups.rs Update pretty tests 2020-03-17 20:58:31 +01:00
disamb-stmt-expr.rs Remove licenses 2018-12-25 21:08:33 -07:00
do1.rs pprust: Do not print spaces before some tokens 2019-08-25 21:23:17 +03:00
doc-comments.rs Remove licenses 2018-12-25 21:08:33 -07:00
dollar-crate.pp resolve: Remove remaining special cases from built-in macros 2019-08-10 21:50:56 +03:00
dollar-crate.rs Pretty print $crate as crate or crate_name in more cases 2019-01-26 17:11:28 +03:00
empty-impl.rs Remove licenses 2018-12-25 21:08:33 -07:00
empty-lines.rs Remove licenses 2018-12-25 21:08:33 -07:00
enum-variant-vis.rs Print the visibility in print_variant. 2019-12-07 05:59:41 +01:00
example1.rs Remove licenses 2018-12-25 21:08:33 -07:00
example2.pp Remove licenses 2018-12-25 21:08:33 -07:00
example2.rs Remove licenses 2018-12-25 21:08:33 -07:00
fn-return.rs Remove licenses 2018-12-25 21:08:33 -07:00
fn-types.rs Remove licenses 2018-12-25 21:08:33 -07:00
fn-variadic.rs Nit 2019-03-03 02:58:09 +00:00
for-comment.rs Remove licenses 2018-12-25 21:08:33 -07:00
gat-bounds.rs print vis & defaultness for nested items 2020-02-21 18:30:56 +01:00
if-attr.rs Extent pretty-print test 2020-03-04 16:43:14 -05:00
import-renames.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-4264.pp Update tests for erasing regions in typeck 2020-03-17 09:07:56 +00:00
issue-4264.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-12590-a.rs use pretty-compare-only in a test 2020-03-18 15:08:25 +01:00
issue-12590-b.rs Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
issue-12590-c.pp Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
issue-12590-c.rs Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
issue-19077.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-25031.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-30731.rs pprust: Fix formatting regressions from the previous commits 2019-07-15 12:42:07 +03:00
issue-31073.pp Remove licenses 2018-12-25 21:08:33 -07:00
issue-31073.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-68710-field-attr-proc-mac-lost.rs Update pretty tests 2020-03-17 20:58:31 +01:00
let.rs Remove licenses 2018-12-25 21:08:33 -07:00
lifetime.rs Remove licenses 2018-12-25 21:08:33 -07:00
llvm-asm-clobbers.rs Add tests for asm! 2020-05-18 14:41:32 +01:00
llvm-asm-options.rs Add tests for asm! 2020-05-18 14:41:32 +01:00
macro.rs Print visibility of macro items 2019-09-15 10:22:13 +01:00
match-block-expr.rs pprust: Do not print spaces before some tokens 2019-08-25 21:23:17 +03:00
match-naked-expr-medium.rs Remove licenses 2018-12-25 21:08:33 -07:00
match-naked-expr.rs Remove licenses 2018-12-25 21:08:33 -07:00
nested-item-vis-defaultness.rs print vis & defaultness for nested items 2020-02-21 18:30:56 +01:00
path-type-bounds.rs Remove licenses 2018-12-25 21:08:33 -07:00
raw-address-of.rs Add more tests for raw_ref_op 2019-12-18 20:30:00 +00:00
raw-str-nonexpr.rs Update tests to use llvm_asm! 2020-03-26 15:49:22 +00:00
stmt_expr_attributes.rs Remove meaningless comments in src/test 2019-08-16 10:54:20 +01:00
struct-pattern.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-tuple.rs Remove licenses 2018-12-25 21:08:33 -07:00
tag-blank-lines.rs Remove licenses 2018-12-25 21:08:33 -07:00
top-level-doc-comments.rs Remove unused ignore-license directives 2020-01-24 00:00:00 +00:00
trait-inner-attr.rs parser: unify item list parsing. 2020-02-13 15:16:29 +01:00
trait-polarity.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
trait-safety.rs Remove licenses 2018-12-25 21:08:33 -07:00
unary-op-disambig.rs Remove licenses 2018-12-25 21:08:33 -07:00
vec-comments.pp Remove licenses 2018-12-25 21:08:33 -07:00
vec-comments.rs Remove licenses 2018-12-25 21:08:33 -07:00
where-clauses.rs Remove licenses 2018-12-25 21:08:33 -07:00