]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se
Jubilee [Mon, 4 Oct 2021 20:58:08 +0000 (13:58 -0700)]
Rollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se

VecDeque: improve performance for From<[T; N]>

Create `VecDeque` directly from the array instead of inserting items one-by-one.

Benchmark
```
./x.py bench library/alloc --test-args vec_deque::bench_from_array_1000
```

* Before
```
test vec_deque::bench_from_array_1000                    ... bench:       3,991 ns/iter (+/- 717)
```

* After
```
test vec_deque::bench_from_array_1000                    ... bench:         268 ns/iter (+/- 37)
```

2 years agoRollup merge of #88451 - theo-lw:issue-87771, r=jackh726
Jubilee [Mon, 4 Oct 2021 20:58:07 +0000 (13:58 -0700)]
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726

Fix an ICE caused by type mismatch errors being ignored

This PR fixes #87771. It turns out that the check on `compiler/rustc_typeck/src/check/demand.rs:148` leads to the ICE. I removed it because the early return in [`check_expr_assign`](https://github.com/theo-lw/rust/blob/dec7fc3ced5bc3c18d0e5d29921d087f93189cb8/compiler/rustc_typeck/src/check/expr.rs#L928) already prevents unnecessary error messages from the call to `check_expr_coercable_to_type`.

2 years agoRollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett
Jubilee [Mon, 4 Oct 2021 20:58:07 +0000 (13:58 -0700)]
Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett

implement advance_(back_)_by on more iterators

Add more efficient, non-default implementations for `feature(iter_advance_by)` (#77404) on more iterators and adapters.

This PR only contains implementations where skipping over items doesn't elide any observable side-effects such as user-provided closures or `clone()` functions. I'll put those in a separate PR.

2 years agoRollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee
Jubilee [Mon, 4 Oct 2021 20:58:06 +0000 (13:58 -0700)]
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee

[aarch64] add target feature outline-atomics

Enable outline-atomics by default as enabled in clang by the following commit
https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11

Performance improves by several orders of magnitude when using the LSE instructions
instead of the ARMv8.0 compatible load/store exclusive instructions.

Tested on Graviton2 aarch64-linux with
x.py build && x.py install && x.py test

2 years agoAuto merge of #88834 - the8472:char-count, r=joshtriplett
bors [Mon, 4 Oct 2021 12:49:57 +0000 (12:49 +0000)]
Auto merge of #88834 - the8472:char-count, r=joshtriplett

optimize str::from_utf8() validation when slice contains multibyte chars and str.chars().count() in all cases

The change shows small but consistent improvements across several x86 target feature levels. I also tried to optimize counting with `slice.as_chunks` but that yielded more inconsistent results, bigger improvements for some optimization levels, lesser ones in others.

```
old, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,924 ns/iter (+/- 26)
test str::str_char_count_lorem                                  ... bench:         879 ns/iter (+/- 12)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,878 ns/iter (+/- 21)
test str::str_char_count_lorem                                  ... bench:         851 ns/iter (+/- 11)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,477 ns/iter (+/- 46)
test str::str_char_count_lorem                                  ... bench:         675 ns/iter (+/- 15)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,323 ns/iter (+/- 39)
test str::str_char_count_lorem                                  ... bench:         593 ns/iter (+/- 18)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         748 ns/iter (+/- 7)
test str::str_char_count_lorem                                  ... bench:         348 ns/iter (+/- 2)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         650 ns/iter (+/- 4)
test str::str_char_count_lorem                                  ... bench:         301 ns/iter (+/- 1)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)
```

and for the multibyte-char string validation:

```
old, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       4,606 ns/iter (+/- 64)

new, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       3,837 ns/iter (+/- 60)
```

2 years agoAuto merge of #89489 - FabianWolff:issue-89485, r=oli-obk
bors [Mon, 4 Oct 2021 10:09:04 +0000 (10:09 +0000)]
Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obk

Fix unsound optimization with explicit variant discriminants

Fixes #89485.

2 years agoAuto merge of #89512 - Manishearth:rollup-meh9x7r, r=Manishearth
bors [Mon, 4 Oct 2021 07:25:50 +0000 (07:25 +0000)]
Auto merge of #89512 - Manishearth:rollup-meh9x7r, r=Manishearth

Rollup of 14 pull requests

Successful merges:

 - #86434 (Add `Ipv6Addr::is_benchmarking`)
 - #86828 (const fn for option copied, take & replace)
 - #87679 (BTree: refine some comments)
 - #87910 (Mark unsafe methods NonZero*::unchecked_(add|mul) as const.)
 - #88286 (Remove unnecessary unsafe block in `process_unix`)
 - #88305 (Manual Debug for Unix ExitCode ExitStatus ExitStatusError)
 - #88353 (Partially stabilize `array_methods`)
 - #88370 (Add missing `# Panics` section to `Vec` method)
 - #88481 (Remove some feature gates)
 - #89138 (Fix link in Ipv6Addr::to_ipv4 docs)
 - #89401 (Add truncate note to Vec::resize)
 - #89467 (Fix typos in rustdoc/lints)
 - #89472 (Only register `WSACleanup` if `WSAStartup` is actually ever called)
 - #89505 (Add regression test for spurious const error with NLL)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #89505 - Aaron1011:nll-const-test, r=Mark-Simulacrum
Manish Goregaokar [Mon, 4 Oct 2021 06:13:25 +0000 (23:13 -0700)]
Rollup merge of #89505 - Aaron1011:nll-const-test, r=Mark-Simulacrum

Add regression test for spurious const error with NLL

Fixes #55825

2 years agoRollup merge of #89472 - nagisa:nagisa/wsa-cleanup, r=dtolnay
Manish Goregaokar [Mon, 4 Oct 2021 06:13:24 +0000 (23:13 -0700)]
Rollup merge of #89472 - nagisa:nagisa/wsa-cleanup, r=dtolnay

Only register `WSACleanup` if `WSAStartup` is actually ever called

See https://github.com/rust-lang/rust/pull/85595

Fixes #85441

2 years agoRollup merge of #89467 - tniessen:rustdoc-unecessary, r=jyn514
Manish Goregaokar [Mon, 4 Oct 2021 06:13:23 +0000 (23:13 -0700)]
Rollup merge of #89467 - tniessen:rustdoc-unecessary, r=jyn514

Fix typos in rustdoc/lints

This PR merely fixes a few typos in a recently introduced change :)

Refs: https://github.com/rust-lang/rust/pull/85223

2 years agoRollup merge of #89401 - owengage:master, r=joshtriplett
Manish Goregaokar [Mon, 4 Oct 2021 06:13:22 +0000 (23:13 -0700)]
Rollup merge of #89401 - owengage:master, r=joshtriplett

Add truncate note to Vec::resize

A very minor addition to the `Vec::resize` documentation to point out the `truncate` method.
When I was searching for something matching `truncate` I managed to miss it, along with some colleagues. We later found it by chance. We did find `resize` however, so I was hoping to point it out in the documentation.

2 years agoRollup merge of #89138 - newpavlov:patch-2, r=dtolnay
Manish Goregaokar [Mon, 4 Oct 2021 06:13:21 +0000 (23:13 -0700)]
Rollup merge of #89138 - newpavlov:patch-2, r=dtolnay

Fix link in Ipv6Addr::to_ipv4 docs

2 years agoRollup merge of #88481 - bjorn3:remove_feature_gates, r=cjgillot
Manish Goregaokar [Mon, 4 Oct 2021 06:13:20 +0000 (23:13 -0700)]
Rollup merge of #88481 - bjorn3:remove_feature_gates, r=cjgillot

Remove some feature gates

The first commit removes various feature gates that are unused. The second commit replaces some `Fn` implementations with `Iterator` implementations, which is much cleaner IMO. The third commit replaces an unboxed_closures feature gate with min_specialization. For some reason the unboxed_closures feature gate suppresses the min_specialization feature gate from triggering on an `TrustedStep` impl. The last comment just turns a regular comment into a doc comment as drive by cleanup. I can move it to a separate PR if preferred.

2 years agoRollup merge of #88370 - Seppel3210:master, r=dtolnay
Manish Goregaokar [Mon, 4 Oct 2021 06:13:20 +0000 (23:13 -0700)]
Rollup merge of #88370 - Seppel3210:master, r=dtolnay

Add missing `# Panics` section to `Vec` method

namely `Vec::extend_from_within`

2 years agoRollup merge of #88353 - jhpratt:stabilize-array-as-ref, r=joshtriplett
Manish Goregaokar [Mon, 4 Oct 2021 06:13:19 +0000 (23:13 -0700)]
Rollup merge of #88353 - jhpratt:stabilize-array-as-ref, r=joshtriplett

Partially stabilize `array_methods`

This stabilizes `<[T; N]>::as_slice` and `<[T; N]>::as_mut_slice`, which is forms part of the `array_methods` feature: #76118.

This also makes `<[T; N]>::as_slice` const due to its trivial nature.

2 years agoRollup merge of #88305 - ijackson:exitstatus-debug, r=dtolnay
Manish Goregaokar [Mon, 4 Oct 2021 06:13:18 +0000 (23:13 -0700)]
Rollup merge of #88305 - ijackson:exitstatus-debug, r=dtolnay

Manual Debug for Unix ExitCode ExitStatus ExitStatusError

These structs have misleading names.  An ExitStatus[Error] is actually a Unix wait status; an ExitCode is actually an exit status.  These misleading names appear in the `Debug` output.

The `Display` impls on Unix have been improved, but the `Debug` impls are still misleading, as reported in #74832.

Fix this by pretending that these internal structs are called `unix_exit_status` and `unix_wait_status` as applicable.  (We can't actually rename the structs because of the way that the cross-platform machinery works: the names are cross-platform.)

After this change, this program
```
#![feature(exit_status_error)]
fn main(){
    let x = std::process::Command::new("false").status().unwrap();
    dbg!(x.exit_ok());
    eprintln!("x={:?}",x);
}
```
produces this output
```
[src/main.rs:4] x.exit_ok() = Err(
    ExitStatusError(
        unix_wait_status(
            256,
        ),
    ),
)
x=ExitStatus(unix_wait_status(256))
```

Closes #74832

2 years agoRollup merge of #88286 - LeSeulArtichaut:unnecessary-unsafe-block-std, r=dtolnay
Manish Goregaokar [Mon, 4 Oct 2021 06:13:18 +0000 (23:13 -0700)]
Rollup merge of #88286 - LeSeulArtichaut:unnecessary-unsafe-block-std, r=dtolnay

Remove unnecessary unsafe block in `process_unix`

Because it's nested under this unsafe fn!

This block isn't detected as unnecessary because of a bug in the compiler: #88260.

2 years agoRollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtr...
Manish Goregaokar [Mon, 4 Oct 2021 06:13:17 +0000 (23:13 -0700)]
Rollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtriplett

Mark unsafe methods NonZero*::unchecked_(add|mul) as const.

Now that https://github.com/rust-lang/rfcs/pull/3016 has landed, these two unstable `std` function can be marked `const`, according to this detail of #84186.

2 years agoRollup merge of #87679 - ssomers:btree_comments, r=joshtriplett
Manish Goregaokar [Mon, 4 Oct 2021 06:13:16 +0000 (23:13 -0700)]
Rollup merge of #87679 - ssomers:btree_comments, r=joshtriplett

BTree: refine some comments

2 years agoRollup merge of #86828 - lambinoo:67441-const-fn-copied-take-replace, r=joshtriplett
Manish Goregaokar [Mon, 4 Oct 2021 06:13:16 +0000 (23:13 -0700)]
Rollup merge of #86828 - lambinoo:67441-const-fn-copied-take-replace, r=joshtriplett

const fn for option copied, take & replace

Tracking issue: [#67441](https://github.com/rust-lang/rust/issues/67441)

Adding const fn for the copied, take and replace method of Option. Also adding necessary unit test.

It's my first contribution so I am pretty sure I don't know what I'm doing but there's a first for everything!

2 years agoRollup merge of #86434 - CDirkx:ipv6-benchmarking, r=joshtriplett
Manish Goregaokar [Mon, 4 Oct 2021 06:13:15 +0000 (23:13 -0700)]
Rollup merge of #86434 - CDirkx:ipv6-benchmarking, r=joshtriplett

Add `Ipv6Addr::is_benchmarking`

This PR adds the unstable method `Ipv6Addr::is_benchmarking`. This method is added for parity with `Ipv4Addr::is_benchmarking`, and I intend to use it in a future rework of `Ipv6Addr::is_global` (edit: #86634) to more accurately follow the [IANA Special Address Registry](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml) (like is done in `Ipv4Addr::is_global`).

With `Ipv6Addr::is_benchmarking` and `Ipv4Addr::is_benchmarking` now both existing, `IpAddr::is_benchmarking` is also added.

2 years agoAuto merge of #89165 - jkugelman:read-to-end-overallocation, r=joshtriplett
bors [Mon, 4 Oct 2021 04:44:56 +0000 (04:44 +0000)]
Auto merge of #89165 - jkugelman:read-to-end-overallocation, r=joshtriplett

Fix read_to_end to not grow an exact size buffer

If you know how much data to expect and use `Vec::with_capacity` to pre-allocate a buffer of that capacity, `Read::read_to_end` will still double its capacity. It needs some space to perform a read, even though that read ends up returning `0`.

It's a bummer to carefully pre-allocate 1GB to read a 1GB file into memory and end up using 2GB.

This fixes that behavior by special casing a full buffer and reading into a small "probe" buffer instead. If that read returns `0` then it's confirmed that the buffer was the perfect size. If it doesn't, the probe buffer is appended to the normal buffer and the read loop continues.

Fixing this allows several workarounds in the standard library to be removed:

- `Take` no longer needs to override `Read::read_to_end`.
- The `reservation_size` callback that allowed `Take` to inhibit the previous over-allocation behavior isn't needed.
- `fs::read` doesn't need to reserve an extra byte in `initial_buffer_size`.

Curiously, there was a unit test that specifically checked that `Read::read_to_end` *does* over-allocate. I removed that test, too.

2 years agoAdd regression test for spurious const error with NLL
Aaron Hill [Sun, 3 Oct 2021 21:54:54 +0000 (16:54 -0500)]
Add regression test for spurious const error with NLL

Fixes #55825

2 years agoAuto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth
bors [Sun, 3 Oct 2021 21:44:10 +0000 (21:44 +0000)]
Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth

Add expansion to while desugar spans

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`

2 years agoDisable `SimplifyBranchSame` optimization for now
Fabian Wolff [Sun, 3 Oct 2021 20:58:24 +0000 (22:58 +0200)]
Disable `SimplifyBranchSame` optimization for now

2 years agoUpdate comments
Fabian Wolff [Sun, 3 Oct 2021 19:06:49 +0000 (21:06 +0200)]
Update comments

2 years agoAuto merge of #89486 - rusticstuff:docker_letsencrypt_ca_update, r=Mark-Simulacrum
bors [Sun, 3 Oct 2021 19:03:23 +0000 (19:03 +0000)]
Auto merge of #89486 - rusticstuff:docker_letsencrypt_ca_update, r=Mark-Simulacrum

Update Let's Encrypt ROOT CA certificate in dist-(i686|x86_64)-linux docker images

The DST Root CA X3 used by Let's Encrypt has expired ([Let's Encrypt announcement](https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/)). This patch installs the new root certificate (ISRG Root X1) and disables the old one. Disabling the old one is necessary because otherwise curl still fails to download from servers with Let's Encrypt certs even though they are cross-signed.

Fixes #89484.

2 years agoAuto merge of #88086 - ssomers:btree_clone_testing, r=dtolnay
bors [Sun, 3 Oct 2021 16:22:37 +0000 (16:22 +0000)]
Auto merge of #88086 - ssomers:btree_clone_testing, r=dtolnay

BTree: toughen panicky test of clone()

Test did not cover the second half of `clone_subtree` and why this clones key & value first.

2 years agoReplace Fn impls with RPIT impls in rustc_index
bjorn3 [Sat, 2 Oct 2021 17:47:04 +0000 (19:47 +0200)]
Replace Fn impls with RPIT impls in rustc_index

This is cleaner and removes an unstable feature usage

2 years agoFix unsound optimization with explicit variant discriminants
Fabian Wolff [Sun, 3 Oct 2021 13:29:56 +0000 (15:29 +0200)]
Fix unsound optimization with explicit variant discriminants

2 years agoAuto merge of #87870 - WaffleLapkin:pub_split_at_unchecked, r=dtolnay
bors [Sun, 3 Oct 2021 13:41:52 +0000 (13:41 +0000)]
Auto merge of #87870 - WaffleLapkin:pub_split_at_unchecked, r=dtolnay

Make `<[T]>::split_at_unchecked` and `<[T]>::split_at_mut_unchecked` public

The methods were originally added in https://github.com/rust-lang/rust/pull/75936 (https://github.com/sdroege/rust/commit/30dc32b10eb53e4a92c61a42062983db58838217), but for some reason as private. Nevertheless, the methods have documentation and even a [tracking issue](https://github.com/rust-lang/rust/issues/76014).

It's very weird to have a tracking issue for private methods and these methods may be useful outside of the standard library. As such, this PR makes the methods public.

2 years agoAuto merge of #89459 - tspiteri:idiv-overflow-bitand, r=kennytm
bors [Sun, 3 Oct 2021 10:34:57 +0000 (10:34 +0000)]
Auto merge of #89459 - tspiteri:idiv-overflow-bitand, r=kennytm

Use bitand when checking for signed integer division overflow

For `self == Self::MIN && rhs == -1`, LLVM does not realize that this is the same check made by `self / rhs`, so the code generated may have some unnecessary duplication. For `(self == Self::MIN) & (rhs == -1)`, LLVM realizes it is the same check.

2 years agoUpdate Let's Encrypt ROOT CA certificate in dist-(i686|x86_64)-linux docker images
Hans Kratz [Sun, 3 Oct 2021 08:58:37 +0000 (10:58 +0200)]
Update Let's Encrypt ROOT CA certificate in dist-(i686|x86_64)-linux docker images

2 years agoAuto merge of #88060 - TennyZhuang:optimize-vec-retain, r=dtolnay
bors [Sun, 3 Oct 2021 06:24:06 +0000 (06:24 +0000)]
Auto merge of #88060 - TennyZhuang:optimize-vec-retain, r=dtolnay

Optimize unnecessary check in Vec::retain

The function `vec::Vec::retain` only have two stages:

1. Nothing was deleted.
2. Some elements were deleted.

Here is an unnecessary check `if g.deleted_cnt > 0` in the loop, and it's difficult for compiler to optimize it. I split the loop into two stages manully and keep the code clean using const generics.

I write a special but common bench case for this optimization. I call retain on vec but keep all elements.

Before and after this optimization:

```
test vec::bench_retain_whole_100000                      ... bench:      84,803 ns/iter (+/- 17,314)
```

```
test vec::bench_retain_whole_100000                      ... bench:      42,638 ns/iter (+/- 16,910)
```

The result is expected, there are two `if`s before the optimization and one `if` after.

2 years agoAuto merge of #89479 - camsteffen:diag-naming, r=Manishearth
bors [Sun, 3 Oct 2021 03:43:21 +0000 (03:43 +0000)]
Auto merge of #89479 - camsteffen:diag-naming, r=Manishearth

Make diangostic item naming consistent

Right now there is about a 50/50 split of naming diagnostic items as `vec_type` vs `Vec`. So it is hard to guess a diagnostic item name with confidence. I know it's not great to change these retroactively, but I think it will be much easier to maintain consistency after consistency is established.

2 years agoAuto merge of #84267 - dtolnay:ptrunit, r=nagisa
bors [Sun, 3 Oct 2021 00:41:49 +0000 (00:41 +0000)]
Auto merge of #84267 - dtolnay:ptrunit, r=nagisa

Make *const (), *mut () okay for FFI

Pointer-to-() is used occasionally in the standard library to mean "pointer to none-of-your-business". Examples:

- `RawWakerVTable::new` https://doc.rust-lang.org/1.51.0/std/task/struct.RawWakerVTable.html#method.new
- `<*const T>::to_raw_parts` https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.to_raw_parts

I believe it's useful for the same purpose in FFI signatures, even while `()` itself is not FFI safe. The following should be allowed:

```rust
extern "C" {
    fn demo(pc: *const (), pm: *mut ());
}
```

Prior to this PR, those pointers were not considered okay for an extern signature.

```console
warning: `extern` block uses type `()`, which is not FFI-safe
 --> src/main.rs:2:17
  |
2 |     fn demo(pc: *const (), pm: *mut ());
  |                 ^^^^^^^^^ not FFI-safe
  |
  = note: `#[warn(improper_ctypes)]` on by default
  = help: consider using a struct instead
  = note: tuples have unspecified layout

warning: `extern` block uses type `()`, which is not FFI-safe
 --> src/main.rs:2:32
  |
2 |     fn demo(pc: *const (), pm: *mut ());
  |                                ^^^^^^^ not FFI-safe
  |
  = help: consider using a struct instead
  = note: tuples have unspecified layout
```

2 years agoMake diangostic item names consistent
Cameron Steffen [Sat, 2 Oct 2021 23:51:01 +0000 (18:51 -0500)]
Make diangostic item names consistent

2 years agoAdd desugaring mark to while loop
Cameron Steffen [Thu, 19 Aug 2021 21:57:15 +0000 (16:57 -0500)]
Add desugaring mark to while loop

2 years agoAuto merge of #89345 - jackh726:89333, r=estebank
bors [Sat, 2 Oct 2021 21:30:51 +0000 (21:30 +0000)]
Auto merge of #89345 - jackh726:89333, r=estebank

Don't lose binders when printing trait bound suggestion

Fixes #89333

2 years agoRun the #85441 regression test on MSVC only
Simonas Kazlauskas [Sat, 2 Oct 2021 19:10:00 +0000 (22:10 +0300)]
Run the #85441 regression test on MSVC only

On MinGW toolchains the various features (such as function sections)
necessary to eliminate dead function references are disabled due to
various bugs. This means that the windows sockets library will most
likely remain linked to any mingw toolchain built program that also
utilizes libstd.

That said, I made an attempt to also enable `function-sections` and
`--gc-sections` during my experiments, but the symbol references
remained, sadly.

2 years agoAdd test for checking if WS2_32.dll is linked
Christiaan Dirkx [Mon, 24 May 2021 22:05:18 +0000 (00:05 +0200)]
Add test for checking if WS2_32.dll is linked

2 years agoOnly register `WSACleanup` if `WSAStartup` is actually ever called
Christiaan Dirkx [Mon, 24 May 2021 21:58:20 +0000 (23:58 +0200)]
Only register `WSACleanup` if `WSAStartup` is actually ever called

2 years agoAuto merge of #89341 - audunhalland:derive-type-params-with-bound-generic-params...
bors [Sat, 2 Oct 2021 18:46:27 +0000 (18:46 +0000)]
Auto merge of #89341 - audunhalland:derive-type-params-with-bound-generic-params, r=jackh726

Deriving: Include bound generic params in type parameters for where clause

Fixes #89188.

The `derive` macro ignored the `for<'s>` needed with the `Fn` trait in that code example.

edit: I'm unsure if this might cause regressions. I'm not an experienced compiler developer so I'm not used to thinking about unwanted side effects code changes like this might have.

2 years agoTurn a module non-doc comment into a doc comment
bjorn3 [Sun, 29 Aug 2021 18:39:32 +0000 (20:39 +0200)]
Turn a module non-doc comment into a doc comment

2 years agoSwap out unboxed_closures feature gate for min_specialization
bjorn3 [Sun, 29 Aug 2021 17:42:41 +0000 (19:42 +0200)]
Swap out unboxed_closures feature gate for min_specialization

For some reason unboxed_closures supresses the feature gate for
min_specialization when implementing TrustedStep. min_specialization is
the true feature that is used.

2 years agoRemove various unused feature gates
bjorn3 [Sun, 29 Aug 2021 19:09:45 +0000 (21:09 +0200)]
Remove various unused feature gates

2 years agoFix typos in rustdoc/lints
Tobias Nießen [Sat, 2 Oct 2021 17:03:32 +0000 (19:03 +0200)]
Fix typos in rustdoc/lints

Refs: https://github.com/rust-lang/rust/pull/85223

2 years agoAuto merge of #89239 - petrochenkov:modcache, r=cjgillot
bors [Sat, 2 Oct 2021 16:17:13 +0000 (16:17 +0000)]
Auto merge of #89239 - petrochenkov:modcache, r=cjgillot

resolve: Cache module loading for all foreign modules

It was previously cached for modules loaded from `fn get_module`, but not for modules loaded from `fn build_reduced_graph_for_external_crate_res`.
This also makes all foreign modules use their real parent, span and expansion instead of possibly a parent/span/expansion of their reexport.
Modules are also often compared using referential equality (`ptr::eq`), this change makes such comparisons correct in all cases.

An ICE happening on attempt to decode expansions for foreign enums and traits is avoided.

Also local enums and traits are now added to the module map.

Follow up to https://github.com/rust-lang/rust/pull/88872.
r? `@cjgillot`

2 years agorustc_span: Make hygiene debug printing reproducible
Vadim Petrochenkov [Sun, 26 Sep 2021 21:43:04 +0000 (00:43 +0300)]
rustc_span: Make hygiene debug printing reproducible

2 years agoresolve: Avoid comparing modules by optional def-id
Vadim Petrochenkov [Sun, 26 Sep 2021 16:29:53 +0000 (19:29 +0300)]
resolve: Avoid comparing modules by optional def-id

It makes all block modules identical during comparison

2 years agoresolve: Cache module loading for all foreign modules
Vadim Petrochenkov [Fri, 24 Sep 2021 23:27:00 +0000 (02:27 +0300)]
resolve: Cache module loading for all foreign modules

It was previously cached for modules loaded from `fn get_module`, but not for modules loaded from `fn build_reduced_graph_for_external_crate_res`.
This also makes all foreign modules use their real parent, span and expansion instead of possibly a parent/span/expansion of their reexport.

An ICE happening on attempt to decode expansions for foreign enums and traits is avoided.

Also local enums and traits are now added to the module map.

2 years agoAuto merge of #89408 - Mark-Simulacrum:fix-query-nondet, r=petrochenkov
bors [Sat, 2 Oct 2021 13:36:27 +0000 (13:36 +0000)]
Auto merge of #89408 - Mark-Simulacrum:fix-query-nondet, r=petrochenkov

Avoid nondeterminism in trimmed_def_paths

Previously this query depended on the global interning order of Symbols, which
meant that irrelevant changes could influence the query and cause
recompilations. This commit ensures that the return set is stable and will not
be affected by the global order by deterministically (in lexicographic order)
choosing a name to use if there are multiple names for a single DefId.

This should fix the cause of the [regressions] in #83343.

[regressions]: https://perf.rust-lang.org/compare.html?start=9620f3a84b079decfdc2e557be007580b097fe43&end=addb4da686a97da46159f0123cb6cdc2ce3d7fdb

2 years agoAuto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillot
bors [Sat, 2 Oct 2021 10:52:09 +0000 (10:52 +0000)]
Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillot

Fix clippy lints

I'm currently working on allowing clippy to run on librustdoc after a discussion I had with `@Mark-Simulacrum.` So in the meantime, I fixed a few lints on the compiler crates.

2 years agoUse bitand when checking for signed integer division overflow
Trevor Spiteri [Sat, 2 Oct 2021 10:16:08 +0000 (12:16 +0200)]
Use bitand when checking for signed integer division overflow

For `self == Self::MIN && rhs == -1`, LLVM does not realize that this is the
same check made by `self / rhs`, so the code generated may have some unnecessary
duplication. For `(self == Self::MIN) & (rhs == -1)`, LLVM realizes it is the
same check.

2 years agoExpand one test (from jackh726)
Audun Halland [Sat, 2 Oct 2021 09:26:10 +0000 (11:26 +0200)]
Expand one test (from jackh726)

2 years agoAuto merge of #89450 - usbalbin:const_try_revert, r=oli-obk
bors [Sat, 2 Oct 2021 07:41:25 +0000 (07:41 +0000)]
Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk

Revert #86853

Should fix issue found in #89432

2 years agoAdd regression test for #89432
Albin Hedman [Fri, 1 Oct 2021 23:12:15 +0000 (01:12 +0200)]
Add regression test for #89432

Co-authored-by: Josh Stone <cuviper@gmail.com>
2 years agoAuto merge of #89449 - Manishearth:rollup-3alb61f, r=Manishearth
bors [Fri, 1 Oct 2021 22:47:22 +0000 (22:47 +0000)]
Auto merge of #89449 - Manishearth:rollup-3alb61f, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #85223 (rustdoc: Clarified the attribute which prompts the warning)
 - #88847 (platform-support.md: correct ARMv7+MUSL platform triple notes)
 - #88963 (Coerce const FnDefs to implement const Fn traits )
 - #89376 (Fix use after drop in self-profile with llvm events)
 - #89422 (Replace whitespaces in doctests' name with dashes)
 - #89440 (Clarify a sentence in the documentation of Vec (#84488))
 - #89441 (Normalize after substituting via `field.ty()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRevert "Auto merge of #86853 - usbalbin:const_try, r=oli-obk"
Albin Hedman [Fri, 1 Oct 2021 22:07:48 +0000 (00:07 +0200)]
Revert "Auto merge of #86853 - usbalbin:const_try, r=oli-obk"

This reverts commit c6007fdc7059c677a6c089e8d2915b264c0d1326, reversing
changes made to 69c1c6a173dcae20c245348f6c7d19074b6109b7.

2 years agoRollup merge of #89441 - Nadrieril:fix-89393, r=tmandry
Manish Goregaokar [Fri, 1 Oct 2021 21:46:52 +0000 (14:46 -0700)]
Rollup merge of #89441 - Nadrieril:fix-89393, r=tmandry

Normalize after substituting via `field.ty()`

Back in https://github.com/rust-lang/rust/issues/72476 I hadn't understood where the problem was coming from, and only worked around the issue. What happens is that calling `field.ty()` on a field of a generic struct substitutes the appropriate generics but doesn't normalize the resulting type.
As a consumer of types I'm surprised that one would substitute without normalizing, feels like a footgun, so I added a comment.

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

2 years agoRollup merge of #89440 - chrismit3s:issue-84488-fix, r=steveklabnik
Manish Goregaokar [Fri, 1 Oct 2021 21:46:51 +0000 (14:46 -0700)]
Rollup merge of #89440 - chrismit3s:issue-84488-fix, r=steveklabnik

Clarify a sentence in the documentation of Vec (#84488)

 I literally changed a single word, but this should clear up the confusion of #84488. Can probably be `rollup`ed :) (My first PR, hope I'm doing this right)

fixes #84488

r? `@steveklabnik`

2 years agoRollup merge of #89422 - GuillaumeGomez:doctest-whitespace-name, r=CraftSpider
Manish Goregaokar [Fri, 1 Oct 2021 21:46:50 +0000 (14:46 -0700)]
Rollup merge of #89422 - GuillaumeGomez:doctest-whitespace-name, r=CraftSpider

Replace whitespaces in doctests' name with dashes

Fixes #88263.

Instead of handling white spaces when we filter tests (which would be quite complicated since we split on them!), I propose to instead replace them with dashes.

So for example, this:

```console
test foo.rs - Iter2<T, P>::len (line 13) ... ok
test foo.rs - Iter<T, P>::len (line 4) ... ok
```

becomes:

```console
test foo.rs - Iter<T,-P>::len (line 4) ... ok
test foo.rs - Iter2<T,-P>::len (line 13) ... ok
```

r? `@jyn514`

2 years agoRollup merge of #89376 - andjo403:selfProfileUseAfterDropFix, r=Mark-Simulacrum
Manish Goregaokar [Fri, 1 Oct 2021 21:46:49 +0000 (14:46 -0700)]
Rollup merge of #89376 - andjo403:selfProfileUseAfterDropFix, r=Mark-Simulacrum

Fix use after drop in self-profile with llvm events

self-profile with `-Z self-profile-events=llvm` have failed with a segmentation fault due to this use after drop.
this type of events can be more useful now that the new passmanager is the default.

2 years agoRollup merge of #88963 - fee1-dead:const-iterator, r=oli-obk
Manish Goregaokar [Fri, 1 Oct 2021 21:46:48 +0000 (14:46 -0700)]
Rollup merge of #88963 - fee1-dead:const-iterator, r=oli-obk

Coerce const FnDefs to implement const Fn traits

You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`.

r? ``@oli-obk``

``@rustbot`` label T-compiler F-const_trait_impl

2 years agoRollup merge of #88847 - oliverbr:master, r=steveklabnik
Manish Goregaokar [Fri, 1 Oct 2021 21:46:47 +0000 (14:46 -0700)]
Rollup merge of #88847 - oliverbr:master, r=steveklabnik

platform-support.md: correct ARMv7+MUSL platform triple notes

This PR fixes two minor inconsistencies in the platform support list.

- use "with MUSL" suffix for "armv7-unknown-linux-musleabi"
- add "hardfloat" suffix for "armv7-unknown-linux-musleabihf"

r? `@steveklabnik`

2 years agoRollup merge of #85223 - simbleau:master, r=steveklabnik
Manish Goregaokar [Fri, 1 Oct 2021 21:46:46 +0000 (14:46 -0700)]
Rollup merge of #85223 - simbleau:master, r=steveklabnik

rustdoc: Clarified the attribute which prompts the warning

The example call was lacking clarification of the  `#![warn(rustdoc::invalid_codeblock_attributes)]` attribute which generates the specified warning.

2 years agoDon't use Default, since the impls are different on wasm
jackh726 [Fri, 1 Oct 2021 21:21:39 +0000 (17:21 -0400)]
Don't use Default, since the impls are different on wasm

2 years agoFix clippy lints
Guillaume Gomez [Thu, 30 Sep 2021 17:38:50 +0000 (19:38 +0200)]
Fix clippy lints

2 years agoAuto merge of #88880 - cjgillot:no-krate, r=oli-obk
bors [Fri, 1 Oct 2021 20:06:34 +0000 (20:06 +0000)]
Auto merge of #88880 - cjgillot:no-krate, r=oli-obk

Rework HIR API to make invocations of the hir_crate query harder.

`hir_crate` forces the recomputation of queries that depend on it.

This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.

2 years agoDon't lose binders when printing trait bound suggestion
jackh726 [Wed, 29 Sep 2021 00:12:46 +0000 (20:12 -0400)]
Don't lose binders when printing trait bound suggestion

2 years agoReplace whitespaces in doctests' name with dashes
Guillaume Gomez [Fri, 1 Oct 2021 09:46:34 +0000 (11:46 +0200)]
Replace whitespaces in doctests' name with dashes

2 years agoNormalize after substituting via `field.ty()`
Nadrieril [Fri, 1 Oct 2021 18:09:43 +0000 (19:09 +0100)]
Normalize after substituting via `field.ty()`

2 years agoClarify a sentence in the documentation of Vec (#84488)
chrismit3s [Fri, 1 Oct 2021 18:07:36 +0000 (20:07 +0200)]
Clarify a sentence in the documentation of Vec (#84488)

2 years agoAuto merge of #89435 - Manishearth:rollup-vh2ih7k, r=Manishearth
bors [Fri, 1 Oct 2021 17:17:43 +0000 (17:17 +0000)]
Auto merge of #89435 - Manishearth:rollup-vh2ih7k, r=Manishearth

Rollup of 6 pull requests

Successful merges:

 - #87868 (Added -Z randomize-layout flag)
 - #88820 (Add `pie` as another `relocation-model` value)
 - #89029 (feat(rustc_parse): recover from pre-RFC-2000 const generics syntax)
 - #89322 (Reapply "Remove optimization_fuel_crate from Session")
 - #89340 (Improve error message for `printf`-style format strings)
 - #89415 (Correct caller/callsite confusion in inliner message)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #89415 - wesleywiser:inliner_caller_callsite_message, r=michaelwoerister
Manish Goregaokar [Fri, 1 Oct 2021 16:18:20 +0000 (09:18 -0700)]
Rollup merge of #89415 - wesleywiser:inliner_caller_callsite_message, r=michaelwoerister

Correct caller/callsite confusion in inliner message

`callee_body` is the MIR `Body` for the `callsite.callee` so this message basically says `"Inline {bar span} into bar"` when it should say `"Inline bar into foo"`.

Extracted out of #82280

2 years agoRollup merge of #89340 - FabianWolff:issue-89173, r=petrochenkov
Manish Goregaokar [Fri, 1 Oct 2021 16:18:19 +0000 (09:18 -0700)]
Rollup merge of #89340 - FabianWolff:issue-89173, r=petrochenkov

Improve error message for `printf`-style format strings

Fixes #89173. The following is actually supported today:
```rust
fn main() {
    let num = 5;
    let width = 20;
    print!("%*2$x", num, width);
}
```
```
error: multiple unused formatting arguments
 --> src/main.rs:4:21
  |
4 |     print!("%*2$x", num, width);
  |            -------  ^^^  ^^^^^ argument never used
  |            ||       |
  |            ||       argument never used
  |            |help: format specifiers use curly braces: `{:1$x}`
  |            multiple missing formatting specifiers
  |
  = note: printf formatting not supported; see the documentation for `std::fmt`
```
However, as noted in #89173, something like
```rust
    print!("%0*x", width, num);
```
does not give a helpful suggestion. I think this is partly intended, because there actually _is_ no Rust equivalent to this; you always have to use a positional or named argument to specify the width (instead of just using the "next" argument, as `printf` or even `.*` as a precision specifier in Rust would). Therefore, I have added a note:
```
[...]
note: format specifiers use curly braces, and you have to use a positional or named parameter for the width
 --> t2.rs:4:13
  |
4 |     print!("%0*x", width, num);
  |             ^^^^
  = note: printf formatting not supported; see the documentation for `std::fmt`
```
This is not perfect, but it should at least point the user in the right direction, instead of issuing no explanation at all.

cc ```@lcnr```

2 years agoRollup merge of #89322 - tmiasko:rm-optimization-fuel, r=michaelwoerister
Manish Goregaokar [Fri, 1 Oct 2021 16:18:18 +0000 (09:18 -0700)]
Rollup merge of #89322 - tmiasko:rm-optimization-fuel, r=michaelwoerister

Reapply "Remove optimization_fuel_crate from Session"

2 years agoRollup merge of #89029 - notriddle:notriddle/issue-89013, r=estebank
Manish Goregaokar [Fri, 1 Oct 2021 16:18:17 +0000 (09:18 -0700)]
Rollup merge of #89029 - notriddle:notriddle/issue-89013, r=estebank

feat(rustc_parse): recover from pre-RFC-2000 const generics syntax

Fixes #89013

2 years agoRollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkov
Manish Goregaokar [Fri, 1 Oct 2021 16:18:16 +0000 (09:18 -0700)]
Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkov

Add `pie` as another `relocation-model` value

MCP: https://github.com/rust-lang/compiler-team/issues/461

2 years agoRollup merge of #87868 - Kixiron:packing-on-the-pounds, r=eddyb
Manish Goregaokar [Fri, 1 Oct 2021 16:18:16 +0000 (09:18 -0700)]
Rollup merge of #87868 - Kixiron:packing-on-the-pounds, r=eddyb

Added -Z randomize-layout flag

An implementation of #77316, it currently randomly shuffles the fields of `repr(rust)` types based on their `DefPathHash`
r? ``@eddyb``

2 years agoAuto merge of #89403 - camsteffen:fmt-unsafe-private, r=Mark-Simulacrum
bors [Fri, 1 Oct 2021 12:08:35 +0000 (12:08 +0000)]
Auto merge of #89403 - camsteffen:fmt-unsafe-private, r=Mark-Simulacrum

Add private arg to fmt::UnsafeArg

As discussed [here](https://github.com/rust-lang/rust/pull/89139#discussion_r719467357)

r? `@Mark-Simulacrum`

2 years agoAuto merge of #89417 - Manishearth:rollup-j2gdu95, r=Manishearth
bors [Fri, 1 Oct 2021 09:00:42 +0000 (09:00 +0000)]
Auto merge of #89417 - Manishearth:rollup-j2gdu95, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #88838 (Do not suggest importing inaccessible items)
 - #89251 (Detect when negative literal indices are used and suggest appropriate code)
 - #89321 (Rebase resume argument projections during state transform)
 - #89327 (Pick one possible lifetime in case there are multiple choices)
 - #89344 (Cleanup lower_generics_mut and make span be the bound itself)
 - #89397 (Update `llvm` submodule to fix function name mangling on x86 Windows)
 - #89412 (Add regression test for issues #88969 and #89119 )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #89412 - lqd:zvariant-repro, r=Aaron1011
Manish Goregaokar [Fri, 1 Oct 2021 06:41:11 +0000 (23:41 -0700)]
Rollup merge of #89412 - lqd:zvariant-repro, r=Aaron1011

Add regression test for issues #88969 and #89119

This adds a regression test to complete https://github.com/rust-lang/rust/pull/89125, and thus for issues #88969 and #89119, which needed a test.

Used with multiple crates, [this](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f665e7e882059157e0f86cfb09c47187) minimized from `zvariant-2.8.0` reproduces the error on `nightly-2021-09-19`.

The test in this PR fails on master if the commit 6dbb9d4eee0a2789a74bb2d4b8228626f7cd741c from #89125 is reverted, and passes otherwise since it's now fixed.

r? `@Aaron1011`

2 years agoRollup merge of #89397 - wesleywiser:update_llvm_submodule, r=cuviper
Manish Goregaokar [Fri, 1 Oct 2021 06:41:10 +0000 (23:41 -0700)]
Rollup merge of #89397 - wesleywiser:update_llvm_submodule, r=cuviper

Update `llvm` submodule to fix function name mangling on x86 Windows

Fixes #89307

2 years agoRollup merge of #89344 - jackh726:maybe-bound-eror, r=cjgillot
Manish Goregaokar [Fri, 1 Oct 2021 06:41:09 +0000 (23:41 -0700)]
Rollup merge of #89344 - jackh726:maybe-bound-eror, r=cjgillot

Cleanup lower_generics_mut and make span be the bound itself

Closes #86298 (supersedes those changes)

r? `@cjgillot` since you reviewed the other PR

(Used wrong branch for #89338)

2 years agoRollup merge of #89327 - oli-obk:nll_diag_infer_vars, r=wesleywiser
Manish Goregaokar [Fri, 1 Oct 2021 06:41:08 +0000 (23:41 -0700)]
Rollup merge of #89327 - oli-obk:nll_diag_infer_vars, r=wesleywiser

Pick one possible lifetime in case there are multiple choices

In case a lifetime variable is created, but doesn't have an obvious lifetime in the list of named lifetimes that it should be inferred to, just pick the first one for the diagnostic.

This happens e.g. in

```rust
fn foo<'a, 'b>(a: Struct<'a>, b: Struct<'b>) -> impl Trait<'a, 'b> {
    if bar() { a } else { b }
}
```

where we get a lifetime variable that combines the lifetimes of `a` and `b` creating a lifetime that is the intersection of both. Right now the type system cannot express this and thus we get an error, but that error also can't express this.

I can also create an entirely new diagnostic that mentions all involved lifetimes, so it would actually mention `'a` and `'b` instead of just `'b`.

2 years agoRollup merge of #89321 - tmiasko:rebase-resume-arg, r=estebank
Manish Goregaokar [Fri, 1 Oct 2021 06:41:07 +0000 (23:41 -0700)]
Rollup merge of #89321 - tmiasko:rebase-resume-arg, r=estebank

Rebase resume argument projections during state transform

When remapping a resume argument with projections rebase them on top of
the new base.

The case where resume argument has projections is unusual, but might
arise with box syntax where the assignment is performed directly into
the box without an intermediate temporary.

Fixes #85635.

2 years agoRollup merge of #89251 - estebank:negative-index-literals, r=davidtwco
Manish Goregaokar [Fri, 1 Oct 2021 06:41:06 +0000 (23:41 -0700)]
Rollup merge of #89251 - estebank:negative-index-literals, r=davidtwco

Detect when negative literal indices are used and suggest appropriate code

2 years agoRollup merge of #88838 - FabianWolff:issue-88472, r=estebank
Manish Goregaokar [Fri, 1 Oct 2021 06:41:05 +0000 (23:41 -0700)]
Rollup merge of #88838 - FabianWolff:issue-88472, r=estebank

Do not suggest importing inaccessible items

Fixes #88472. For this example:
```rust
mod a {
    struct Foo;
}

mod b {
    type Bar = Foo;
}
```
rustc currently emits:
```
error[E0412]: cannot find type `Foo` in this scope
 --> test.rs:6:16
  |
6 |     type Bar = Foo;
  |                ^^^ not found in this scope
  |
help: consider importing this struct
  |
6 |     use a::Foo;
  |
```
this is incorrect, as applying this suggestion leads to
```
error[E0603]: struct `Foo` is private
 --> test.rs:6:12
  |
6 |     use a::Foo;
  |            ^^^ private struct
  |
note: the struct `Foo` is defined here
 --> test.rs:2:5
  |
2 |     struct Foo;
  |     ^^^^^^^^^^^
```
With my changes, I get:
```
error[E0412]: cannot find type `Foo` in this scope
 --> test.rs:6:16
  |
6 |     type Bar = Foo;
  |                ^^^ not found in this scope
  |
  = note: this struct exists but is inaccessible:
          a::Foo
```
As for the wildcard mentioned in #88472, I would argue that the warning is actually correct, since the import _is_ unused. I think the real issue is the wrong suggestion, which I have fixed here.

2 years agoAuto merge of #89395 - In-line:remove_visible_path_from_allowed_deprecated_lint,...
bors [Fri, 1 Oct 2021 06:19:52 +0000 (06:19 +0000)]
Auto merge of #89395 - In-line:remove_visible_path_from_allowed_deprecated_lint, r=jyn514

Remove visible path calculation from allowed deprecation lint

2 years agoAdd `pie` as another `relocation-model` value
Marcel Hlopko [Fri, 10 Sep 2021 13:11:56 +0000 (15:11 +0200)]
Add `pie` as another `relocation-model` value

2 years agoAuto merge of #89414 - Manishearth:rollup-hs11bcq, r=Manishearth
bors [Fri, 1 Oct 2021 03:23:17 +0000 (03:23 +0000)]
Auto merge of #89414 - Manishearth:rollup-hs11bcq, r=Manishearth

Rollup of 8 pull requests

Successful merges:

 - #88782 (Fix ICE when `start` lang item has wrong generics)
 - #89202 (Resolve infered types when complaining about unexpected call type )
 - #89248 (Suggest similarly named associated items in trait impls)
 - #89303 (Add `#[must_not_suspend]` to some types in std)
 - #89306 (thread: implements available_concurrency on haiku)
 - #89314 (fix(lint): don't suggest refutable patterns to "fix" irrefutable bind)
 - #89370 (CTFE: tweak aggregate rvalue handling)
 - #89392 (bootstrap: Update comment in config.library.toml.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoCorrect caller/callsite confusion in inliner message
Wesley Wiser [Fri, 1 Oct 2021 01:25:00 +0000 (21:25 -0400)]
Correct caller/callsite confusion in inliner message

2 years agoRollup merge of #89392 - BGR360:master, r=jyn514
Manish Goregaokar [Fri, 1 Oct 2021 01:05:27 +0000 (18:05 -0700)]
Rollup merge of #89392 - BGR360:master, r=jyn514

bootstrap: Update comment in config.library.toml.

Downloading LLVM from CI works for all platforms now.

All other templates in this directory already have the proper comment. Seems this one was neglected.

2 years agoRollup merge of #89370 - RalfJung:ctfe-aggregate-rvalue, r=oli-obk
Manish Goregaokar [Fri, 1 Oct 2021 01:05:26 +0000 (18:05 -0700)]
Rollup merge of #89370 - RalfJung:ctfe-aggregate-rvalue, r=oli-obk

CTFE: tweak aggregate rvalue handling

I have not looked at this code in ages... I think Miri does not even hit it, since (most?) aggregate rvalues are lowered somewhere in the MIR pipeline, but CTFE does hit it.

So this adds some extra sanity assertions, and removes a ZST special case -- ZST should only be special cased fairly late (when the actual memory access happens); e.g. `!` is a ZST and we still want `copy_op` to be called for it since it will perform validation (and raise UB, since `!` is never valid).

2 years agoRollup merge of #89314 - notriddle:notriddle/lint-fix-enum-variant-match, r=davidtwco
Manish Goregaokar [Fri, 1 Oct 2021 01:05:25 +0000 (18:05 -0700)]
Rollup merge of #89314 - notriddle:notriddle/lint-fix-enum-variant-match, r=davidtwco

fix(lint): don't suggest refutable patterns to "fix" irrefutable bind

In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work.

The general warning is still kept, because code like this is confusing.

Fixes #88730

p.s. `src/test/ui/lint/lint-uppercase-variables.rs` already tests the one-variant case.

2 years agoRollup merge of #89306 - devnexen:haiku_ncpus, r=nagisa
Manish Goregaokar [Fri, 1 Oct 2021 01:05:24 +0000 (18:05 -0700)]
Rollup merge of #89306 - devnexen:haiku_ncpus, r=nagisa

thread: implements available_concurrency on haiku

2 years agoRollup merge of #89303 - guswynn:std_suspend, r=dtolnay
Manish Goregaokar [Fri, 1 Oct 2021 01:05:23 +0000 (18:05 -0700)]
Rollup merge of #89303 - guswynn:std_suspend, r=dtolnay

Add `#[must_not_suspend]` to some types in std

I am not sure what else should have it? `Ref`?

2 years agoRollup merge of #89248 - hkmatsumoto:suggest-similarly-named-assoc-items, r=estebank
Manish Goregaokar [Fri, 1 Oct 2021 01:05:22 +0000 (18:05 -0700)]
Rollup merge of #89248 - hkmatsumoto:suggest-similarly-named-assoc-items, r=estebank

Suggest similarly named associated items in trait impls

Fix #85942

Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.

2 years agoRollup merge of #89202 - estebank:infer-call-type, r=oli-obk
Manish Goregaokar [Fri, 1 Oct 2021 01:05:21 +0000 (18:05 -0700)]
Rollup merge of #89202 - estebank:infer-call-type, r=oli-obk

Resolve infered types when complaining about unexpected call type

```
error[E0618]: expected function, found `{integer}`
  --> $DIR/call-block.rs:2:13
   |
LL |     let _ = {42}();
   |             ^^^^--
   |             |
   |             call expression requires function
```
instead of
```
error[E0618]: expected function, found `_`
  --> $DIR/call-block.rs:2:13
   |
LL |     let _ = {42}();
   |             ^^^^--
   |             |
   |             call expression requires function
```