Commit graph

132437 commits

Author SHA1 Message Date
bors e8cbaf2ae7 Auto merge of #78623 - m-ou-se:rollup-m6y5j0m, r=m-ou-se
Rollup of 6 pull requests

Successful merges:

 - #78073 (Add #[inline] to some functions in core::str.)
 - #78596 (Fix doc links to std::fmt)
 - #78599 (Add note to process::arg[s] that args shouldn't be escaped or quoted)
 - #78602 (fix various aliasing issues in the standard library)
 - #78603 (expand: Tweak a comment in implementation of `macro_rules`)
 - #78621 (Inline Default::default() for atomics)

Failed merges:

r? `@ghost`
2020-11-01 11:54:58 +00:00
Mara Bos 97678b8358
Rollup merge of #78621 - solson:inline, r=m-ou-se
Inline Default::default() for atomics

Functions like `AtomicUsize::default()` are not cross-crate inlineable before this PR ([see assembly output here](https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=e353321766418f759c69fb141d3732f8)), which can lead to unexpected performance issues when initializing a large array using this function, e.g. as seen [here](d513996a85/src/histogram.rs (L53)) which should turn into a simple loop writing zeroes but doesn't.

r? @m-ou-se
2020-11-01 11:53:39 +01:00
Mara Bos 540d4743cc
Rollup merge of #78603 - petrochenkov:fourdigits, r=matthewjasper
expand: Tweak a comment in implementation of `macro_rules`

The answer to the removed FIXME is that we don't apply mark to the span `sp` just because that span is no longer used. We could apply it, but that would just be unnecessary extra work.

The comments in code tell why the span is unused, it's a span of `$var` literally, which is lost for `tt` variables because their tokens are outputted directly, but kept for other variables which are outputted as [groups](https://doc.rust-lang.org/nightly/proc_macro/struct.Group.html) and `sp` is kept as the group's span.

Closes https://github.com/rust-lang/rust/issues/2887
2020-11-01 11:53:37 +01:00
Mara Bos 8ed31d2782
Rollup merge of #78602 - RalfJung:raw-ptr-aliasing-issues, r=m-ou-se
fix various aliasing issues in the standard library

This fixes various cases where the standard library either used raw pointers after they were already invalidated by using the original reference again, or created raw pointers for one element of a slice and used it to access neighboring elements.
2020-11-01 11:53:36 +01:00
Mara Bos f281a76f83
Rollup merge of #78599 - panstromek:master, r=m-ou-se
Add note to process::arg[s] that args shouldn't be escaped or quoted

This came out of discussion on [forum](https://users.rust-lang.org/t/how-to-get-full-output-from-command/50626), where I recently asked a question and it turned out that the problem was redundant quotation:

```rust
 Command::new("rg")
        .arg("\"pattern\"") // this will look for "pattern" with quotes included
```

This is something that has bitten me few times already (in multiple languages actually), so It'd be grateful to have it in the docs, even though it's not sctrictly Rust specific problem. Other users also agreed.

This can be really annoying to debug, because in many cases (inluding mine), quotes can be legal part of the argument, so the command doesn't fail, it just behaves unexpectedly. Not everybody (including me) knows that quotes around arguments are part of the shell and not part of the called program. Coincidentally, somoene had the same problem [yesterday](https://www.reddit.com/r/rust/comments/jkxelc/going_crazy_over_running_a_curl_process_from_rust/) on reddit.

I am not a native speaker, so I welcome any corrections or better formulation, I don't expect this to be merged as is. I was also reminded that this is platform/shell specific behaviour, but I didn't find a good way to formulate that briefly, any ideas welcome.

 It's also my first PR here, so I am not sure I did everything correctly, I did this just from Github UI.
2020-11-01 11:53:34 +01:00
Mara Bos 25eac92987
Rollup merge of #78596 - pavlukivan:master, r=m-ou-se
Fix doc links to std::fmt

`std::format` and `core::write` macros' docs linked to `core::fmt` for format string reference, even though only `std::fmt` has format string documentation (and the link titles were `std::fmt`)
2020-11-01 11:53:33 +01:00
Mara Bos 835310e3cc
Rollup merge of #78073 - fusion-engineering-forks:inline, r=eddyb
Add #[inline] to some functions in core::str.

Almost all str functions already had #[inline].
2020-11-01 11:53:29 +01:00
bors 1e37ba76d4 Auto merge of #78531 - cuviper:unwrap-metadata, r=tmandry
rustc_llvm: unwrap LLVMMetadataRef before casting

Directly casting the opaque pointer was [reported] to cause an
"incomplete type" error with GCC 9.3:

```
llvm-wrapper/RustWrapper.cpp:939:31:   required from here
/usr/include/c++/9.3/type_traits:1301:12: error: invalid use of incomplete type 'struct LLVMOpaqueMetadata'
 1301 |     struct is_base_of
      |            ^~~~~~~~~~
In file included from [...]/rust/src/llvm-project/llvm/include/llvm-c/BitReader.h:23,
                 from llvm-wrapper/LLVMWrapper.h:1,
                 from llvm-wrapper/RustWrapper.cpp:1:
[...]/rust/src/llvm-project/llvm/include/llvm-c/Types.h:89:16: note: forward declaration of 'struct LLVMOpaqueMetadata'
   89 | typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
      |                ^~~~~~~~~~~~~~~~~~
```

[reported]: https://zulip-archive.rust-lang.org/182449tcompilerhelp/12215halprustcllvmbuildfail.html#214915124

A simple `unwrap` fixes the issue.

r? `@eddyb`
2020-11-01 09:30:11 +00:00
bors 1d5b7c3c96 Auto merge of #78420 - estebank:suggest-assoc-fn, r=petrochenkov
Suggest calling associated `fn` inside `trait`s

When calling a function that doesn't exist inside of a trait's
associated `fn`, and another associated `fn` in that trait has that
name, suggest calling it with the appropriate fully-qualified path.

Expand the label to be more descriptive.

Prompted by the following user experience:
https://users.rust-lang.org/t/cannot-find-function/50663
2020-11-01 06:49:16 +00:00
Scott Olson e5b1f69d63 Inline Default::default() for atomics 2020-11-01 04:38:41 +00:00
bors a6403b0f04 Auto merge of #78147 - tmiasko:validate-storage, r=jonas-schievink
Assert that locals have storage when used

The validator in visit_local asserts that local has a stroage when used,
but visit_local is never called so validation is ineffective.

Use super_statement and super_terminator to ensure that locals are visited.
2020-11-01 01:27:15 +00:00
Tomasz Miąsko 3b7157dc1a Assert that locals have storage when used
The validator in visit_local asserts that local has a stroage when used,
but visit_local is never called so validation is ineffective.

Use super_statement and super_terminator to ensure that locals are visited.
2020-10-31 21:06:29 +01:00
bors 4f7612ac14 Auto merge of #78594 - m-ou-se:rollup-h5c8frs, r=m-ou-se
Rollup of 7 pull requests

Successful merges:

 - #74622 (Add std::panic::panic_any.)
 - #77099 (make exp_m1 and ln_1p examples more representative of use)
 - #78526 (Strip tokens from trait and impl items before printing AST JSON)
 - #78550 (x.py setup: Create config.toml in the current directory, not the top-level directory)
 - #78577 (validator: Extend aliasing check to a call terminator)
 - #78581 (Constantify more BTreeMap and BTreeSet functions)
 - #78587 (parser: Cleanup `LazyTokenStream` and avoid some clones)

Failed merges:

r? `@ghost`
2020-10-31 17:09:38 +00:00
Matyáš Racek db416b232c
Apply suggestions from code review
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2020-10-31 17:28:44 +01:00
Ralf Jung 9749eb72af fix aliasing issues in SipHasher 2020-10-31 16:26:06 +01:00
Ralf Jung 607076e209 fix aliasing issue in binary_heap 2020-10-31 16:26:06 +01:00
Ralf Jung 9f630af930 fix aliasing issue in unix sleep function 2020-10-31 16:26:06 +01:00
Ralf Jung ed96321e7e fix aliasing issues in u128 formatting code 2020-10-31 16:26:06 +01:00
Vadim Petrochenkov 7652bc3f68 expand: Tweak a comment in implementation of macro_rules 2020-10-31 18:13:46 +03:00
Matyáš Racek d417bbef95
Add note to process::arg[s] that args shouldn't be escaped or quoted 2020-10-31 14:40:36 +01:00
Ivan Pavluk 3baf6a4a74 Fix doc links to std::fmt
std::format and core::write macros' docs linked to core::fmt for format string reference, even though only std::fmt has format string documentation and the link titles were std::fmt.
2020-10-31 18:02:55 +07:00
Mara Bos 1873ca55b3
Rollup merge of #78587 - petrochenkov:lazytok, r=Aaron1011
parser: Cleanup `LazyTokenStream` and avoid some clones

by using a named struct instead of a closure.

r? @Aaron1011
2020-10-31 09:49:41 +01:00
Mara Bos 3601f9d40b
Rollup merge of #78581 - a1phyr:const_btree_more, r=dtolnay
Constantify more BTreeMap and BTreeSet functions

Just because we can:

- `BTreeMap::len`
- `BTreeMap::is_empty`
- `BTreeSet::len`
- `BTreeSet::is_empty`

Note that I put the `const` under `const_btree_new`, because I don't think their is a need to create another feature flag for that.

cc #71835
2020-10-31 09:49:39 +01:00
Mara Bos 841f0e7f2c
Rollup merge of #78577 - tmiasko:validate-aliasing, r=jonas-schievink
validator: Extend aliasing check to a call terminator
2020-10-31 09:49:38 +01:00
Mara Bos c0f356d28f
Rollup merge of #78550 - jyn514:setup, r=Mark-Simulacrum
x.py setup: Create config.toml in the current directory, not the top-level directory

See https://github.com/rust-lang/rust/issues/78509 for discussion.

r? @pnkfelix
cc @cuviper @Mark-Simulacrum
2020-10-31 09:49:36 +01:00
Mara Bos 89aea55a7d
Rollup merge of #78526 - Aaron1011:fix/assoc-tokens, r=estebank
Strip tokens from trait and impl items before printing AST JSON

Fixes #78510
2020-10-31 09:49:34 +01:00
Mara Bos 4ebd5536b4
Rollup merge of #77099 - tspiteri:exp_m1-examples, r=m-ou-se
make exp_m1 and ln_1p examples more representative of use

With this PR, the examples for `exp_m1` would fail if `x.exp() - 1.0` is used instead of `x.exp_m1()`, and the examples for `ln_1p` would fail if `(x + 1.0).ln()` is used instead of `x.ln_1p()`.
2020-10-31 09:49:32 +01:00
Mara Bos 76b8b00b4f
Rollup merge of #74622 - fusion-engineering-forks:panic-box, r=KodrAus
Add std::panic::panic_any.

The discussion of #67984 lead to the conclusion that there should be a macro or function separate from `std::panic!()` for throwing arbitrary payloads, to make it possible to deprecate or disallow (in edition 2021) `std::panic!(arbitrary_payload)`.

Alternative names:

- `panic_with!(..)`
- ~~`start_unwind(..)`~~ (panicking doesn't always unwind)
- `throw!(..)`
- `panic_throwing!(..)`
- `panic_with_value(..)`
- `panic_value(..)`
- `panic_with(..)`
- `panic_box(..)`
- `panic(..)`

The equivalent (private, unstable) function in `libstd` is called `std::panicking::begin_panic`.

I suggest `panic_any`, because it allows for any (`Any + Send`) type.

_Tracking issue: #78500_
2020-10-31 09:49:28 +01:00
bors 3478d7c360 Auto merge of #76257 - JulianKnodt:i75777, r=Dylan-DPC
Add regression test

This adds a regression test for #75777, effectively closing it since it is solved on nightly and beta.

Closes #75777
2020-10-31 01:34:49 +00:00
Vadim Petrochenkov d0c63bccc5 parser: Cleanup LazyTokenStream and avoid some clones
by using a named struct instead of a closure.
2020-10-31 01:56:34 +03:00
bors 0d033dee3e Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk
TypeVisitor: use `std::ops::ControlFlow` instead of `bool`

Implements MCP rust-lang/compiler-team#374.

Blocked on FCP in rust-lang/compiler-team#374.
r? `@lcnr` cc `@jonas-schievink`
2020-10-30 22:53:55 +00:00
Benoît du Garreau 307cc11beb Constantify more BTreeMap and BTreeSet functions
- BTreeMap::len
- BTreeMap::is_empty
- BTreeSet::len
- BTreeSet::is_empty
2020-10-30 19:24:08 +01:00
bors ffe52882ed Auto merge of #78424 - jyn514:THE-PAPERCLIP-COMETH, r=davidtwco
Fix some more clippy warnings

Found while working on https://github.com/rust-lang/rust/pull/77351. It turns out that `x.py clippy --fix` does work on that branch as long as you pass `CARGOFLAGS=--lib`.
2020-10-30 14:24:02 +00:00
Joshua Nelson 5339bd1ebe Add back missing comments 2020-10-30 10:13:41 -04:00
Joshua Nelson 57c6ed0c07 Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
Joshua Nelson bfecb18771 Fix some more clippy warnings 2020-10-30 10:12:56 -04:00
LeSeulArtichaut 9433eb83fe Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut 24e1a7e656 Use ControlFlow::is{break,continue} 2020-10-30 12:27:46 +01:00
LeSeulArtichaut 8e4cf0b3ed TypeVisitor: use ControlFlow in clippy 2020-10-30 12:27:45 +01:00
LeSeulArtichaut 61f8182cec TypeVisitor: use ControlFlow in rustc_{mir,privacy,traits,typeck} 2020-10-30 12:27:44 +01:00
LeSeulArtichaut 4fe735b320 TypeVisitor: use ControlFlow in rustc_{infer,lint,trait_selection} 2020-10-30 12:27:34 +01:00
LeSeulArtichaut 2c85b6fae0 TypeVisitor: use std::ops::ControlFlow instead of bool 2020-10-30 12:25:24 +01:00
bors 388ef34904 Auto merge of #78562 - JohnTitor:rollup-otg906u, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #77334 (Reorder benches const variable)
 - #77888 (Simplify a nested bool match)
 - #77921 (f64: Refactor collapsible_if)
 - #78523 (Revert invalid `fn` return type parsing change)
 - #78524 (Avoid BorrowMutError with RUSTC_LOG=debug)
 - #78545 (Make anonymous binders start at 0)
 - #78554 (Improve wording of `core::ptr::drop_in_place` docs)
 - #78556 (Link to pass docs from NRVO module docs)

Failed merges:

 - #78424 (Fix some more clippy warnings)

r? `@ghost`
2020-10-30 10:01:49 +00:00
Yuki Okushi 2471a7cdaa
Rollup merge of #78556 - camelid:mir-opt-nrvo-docs, r=jyn514
Link to pass docs from NRVO module docs

It can be easy to miss that this is documented on the pass's struct if you are
looking at the module docs.

Cc https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/what.20is.20NRVO.3F
2020-10-30 18:00:58 +09:00
Yuki Okushi 73d0340fd5
Rollup merge of #78554 - camelid:improve-drop_in_place-docs-wording, r=jyn514
Improve wording of `core::ptr::drop_in_place` docs

And two small intra-doc link conversions in `std::{f32, f64}`.
2020-10-30 18:00:58 +09:00
Yuki Okushi 05f80f03a9
Rollup merge of #78545 - jackh726:anonymous, r=oli-obk
Make anonymous binders start at 0

A few changes to some test outputs, but these actually look *more* correct to me.
2020-10-30 18:00:56 +09:00
Yuki Okushi f8539221d0
Rollup merge of #78524 - tmiasko:source-files-borrow, r=Aaron1011
Avoid BorrowMutError with RUSTC_LOG=debug

```console
$ touch empty.rs
$ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs
```

Fails with a `BorrowMutError` because source map files are already
borrowed while `features_query` attempts to format a log message
containing a span.

Release the borrow before the query to avoid the issue.
2020-10-30 18:00:54 +09:00
Yuki Okushi 8111706c18
Rollup merge of #78523 - estebank:fix-return-type-parse-regression, r=dtolnay
Revert invalid `fn` return type parsing change

Revert one of the changes in #78379.

Fix #78507.
2020-10-30 18:00:53 +09:00
Yuki Okushi 02a4b58a3f
Rollup merge of #77921 - wcampbell0x2a:f64-collapsible-if, r=jyn514
f64: Refactor collapsible_if
2020-10-30 18:00:49 +09:00
Yuki Okushi 439ea4b621
Rollup merge of #77888 - LingMan:ast_pretty_tt_prepend_space, r=jyn514
Simplify a nested bool match

Logically this first eliminates the innermost match by merging the patterns.
Then, in a second step, turns the newly innermost match into a `matches!` call.
2020-10-30 18:00:45 +09:00