bors [Wed, 27 Jan 2021 18:36:32 +0000 (18:36 +0000)]
Auto merge of #81335 - thomwiggers:no-panic-shrink-to, r=Mark-Simulacrum
Trying to shrink_to greater than capacity should be no-op
Per the discussion in https://github.com/rust-lang/rust/issues/56431, `shrink_to` shouldn't panic if you try to make a vector shrink to a capacity greater than its current capacity.
bors [Wed, 27 Jan 2021 10:19:51 +0000 (10:19 +0000)]
Auto merge of #80987 - GuillaumeGomez:remove-cache-key, r=jyn514
Remove CACHE_KEY global
We realized in https://github.com/rust-lang/rust/pull/80914 that the cache handling (through a global) needed to be updated to make it much easier to handle.
bors [Tue, 26 Jan 2021 19:44:26 +0000 (19:44 +0000)]
Auto merge of #81417 - JohnTitor:rollup-yi3q05s, r=JohnTitor
Rollup of 14 pull requests
Successful merges:
- #80812 (Update RELEASES.md for 1.50.0)
- #80876 (Add `unwrap_unchecked()` methods for `Option` and `Result`)
- #80900 (Fix ICE with `ReadPointerAsBytes` validation error)
- #81191 (BTreeMap: test all borrowing interfaces and test more chaotic order behavior)
- #81195 (Account for generics when suggesting bound)
- #81299 (Fix some bugs reported by eslint)
- #81325 (typeck: Don't suggest converting LHS exprs)
- #81353 (Fix spelling in documentation for error E0207)
- #81369 (rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entry)
- #81389 (rustdoc: Document CommonMark extensions.)
- #81399 (Update books)
- #81401 (tidy: Some code cleanup.)
- #81407 (Refine "remove semicolon" suggestion in trait selection)
- #81412 (Fix assertion in `MaybeUninit::array_assume_init()` for zero-length arrays)
Yuki Okushi [Tue, 26 Jan 2021 19:43:37 +0000 (04:43 +0900)]
Rollup merge of #81412 - hyd-dev:array-assume-init-wrong-assertion, r=m-ou-se
Fix assertion in `MaybeUninit::array_assume_init()` for zero-length arrays
That assertion has a false positive ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=63922b8c897b04112adcdf346deb1d0e)):
```rust
#![feature(maybe_uninit_array_assume_init)]
use std::mem::MaybeUninit;
enum Uninhabited {}
fn main() {
unsafe {
// thread 'main' panicked at 'attempted to instantiate uninhabited type `Uninhabited`'
MaybeUninit::<Uninhabited>::array_assume_init([]);
}
}
```
*Previously reported in https://github.com/rust-lang/rust/pull/80600#discussion_r564496692.*
Yuki Okushi [Tue, 26 Jan 2021 19:43:33 +0000 (04:43 +0900)]
Rollup merge of #81401 - ehuss:tidy-cleanup, r=Mark-Simulacrum
tidy: Some code cleanup.
This is just some cleanup that shouldn't have any change in behavior. (See commit messages for more details.)
* Remove cargo check. This test wasn't working, and is no longer valid.
* Remove edition filter exceptions. They are no longer necessary.
* Remove unnecessary trailing semicolon. Otherwise the warning will prevent tidy from building after the beta branch.
Yuki Okushi [Tue, 26 Jan 2021 19:43:32 +0000 (04:43 +0900)]
Rollup merge of #81399 - ehuss:update-books, r=ehuss
Update books
## nomicon
7 commits in a8584998eacdea7106a1dfafcbf6c1c06fcdf925..bbf06ad39d1f45654047e9596b750cc6e6d1b693
2021-01-06 12:49:49 -0500 to 2021-01-22 07:07:31 -0800
- Fix alloc link in exotic-sizes for local docs (rust-lang-nursery/nomicon#255)
- Remove TODO
- Fix small punctuation error
- Arc revisions (Clone atomic explanation) (pt2/3(+?))
- Fix Arc Clone
- Arc revisions (pt1/2(+?))
- Simple Arc implementation (without Weak refs)
## reference
5 commits in 50af691f838937c300b47812d0507c6d88c14f97..f02b09eb6e8af340ad1256a54adb7aae2ff3163e
2021-01-12 21:19:20 -0800 to 2021-01-22 01:53:02 -0800
- Fix missing space (rust-lang-nursery/reference#941)
- Start documenting name resolution. (rust-lang-nursery/reference#937)
- Fix plural and delete spurious words in comparison ops (rust-lang-nursery/reference#932)
- Document execution order (rust-lang-nursery/reference#888)
- Compound operator expressions (rust-lang-nursery/reference#915)
## book
3 commits in ac57a0ddd23d173b26731ccf939f3ba729753275..e724bd826580ff95df48a8533af7dec1080693d4
2021-01-09 14:18:45 -0500 to 2021-01-20 08:19:49 -0600
- Fixes rust-lang/book#2417. Get the index from user input instead of a const. (rust-lang/book#2566)
- Turn off the playground in a bunch more lib.rs inclusions (rust-lang/book#2569)
- Merge pull request rust-lang/book#2567 from rust-lang/rust-1.49
Yuki Okushi [Tue, 26 Jan 2021 19:43:28 +0000 (04:43 +0900)]
Rollup merge of #81369 - tgnottingham:codegen-to-llvm-ir-wall-time, r=lcnr
rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entry
Use elapsed wall time spent on codegen_to_LLVM_IR for all CGUs as a
whole, rather than the sum for each CGU (the distinction matters for
parallel builds, where some CGUs are processed in parallel).
Yuki Okushi [Tue, 26 Jan 2021 19:43:14 +0000 (04:43 +0900)]
Rollup merge of #80876 - ojeda:option-result-unwrap_unchecked, r=m-ou-se
Add `unwrap_unchecked()` methods for `Option` and `Result`
In particular:
- `unwrap_unchecked()` for `Option`.
- `unwrap_unchecked()` and `unwrap_err_unchecked()` for `Result`.
These complement other `*_unchecked()` methods in `core` etc.
Currently there are a couple of places it may be used inside rustc (`LinkedList`, `BTree`). It is also easy to find other repositories with similar functionality.
bors [Tue, 26 Jan 2021 14:47:51 +0000 (14:47 +0000)]
Auto merge of #81217 - ssomers:btree_bring_back_the_slice, r=Mark-Simulacrum
BTreeMap: bring back the key slice for immutable lookup
Pave the way for binary search, by reverting a bit of #73971, which banned `keys` for misbehaving while it was defined for every `BorrowType`. Adding some `debug_assert`s along the way.
bors [Tue, 26 Jan 2021 11:15:44 +0000 (11:15 +0000)]
Auto merge of #81367 - andersk:join-test-threads, r=dtolnay
libtest: Wait for test threads to exit after they report completion
Otherwise we can miss bugs where a test reports that it succeeded but then panics within a TLS destructor.
Example:
```rust
use std::thread::sleep;
use std::time::Duration;
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
sleep(Duration::from_secs(1));
panic!()
}
}
thread_local!(static FOO: Foo = Foo);
#[test]
pub fn test() {
FOO.with(|_| {});
}
```
Before this fix, `cargo test` incorrectly reports success.
```console
$ cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running target/debug/deps/panicking_test-85130fa46b54f758
running 1 test
test test ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
$ echo $?
0
```
After this fix, the failure is visible. (The entire process is aborted due to #24479.)
```console
$ cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running target/debug/deps/panicking_test-76180625bc2ee3c9
running 1 test
thread 'test' panicked at 'explicit panic', src/main.rs:9:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
error: test failed, to rerun pass '--bin panicking-test'
Caused by:
process didn't exit successfully: `/tmp/panicking-test/target/debug/deps/panicking_test-76180625bc2ee3c9 --nocapture` (signal: 6, SIGABRT: process abort signal)
bors [Tue, 26 Jan 2021 05:47:23 +0000 (05:47 +0000)]
Auto merge of #80692 - Aaron1011:feature/query-result-debug, r=estebank
Enforce that query results implement Debug
Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk.
This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
bors [Tue, 26 Jan 2021 02:56:37 +0000 (02:56 +0000)]
Auto merge of #79113 - andjo403:raw_vec_ptr, r=m-ou-se
mark raw_vec::ptr with inline
when a lot of vectors is used in a enum as in the example in #66617 if this function is not inlined and multiple cgus is used this results in huge compile times. with this fix the compile time is 6s from minutes for the example in #66617. I did not have the patience to wait for it to compile for more then 3 min.
Eric Huss [Mon, 25 Jan 2021 20:28:29 +0000 (12:28 -0800)]
tidy: Remove cargo check.
The cargo check was checking that every dependency had an `extern crate`.
The compiler has not used `extern crate` in a long time (edition 2018).
The test was broken (the call to `!super::filter_dirs(path)` was backwards).
This just removes it since it is no longer valid.
Anders Kaseorg [Mon, 25 Jan 2021 20:19:25 +0000 (12:19 -0800)]
libtest: Store pending timeouts in a deque
This reduces the total complexity of checking timeouts from quadratic
to linear, and should also fix an unwrap of None on completion of an
already timed-out test.
bors [Mon, 25 Jan 2021 19:03:37 +0000 (19:03 +0000)]
Auto merge of #68828 - oli-obk:inline_cycle, r=wesleywiser
Prevent query cycles in the MIR inliner
r? `@eddyb` `@wesleywiser`
cc `@rust-lang/wg-mir-opt`
The general design is that we have a new query that is run on the `validated_mir` instead of on the `optimized_mir`. That query is forced before going into the optimization pipeline, so as to not try to read from a stolen MIR.
The query should not be cached cross crate, as you should never call it for items from other crates. By its very design calls into other crates can never cause query cycles.
This is a pessimistic approach to inlining, since we strictly have more calls in the `validated_mir` than we have in `optimized_mir`, but that's not a problem imo.
Tyson Nottingham [Mon, 25 Jan 2021 05:23:38 +0000 (21:23 -0800)]
rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entry
Use elapsed wall time spent on codegen_to_LLVM_IR for all CGUs as a
whole, rather than the sum for each CGU (the distinction matters for
parallel builds, where some CGUs are processed in parallel).
bors [Sun, 24 Jan 2021 23:04:15 +0000 (23:04 +0000)]
Auto merge of #81355 - jonas-schievink:rollup-vpaadij, r=jonas-schievink
Rollup of 14 pull requests
Successful merges:
- #75180 (Implement Error for &(impl Error))
- #78578 (Permit mutable references in all const contexts)
- #79174 (Make std::future a re-export of core::future)
- #79884 (Replace magic numbers with existing constants)
- #80855 (Expand assert!(expr, args..) to include $crate for hygiene on 2021.)
- #80933 (Fix sysroot option not being honored across rustc)
- #81259 (Replace version_check dependency with own version parsing code)
- #81264 (Add unstable option to control doctest run directory)
- #81279 (Small refactor in typeck)
- #81297 (Don't provide backend_optimization_level query for extern crates)
- #81302 (Fix rendering of stabilization version for trait implementors)
- #81310 (Do not mark unit variants as used when in path pattern)
- #81320 (Make bad shlex parsing a pretty error)
- #81338 (Clean up `dominators_given_rpo`)
Jonas Schievink [Sun, 24 Jan 2021 21:10:04 +0000 (22:10 +0100)]
Rollup merge of #81302 - LeSeulArtichaut:80777-trait-render, r=jyn514
Fix rendering of stabilization version for trait implementors
Rustdoc compares an item's stabilization version with its parent's to not render it if they are the same. Here, the implementor was compared with itself, resulting in the stabilization version never getting shown.
Jonas Schievink [Sun, 24 Jan 2021 21:10:01 +0000 (22:10 +0100)]
Rollup merge of #81279 - bugadani:iter, r=davidtwco
Small refactor in typeck
- `check_impl_items_against_trait` only queries and walks through associated items once
- extracted function that reports errors
- don't check specialization validity when trait item does not match
- small additional cleanups
Jonas Schievink [Sun, 24 Jan 2021 21:09:59 +0000 (22:09 +0100)]
Rollup merge of #81264 - Swatinem:doctest-run-directory, r=jyn514
Add unstable option to control doctest run directory
This option will allow splitting the compile-time from the run-time
directory of doctest invocations and is one step to solve
https://github.com/rust-lang/cargo/issues/8993#issuecomment-760088944
Jonas Schievink [Sun, 24 Jan 2021 21:09:57 +0000 (22:09 +0100)]
Rollup merge of #81259 - est31:cfg_version, r=petrochenkov
Replace version_check dependency with own version parsing code
This gives compiler maintainers a better degree of control
over how the version gets parsed and is a good way to ensure
that there are no changes of behaviour in the future.
Also, issue a warning if the version is invalid instead of erroring
so that we stay forwards compatible with possible future changes
of the versioning scheme.
Jonas Schievink [Sun, 24 Jan 2021 21:09:55 +0000 (22:09 +0100)]
Rollup merge of #80933 - rcvalle:fix-sysroot-option, r=nagisa
Fix sysroot option not being honored across rustc
Change link_sanitizer_runtime() to check if the sanitizer library exists in the specified/session sysroot, and if it doesn't exist, use the default sysroot. (See #79253.)
Jonas Schievink [Sun, 24 Jan 2021 21:09:53 +0000 (22:09 +0100)]
Rollup merge of #80855 - m-ou-se:assert-2021, r=petrochenkov
Expand assert!(expr, args..) to include $crate for hygiene on 2021.
This makes `assert!(expr, args..)` properly hygienic in Rust 2021.
This is part of rust-lang/rfcs#3007, see #80162.
Before edition 2021, this was a breaking change, as `std::panic` and `core::panic` are different. In edition 2021 they will be identical, making it possible to apply proper hygiene here.
Jonas Schievink [Sun, 24 Jan 2021 21:09:45 +0000 (22:09 +0100)]
Rollup merge of #75180 - KodrAus:feat/error-by-ref, r=m-ou-se
Implement Error for &(impl Error)
Opening this up just to see what it breaks. It's unfortunate that `&(impl Error)` doesn't actually implement `Error`. If this direct approach doesn't work out then I'll try something different, like an `Error::by_ref` method.
**EDIT:** This is a super low-priority experiment so feel free to cancel it for more important crater runs! 🙂
-----
# Stabilization Report
## Why?
We've been working for the last few years to try "fix" the `Error` trait, which is probably one of the most fundamental in the whole standard library. One of its issues is that we commonly expect you to work with abstract errors through `dyn Trait`, but references and smart pointers over `dyn Trait` don't actually implement the `Error` trait. If you have a `&dyn Error` or a `Box<dyn Error>` you simply can't pass it to a method that wants a `impl Error`.
This means that `&dyn Error` will now satisfy a `impl Error` bound.
It doesn't do anything with `Box<dyn Error>` directly. We discussed how we could do `Box<dyn Error>` in the thread here (and elsewhere in the past), but it seems like we need something like lattice-based specialization or a sprinkling of snowflake compiler magic to make that work. Having said that, with this new impl you _can_ now get a `impl Error` from a `Box<dyn Error>` by dereferencing it.
## What breaks?
A crater run revealed a few crates broke with something like the following:
```rust
// where e: &'short &'long dyn Error
err.source()
```
previously we'd auto-deref that `&'short &'long dyn Error` to return a `Option<&'long dyn Error>` from `source`, but now will call directly on `&'short impl Error`, so will return a `Option<&'short dyn Error>`. The fix is to manually deref:
```rust
// where e: &'short &'long dyn Error
(*err).source()
```
In the recent Libs meeting we considered this acceptable breakage.
bors [Sun, 24 Jan 2021 12:34:08 +0000 (12:34 +0000)]
Auto merge of #81250 - sivadeilra:remove_xp_compat, r=joshtriplett,m-ou-se
Remove delay-binding for Win XP and Vista
The minimum supported Windows version is now Windows 7. Windows XP
and Windows Vista are no longer supported; both are already broken, and
require extra steps to use.
This commit removes the delayed-binding support for Windows API
functions that are present on all supported Windows targets. This has
several benefits: Removes needless complexity. Removes a load and
dynamic call on hot paths in mutex acquire / release. This may have
performance benefits.
* "Drop official support for Windows XP"
https://github.com/rust-lang/compiler-team/issues/378
* "Firefox has ended support for Windows XP and Vista"
https://support.mozilla.org/en-US/kb/end-support-windows-xp-and-vista
bors [Sun, 24 Jan 2021 09:44:42 +0000 (09:44 +0000)]
Auto merge of #80838 - nagisa:nagisa/stack-probe-type, r=cuviper
Target stack-probe support configurable finely
This adds capability to configure the target's stack probe support in a
more precise manner than just on/off. In particular now we allow
choosing between always inline-asm, always call or either one of those
depending on the LLVM version.
Note that this removes the ability to turn off the generation of the
stack-probe attribute. This is valid to replace it with inline-asm for all targets because
`probe-stack="inline-asm"` will not generate any machine code on targets
that do not currently support stack probes. This makes support for stack
probes on targets that don't have any right now automatic with LLVM
upgrades in the future.
(This is valid to do based on the fact that clang unconditionally sets
this attribute when `-fstack-clash-protection` is used, AFAICT)
bors [Sun, 24 Jan 2021 02:59:14 +0000 (02:59 +0000)]
Auto merge of #80594 - bjorn3:abi_refactor3, r=petrochenkov
Various ABI refactorings
This includes changes to the rust abi and various refactorings that will hopefully make it easier to use the abi handling infrastructure of rustc in cg_clif. There are several refactorings that I haven't done. I am opening this draft PR to check that I haven't broken any non x86_64 architectures.
est31 [Fri, 22 Jan 2021 05:57:33 +0000 (06:57 +0100)]
Replace version_check dependency with own version parsing code
This gives compiler maintainers a better degree of control
over how the version gets parsed and is a good way to ensure
that there are no changes of behaviour in the future.
Also, issue a warning if the version is invalid instead of erroring
so that we stay forwards compatible with possible future changes
of the versioning scheme.
bors [Sat, 23 Jan 2021 21:13:14 +0000 (21:13 +0000)]
Auto merge of #81304 - jonas-schievink:rollup-d9kuugm, r=jonas-schievink
Rollup of 15 pull requests
Successful merges:
- #79841 (More clear documentation for NonNull<T>)
- #81072 (PlaceRef::ty: use method call syntax)
- #81130 (Edit rustc_middle::dep_graph module documentation)
- #81170 (Avoid hash_slice in VecDeque's Hash implementation)
- #81243 (mir: Improve size_of handling when arg is unsized)
- #81245 (Update cargo)
- #81249 (Lower closure prototype after its body.)
- #81252 (Add more self-profile info to rustc_resolve)
- #81275 (Fix <unknown> queries and add more timing info to render_html)
- #81281 (Inline methods of Path and OsString)
- #81283 (Note library tracking issue template in tracking issue template.)
- #81285 (Remove special casing of rustdoc in rustc_lint)
- #81288 (rustdoc: Fix visibility of trait and impl items)
- #81298 (replace RefCell with Cell in FnCtxt)
- #81301 (Fix small typo)
Aaron Hill [Mon, 7 Dec 2020 22:44:40 +0000 (17:44 -0500)]
Add disambiugator to ExpnData
Due to macro expansion, its possible to end up with two distinct
`ExpnId`s that have the same `ExpnData` contents. This violates the
contract of `HashStable`, since two unequal `ExpnId`s will end up with
equal `Fingerprint`s.
This commit adds a `disambiguator` field to `ExpnData`, which is used to
force two otherwise-equivalent `ExpnData`s to be distinct.
This happened because `alloc_query_strings` was never called.
## Add more timing info to render_html
This still has some issues I'm not sure how to work out:
- `create_renderer` and `renderer_after_krate` aren't shown by default.
I want something like `verbose_generic_activity_with_arg`, but it doesn't exist.
I'm also not sure how to show activities that aren't on by default - I
tried `-Z self-profile -Z self-profile-args=all`, but it didn't show up.