Commit graph

151203 commits

Author SHA1 Message Date
Yuki Okushi 7be29c1627
Rollup merge of #86907 - pietroalbini:ci-cpu-stats-python3, r=Mark-Simulacrum
Migrate `cpu-usage-over-time.py` to Python 3

The only change here is a fix for `sys.platform` on Linux. Python 3.3 changed the API to return `"linux"` instead of `"linux2"`/`"linux3"`, so this PR uses `.startswith("linux")` to make the code work on Python 3 without breaking Python 2.
2021-07-07 12:17:43 +09:00
Yuki Okushi fe3d6a74d9
Rollup merge of #86906 - juniorbassani:update-sync-docs, r=yaahc
Replace deprecated compare_and_swap and fix typo in core::sync::atomic::{fence, compiler_fence} docs
2021-07-07 12:17:42 +09:00
Yuki Okushi c630b6b0fc
Rollup merge of #86880 - m-ou-se:test-manuallydrop-clone-from, r=Mark-Simulacrum
Test ManuallyDrop::clone_from.

See #86288
2021-07-07 12:17:41 +09:00
Yuki Okushi cbb40cd0f2
Rollup merge of #86819 - GuillaumeGomez:cleanup-rustdoc-ids, r=jyn514
Clean up rustdoc IDs

I cherry-picked the commit from https://github.com/rust-lang/rust/pull/86178. It adds missing rustdoc IDs (for the HTML) and remove unused ones.

cc `@camelid`

r? `@jyn514`
2021-07-07 12:17:40 +09:00
Yuki Okushi 7e95290caa
Rollup merge of #86717 - rylev:rename, r=nikomatsakis
Rename some Rust 2021 lints to better names

Based on conversation in https://github.com/rust-lang/rust/issues/85894.

Rename a bunch of Rust 2021 related lints:

Lints that are officially renamed because they are already in beta or stable:
* `disjoint_capture_migration` => `rust_2021_incompatible_closure_captures`
* `or_patterns_back_compat` => `rust_2021_incompatible_or_patterns`
* `non_fmt_panic` => `non_fmt_panics`

Lints that are renamed but don't require any back -compat work since they aren't yet in stable:
* `future_prelude_collision` => `rust_2021_prelude_collisions`
* `reserved_prefix` => `rust_2021_token_prefixes`

Lints that have been discussed but that I did not rename:
* ~`non_fmt_panic` and `bare_trait_object`: is making this plural worth the headache we might cause users?~
* `array_into_iter`: I'm unsure of a good name and whether bothering users with a name change is worth it.

r? `@nikomatsakis`
2021-07-07 12:17:39 +09:00
Yuki Okushi 9bbc470e97
Rollup merge of #80918 - yoshuawuyts:int-log2, r=m-ou-se
Add Integer::log variants

_This is another attempt at landing https://github.com/rust-lang/rust/pull/70835, which was approved by the libs team but failed on Android tests through Bors. The text copied here is from the original issue. The only change made so far is the addition of non-`checked_` variants of the log methods._

_Tracking issue: #70887_

---

This implements `{log,log2,log10}` methods for all integer types. The implementation was provided by `@substack` for use in the stdlib.

_Note: I'm not big on math, so this PR is a best effort written with limited knowledge. It's likely I'll be getting things wrong, but happy to learn and correct. Please bare with me._

## Motivation
Calculating the logarithm of a number is a generally useful operation. Currently the stdlib only provides implementations for floats, which means that if we want to calculate the logarithm for an integer we have to cast it to a float and then back to an int.

> would be nice if there was an integer log2 instead of having to either use the f32 version or leading_zeros() which i have to verify the results of every time to be sure

_— [`@substack,` 2020-03-08](https://twitter.com/substack/status/1236445105197727744)_

At higher numbers converting from an integer to a float we also risk overflows. This means that Rust currently only provides log operations for a limited set of integers.

The process of doing log operations by converting between floats and integers is also prone to rounding errors. In the following example we're trying to calculate `base10` for an integer. We might try and calculate the `base2` for the values, and attempt [a base swap](https://www.rapidtables.com/math/algebra/Logarithm.html#log-rules) to arrive at `base10`. However because we're performing intermediate rounding we arrive at the wrong result:

```rust
// log10(900) = ~2.95 = 2
dbg!(900f32.log10() as u64);

// log base change rule: logb(x) = logc(x) / logc(b)
// log2(900) / log2(10) = 9/3 = 3
dbg!((900f32.log2() as u64) / (10f32.log2() as u64));
```
_[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6bd6c68b3539e400f9ca4fdc6fc2eed0)_

This is somewhat nuanced as a lot of the time it'll work well, but in real world code this could lead to some hard to track bugs. By providing correct log implementations directly on integers we can help prevent errors around this.

## Implementation notes

I checked whether LLVM intrinsics existed before implementing this, and none exist yet. ~~Also I couldn't really find a better way to write the `ilog` function. One option would be to make it a private method on the number, but I didn't see any precedent for that. I also didn't know where to best place the tests, so I added them to the bottom of the file. Even though they might seem like quite a lot they take no time to execute.~~

## References

- [Log rules](https://www.rapidtables.com/math/algebra/Logarithm.html#log-rules)
- [Rounding error playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6bd6c68b3539e400f9ca4fdc6fc2eed0)
- [substack's tweet asking about integer log2 in the stdlib](https://twitter.com/substack/status/1236445105197727744)
- [Integer Logarithm, A. Jaffer 2008](https://people.csail.mit.edu/jaffer/III/ilog.pdf)
2021-07-07 12:17:32 +09:00
bors c0bd5a584d Auto merge of #86901 - sexxi-goose:query_remove, r=nikomatsakis
Make type_implements_trait not a query

r? `@nikomatsakis`
2021-07-07 01:03:41 +00:00
Niko Matsakis 38dcae2cda
Apply suggestions from code review 2021-07-06 20:52:53 -04:00
Eric Holk 8b4f538320 Unify lint tool and lint name checking
This shares a little more code between checking command line and
attribute lint specifications.
2021-07-06 17:19:20 -07:00
Eric Huss 1b4704d200 Update books 2021-07-06 17:07:35 -07:00
Eric Holk 1e0db4cfed Parse tool name for command line lint options 2021-07-06 15:50:10 -07:00
Eric Holk 65b28a987b Add ui test for command line lints with tool names
This adds a ui test to make sure rustc accepts lint arguments such as
`-A clippy::foo` when clippy is disabled.
2021-07-06 15:49:47 -07:00
bors b20e3ff2af Auto merge of #86911 - bjorn3:crate_info_refactor, r=petrochenkov
Refactor linker code

This merges `LinkerInfo` into `CrateInfo` as there is no reason to keep them separate. `LinkerInfo::to_linker` is merged into `get_linker` as both have different logic for each linker type and `to_linker` is directly called after `get_linker`. Also contains a couple of small cleanups.

See the individual commits for all changes.
2021-07-06 22:20:43 +00:00
Michael Howell a151982af3 Add doc comment for impl From<LayoutError> for TryReserveError 2021-07-06 14:44:18 -07:00
Aman Arora 1bcbc18e3d Fix depnode size 2021-07-06 15:55:13 -04:00
Godmar Back fb464a3b39 rewrote documentation for thread::yield_now()
The old documentation suggested the use of yield_now for repeated
polling instead of discouraging it; it also made the false claim that
channels are implementing using yield_now. (They are not, except for
a corner case).
2021-07-06 15:50:42 -04:00
bors 885399992c Auto merge of #86636 - wesleywiser:misc_enum_improvements, r=michaelwoerister
[msvc] Consistently show active variant and fix visualization for single variant enums

Prior to this change, there were a few cases where inspecting an enum in either WinDbg or Visual Studio would not show the active variant name. After these changes, we now consistently show the active variant name as `[variant]` in the debugger.

We also didn't handle single variant enums very well. That is now also resolved.

Before:
![image](https://user-images.githubusercontent.com/831192/123480097-dc8b5f00-d5cf-11eb-93a8-9fc05a97029b.png)

After:
![image](https://user-images.githubusercontent.com/831192/123479966-aa79fd00-d5cf-11eb-955e-9798616a8829.png)

r? `@michaelwoerister`
2021-07-06 19:31:24 +00:00
Aman Arora 8ef5212eff Make type_implements_trait not a query 2021-07-06 14:38:10 -04:00
Ryan Levick d4e384bc1d rename rust_2021_token_prefixes to rust_2021_prefixes_incompatible_syntax 2021-07-06 20:13:36 +02:00
Ryan Levick 941eb2adbd Rename future_prelude_collisions to rust_2021_prelude_collisions 2021-07-06 20:13:17 +02:00
Ryan Levick 81c11a212e rust_2021_token_prefixes 2021-07-06 20:13:16 +02:00
Ryan Levick a902e25f58 Add s to non_fmt_panic 2021-07-06 20:12:56 +02:00
Ryan Levick 4e5b78fdcf Allow lint names to have ascii numbers 2021-07-06 20:12:55 +02:00
Ryan Levick 3a45bb919c Fix mis-styled code 2021-07-06 20:12:55 +02:00
Ryan Levick 6c87772e3c Rename reserved_prefix lint to reserved_prefixes 2021-07-06 20:12:55 +02:00
Ryan Levick ecca9a8b1a Add s to FUTURE_PRELUDE_COLLISION 2021-07-06 20:11:45 +02:00
Ryan Levick 1d49658f5c Change or_patterns_back_compat lint to rust_2021_incompatible_or_patterns 2021-07-06 20:11:45 +02:00
Ryan Levick df71a99a0e Rename lint 2021-07-06 20:11:45 +02:00
Ryan Levick bbfb8579ff Rename disjoint_capture_migration lint to rust_2021_incompatible_closure_captures 2021-07-06 20:11:45 +02:00
bjorn3 25e45baf55 Fix test 2021-07-06 19:40:21 +02:00
bjorn3 73d2e22969 Sync from rust b09dad3edd 2021-07-06 18:59:42 +02:00
bors 238fd72880 Auto merge of #86572 - rylev:force-warnings-always, r=nikomatsakis
Force warnings even when can_emit_warnings == false

Fixes an issue mentioned in #85512 with --cap-lints overriding --force-warnings.

Fixes https://github.com/rust-lang/rust/issues/86751

r? `@ehuss`
2021-07-06 16:50:33 +00:00
bjorn3 b21cbfd77d Fold LinkerInfo into CrateInfo 2021-07-06 18:28:07 +02:00
bjorn3 b4a12f95c1 Don't store the full LinkerInfo inside Linker impls 2021-07-06 18:09:49 +02:00
bjorn3 cfff3a35a2 Merge LinkerInfo::to_linker into get_linker 2021-07-06 18:01:44 +02:00
bjorn3 0b061cbeac Move get_linker to linker.rs 2021-07-06 17:54:13 +02:00
bjorn3 56ee9864c1 Don't pass local_crate_name to link_binary separately
It is already part of CodegenResults
2021-07-06 17:49:23 +02:00
bjorn3 5aaa953dcc Remove unused panic_runtime field from CrateInfo 2021-07-06 17:38:27 +02:00
Pietro Albini 0b3653bbdd
migrate cpu-usage-over-time.py to python 3
The only change here is a fix for `sys.platform` on Linux. Python 3.3
changed the API to return "linux" instead of "linux2"/"linux3", so this
commit uses `.startswith("python")` to make the code work on Python 3
without breaking Python 2.
2021-07-06 16:34:51 +02:00
bors b09dad3edd Auto merge of #86231 - nagisa:nagisa/abi-allowlist, r=petrochenkov
Replace per-target ABI denylist with an allowlist

It makes very little sense to maintain denylists of ABIs when, as far as
non-generic ABIs are concerned, targets usually only support a small
subset of the available ABIs.

This has historically been a cause of bugs such as us allowing use of
the platform-specific ABIs on x86 targets – these in turn would cause
LLVM errors or assertions to fire.

In this PR we got rid of the per-target ABI denylists, and instead compute
which ABIs are supported with a simple match based on, mostly, the
`Target::arch` field. Among other things, this makes it impossible to
forget to consider this problem (in either direction) and forces one to
consider what the ABI support looks like when adding an ABI (rarely)
rather than target (often), which should hopefully also reduce the
cognitive load on both contributors as well as reviewers.

Fixes #57182

Sponsored by: standard.ai

---

## Summary for teams

One significant user-facing change after this PR is that there's now a future compat warning when building…

* `stdcall`, `fastcall`, `thiscall` using code with targets other than 32-bit x86 (i386...i686) or *-windows-*;
* `vectorcall` using code when building for targets other than x86 (either 32 or 64 bit) or *-windows-*.

Previously these ABIs have been accepted much more broadly, even for architectures and targets where this made no sense (e.g. on wasm32) and would fall back to the C ABI. In practice this doesn't seem to be used too widely and the [breakages in crater](https://github.com/rust-lang/rust/pull/86231#issuecomment-866300943) that we see are mostly about Windows-specific code that was missing relevant `cfg`s and just happened to successfully `check` on Linux for one reason or another.

The intention is that this warning becomes a hard error after some time.
2021-07-06 14:02:19 +00:00
Wesley Wiser 457165e1ed Fix failing test on i686-pc-windows-msvc 2021-07-06 09:55:11 -04:00
Júnior Bassani 0d61e6e8d6
Fix typo in core::sync::atomic::compiler_fence example 2021-07-06 10:53:14 -03:00
Júnior Bassani a87fb18027
Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example 2021-07-06 10:50:17 -03:00
bjorn3 323a74779f Move LinkerInfo into CrateInfo 2021-07-06 15:31:38 +02:00
Ryan Levick 5af5a6d49d Add missing docs and remove dead code 2021-07-06 13:47:03 +02:00
bors d04ec47358 Auto merge of #86143 - bjorn3:revert_revert_merge_crate_disambiguator, r=michaelwoerister
Reland "Merge CrateDisambiguator into StableCrateId"

Reverts https://github.com/rust-lang/rust/pull/85891 as this revert of #85804 made perf even worse.

r? `@Mark-Simulacrum`
2021-07-06 11:31:59 +00:00
Simonas Kazlauskas 8240e7aa10 Replace per-target ABI denylist with an allowlist
It makes very little sense to maintain denylists of ABIs when, as far as
non-generic ABIs are concerned, targets usually only support a small
subset of the available ABIs.

This has historically been a cause of bugs such as us allowing use of
the platform-specific ABIs on x86 targets – these in turn would cause
LLVM errors or assertions to fire.

Fixes #57182

Sponsored by: standard.ai
2021-07-06 13:12:15 +03:00
bjorn3 56c6a48d2e Truncate hex stable crate id to 8 characters (32 bits) 2021-07-06 11:36:23 +02:00
bjorn3 ca935ddbf1 Make tcx.stable_crate_id() faster 2021-07-06 11:28:06 +02:00
bjorn3 e95bd03f01 Revert "Revert "Update mir opt tests""
This reverts commit 8d5fb5bf7d.
2021-07-06 11:28:06 +02:00