rust/src/test
Manish Goregaokar 9c84c6b836
Rollup merge of #74056 - fusion-engineering-forks:fmt-arguments-as-str, r=Amanieu
Add Arguments::as_str().

There exist quite a few macros in the Rust ecosystem which use `format_args!()` for formatting, but special case the one-argument case for optimization:

```rust
#[macro_export]
macro_rules! some_macro {
    ($s:expr) => { /* print &str directly, no formatting, no buffers */ };
    ($s:expr, $($tt:tt)*) => { /* use format_args to write to a buffer first */ }
}
```

E.g. [here](7a961f0fbe/src/macros.rs (L48-L58)), [here](20f9a9e223/src/macros.rs (L9-L17)), and [here](7b679cd6da/px4/src/logging.rs (L45-L52)).

The problem with these is that a forgotten argument such as in `some_macro!("{}")` will not be diagnosed, but just prints `"{}"`.

With this PR, it is possible to handle the no-arguments case separately *after* `format_args!()`, while simplifying the macro. Then these macros can give the proper error about a missing argument, just like `print!("{}")` does, while still using the same optimized implementation as before.

This is even more important with [RFC 2795](https://github.com/rust-lang/rfcs/pull/2795), to make sure `some_macro!("{some_variable}")` works as expected.
2020-07-17 14:09:06 -07:00
..
assembly Add initial asm!() support for hexagon 2020-06-16 08:58:13 -05:00
auxiliary
codegen Rollup merge of #74171 - ehuss:44056-debug-macos, r=nikomatsakis 2020-07-16 11:18:48 -07:00
codegen-units Change how compiler-builtins gets many CGUs 2020-06-15 07:38:00 -07:00
compile-fail Remove some ignore-stage1 annotations. 2020-07-02 22:29:38 -07:00
debuginfo Modify type names on MSVC to make tuples .natvis compatible. 2020-06-24 19:28:12 -07:00
incremental Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
mir-opt Make fmt::Arguments::as_str() return a 'static str. 2020-07-17 17:56:55 +02:00
pretty Make fmt::Arguments::as_str() return a 'static str. 2020-07-17 17:56:55 +02:00
run-make expand: Stop using nonterminals for passing tokens to attribute and derive macros 2020-07-01 13:13:21 +03:00
run-make-fulldeps Fix various tests to run on windows-gnu 2020-07-17 20:45:29 +02:00
run-pass-valgrind
rustdoc Update src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs 2020-07-16 22:22:48 -07:00
rustdoc-js rustdoc: Fix doc aliases with crate filtering 2020-06-23 09:27:37 +01:00
rustdoc-js-std
rustdoc-ui Fix invalid lint 2020-07-16 18:26:58 -04:00
rustfix
ui Rollup merge of #73930 - a1phyr:feature_const_option, r=dtolnay 2020-07-17 14:09:02 -07:00
ui-fulldeps Avoid "whitelist" 2020-07-10 07:39:28 -04:00
COMPILER_TESTS.md