Commit Graph

109764 Commits

Author SHA1 Message Date
bors
b543afca9b Auto merge of #70816 - Dylan-DPC:rollup-kzcs8px, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #67797 (Query-ify Instance::resolve)
 - #70777 (Don't import integer and float modules, use assoc consts)
 - #70795 (Keep track of position when deleting from a BTreeMap)
 - #70812 (Do not use "nil" to refer to `()`)
 - #70815 (Enable layout debugging for `impl Trait` type aliases)

Failed merges:

r? @ghost
2020-04-05 19:31:14 +00:00
Ralf Jung
e92bde373a make set_span public, as all the fields it touches are public already 2020-04-05 19:28:28 +02:00
Ralf Jung
43cdfbb3fe set span more accurately during const_prop 2020-04-05 19:28:28 +02:00
Ralf Jung
fb9b693acc Miri engine: use span_bug in a few places 2020-04-05 19:27:01 +02:00
Roland Kuhn
2275b875c2 expose suggestions::InferCtxtExt for clippy 2020-04-05 19:25:32 +02:00
Ralf Jung
0ad3b1c9bf add test 2020-04-05 19:23:35 +02:00
Ralf Jung
a524a9af91 Miri terminator handling: only do progress sanity check for 'Call' terminator 2020-04-05 19:23:35 +02:00
Esteban Küber
0cd4c89366 "cannot resolve" → "cannot satisfy" 2020-04-05 10:14:04 -07:00
Dylan DPC
8c081f69fb
Rollup merge of #70815 - RalfJung:layout-debug, r=jonas-schievink
Enable layout debugging for `impl Trait` type aliases

I also made it print the actual type name that the alias picks under the hood.
2020-04-05 18:47:50 +02:00
Dylan DPC
4827aa6034
Rollup merge of #70812 - rossmacarthur:fix/unit-called-nil, r=LukasKalbertodt
Do not use "nil" to refer to `()`

"nil" is not used in the [book](https://doc.rust-lang.org/book) or in the [standard library](https://doc.rust-lang.org/std) anywhere else. Because "nil" is often used in programming languages to refer to "None" or "null" I think it could be a little confusing for newcomers to see this type referred to as "nil".
2020-04-05 18:47:48 +02:00
Dylan DPC
2ec0e148f1
Rollup merge of #70795 - Amanieu:btree_remove_tracking, r=Mark-Simulacrum
Keep track of position when deleting from a BTreeMap

This improves the performance of drain_filter and is needed for future Cursor support for BTreeMap.

cc @ssomers
r? @Mark-Simulacrum
2020-04-05 18:47:47 +02:00
Dylan DPC
c2595539e7
Rollup merge of #70777 - faern:use-assoc-int-consts2, r=dtolnay
Don't import integer and float modules, use assoc consts

Stop importing the standard library integer and float modules to reach the `MIN`, `MAX` and other constants. They are available directly on the primitive types now.

This PR is a follow up of #69860 which made sure we use the new constants in documentation.

This type of change touches a lot of files, and previously all my assoc int consts PRs had collisions and were accepted only after a long delay. So I'd prefer to do it in smaller steps now. Just removing these imports seem like a good next step.

r? @dtolnay
2020-04-05 18:47:45 +02:00
Dylan DPC
829154f980
Rollup merge of #67797 - Aaron1011:feature/instance-query, r=nikomatsakis
Query-ify Instance::resolve

Split off from #65989

Instance::resolve is now a wrapper for a new `resolve_instance` query.
This greatly improves performance on several benchmarks
2020-04-05 18:47:44 +02:00
bors
6387b09153 Auto merge of #70809 - matthiaskrgr:submodule_upd, r=Mark-Simulacrum
submodules: update clippy from 326b2204 to 7907abea

Changes:
````
Rustup to rust-lang/rust#70634
Update clippy_lints/src/types.rs
Update types.rs
Update types.rs
Improve docs for option_option
useless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>, Box<&T>
Allow let_underscore
Update option_option ui test
Test for ignoring let_underscore_must_use
Downgrade option_option to pedantic
````

Fixes #70709
2020-04-05 16:13:44 +00:00
Ralf Jung
8f6c109371 also print type type 2020-04-05 17:13:30 +02:00
Ralf Jung
4a75883a78 also print rustc_layout on impl trait type aliases 2020-04-05 17:07:06 +02:00
Amanieu d'Antras
51357cf1cd Apply review feedback 2020-04-05 14:29:00 +01:00
bors
e6cef04457 Auto merge of #70807 - Dylan-DPC:rollup-qd1kgl2, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #70558 (Fix some aliasing issues in Vec)
 - #70760 (docs: make the description of Result::map_or more clear)
 - #70769 (Miri: remove an outdated FIXME)
 - #70776 (clarify comment in RawVec::into_box)
 - #70806 (fix Miri assignment sanity check)

Failed merges:

r? @ghost
2020-04-05 13:00:36 +00:00
Ross MacArthur
bc26f58521
Do not use "nil" to refer to () 2020-04-05 14:30:13 +02:00
Matthias Krüger
04a38e7e1b submodules: update clippy from 326b2204 to 7907abea
Changes:
````
Rustup to rust-lang/rust#70634
Update clippy_lints/src/types.rs
Update types.rs
Update types.rs
Improve docs for option_option
useless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>, Box<&T>
Allow let_underscore
Update option_option ui test
Test for ignoring let_underscore_must_use
Downgrade option_option to pedantic
````

Fixes #70709
2020-04-05 13:50:21 +02:00
Stefan Lankes
935683bd9c Simplify dtor registration for HermitCore by using a list of destructors
The implementation is similiar to macOS solution doesn't
depend on additional OS support
2020-04-05 13:41:17 +02:00
Amanieu d'Antras
7365748c0c Keep track of position when deleting from a BTreeMap
This improves the performance of drain_filter and is needed for
future Cursor support for BTreeMap.
2020-04-05 12:18:46 +01:00
Dylan DPC
31b8d65803
Rollup merge of #70806 - RalfJung:miri-assignment-check, r=eddyb
fix Miri assignment sanity check

Thanks @eddyb for pointing me to the right APIs!

r? @eddyb
Fixes https://github.com/rust-lang/rust/issues/70804
2020-04-05 13:13:14 +02:00
Dylan DPC
c185c4fe47
Rollup merge of #70776 - RalfJung:raw-vec, r=Dylan-DPC,TimDiekmann
clarify comment in RawVec::into_box

On first reading I almost thought "len <= cap" would be all that there is to check here. Expand the comment to clarify that that is not the case.
2020-04-05 13:13:13 +02:00
Dylan DPC
2448a23554
Rollup merge of #70769 - RalfJung:fixed, r=Dylan-DPC
Miri: remove an outdated FIXME

We even [have a test ](49dc2f9f09/src/test/ui/consts/miri_unleashed/drop.rs) making sure that we detect dropping with a non-const implementation.

r? @oli-obk
2020-04-05 13:13:11 +02:00
Dylan DPC
6f595e8713
Rollup merge of #70760 - PonasKovas:docs, r=Dylan-DPC
docs: make the description of Result::map_or more clear

The documentation of [`Result::map_or`](https://doc.rust-lang.org/std/result/enum.Result.html#method.map_or) is very unclear and confusing, probably because it was copied straight from [`Option::map_or`](https://doc.rust-lang.org/std/option/enum.Option.html#method.map_or) and someone forgot to adapt it for Result.
2020-04-05 13:13:10 +02:00
Dylan DPC
7e4ed72d64
Rollup merge of #70558 - RalfJung:vec-extend-aliasing, r=Amanieu
Fix some aliasing issues in Vec

`Vec::extend` and `Vec::truncate` invalidated references into the vector even without reallocation, because they (implicitly) created a mutable reference covering the *entire* initialized part of the vector.

Fixes https://github.com/rust-lang/rust/issues/70301
I verified the fix by adding some new tests here that I ran in Miri.
2020-04-05 13:13:08 +02:00
Linus Färnstrand
28c9231a91 Make libcore float constant examples similar to libstd 2020-04-05 12:20:27 +02:00
Linus Färnstrand
daf8afdc85 Remove more std::f32 imports in libstd 2020-04-05 12:20:27 +02:00
Ralf Jung
e52a451913 fix comment 2020-04-05 12:11:33 +02:00
Ralf Jung
6cbe1726a7 clarify safety in RawVec::into_box 2020-04-05 12:09:03 +02:00
Ralf Jung
315a3b96a4 add test 2020-04-05 11:56:02 +02:00
Ralf Jung
05a5895f0d miri assignment check: compare types after normalizing all late-bound regions away 2020-04-05 11:55:52 +02:00
bors
607b858236 Auto merge of #70803 - arlosi:hash-regression, r=eddyb
Fix performance regression in debuginfo file_metadata.

Fixes performance regression caused by #69718.

Finding the `SourceFile` associated with a `FileName` called `get_source_file` on the `SourceMap`, which does a linear search through all files in the `SourceMap`.

This resolves the issue by passing the `SourceFile` in from the caller (which already had it available) instead of the `FileName`

Fixes #70785.
2020-04-05 09:50:30 +00:00
Linus Färnstrand
d06b26fb6c Stop importing the float modules. Use assoc consts 2020-04-05 11:30:25 +02:00
Linus Färnstrand
101085ad9f Stop importing integer modules in libstd 2020-04-05 11:22:01 +02:00
Linus Färnstrand
d0fc5d9e6b Stop importing int module in float parse test 2020-04-05 11:22:01 +02:00
Linus Färnstrand
d7f8928efd Stop importing int modules in librustdoc 2020-04-05 11:22:01 +02:00
Linus Färnstrand
bc8d6c1b33 Stop importing int/float modules in libserialize 2020-04-05 11:22:01 +02:00
Linus Färnstrand
fcf45999f7 Stop importing int/float modules in librustc_* 2020-04-05 11:22:01 +02:00
Linus Färnstrand
a88b36b93b Stop importing int/float modules in libcore 2020-04-05 11:22:01 +02:00
Linus Färnstrand
fff4f08398 Stop importing integer modules in liballoc 2020-04-05 11:22:01 +02:00
Arlo Siemsen
4cdceda5a3 Fix performance regression in debuginfo file_metadata.
Finding the `SourceFile` associated with a `FileName` called `get_source_file` on
the `SourceMap`, which does a linear search through all files in the `SourceMap`.

This resolves the issue by passing the SourceFile in from the caller (which already
had it available).
2020-04-05 01:43:44 -07:00
Ralf Jung
7e81c11aa8 tweak swap_remove 2020-04-05 08:40:40 +02:00
bors
7b657d340d Auto merge of #70800 - Dylan-DPC:rollup-9jjoptp, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #70635 (rustc_target: Some cleanup to `no_default_libraries`)
 - #70748 (Do not disable field reordering on enums with big discriminant)
 - #70752 (Add slice::fill)
 - #70766 (use ManuallyDrop instead of forget inside collections)
 - #70768 (macro_rules: `NtLifetime` cannot start with an identifier)
 - #70783 (comment refers to removed type)

Failed merges:

r? @ghost
2020-04-05 06:22:35 +00:00
Aaron Hill
63d6ef65af
Query-ify Instance::resolve 2020-04-05 01:21:36 -04:00
Dylan DPC
5c42fafaf9
Rollup merge of #70783 - tshepang:deleted-types, r=Xanewok
comment refers to removed type

Was removed in 51938c61f6
2020-04-05 06:44:50 +02:00
Dylan DPC
d0dda18bd1
Rollup merge of #70768 - petrochenkov:macambig, r=Centril,mark-i-m
macro_rules: `NtLifetime` cannot start with an identifier

Fixes https://github.com/rust-lang/rust/issues/70446
2020-04-05 06:44:48 +02:00
Dylan DPC
590cb8b3b0
Rollup merge of #70766 - tspiteri:forget-to-ManuallyDrop, r=Mark-Simulacrum,RalfJung
use ManuallyDrop instead of forget inside collections

This PR changes some usage of `mem::forget` into `mem::ManuallyDrop` in some `Vec`, `VecDeque`, `BTreeMap` and `Box` methods.

Before the commit, the generated IR for some of the methods was longer, and even after optimization, some unwinding artifacts were still present.
2020-04-05 06:44:47 +02:00
Dylan DPC
6ea27010b5
Rollup merge of #70752 - yoshuawuyts:slice_fill, r=dtolnay
Add slice::fill

Adds the `slice::fill` method to fill a slice with an item. This replaces manual for loops where items are copied one-by-one. This is a counterpart to C++20's [`std::fill`](https://en.cppreference.com/w/cpp/algorithm/fill) function.

## Usage

```rust
let mut buf = vec![0; 10];
buf.fill(1);
assert_eq!(buf, vec![1; 10]);
```

## Performance

When compiling in release mode, for `[u8]` and `[u16]` this method will optimize to a `memset(3)` call ([godbolt](https://godbolt.org/z/85El_c)). The initial implementation relies on LLVM's optimizer to make it as fast as possible for any given input. But as @jonas-schievink [pointed out](https://twitter.com/sheevink/status/1245756597453885442) this can later be optimized through specialization to guarantee it has a specific performance profile.

## Why now?

Conversations about adding `slice::fill` are not new. In fact, https://github.com/rust-lang/rfcs/issues/2067 was opened 3 years ago about this exact topic. However discussion stranded while discussing implementation details, and it's not seen much forward motion since.

In ["The Hunt for the Fastest Zero"](https://travisdowns.github.io/blog/2020/01/20/zero.html) Travis Downs provides disects C++'s `std::fill` performance profile on gcc, comparing it among others to `memset(3)`. Even though `memset(3)` outperforms `std::fill` in their tests, the author notes the following:

>  That the optimization fails, perhaps unexpectedly, in some cases is unfortunate but it’s nice that you can fix it yourself. [...] Do we throw out modern C++ idioms, at least where performance matters, for example by replacing std::fill with memset? I don’t think so.

Much of the article focuses on how how to fix the performance of `std::fill` by providing specializations for specific input. In Rust we don't have any dedicated methods to fill slices with values, so it either needs to be optimized at the MIR layer, or more likely rely on LLVM's optimizer.

By adding a dedicated method for filling slices with values it opens up the ability for us to in the future guarantee that e.g. `Vec<u8>` will always optimize to `memset` even in debug mode. Or perhaps provide stronger guarantees about memory when zeroing values when a certain flag is passed. But regardless of that, it improves general ergonomics of working with slices by providing a dedicated method with documentation and examples.

## References
- [slice-fill prototype on docs.rs](https://docs.rs/slice-fill/1.0.1/slice_fill/)
- [The Hunt For The Fastest Zero](https://travisdowns.github.io/blog/2020/01/20/zero.html)
- [Safe memset for slices](https://github.com/rust-lang/rfcs/issues/2067)
- [C++20 std::fill](https://en.cppreference.com/w/cpp/algorithm/fill)
- [ASM output on Godbolt](https://godbolt.org/z/5-XU66)
2020-04-05 06:44:45 +02:00