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.
Fix MinGW `run-make-fulldeps` tests
`compiler-rt-works-on-mingw` and `libs-search-path` were not ran because `only-mingw` doesn't match any target.
Enabled and verified few ignored tests with `windows-gnu` toolchain. They are still ignored on MSVC since I'm not experienced with this target.
Make some Option methods const
Tracking issue: #67441
Constantify the following methods of `Option`:
- `as_ref`
- `is_some`
- `is_none`
- `iter` (not sure about this one, but it is possible, and will be useful when const traits are a thing)
cc @rust-lang/wg-const-eval @rust-lang/libs
Enforce even more the code blocks attributes check through rustdoc
`rustdoc` now has a lint which allows it to warn if a code block attribute is malformated (which can end up in bad situations, even more in case of testing examples!). Now it'll fail if such a situation is encountered when testing markdown code blocks examples.
r? @Mark-Simulacrum
This commit stops linting against `Box` in `extern "C" fn`s for the
`improper_ctypes_definitions` lint - boxes are documented to be
FFI-safe.
Signed-off-by: David Wood <david@davidtw.co>
When ran on Windows `cp` will follow symlink: `checkout/build/<target>/<stage>/lib/rustlib/src/rust`.
It points to `checkout` which means the test will get stuck in copying loop until there is no space left.
`rustc` allows passing in predefined target triples as well as JSON
target specification files. This change allows bootstrap to have the
first inkling about those differences. This allows building a
cross-compiler for an out-of-tree architecture (even though that
compiler won't work for other reasons).
Even if no one ever uses this functionality, I think the newtype
around the `Interned<String>` improves the readability of the code.
Also, promote defaults.run.shell from inside only the primary jobs to
the top level.
The src/ci/exec-with-shell.py wrapper script was formerly used to change
out the shell mid-job by intercepting a CI_OVERRIDE_SHELL environment
variable. Now, instead, we just set `bash` as the global default across
all jobs, and we also delete the exec-with-shell.py script.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
This will render the src/ci/exec-with-shell.py script more or less
useless, but we're going to replace that by just using the system bash
instead.
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
As a none-native speaker I stumbled upon this, looked it up and couldn't find a phrase, so I made my own assumption that "in any way" was meant (which is the meaning I would've deduced anyway)