]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #91239 - cameron1024:issue-87490-regression, r=jackh726
Matthias Krüger [Tue, 14 Dec 2021 19:47:26 +0000 (20:47 +0100)]
Rollup merge of #91239 - cameron1024:issue-87490-regression, r=jackh726

regression test for issue 87490

Closes #87490

2 years agoRollup merge of #89825 - martinvonz:split-inclusive-empty, r=m-ou-se
Matthias Krüger [Tue, 14 Dec 2021 19:47:26 +0000 (20:47 +0100)]
Rollup merge of #89825 - martinvonz:split-inclusive-empty, r=m-ou-se

Make split_inclusive() on an empty slice yield an empty output

`[].split_inclusive()` currently yields a single, empty slice. That's
different from `"".split_inslusive()`, which yields no output at
all. I think that makes the slice version harder to use.

The case where I ran into this bug was when writing code for
generating a diff between two slices of bytes. I wanted to prefix
removed lines with "-" and a added lines with "+". Due to
`split_inclusive()`'s current behavior, that means that my code prints
just a "-" or "+" for empty files. I suspect most existing callers
have similar "bugs" (which would be fixed by this patch).

Closes #89716.

2 years agoAuto merge of #91902 - matthiaskrgr:rollup-hjjyhow, r=matthiaskrgr
bors [Tue, 14 Dec 2021 11:30:17 +0000 (11:30 +0000)]
Auto merge of #91902 - matthiaskrgr:rollup-hjjyhow, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #91529 (add BinaryHeap::try_reserve and BinaryHeap::try_reserve_exact)
 - #91820 (Suggest to specify a target triple when lang item is missing)
 - #91851 (Make `MaybeUninit::zeroed` `const`)
 - #91875 (Use try_normalize_erasing_regions in RevealAllVisitor)
 - #91887 (Remove `in_band_lifetimes` from `rustc_const_eval`)
 - #91892 (Fix HashStable implementation on InferTy)
 - #91893 (Remove `in_band_lifetimes` from `rustc_hir`)

Failed merges:

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

2 years agoRollup merge of #91893 - pitaj:91867-hir, r=davidtwco
Matthias Krüger [Tue, 14 Dec 2021 09:21:07 +0000 (10:21 +0100)]
Rollup merge of #91893 - pitaj:91867-hir, r=davidtwco

Remove `in_band_lifetimes` from `rustc_hir`

#91867

2 years agoRollup merge of #91892 - compiler-errors:fix-inferty-hashtable, r=dtolnay
Matthias Krüger [Tue, 14 Dec 2021 09:21:07 +0000 (10:21 +0100)]
Rollup merge of #91892 - compiler-errors:fix-inferty-hashtable, r=dtolnay

Fix HashStable implementation on InferTy

HashStable impl forgot to hash the discriminant.

Fixes #91807

2 years agoRollup merge of #91887 - LegionMammal978:less-inband-const_eval, r=oli-obk
Matthias Krüger [Tue, 14 Dec 2021 09:21:06 +0000 (10:21 +0100)]
Rollup merge of #91887 - LegionMammal978:less-inband-const_eval, r=oli-obk

Remove `in_band_lifetimes` from `rustc_const_eval`

See #91867 for more information.

2 years agoRollup merge of #91875 - b-naber:mir-transform-norm-erase-reg, r=Aaron1011
Matthias Krüger [Tue, 14 Dec 2021 09:21:05 +0000 (10:21 +0100)]
Rollup merge of #91875 - b-naber:mir-transform-norm-erase-reg, r=Aaron1011

Use try_normalize_erasing_regions in RevealAllVisitor

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

Thanks to ``@Aaron1011`` for [pointing out the problem](https://github.com/rust-lang/rust/issues/91745#issuecomment-991996008).

r? ``@Aaron1011``

2 years agoRollup merge of #91851 - woppopo:const_maybeuninit_zeroed, r=yaahc
Matthias Krüger [Tue, 14 Dec 2021 09:21:04 +0000 (10:21 +0100)]
Rollup merge of #91851 - woppopo:const_maybeuninit_zeroed, r=yaahc

Make `MaybeUninit::zeroed` `const`

Tracking issue: #91850

```rust
// core::mem
impl<T> MaybeUninit<T> {
    pub const fn zeroed() -> MaybeUninit<T>;
}
```

2 years agoRollup merge of #91820 - rukai:help_with_personality_issues, r=davidtwco
Matthias Krüger [Tue, 14 Dec 2021 09:21:03 +0000 (10:21 +0100)]
Rollup merge of #91820 - rukai:help_with_personality_issues, r=davidtwco

Suggest to specify a target triple when lang item is missing

It is very common for newbies to embedded to hit this confusing error when forgetting to specify the target.
Source: me googling this error many times.

## Possible changes
* We could possibly restrict the note+help to only be included on eh_personality lang item if that helped reduce false positives, but its also possible doing so would just increase false negatives
* Open to any suggestions on rewriting the messages
* We could possibly remove the `.cargo/config` alternative to avoid the message getting too noisy but I think its valuable to have as its the correct approach for most embedded projects so that `cargo build` just works.

r? rust-lang/diagnostics

2 years agoRollup merge of #91529 - TennyZhuang:try_reserve_binary_heap, r=yaahc
Matthias Krüger [Tue, 14 Dec 2021 09:21:02 +0000 (10:21 +0100)]
Rollup merge of #91529 - TennyZhuang:try_reserve_binary_heap, r=yaahc

add BinaryHeap::try_reserve and BinaryHeap::try_reserve_exact

`try_reserve` of many collections were stablized in https://github.com/rust-lang/rust/pull/87993 in 1.57.0. Add `try_reserve` for the rest collections such as `BinaryHeap` should be not controversial.

2 years agoAuto merge of #91766 - scottmcm:more-array-raw-eq, r=yaahc
bors [Tue, 14 Dec 2021 08:22:31 +0000 (08:22 +0000)]
Auto merge of #91766 - scottmcm:more-array-raw-eq, r=yaahc

Allow `memcmp` for more array comparisons

This way comparing `[NonZeroU8; 8]` is just as fast as comparing `[u8; 8]`.

2 years agoFix HashStable implementation on InferTy
Michael Goulet [Tue, 14 Dec 2021 04:36:17 +0000 (20:36 -0800)]
Fix HashStable implementation on InferTy

2 years agoRemove `in_band_lifetimes` from `rustc_hir`
Peter Jaszkowiak [Tue, 14 Dec 2021 04:33:53 +0000 (21:33 -0700)]
Remove `in_band_lifetimes` from `rustc_hir`

2 years agoAuto merge of #91680 - saethlin:spare_capacity_mut-in-join, r=dtolnay
bors [Tue, 14 Dec 2021 04:29:54 +0000 (04:29 +0000)]
Auto merge of #91680 - saethlin:spare_capacity_mut-in-join, r=dtolnay

Use spare_capacity_mut instead of invalid unchecked indexing when joining str

This is a fix for https://github.com/rust-lang/rust/issues/91574

I think in general I'd prefer to see this code implemented with raw pointers or `MaybeUninit::write_slice`, but there's existing code in here based on copying from slice to slice, so converting everything from `&[T]` to `&[MaybeUninit<T>]` is less disruptive.

2 years agoRemove `in_band_lifetimes` from `rustc_const_eval`
LegionMammal978 [Tue, 14 Dec 2021 03:34:51 +0000 (22:34 -0500)]
Remove `in_band_lifetimes` from `rustc_const_eval`

See #91867 for more information.

2 years agoAuto merge of #91660 - llogiq:make-a-hash-of-def-ids, r=nnethercote
bors [Tue, 14 Dec 2021 01:39:01 +0000 (01:39 +0000)]
Auto merge of #91660 - llogiq:make-a-hash-of-def-ids, r=nnethercote

manually implement `Hash` for `DefId`

This might speed up hashing for hashers that can work on individual u64s. Just as an experiment, suggested in a reddit thread on `FxHasher`. cc `@nnethercote`

Note that this should not be merged as is without cfg-ing the code path for 64 bits.

2 years agouse try_normalize_erasing_regions in RevealAllVisitor
b-naber [Mon, 13 Dec 2021 21:24:08 +0000 (22:24 +0100)]
use try_normalize_erasing_regions in RevealAllVisitor

2 years agoAuto merge of #91865 - matthiaskrgr:rollup-rai9ecq, r=matthiaskrgr
bors [Mon, 13 Dec 2021 20:12:35 +0000 (20:12 +0000)]
Auto merge of #91865 - matthiaskrgr:rollup-rai9ecq, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #91699 (Add `-webkit-appearance: none` to search input)
 - #91846 (rustdoc: Reduce number of arguments for `run_test` a bit)
 - #91847 (Fix FIXME for `generic_arg_infer` in `create_substs_for_ast_path`)
 - #91849 (GATs outlives lint: Try to prove bounds)
 - #91855 (Stabilize const_cstr_unchecked)

Failed merges:

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

2 years agoRollup merge of #91855 - xfix:const_cstr_unchecked, r=dtolnay
Matthias Krüger [Mon, 13 Dec 2021 17:15:17 +0000 (18:15 +0100)]
Rollup merge of #91855 - xfix:const_cstr_unchecked, r=dtolnay

Stabilize const_cstr_unchecked

Closes #90343

``@rustbot`` modify labels: +T-libs-api

2 years agoRollup merge of #91849 - jackh726:gats-outlives-lint-part2, r=nikomatsakis
Matthias Krüger [Mon, 13 Dec 2021 17:15:16 +0000 (18:15 +0100)]
Rollup merge of #91849 - jackh726:gats-outlives-lint-part2, r=nikomatsakis

GATs outlives lint: Try to prove bounds

Fixes #91036
Fixes #90888
Fixes #91348 (better error + documentation to be added to linked issue)

Instead of checking for bounds directly, try to prove them in the associated type environment.

Also, add a bit of extra information to the error, including a link to the relevant discussion issue (#87479). That should be edited to include a brief summary of the current state of the outlives lint, including a brief background. It also might or might not be worth it to bump this to a full error code at some point.

r? ``@nikomatsakis``

2 years agoRollup merge of #91847 - BoxyUwU:generic_arg_infer_fixme, r=lcnr
Matthias Krüger [Mon, 13 Dec 2021 17:15:15 +0000 (18:15 +0100)]
Rollup merge of #91847 - BoxyUwU:generic_arg_infer_fixme, r=lcnr

Fix FIXME for `generic_arg_infer` in `create_substs_for_ast_path`

Fixes a FIXME, does some general refactoring of this fn, and also fixes a bug where we would use a const params defaults instead of an inference var ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=19456f65ea5dc3fcaa9b696f842ab380))
(lot of stuff in one PR but it was all so close together...)

r? `@lcnr`

Fixes #91614

2 years agoRollup merge of #91846 - camelid:doctest-cleanup, r=GuillaumeGomez
Matthias Krüger [Mon, 13 Dec 2021 17:15:14 +0000 (18:15 +0100)]
Rollup merge of #91846 - camelid:doctest-cleanup, r=GuillaumeGomez

rustdoc: Reduce number of arguments for `run_test` a bit

- rustdoc: Coalesce some `run_test` args as one `LangString` arg
- Rename `TestOptions` to `GlobalTestOptions`
- doctest: Rename `options` to `rustdoc_options`

2 years agoRollup merge of #91699 - jsha:webkit-appearance-search-input, r=GuillaumeGomez
Matthias Krüger [Mon, 13 Dec 2021 17:15:13 +0000 (18:15 +0100)]
Rollup merge of #91699 - jsha:webkit-appearance-search-input, r=GuillaumeGomez

Add `-webkit-appearance: none` to search input

This fixes an issue when displaying on iPad, where the search box had no borders.

r? ``@GuillaumeGomez``

Demo https://rustdoc.crud.net/jsha/webkit-appearance-search-input/std/string/struct.String.html

2 years agoAuto merge of #91353 - eggyal:reuse-rcs-during-folding, r=lcnr
bors [Mon, 13 Dec 2021 17:05:40 +0000 (17:05 +0000)]
Auto merge of #91353 - eggyal:reuse-rcs-during-folding, r=lcnr

Avoid cloning refcounted types during folding

Addresses FIXME comment created in #78313

r? `@lcnr`

2 years agoAdjust wording for review
Jack Huey [Mon, 13 Dec 2021 15:06:57 +0000 (10:06 -0500)]
Adjust wording for review

2 years agoAvoid cloning refcounted types during folding
Alan Egerton [Mon, 29 Nov 2021 12:55:00 +0000 (12:55 +0000)]
Avoid cloning refcounted types during folding

2 years agoAuto merge of #91657 - nikic:update-llvm, r=cuviper
bors [Mon, 13 Dec 2021 13:37:53 +0000 (13:37 +0000)]
Auto merge of #91657 - nikic:update-llvm, r=cuviper

Update LLVM submodule

Update LLVM submodule with recent cherry-picks. In particular:
 * https://github.com/rust-lang/llvm-project/pull/123
 * https://github.com/rust-lang/llvm-project/pull/124

2 years agoSuggest to specify a target triple when eh_personality lang item is missing
Lucas Kent [Sun, 12 Dec 2021 02:04:00 +0000 (13:04 +1100)]
Suggest to specify a target triple when eh_personality lang item is missing

2 years agoAuto merge of #91654 - nikic:llvmbc-section-flags, r=nagisa
bors [Mon, 13 Dec 2021 10:35:28 +0000 (10:35 +0000)]
Auto merge of #91654 - nikic:llvmbc-section-flags, r=nagisa

Use module inline assembly to embed bitcode

In LLVM 14, our current method of setting section flags to avoid
embedding the `.llvmbc` section into final compilation artifacts
will no longer work, see issue #90326. The upstream recommendation
is to instead embed the entire bitcode using module-level inline
assembly, which is what this change does.

I've kept the existing code for platforms where we do not need to
set section flags, but possibly we should always be using the
inline asm approach (which would have to look a bit different for MachO).

r? `@nagisa`

2 years agoStabilize const_cstr_unchecked
Konrad Borowski [Mon, 13 Dec 2021 07:43:19 +0000 (08:43 +0100)]
Stabilize const_cstr_unchecked

2 years agoAuto merge of #91626 - klensy:json-less-alloc, r=petrochenkov
bors [Mon, 13 Dec 2021 07:30:38 +0000 (07:30 +0000)]
Auto merge of #91626 - klensy:json-less-alloc, r=petrochenkov

rustc_serialize: don't allocate `String`s as key for `BTreeMap`, when `str` is enough

2 years agoI wrote these functions, I should use them dang it
Jack Huey [Mon, 13 Dec 2021 06:10:39 +0000 (01:10 -0500)]
I wrote these functions, I should use them dang it

2 years agoInstead of checking for exact bounds, try to prove them
Jack Huey [Mon, 13 Dec 2021 04:23:55 +0000 (23:23 -0500)]
Instead of checking for exact bounds, try to prove them

2 years agoMake `MaybeUninit::zeroed` `const`
woppopo [Mon, 13 Dec 2021 05:17:35 +0000 (14:17 +0900)]
Make `MaybeUninit::zeroed` `const`

2 years agoAdd -webkit-appearance: none to search input
Jacob Hoffman-Andrews [Thu, 9 Dec 2021 07:39:42 +0000 (23:39 -0800)]
Add -webkit-appearance: none to search input

This fixes an issue when displaying on iPad, where the search box had no
borders.

2 years agoAuto merge of #91569 - erikdesjardins:vt-align, r=nikic
bors [Mon, 13 Dec 2021 04:29:20 +0000 (04:29 +0000)]
Auto merge of #91569 - erikdesjardins:vt-align, r=nikic

Attach range metadata to alignment loads from vtables

...because alignment is always nonzero[0].

This helps eliminate redundant runtime alignment checks, when a DST
is a field of a struct whose remaining fields have alignment 1.

Fixes #91438.

---
[0]:

The [reference](https://doc.rust-lang.org/reference/type-layout.html) says that alignment must be at least 1.

And in practice, the alignment field for all vtables is generated here: https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_middle/src/ty/vtable.rs#L68-L90 and is nonzero because [`Align::bytes()`](https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_target/src/abi/mod.rs#L547-L549) is always nonzero.

2 years agoextra test for bug i found
Ellen [Mon, 13 Dec 2021 03:33:14 +0000 (03:33 +0000)]
extra test for bug i found

2 years agohurray for portable simd finding a nice test for this FIXME
Ellen [Mon, 13 Dec 2021 03:16:00 +0000 (03:16 +0000)]
hurray for portable simd finding a nice test for this FIXME

2 years agodoctest: Rename `options` to `rustdoc_options`
Noah Lev [Sat, 4 Dec 2021 03:54:38 +0000 (19:54 -0800)]
doctest: Rename `options` to `rustdoc_options`

These are the rustdoc-wide options. It's easy to confuse them with
options for doctests in particular, so this change should help.

2 years agoRename `TestOptions` to `GlobalTestOptions`
Noah Lev [Sat, 4 Dec 2021 03:49:31 +0000 (19:49 -0800)]
Rename `TestOptions` to `GlobalTestOptions`

It seems to apply to all doctests in the crate.

2 years agorustdoc: Coalesce some `run_test` args as one `LangString` arg
Noah Lev [Sat, 4 Dec 2021 03:43:50 +0000 (19:43 -0800)]
rustdoc: Coalesce some `run_test` args as one `LangString` arg

2 years agoAuto merge of #91841 - matthiaskrgr:rollup-zlhsg5a, r=matthiaskrgr
bors [Mon, 13 Dec 2021 00:56:18 +0000 (00:56 +0000)]
Auto merge of #91841 - matthiaskrgr:rollup-zlhsg5a, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #91086 (Implement `TryFrom<&'_ mut [T]>` for `[T; N]`)
 - #91091 (Stabilize `ControlFlow::{is_break, is_continue}`)
 - #91749 (BTree: improve public descriptions and comments)
 - #91819 (rustbot: Add autolabeling for `T-compiler`)
 - #91824 (Make `(*mut T)::write_bytes` `const`)

Failed merges:

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

2 years agoRollup merge of #91824 - woppopo:const_ptr_write_bytes, r=oli-obk
Matthias Krüger [Sun, 12 Dec 2021 23:20:10 +0000 (00:20 +0100)]
Rollup merge of #91824 - woppopo:const_ptr_write_bytes, r=oli-obk

Make `(*mut T)::write_bytes` `const`

Tracking issue: #86302

2 years agoRollup merge of #91819 - rust-lang:compiler-autolabel, r=jackh726
Matthias Krüger [Sun, 12 Dec 2021 23:20:09 +0000 (00:20 +0100)]
Rollup merge of #91819 - rust-lang:compiler-autolabel, r=jackh726

rustbot: Add autolabeling for `T-compiler`

This commit adds autolabeling for the `T-compiler` label, for PRs that
modify rustc's source code or tests (currently only `src/test/ui`).

This is possible now that rust-lang/triagebot#1321 has landed.

2 years agoRollup merge of #91749 - ssomers:btree_comments, r=Mark-Simulacrum
Matthias Krüger [Sun, 12 Dec 2021 23:20:08 +0000 (00:20 +0100)]
Rollup merge of #91749 - ssomers:btree_comments, r=Mark-Simulacrum

BTree: improve public descriptions and comments

BTreeSet has always used the term "value" next to and meaning the same thing as "elements" (in the mathematical sense but also used for key-value pairs in BTreeMap), while in the BTreeMap sense these "values" are known as "keys" and definitely not "values". Today I had enough of that.

r? `@Mark-Simulacrum`

2 years agoRollup merge of #91091 - ecstatic-morse:control-flow-enum-is, r=m-ou-se
Matthias Krüger [Sun, 12 Dec 2021 23:20:07 +0000 (00:20 +0100)]
Rollup merge of #91091 - ecstatic-morse:control-flow-enum-is, r=m-ou-se

Stabilize `ControlFlow::{is_break, is_continue}`

The type itself was stabilized in 1.55, but using it is not ergonomic without these helper functions. Stabilize them.

r? rust-lang/libs-api

2 years agoRollup merge of #91086 - rhysd:issue-91085, r=m-ou-se
Matthias Krüger [Sun, 12 Dec 2021 23:20:06 +0000 (00:20 +0100)]
Rollup merge of #91086 - rhysd:issue-91085, r=m-ou-se

Implement `TryFrom<&'_ mut [T]>` for `[T; N]`

Fixes #91085.

2 years agoAuto merge of #91549 - fee1-dead:const_env, r=spastorino
bors [Sun, 12 Dec 2021 22:15:32 +0000 (22:15 +0000)]
Auto merge of #91549 - fee1-dead:const_env, r=spastorino

Eliminate ConstnessAnd again

Closes #91489.
Closes #89432.

Reverts #91491.
Reverts #89450.

r? `@spastorino`

2 years agorustbot: Add autolabeling for `T-compiler`
Noah Lev [Sun, 12 Dec 2021 02:03:52 +0000 (18:03 -0800)]
rustbot: Add autolabeling for `T-compiler`

This commit adds autolabeling for the `T-compiler` label, for PRs that
modify rustc's source code or tests (currently only `src/test/ui`).

This is possible now that rust-lang/triagebot#1321 has landed.

2 years agoAuto merge of #90716 - euclio:libloading, r=cjgillot
bors [Sun, 12 Dec 2021 17:28:52 +0000 (17:28 +0000)]
Auto merge of #90716 - euclio:libloading, r=cjgillot

replace dynamic library module with libloading

This PR deletes the `rustc_metadata::dynamic_lib` module in favor of the popular and better tested [`libloading` crate](https://github.com/nagisa/rust_libloading/).

We don't benefit from `libloading`'s symbol lifetimes since we end up leaking the loaded library in all cases, but the call-sites look much nicer by improving error handling and abstracting away some transmutes. We also can remove `rustc_metadata`'s direct dependencies on `libc` and `winapi`.

This PR also adds an exception for `libloading` (and its license) to tidy, so this will need sign-off from the compiler team.

2 years agoAuto merge of #90207 - BoxyUwU:stabilise_cg_defaults, r=lcnr
bors [Sun, 12 Dec 2021 14:24:23 +0000 (14:24 +0000)]
Auto merge of #90207 - BoxyUwU:stabilise_cg_defaults, r=lcnr

Stabilise `feature(const_generics_defaults)`

`feature(const_generics_defaults)` is complete implementation wise and has a pretty extensive test suite so I think is ready for stabilisation.

needs stabilisation report and maybe an RFC :sweat_smile:

r? `@lcnr`
cc `@rust-lang/project-const-generics`

2 years agoclippy owo
Ellen [Sun, 12 Dec 2021 12:34:21 +0000 (12:34 +0000)]
clippy owo

2 years agoAuto merge of #90423 - Aaron1011:deduplicate-projection, r=jackh726
bors [Sun, 12 Dec 2021 11:24:20 +0000 (11:24 +0000)]
Auto merge of #90423 - Aaron1011:deduplicate-projection, r=jackh726

Deduplicate projection sub-obligations

2 years agoAuto merge of #91825 - matthiaskrgr:rollup-e4s8lwp, r=matthiaskrgr
bors [Sun, 12 Dec 2021 06:54:28 +0000 (06:54 +0000)]
Auto merge of #91825 - matthiaskrgr:rollup-e4s8lwp, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #91746 (Btree: assert more API compatibility)
 - #91748 (rustdoc: Add regression test for Iterator as notable trait on &mut T)
 - #91811 (bootstrap: Change unwrap() to expect() for WIX path)
 - #91814 (doc: fix typo in comments)
 - #91815 (better span for unexpected normalization failure in CTFE engine)
 - #91817 (rustbot: Add autolabeling for `T-rustdoc`)

Failed merges:

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

2 years agoRollup merge of #91817 - rust-lang:rustdoc-autolabel, r=Mark-Simulacrum
Matthias Krüger [Sun, 12 Dec 2021 06:45:32 +0000 (07:45 +0100)]
Rollup merge of #91817 - rust-lang:rustdoc-autolabel, r=Mark-Simulacrum

rustbot: Add autolabeling for `T-rustdoc`

This commit adds autolabeling for the `T-rustdoc` label, for PRs that
modify rustdoc's source code, tests, or internal tooling.

This is possible now that rust-lang/triagebot#1321 has landed.

2 years agoRollup merge of #91815 - RalfJung:span, r=oli-obk
Matthias Krüger [Sun, 12 Dec 2021 06:45:31 +0000 (07:45 +0100)]
Rollup merge of #91815 - RalfJung:span, r=oli-obk

better span for unexpected normalization failure in CTFE engine

No reason to use `DUMMY_SP` here.

2 years agoRollup merge of #91814 - japm48:spelling-fix, r=RalfJung
Matthias Krüger [Sun, 12 Dec 2021 06:45:30 +0000 (07:45 +0100)]
Rollup merge of #91814 - japm48:spelling-fix, r=RalfJung

doc: fix typo in comments

`dereferencable -> dereferenceable`

Fixes #91802.

2 years agoRollup merge of #91811 - itzurabhi:boostrap-dist-wix-unwrap-issue, r=Mark-Simulacrum
Matthias Krüger [Sun, 12 Dec 2021 06:45:29 +0000 (07:45 +0100)]
Rollup merge of #91811 - itzurabhi:boostrap-dist-wix-unwrap-issue, r=Mark-Simulacrum

bootstrap: Change unwrap() to expect() for WIX path

On Windows, `x.py dist` command panics without proper error message if `WIX` environment variable is not set. This patch changes `Option::unwrap()` to `Option::expect()`.

2 years agoRollup merge of #91748 - notriddle:notriddle/doc-notable_trait-mut_t_is_not_an_iterat...
Matthias Krüger [Sun, 12 Dec 2021 06:45:28 +0000 (07:45 +0100)]
Rollup merge of #91748 - notriddle:notriddle/doc-notable_trait-mut_t_is_not_an_iterator, r=Mark-Simulacrum

rustdoc: Add regression test for Iterator as notable trait on &mut T

Closes #80737

2 years agoRollup merge of #91746 - ssomers:btree_tests, r=Mark-Simulacrum
Matthias Krüger [Sun, 12 Dec 2021 06:45:28 +0000 (07:45 +0100)]
Rollup merge of #91746 - ssomers:btree_tests, r=Mark-Simulacrum

Btree: assert more API compatibility

Introducing a member such as `BTreeSet::min()` would silently break compatibility if no code calls the existing `BTreeSet::min(set)`. `BTreeSet` is the only btree class silently bringing in stable members, apart from many occurrences of `#[derive(Debug)]` on iterators.

r? `@Mark-Simulacrum`

2 years agoMake `(*mut T)::write_bytes` `const`
woppopo [Sun, 12 Dec 2021 05:02:53 +0000 (14:02 +0900)]
Make `(*mut T)::write_bytes` `const`

2 years agoRemove function from rebase
Deadbeef [Sun, 12 Dec 2021 04:52:30 +0000 (12:52 +0800)]
Remove function from rebase

2 years agoSmall performance tweaks
Deadbeef [Wed, 8 Dec 2021 13:08:44 +0000 (21:08 +0800)]
Small performance tweaks

2 years agoRemap more env constness for queries
Deadbeef [Tue, 7 Dec 2021 12:40:06 +0000 (20:40 +0800)]
Remap more env constness for queries

2 years agoRemap predicate/env constness before querying
Deadbeef [Tue, 7 Dec 2021 08:08:59 +0000 (16:08 +0800)]
Remap predicate/env constness before querying

2 years agoQuery modifier
Deadbeef [Mon, 6 Dec 2021 11:47:54 +0000 (19:47 +0800)]
Query modifier

2 years agoAdd trailing newline
Deadbeef [Sun, 5 Dec 2021 11:03:01 +0000 (19:03 +0800)]
Add trailing newline

2 years agoRevert "Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk"
Deadbeef [Sun, 5 Dec 2021 10:46:29 +0000 (18:46 +0800)]
Revert "Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk"

This reverts commit a8387aef8c378a771686878062e544af4d5e2245, reversing
changes made to 6e1211081239be62a5d0bb3bbcb29a9f14621c81.

2 years agoRevert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"
Deadbeef [Sun, 12 Dec 2021 04:34:46 +0000 (12:34 +0800)]
Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"

This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing
changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.

2 years agoadd regression test for #91489
SNCPlay42 [Fri, 3 Dec 2021 16:31:06 +0000 (16:31 +0000)]
add regression test for #91489

2 years agoFix #91489
Deadbeef [Mon, 6 Dec 2021 12:46:05 +0000 (20:46 +0800)]
Fix #91489

2 years agoAuto merge of #89404 - Kobzol:hash-stable-sort, r=Mark-Simulacrum
bors [Sun, 12 Dec 2021 03:50:30 +0000 (03:50 +0000)]
Auto merge of #89404 - Kobzol:hash-stable-sort, r=Mark-Simulacrum

Slightly optimize hash map stable hashing

I was profiling some of the `rustc-perf` benchmarks locally and noticed that quite some time is spent inside the stable hash of hashmaps. I tried to use a `SmallVec` instead of a `Vec` there, which helped very slightly.

Then I tried to remove the sorting, which was a bottleneck, and replaced it with insertion into a binary heap. Locally, it yielded nice improvements in instruction counts and RSS in several benchmarks for incremental builds. The implementation could probably be much nicer and possibly extended to other stable hashes, but first I wanted to test the perf impact properly.

Can I ask someone to do a perf run? Thank you!

2 years agoAuto merge of #91813 - matthiaskrgr:rollup-nryyeyj, r=matthiaskrgr
bors [Sun, 12 Dec 2021 00:58:30 +0000 (00:58 +0000)]
Auto merge of #91813 - matthiaskrgr:rollup-nryyeyj, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #90081 (Make `intrinsics::write_bytes` const)
 - #91643 (asm: Allow using r9 (ARM) and x18 (AArch64) if they are not reserved by the current target)
 - #91737 (Make certain panicky stdlib functions behave better under panic_immediate_abort)
 - #91750 (rustdoc: Add regression test for Iterator as notable trait on &T)
 - #91764 (Do not ICE when suggesting elided lifetimes on non-existent spans.)
 - #91780 (Remove hir::Node::hir_id.)
 - #91797 (Fix zero-sized reference to deallocated memory)
 - #91806 (Make `Unique`s methods `const`)

Failed merges:

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

2 years agorustbot: Add autolabeling for `T-rustdoc`
Noah Lev [Sun, 12 Dec 2021 00:51:07 +0000 (16:51 -0800)]
rustbot: Add autolabeling for `T-rustdoc`

This commit adds autolabeling for the `T-rustdoc` label, for PRs that
modify rustdoc's source code, tests, or internal tooling.

This is possible now that rust-lang/triagebot#1321 has landed.

2 years agobetter span for unexpected normalization failure in CTFE engine
Ralf Jung [Sat, 11 Dec 2021 23:55:58 +0000 (18:55 -0500)]
better span for unexpected normalization failure in CTFE engine

2 years agodoc: fix typo in comments
japm48 [Sat, 11 Dec 2021 23:23:06 +0000 (00:23 +0100)]
doc: fix typo in comments

dereferencable -> dereferenceable

2 years agoRollup merge of #91806 - woppopo:const_unique, r=dtolnay
Matthias Krüger [Sat, 11 Dec 2021 22:31:55 +0000 (23:31 +0100)]
Rollup merge of #91806 - woppopo:const_unique, r=dtolnay

Make `Unique`s methods `const`

Tracking issue: None

2 years agoRollup merge of #91797 - the8472:fix-invalid-deref, r=Mark-Simulacrum
Matthias Krüger [Sat, 11 Dec 2021 22:31:54 +0000 (23:31 +0100)]
Rollup merge of #91797 - the8472:fix-invalid-deref, r=Mark-Simulacrum

Fix zero-sized reference to deallocated memory

fixes #91772

r? `@camelid`

2 years agoRollup merge of #91780 - cjgillot:localize, r=Mark-Simulacrum
Matthias Krüger [Sat, 11 Dec 2021 22:31:53 +0000 (23:31 +0100)]
Rollup merge of #91780 - cjgillot:localize, r=Mark-Simulacrum

Remove hir::Node::hir_id.

Small cleanup.

2 years agoRollup merge of #91764 - cjgillot:elide-anyway, r=jackh726
Matthias Krüger [Sat, 11 Dec 2021 22:31:52 +0000 (23:31 +0100)]
Rollup merge of #91764 - cjgillot:elide-anyway, r=jackh726

Do not ICE when suggesting elided lifetimes on non-existent spans.

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

r? `@jackh726`

2 years agoRollup merge of #91750 - notriddle:notriddle/doc-notable_trait-mut_t_is_not_ref_t...
Matthias Krüger [Sat, 11 Dec 2021 22:31:51 +0000 (23:31 +0100)]
Rollup merge of #91750 - notriddle:notriddle/doc-notable_trait-mut_t_is_not_ref_t, r=Mark-Simulacrum

rustdoc: Add regression test for Iterator as notable trait on &T

Closes #78160

This regression test is different from the one in #91748, because while neither of these function should have Iterator marked as a notable trait, the reasons are different.

* In this PR, it returns `&T where T: Iterator`. The `mut` is what's missing.
* In #91748, it returns `&mut T`. The trait bounds are what's missing.

2 years agoRollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett
Matthias Krüger [Sat, 11 Dec 2021 22:31:50 +0000 (23:31 +0100)]
Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett

Make certain panicky stdlib functions behave better under panic_immediate_abort

The stdlib has a `panic_immediate_abort` feature that turns panics into immediate aborts, without any formatting/display logic. This feature was [introduced](https://github.com/rust-lang/rust/pull/55011) primarily for codesize-constrained situations.

Unfortunately, this win doesn't quite propagate to `Result::expect()` and `Result::unwrap()`, while the formatting machinery is reduced, `expect()` and `unwrap()` both call `unwrap_failed("msg", &err)` which has a signature of `fn unwrap_failed(msg: &str, error: &dyn fmt::Debug)` and is `#[inline(never)]`. This means that `unwrap_failed` will unconditionally construct a `dyn Debug` trait object even though the object is never used in the function.

Constructing a trait object (even if you never call a method on it!) forces rust to include the vtable and any dependencies. This means that in `panic_immediate_abort` mode, calling expect/unwrap on a Result will pull in a whole bunch of formatting code for the error type even if it's completely unused.

This PR swaps out the function with one that won't require a trait object such that it won't force the inclusion of vtables in the code. It also gates off `#[inline(never)]` in a bunch of other places where allowing the inlining of an abort may be useful (this kind of thing is already done elsewhere in the stdlib).

I don't know how to write a test for this; we don't really seem to have any tests for `panic_immediate_abort` anyway so perhaps it's fine as is.

2 years agoRollup merge of #91643 - Amanieu:r9x18, r=joshtriplett
Matthias Krüger [Sat, 11 Dec 2021 22:31:49 +0000 (23:31 +0100)]
Rollup merge of #91643 - Amanieu:r9x18, r=joshtriplett

asm: Allow using r9 (ARM) and x18 (AArch64) if they are not reserved by the current target

This supersedes https://github.com/rust-lang/rust/pull/88879.

cc `@Skirmisher`

r? `@joshtriplett`

2 years agoRollup merge of #90081 - woppopo:const_write_bytes, r=oli-obk
Matthias Krüger [Sat, 11 Dec 2021 22:31:48 +0000 (23:31 +0100)]
Rollup merge of #90081 - woppopo:const_write_bytes, r=oli-obk

Make `intrinsics::write_bytes` const

This is required to constify `MaybeUninit::zeroed` and `(*mut T)::write_bytes`.

Tracking issue: #86302

2 years agobootstrap: Change `unwrap()` to `expect()` for `WIX` path
Abhishek Sudhakaran [Sat, 11 Dec 2021 22:01:40 +0000 (03:31 +0530)]
bootstrap: Change `unwrap()` to `expect()` for `WIX` path

On Windows, `x.py dist` command panics without proper error message if 'WIX' environment variable is not set. This patch changes `Option::unwrap()` to `Option::expect()`.

2 years agoAuto merge of #91769 - estebank:type-trait-bound-span-2, r=oli-obk
bors [Sat, 11 Dec 2021 21:57:19 +0000 (21:57 +0000)]
Auto merge of #91769 - estebank:type-trait-bound-span-2, r=oli-obk

Tweak assoc type obligation spans

* Point at RHS of associated type in obligation span
* Point at `impl` assoc type on projection error
* Reduce verbosity of recursive obligations
* Point at source of binding lifetime obligation
* Tweak "required bound" note
* Tweak "expected... found opaque (return) type" labels
* Point at set type in impl assoc type WF errors

r? `@oli-obk`

This is a(n uncontroversial) subset of #85799.

2 years agoMake `Unique`s methods `const`
woppopo [Sat, 11 Dec 2021 19:27:43 +0000 (04:27 +0900)]
Make `Unique`s methods `const`

2 years agoAuto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgr
bors [Sat, 11 Dec 2021 18:56:59 +0000 (18:56 +0000)]
Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #83174 (Suggest using a temporary variable to fix borrowck errors)
 - #89734 (Point at capture points for non-`'static` reference crossing a `yield` point)
 - #90270 (Make `Borrow` and `BorrowMut` impls `const`)
 - #90741 (Const `Option::cloned`)
 - #91548 (Add spin_loop hint for RISC-V architecture)
 - #91721 (Minor improvements to `future::join!`'s implementation)

Failed merges:

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

2 years agoFix AArch64 asm ui tests
Amanieu d'Antras [Sat, 11 Dec 2021 17:29:29 +0000 (17:29 +0000)]
Fix AArch64 asm ui tests

2 years agoRollup merge of #91721 - danielhenrymantilla:patch-1, r=joshtriplett
Matthias Krüger [Sat, 11 Dec 2021 16:35:27 +0000 (17:35 +0100)]
Rollup merge of #91721 - danielhenrymantilla:patch-1, r=joshtriplett

Minor improvements to `future::join!`'s implementation

This is a follow-up from #91645, regarding [some remarks I made](https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/join!/near/264293660).

Mainly:
  - it hides the recursive munching through a private `macro`, to avoid leaking such details (a corollary is getting rid of the need to use ``@`` to disambiguate);
  - it uses a `match` binding, _outside_ the `async move` block, to better match the semantics from function-like syntax;
  - it pre-pins the future before calling into `poll_fn`, since `poll_fn`, alone, cannot guarantee that its capture does not move (to clarify: I believe the previous code was sound, thanks to the outer layer of `async`. But I find it clearer / more robust to refactorings this way 🙂).
  - it uses `@ibraheemdev's` very neat `.ready()?`;
  - it renames `Took` to `Taken` for consistency with `Done` (tiny nit 😄).

~~TODO~~Done:

  - [x] Add unit tests to enforce the function-like `:value` semantics are respected.

r? `@nrc`

2 years agoRollup merge of #91548 - luojia65:hint-spin-loop-riscv, r=Amanieu
Matthias Krüger [Sat, 11 Dec 2021 16:35:26 +0000 (17:35 +0100)]
Rollup merge of #91548 - luojia65:hint-spin-loop-riscv, r=Amanieu

Add spin_loop hint for RISC-V architecture

This commit uses the PAUSE instruction (https://github.com/rust-lang/stdarch/pull/1262) to implement RISC-V spin loop, and updates `stdarch` submodule to use the merged PAUSE instruction.

2 years agoRollup merge of #90741 - mbartlett21:patch-4, r=dtolnay
Matthias Krüger [Sat, 11 Dec 2021 16:35:25 +0000 (17:35 +0100)]
Rollup merge of #90741 - mbartlett21:patch-4, r=dtolnay

Const `Option::cloned`

This constifies the two `Option::cloned` functions, bounded on `~const Clone`.

2 years agoRollup merge of #90270 - woppopo:const_borrow_trait, r=dtolnay
Matthias Krüger [Sat, 11 Dec 2021 16:35:24 +0000 (17:35 +0100)]
Rollup merge of #90270 - woppopo:const_borrow_trait, r=dtolnay

Make `Borrow` and `BorrowMut` impls `const`

Tracking issue: #91522

2 years agoRollup merge of #89734 - estebank:issue-72312, r=nikomatsakis
Matthias Krüger [Sat, 11 Dec 2021 16:35:23 +0000 (17:35 +0100)]
Rollup merge of #89734 - estebank:issue-72312, r=nikomatsakis

Point at capture points for non-`'static` reference crossing a `yield` point

```
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
  --> $DIR/issue-72312.rs:10:24
   |
LL |     pub async fn start(&self) {
   |                        ^^^^^ this data with an anonymous lifetime `'_`...
...
LL |         require_static(async move {
   |         -------------- ...is required to live as long as `'static` here...
LL |             &self;
   |             ----- ...and is captured here
   |
note: `'static` lifetime requirement introduced by this trait bound
  --> $DIR/issue-72312.rs:2:22
   |
LL | fn require_static<T: 'static>(val: T) -> T {
   |                      ^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0759`.
```

Fix #72312.

2 years agoRollup merge of #83174 - camelid:borrow-help, r=oli-obk
Matthias Krüger [Sat, 11 Dec 2021 16:35:23 +0000 (17:35 +0100)]
Rollup merge of #83174 - camelid:borrow-help, r=oli-obk

Suggest using a temporary variable to fix borrowck errors

Fixes #77834.

In Rust, nesting method calls with both require `&mut` access to `self`
produces a borrow-check error:

    error[E0499]: cannot borrow `*self` as mutable more than once at a time
     --> src/lib.rs:7:14
      |
    7 |     self.foo(self.bar());
      |     ---------^^^^^^^^^^-
      |     |    |   |
      |     |    |   second mutable borrow occurs here
      |     |    first borrow later used by call
      |     first mutable borrow occurs here

That's because Rust has a left-to-right evaluation order, and the method
receiver is passed first. Thus, the argument to the method cannot then
mutate `self`.

There's an easy solution to this error: just extract a local variable
for the inner argument:

    let tmp = self.bar();
    self.foo(tmp);

However, the error doesn't give any suggestion of how to solve the
problem. As a result, new users may assume that it's impossible to
express their code correctly and get stuck.

This commit adds a (non-structured) suggestion to extract a local
variable for the inner argument to solve the error. The suggestion uses
heuristics that eliminate most false positives, though there are a few
false negatives (cases where the suggestion should be emitted but is
not). Those other cases can be implemented in a future change.

2 years agoFix zero-sized reference to deallocated memory
The 8472 [Sat, 11 Dec 2021 16:10:56 +0000 (17:10 +0100)]
Fix zero-sized reference to deallocated memory

fixes #91772

2 years agoAuto merge of #91792 - matthiaskrgr:rollup-2epg7jq, r=matthiaskrgr
bors [Sat, 11 Dec 2021 15:55:22 +0000 (15:55 +0000)]
Auto merge of #91792 - matthiaskrgr:rollup-2epg7jq, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #91617 (Improve the readability of `List<T>`.)
 - #91640 (Simplify collection of in-band lifetimes)
 - #91682 (rustdoc: Show type layout for type aliases)
 - #91711 (Improve `std::iter::zip` example)
 - #91717 (Add deprecation warning for --passes)
 - #91718 (give more help in the unaligned_references lint)
 - #91782 (Correct since attribute for `is_symlink` feature)

Failed merges:

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

2 years agoRollup merge of #91782 - maxwase:is_symlink_since_attribute, r=jyn514
Matthias Krüger [Sat, 11 Dec 2021 15:02:50 +0000 (16:02 +0100)]
Rollup merge of #91782 - maxwase:is_symlink_since_attribute, r=jyn514

Correct since attribute for `is_symlink` feature

Follow-up from [89677](https://github.com/rust-lang/rust/pull/89677)

2 years agoRollup merge of #91718 - RalfJung:unaligned_references, r=nagisa
Matthias Krüger [Sat, 11 Dec 2021 15:02:49 +0000 (16:02 +0100)]
Rollup merge of #91718 - RalfJung:unaligned_references, r=nagisa

give more help in the unaligned_references lint

Cc https://github.com/rust-lang/rust/issues/82523#issuecomment-988138440 ``@kaisq``

2 years agoRollup merge of #91717 - inashivb:issue-91713, r=jyn514
Matthias Krüger [Sat, 11 Dec 2021 15:02:49 +0000 (16:02 +0100)]
Rollup merge of #91717 - inashivb:issue-91713, r=jyn514

Add deprecation warning for --passes

Issue https://github.com/rust-lang/rust/issues/91713 mentored by ```@jyn514```