Commit Graph

123797 Commits

Author SHA1 Message Date
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
Manish Goregaokar
be3b972820
Rollup merge of #74009 - mati865:mingw-tests-implib, r=nikomatsakis
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.
2020-07-17 14:09:04 -07:00
Manish Goregaokar
f6cd31c3b7
Rollup merge of #73930 - a1phyr:feature_const_option, r=dtolnay
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
2020-07-17 14:09:02 -07:00
Manish Goregaokar
3006ea3560
Rollup merge of #71670 - GuillaumeGomez:enforce-codeblocks-attribute-check, r=Mark-Simulacrum
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
2020-07-17 14:08:55 -07:00
Manish Goregaokar
91314e2d27 Use intra-doc links in BTreeSet docs 2020-07-17 14:00:01 -07:00
Marc-Antoine Perennou
4adb13c3a4 rustbuild: drop tool::should_install
Always install when the build succeeds

Fixes #74431

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-07-17 22:11:06 +02:00
Manish Goregaokar
69dab50762 Add test for module ambiguity 2020-07-17 13:04:54 -07:00
Nazım Can Altınova
c45e9c86ca Add a test for const unsafe_unreachable that triggers UB 2020-07-17 22:03:33 +02:00
Nazım Can Altınova
2f28d5945d Add a passing test for const unsafe_unreachable 2020-07-17 22:00:06 +02:00
Nazım Can Altınova
4fefa2c75d Make unreachable_unchecked a const fn 2020-07-17 21:57:13 +02:00
Rich Kadel
a6f8b8a211 Generating the coverage map
rustc now generates the coverage map and can support (limited)
coverage report generation, at the function level.

Example:

$ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu
$ $BUILD/stage1/bin/rustc -Zinstrument-coverage \
$HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs
$ LLVM_PROFILE_FILE="main.profraw" ./main
called
$ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata
$ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main
    1|      1|pub fn will_be_called() {
    2|      1|    println!("called");
    3|      1|}
    4|       |
    5|      0|pub fn will_not_be_called() {
    6|      0|    println!("should not have been called");
    7|      0|}
    8|       |
    9|      1|fn main() {
   10|      1|    let less = 1;
   11|      1|    let more = 100;
   12|      1|
   13|      1|    if less < more {
   14|      1|        will_be_called();
   15|      1|    } else {
   16|      1|        will_not_be_called();
   17|      1|    }
   18|      1|}
2020-07-17 11:49:35 -07:00
Mateusz Mikuła
af1d01ebb3 Fix various tests to run on windows-gnu 2020-07-17 20:45:29 +02:00
Manish Goregaokar
fe98de2a8e intra-doc links: Resolve modules in type namespace 2020-07-17 11:04:36 -07:00
aticu
4127ed1732 Fix Safety docs for from_raw_parts_mut 2020-07-17 19:47:25 +02:00
bors
39d5a61f2e Auto merge of #72983 - Lezzz:rename-typeck, r=nikomatsakis
Rename TypeckTables to TypeckResults.

Originally suggested by @eddyb.
2020-07-17 17:25:09 +00:00
David Wood
95df8024e7
improper_ctypes_definitions: allow Box
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>
2020-07-17 17:55:37 +01:00
Mateusz Mikuła
933a06d8a3 Remove invalid test
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.
2020-07-17 18:07:53 +02:00
Mateusz Mikuła
2a9b51dcc4 Allow matching test by target and env 2020-07-17 18:07:51 +02:00
Mateusz Mikuła
48fe5fcbb8 Create implib for dlls when testing MinGW targets 2020-07-17 18:07:50 +02:00
Mara Bos
9c3353b97c Add tracking issue number for fmt_as_str. 2020-07-17 17:56:55 +02:00
Mara Bos
0c51f53edf Make fmt::Arguments::as_str() return a 'static str. 2020-07-17 17:56:55 +02:00
Bastian Kauschke
0bac36105e add test for #62878 2020-07-17 17:44:11 +02:00
Erik Desjardins
3924672ccc document test changes 2020-07-17 10:53:02 -04:00
Erik Desjardins
2e431c62b6 compare tagged/niche-filling layout and pick the best one 2020-07-17 10:52:57 -04:00
Eduard-Mihai Burtescu
b0a7fbd91f [experiment] ty/layout: compute both niche-filling and tagged layouts for enums. 2020-07-17 10:52:30 -04:00
Alex Macleod
f7979d3c93 Add regression test for #69414
Closes #69414 (no longer ICEs after #74159)
2020-07-17 15:45:50 +01:00
Ralf Jung
87b49764bc warn about uninit multi-variant enums 2020-07-17 16:39:59 +02:00
Jake Goulding
e2b337dc57 Teach bootstrap about target files vs target triples
`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.
2020-07-17 10:08:04 -04:00
bors
3014f23ddd Auto merge of #74439 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/74345
2020-07-17 13:54:21 +00:00
Kristofer Rye
586629c0b6
ci: Replace exec-with-shell wrapper with "plain bash"
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>
2020-07-17 08:44:14 -05:00
Mara Bos
e17c17a1af Make Arguments::as_str() work for empty format strings. 2020-07-17 15:35:59 +02:00
Mara Bos
bc4e33e6c1 Add #[inline] to Arguments::as_str(). 2020-07-17 15:35:59 +02:00
Mara Bos
e73a23fa96 Add Arguments::as_str(). 2020-07-17 15:35:58 +02:00
Kristofer Rye
49f5078048
ci: Stop setting CI_OVERRIDE_SHELL environment variable
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>
2020-07-17 08:29:01 -05:00
Lzu Tao
5ffdd7c565 Deny intra_doc_link_resolution_failure in libcore 2020-07-17 13:25:06 +00:00
Eduard-Mihai Burtescu
b5076fbb96 bootstrap.py: patch RPATH on NixOS to handle the new zlib dependency. 2020-07-17 16:25:05 +03:00
Abendstolz
8aeecc63f8
Fix Arc::as_ptr docs
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)
2020-07-17 15:21:57 +02:00
Ralf Jung
8a917f9873 update Miri 2020-07-17 15:07:15 +02:00
Lzu Tao
67c1e89657 Remove code span for impl
Because the old one is harder to read and confuse typing checkers.
2020-07-17 13:00:50 +00:00
Lzu Tao
1a90ba73fb Link Some(item) 2020-07-17 13:00:50 +00:00
Lzu Tao
3fb3c0c0bd Remove unneeded link for Option 2020-07-17 13:00:50 +00:00
Lzu Tao
a7f067a2a4 Intra-doc for iter Sum and Product traits 2020-07-17 13:00:50 +00:00
Lzu Tao
69f43ddbbe Intra-doc for DoubleEndIterator 2020-07-17 13:00:50 +00:00
Lzu Tao
53a1d6f12f Intra doc for iter marker traits 2020-07-17 13:00:50 +00:00
Lzu Tao
91738d804a Use intra-doc link on Iterator page 2020-07-17 13:00:50 +00:00
Eduard-Mihai Burtescu
d866160b85 bootstrap.py: guard against GC in NixOS patching support. 2020-07-17 15:35:49 +03:00
Valentin Lazureanu
1e6adad33f Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
Guillaume Gomez
83ffd5c18d Fix tidy issues 2020-07-17 10:22:09 +02:00
Guillaume Gomez
3429dedf13 Add tidy checks for rustdoc css files 2020-07-17 10:14:58 +02:00
Guillaume Gomez
6969b30996 Convert whitespaces to tabs 2020-07-17 10:14:58 +02:00