bors [Sun, 14 Feb 2021 04:53:24 +0000 (04:53 +0000)]
Auto merge of #81956 - ssomers:btree_post_75200, r=Mark-Simulacrum
BTree: remove outdated traces of coercions
The introduction of `marker::ValMut` (#75200) meant iterators no longer see mutable keys but their code still pretends it does. And settle on the majority style `Some(unsafe {…})` over `unsafe { Some(…) }`.
bors [Sat, 13 Feb 2021 20:30:07 +0000 (20:30 +0000)]
Auto merge of #81238 - RalfJung:copy-intrinsics, r=m-ou-se
directly expose copy and copy_nonoverlapping intrinsics
This effectively un-does https://github.com/rust-lang/rust/pull/57997. That should help with `ptr::read` codegen in debug builds (and any other of these low-level functions that bottoms out at `copy`/`copy_nonoverlapping`), where the wrapper function will not get inlined. See the discussion in https://github.com/rust-lang/rust/pull/80290 and https://github.com/rust-lang/rust/issues/81163.
bors [Sat, 13 Feb 2021 17:29:22 +0000 (17:29 +0000)]
Auto merge of #81494 - cuviper:btree-node-init, r=Mark-Simulacrum
Initialize BTree nodes directly in the heap
We can avoid any stack-local nodes entirely by using `Box::new_uninit`, and since the nodes are mostly `MaybeUninit` fields, we only need a couple of actual writes before `assume_init`. This should help with the stack overflows in #81444, and may also improve performance in general.
Aaron Hill [Fri, 22 Jan 2021 18:28:08 +0000 (13:28 -0500)]
Require passing an `AttrWrapper` to `collect_tokens_trailing_token`
This is a pure refactoring split out from #80689.
It represents the most invasive part of that PR, requiring changes in
every caller of `parse_outer_attributes`
In order to eagerly expand `#[cfg]` attributes while preserving the
original `TokenStream`, we need to know the range of tokens that
corresponds to every attribute target. This is accomplished by making
`parse_outer_attributes` return an opaque `AttrWrapper` struct. An
`AttrWrapper` must be converted to a plain `AttrVec` by passing it to
`collect_tokens_trailing_token`. This makes it difficult to accidentally
construct an AST node with attributes without calling `collect_tokens_trailing_token`,
since AST nodes store an `AttrVec`, not an `AttrWrapper`.
As a result, we now call `collect_tokens_trailing_token` for attribute
targets which only support inert attributes, such as generic arguments
and struct fields. Currently, the constructed `LazyTokenStream` is
simply discarded. Future PRs will record the token range corresponding
to the attribute target, allowing those tokens to be removed from an
enclosing `collect_tokens_trailing_token` call if necessary.
bors [Sat, 13 Feb 2021 07:58:44 +0000 (07:58 +0000)]
Auto merge of #82053 - JohnTitor:rollup-ymi9q0g, r=JohnTitor
Rollup of 8 pull requests
Successful merges:
- #81811 (Fix doc test for Vec::retain(), now passes clippy::eval_order_dependence)
- #81900 (Organize trait test files)
- #81995 (Fix suggestion to introduce explicit lifetime)
- #82031 (Drop an unnecessary intermediate variable)
- #82033 (Refactor `get_word_attr` to return only `Option`)
- #82040 (Add test to prevent src link regression)
- #82041 (Add docs for shared_from_slice From impls)
- #82050 (Added tests to drain an empty vec)
Yuki Okushi [Sat, 13 Feb 2021 07:36:48 +0000 (16:36 +0900)]
Rollup merge of #82033 - magurotuna:issue82016, r=jyn514
Refactor `get_word_attr` to return only `Option`
This commit removes `bool` from the return type of `NestedAttributesExt::get_word_attr` so it will return only `Option<ast::NestedMetaItem>` for less redundancy.
Yuki Okushi [Sat, 13 Feb 2021 07:36:46 +0000 (16:36 +0900)]
Rollup merge of #81995 - 0yoyoyo:fix-issue-81650-explicit-lifetime-error, r=estebank
Fix suggestion to introduce explicit lifetime
Addresses #81650
Error message after fix:
```
error[E0311]: the parameter type `T` may not live long enough
--> src/main.rs:25:11
|
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
| -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 | scope.spawn(move |_| {
| ^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 24:1...
--> src/main.rs:24:1
|
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
--> src/main.rs:25:11
|
25 | scope.spawn(move |_| {
| ^^^^^
```
Yuki Okushi [Sat, 13 Feb 2021 07:36:40 +0000 (16:36 +0900)]
Rollup merge of #81811 - schteve:fix_vec_retain_doc_test, r=m-ou-se
Fix doc test for Vec::retain(), now passes clippy::eval_order_dependence
Doc test for Vec::retain() works correctly but is flagged by clippy::eval_order_dependence. Fix avoids the issue by using an iterator instead of an index.
bors [Sat, 13 Feb 2021 02:46:57 +0000 (02:46 +0000)]
Auto merge of #82045 - Dylan-DPC:rollup-244l0sb, r=Dylan-DPC
Rollup of 10 pull requests
Successful merges:
- #79775 (Fix injected errors when running doctests on a crate named after a keyword)
- #81012 (Stabilize the partition_point feature)
- #81479 (Allow casting mut array ref to mut ptr)
- #81506 (HWAddressSanitizer support)
- #81741 (Increment `self.index` before calling `Iterator::self.a.__iterator_ge…)
- #81850 (use RWlock when accessing os::env)
- #81911 (GAT/const_generics: Allow with_opt_const_param to return GAT param def_id)
- #82022 (Push a `char` instead of a `str` with len one into a String)
- #82023 (Remove unnecessary lint allow attrs on example)
- #82030 (Use `Iterator::all` instead of open-coding it)
Tomasz Miąsko [Sat, 13 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Use debug log level for developer oriented logs
The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.
Reduce log level from info to debug for developer oriented information.
For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.
Dylan DPC [Fri, 12 Feb 2021 21:53:32 +0000 (22:53 +0100)]
Rollup merge of #81741 - sdroege:zip-trusted-random-access-specialization-panic-safety, r=KodrAus
Increment `self.index` before calling `Iterator::self.a.__iterator_ge…
…`t_unchecked` in `Zip` `TrustedRandomAccess` specialization
Otherwise if `Iterator::self.a.__iterator_get_unchecked` panics the
index would not have been incremented yet and another call to
`Iterator::next` would read from the same index again, which is not
allowed according to the API contract of `TrustedRandomAccess` for
`!Clone`.
Dylan DPC [Fri, 12 Feb 2021 21:53:30 +0000 (22:53 +0100)]
Rollup merge of #81506 - vo4:hwasan, r=nagisa
HWAddressSanitizer support
# Motivation
Compared to regular ASan, HWASan has a [smaller overhead](https://source.android.com/devices/tech/debug/hwasan). The difference in practice is that HWASan'ed code is more usable, e.g. Android device compiled with HWASan can be used as a daily driver.
# Example
```
fn main() {
let xs = vec![0, 1, 2, 3];
let _y = unsafe { *xs.as_ptr().offset(4) };
}
```
```
==223==ERROR: HWAddressSanitizer: tag-mismatch on address 0xefdeffff0050 at pc 0xaaaad00b3468
READ of size 4 at 0xefdeffff0050 tags: e5/00 (ptr/mem) in thread T0
#0 0xaaaad00b3464 (/root/main+0x53464)
#1 0xaaaad00b39b4 (/root/main+0x539b4)
#2 0xaaaad00b3dd0 (/root/main+0x53dd0)
#3 0xaaaad00b61dc (/root/main+0x561dc)
#4 0xaaaad00c0574 (/root/main+0x60574)
#5 0xaaaad00b6290 (/root/main+0x56290)
#6 0xaaaad00b6170 (/root/main+0x56170)
#7 0xaaaad00b3578 (/root/main+0x53578)
#8 0xffff81345e70 (/lib64/libc.so.6+0x20e70)
#9 0xaaaad0096310 (/root/main+0x36310)
[0xefdeffff0040,0xefdeffff0060) is a small allocated heap chunk; size: 32 offset: 16
0xefdeffff0050 is located 0 bytes to the right of 16-byte region [0xefdeffff0040,0xefdeffff0050)
allocated here:
#0 0xaaaad009bcdc (/root/main+0x3bcdc)
#1 0xaaaad00b1eb0 (/root/main+0x51eb0)
#2 0xaaaad00b20d4 (/root/main+0x520d4)
#3 0xaaaad00b2800 (/root/main+0x52800)
#4 0xaaaad00b1cf4 (/root/main+0x51cf4)
#5 0xaaaad00b33d4 (/root/main+0x533d4)
#6 0xaaaad00b39b4 (/root/main+0x539b4)
#7 0xaaaad00b61dc (/root/main+0x561dc)
#8 0xaaaad00b3578 (/root/main+0x53578)
#9 0xaaaad0096310 (/root/main+0x36310)
# Comments/Caveats
* HWASan is only supported on arm64.
* I'm not sure if I should add a feature gate or piggyback on the existing one for sanitizers.
* HWASan requires `-C target-feature=+tagged-globals`. That flag should probably be set transparently to the user. Not sure how to go about that.
# TODO
* Need more tests.
* Update documentation.
* Fix symbolization.
* Integrate with CI
bors [Fri, 12 Feb 2021 17:38:15 +0000 (17:38 +0000)]
Auto merge of #81744 - rylev:overlapping-early-exit2, r=lcnr
Try fast_reject::simplify_type in coherence before doing full check
This is a reattempt at landing #69010 (by `@jonas-schievink).` The change adds a fast path for coherence checking to see if there's no way for types to unify since full coherence checking can be somewhat expensive.
This has big effects on code generated by the [`windows`](https://github.com/microsoft/windows-rs) which in some cases spends as much as 20% of compilation time in the `specialization_graph_of` query. In local benchmarks this took a compilation that previously took ~500 seconds down to ~380 seconds.
This is surely not going to make a difference on much smaller crates, so the question is whether it will have a negative impact. #69010 was closed because some of the perf suite crates did show small regressions.
Additional discussion of this issue is happening [here](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/windows-rs.20perf).
bors [Fri, 12 Feb 2021 14:40:27 +0000 (14:40 +0000)]
Auto merge of #82025 - JohnTitor:rollup-cohp0gy, r=JohnTitor
Rollup of 16 pull requests
Successful merges:
- #79983 (fix indefinite article in cell.rs)
- #81831 (Don't display `mut` in arguments for functions documentation)
- #81947 (Relax ItemCtxt::to_ty lifetime)
- #81954 (RELEASES.md 1.50: Group platform support notes together)
- #81955 (bootstrap: Locate llvm-dwp based on llvm-config bindir)
- #81959 (Fix assosiated typo)
- #81964 (Fix documentation not showing on localStorage error)
- #81968 (bootstrap: fix wrong docs installation path)
- #81990 (Make suggestion of changing mutability of arguments broader)
- #81994 (Improve long explanation for E0542 and E0546)
- #81997 (dist: include src/build_helper as part of the crate graph for rustc-dev)
- #82003 (Stack probes: fix error message)
- #82004 (clean up clean::Static struct)
- #82011 (Fix private intra-doc warnings on associated items)
- #82013 (Tell user how to fix CI file being not up to date)
- #82017 (Fix typo in mod.rs)
Yuki Okushi [Fri, 12 Feb 2021 10:32:20 +0000 (19:32 +0900)]
Rollup merge of #82011 - jyn514:warn-private-assoc-item, r=max-heller
Fix private intra-doc warnings on associated items
The issue was that the `kind, id` override was previously only being
considered for the disambiguator check, not the privacy check. This uses
the same ID for both.
Yuki Okushi [Fri, 12 Feb 2021 10:32:16 +0000 (19:32 +0900)]
Rollup merge of #81997 - bnjbvr:dist-include-build-helper, r=Mark-Simulacrum
dist: include src/build_helper as part of the crate graph for rustc-dev
The build_helper dependency is used to build the compiler/rustc_llvm build script.
Since it was missing, it wasn't possible to really use rustc-dev to
build, see for instance: https://github.com/rust-analyzer/rust-analyzer/issues/7589.
Yuki Okushi [Fri, 12 Feb 2021 10:32:14 +0000 (19:32 +0900)]
Rollup merge of #81990 - matsujika:suggest-mut-reference, r=estebank
Make suggestion of changing mutability of arguments broader
Fix #81421
Previously rustc tries to emit the suggestion of changing mutablity unless `!trait_ref.has_infer_types_or_consts() && self.predicate_can_apply(obligation.param_env, trait_ref)` and this led to some false negatives to occur.
Yuki Okushi [Fri, 12 Feb 2021 10:32:13 +0000 (19:32 +0900)]
Rollup merge of #81968 - pietroalbini:fix-doc-install-path, r=Mark-Simulacrum
bootstrap: fix wrong docs installation path
This PR fixes https://github.com/rust-lang/rust/issues/81967, a regression introduced by https://github.com/rust-lang/rust/pull/80797. The commit has already been backported to stable 1.50.0.
Yuki Okushi [Fri, 12 Feb 2021 10:32:11 +0000 (19:32 +0900)]
Rollup merge of #81955 - dtolnay:dwp, r=Mark-Simulacrum
bootstrap: Locate llvm-dwp based on llvm-config bindir
Fixes #81949.
Tested by successfully building 1.50.0 pre-release, which is where I originally hit the issue (https://internals.rust-lang.org/t/rust-1-50-0-pre-release-testing/14012/4?u=dtolnay). Tested both with and without prebuilt LLVM. The check for dry_run is necessary in the non-prebuilt case because the llvm-config built by bootstrap won't exist yet.
Yuki Okushi [Fri, 12 Feb 2021 10:32:07 +0000 (19:32 +0900)]
Rollup merge of #81831 - LeSeulArtichaut:81289-mut-arg, r=camelid
Don't display `mut` in arguments for functions documentation
Fixes #81289 by reverting #80799, as requested in https://github.com/rust-lang/rust/pull/81328#issuecomment-766364413.
Supersedes #81328.
r? ``@camelid`` cc ``@jyn514``
bors [Fri, 12 Feb 2021 06:34:21 +0000 (06:34 +0000)]
Auto merge of #81486 - ssomers:btree_separate_drop, r=Mark-Simulacrum
BTreeMap: disentangle Drop implementation from IntoIter
No longer require every `BTreeMap` to dig up its last leaf edge before dying. This speeds up the `clone_` benchmarks by 25% for normal keys and values (far less for huge values).
Joshua Nelson [Fri, 12 Feb 2021 00:15:16 +0000 (19:15 -0500)]
Fix private intra-doc warnings on associated items
The issue was that the `kind, id` override was previously only being
considered for the disambiguator check, not the privacy check. This uses
the same ID for both.
Joshua Nelson [Sun, 6 Dec 2020 22:56:01 +0000 (17:56 -0500)]
Fix injected errors when running doctests on a crate named after a keyword
Unfortunately, this can't currently be tested. The problem is that we
need the file to be compiled first to then be used as dependency, which
cannot be done currently unfortunately in the rustdoc test suites.
Example:
```rust
// name this file "foo.rs"
/// ```
/// let x = foo::foo();
/// ```
pub fn foo() {}
```
If you run `rustdoc --test foo.rs`, you'll get:
```
running 1 test
test foo.rs - foo (line 1) ... FAILED
If a test were possible, it would look something like
````rust
#![crate_name = "mod"]
#![crate_type = "lib"]
//! ```
//! // NOTE: requires that the literal string 'mod' appears in the doctest for
//! // the bug to appear
//! assert_eq!(1, 1);
//! ```
````
Rich Kadel [Thu, 4 Feb 2021 00:26:25 +0000 (16:26 -0800)]
Ensures `make` tests run under /bin/dash, like CI, and fixes a Makefile
Updates `tools.mk` to explicitly require `SHELL := /bin/dash`, since CI
uses `dash` but other environments (including developer local machines)
may default to `bash`.
Replaces bash-specific shell command in one Makefile with a
dash-compatible alternative, and re-enables the affected Makefile test.
Removes apparently redundant definition of `UNAME`.