]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #91818 - camelid:unused-result-type, r=jackh726
Matthias Krüger [Sat, 18 Dec 2021 07:16:27 +0000 (08:16 +0100)]
Rollup merge of #91818 - camelid:unused-result-type, r=jackh726

Show the unused type for `unused_results` lint

I think it's helpful to know what type was unused when looking at these
warnings. The type will likely determine whether the result *should* be
used, or whether it should just be ignored.

Including the type also matches the behavior of the `must_use` lint:
unused `SomeType` that must be used.

2 years agoRollup merge of #89090 - cjgillot:bare-dyn, r=jackh726
Matthias Krüger [Sat, 18 Dec 2021 07:16:26 +0000 (08:16 +0100)]
Rollup merge of #89090 - cjgillot:bare-dyn, r=jackh726

Lint bare traits in AstConv.

Removing the lint from lowering allows to:
- make lowering querification easier;
- have the lint implementation in only one place.

r? `@estebank`

2 years agoRollup merge of #87901 - poliorcetics:pub-pub-pub, r=jackh726
Matthias Krüger [Sat, 18 Dec 2021 07:16:25 +0000 (08:16 +0100)]
Rollup merge of #87901 - poliorcetics:pub-pub-pub, r=jackh726

Fix suggestion of additional `pub` when using `pub pub fn ...`

Fix #87694.

Marked as draft to start with because I want to explore doing the same fix for `const const fn` and other repeated-but-valid keywords.

`@rustbot` label A-diagnostics D-invalid-suggestion T-compiler

2 years agoAuto merge of #89841 - cormacrelf:let-else-typed, r=nagisa
bors [Fri, 17 Dec 2021 22:12:34 +0000 (22:12 +0000)]
Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisa

Implement let-else type annotations natively

Tracking issue: #87335

Fixes #89688, fixes #89807, edit: fixes  #89960 as well

As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved.

This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically:

* `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~
* It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that.

* ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~
* ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~
    * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~

Some other misc notes:

* ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~
* in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.

2 years agoAuto merge of #91838 - scottmcm:array-slice-eq-via-arrays-not-slices, r=dtolnay
bors [Fri, 17 Dec 2021 19:17:29 +0000 (19:17 +0000)]
Auto merge of #91838 - scottmcm:array-slice-eq-via-arrays-not-slices, r=dtolnay

Do array-slice equality via array equality, rather than always via slices

~~Draft because it needs a rebase after #91766 eventually gets through bors.~~

This enables the optimizations from #85828 to be used for array-to-slice comparisons too, not just array-to-array.

For example, <https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=5f9ba69b3d5825a782f897c830d3a6aa>
```rust
pub fn demo(x: &[u8], y: [u8; 4]) -> bool {
    *x == y
}
```
Currently writes the array to stack for no reason:
```nasm
sub rsp, 4
mov dword ptr [rsp], edx
cmp rsi, 4
jne .LBB0_1
mov eax, dword ptr [rdi]
cmp eax, dword ptr [rsp]
sete al
add rsp, 4
ret

.LBB0_1:
xor eax, eax
add rsp, 4
ret
```
Whereas with the change in this PR it just compares it directly:
```nasm
cmp rsi, 4
jne .LBB1_1
cmp dword ptr [rdi], edx
sete al
ret

.LBB1_1:
xor eax, eax
ret
```

2 years agoAuto merge of #92036 - flip1995:clippyup, r=Manishearth
bors [Fri, 17 Dec 2021 15:29:35 +0000 (15:29 +0000)]
Auto merge of #92036 - flip1995:clippyup, r=Manishearth

Update Clippy

Only one day delayed! :sweat_smile:

r? `@Manishearth`

2 years agoMerge commit '23d11428de3e973b34a5090a78d62887f821c90e' into clippyup
flip1995 [Fri, 17 Dec 2021 12:40:22 +0000 (13:40 +0100)]
Merge commit '23d11428de3e973b34a5090a78d62887f821c90e' into clippyup

2 years agoAuto merge of #8134 - flip1995:rustup, r=flip1995
bors [Fri, 17 Dec 2021 12:24:03 +0000 (12:24 +0000)]
Auto merge of #8134 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-12-17
flip1995 [Fri, 17 Dec 2021 12:22:34 +0000 (13:22 +0100)]
Bump nightly version -> 2021-12-17

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Fri, 17 Dec 2021 11:22:41 +0000 (12:22 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #92023 - ehuss:update-cargo, r=ehuss
bors [Fri, 17 Dec 2021 10:37:26 +0000 (10:37 +0000)]
Auto merge of #92023 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in a359ce16073401f28b84840da85b268aa3d37c88..fcef61230c3b6213b6b0d233a36ba4ebd1649ec3
2021-12-14 18:40:22 +0000 to 2021-12-17 02:30:38 +0000
- Minor docs change for `cargo test --help` (rust-lang/cargo#10210)
- Make clippy happy (rust-lang/cargo#10205)
- Enhance descriptions of issue templates (rust-lang/cargo#10202)
- Add workaround for sporadic kills when building on Macos (rust-lang/cargo#10196)
- Detect filesystem loop during walking the projects (rust-lang/cargo#10188)
- Error about not having any crates with documentation (rust-lang/cargo#10204)
- Don't document libs with doc=false (rust-lang/cargo#10201)
- Bumps up tar to 0.4.36 (rust-lang/cargo#10198)

2 years agoAuto merge of #91812 - camelid:assoc-const-lazy, r=GuillaumeGomez
bors [Fri, 17 Dec 2021 06:03:38 +0000 (06:03 +0000)]
Auto merge of #91812 - camelid:assoc-const-lazy, r=GuillaumeGomez

rustdoc: Pretty-print assoc const defaults on-demand

This should improve performance, clean up the code, and help pave the
way for #83035.

2 years agoUpdate cargo
Eric Huss [Fri, 17 Dec 2021 04:35:44 +0000 (20:35 -0800)]
Update cargo

2 years agoAuto merge of #91672 - b-naber:merge-normalize-erasing-regions-queries, r=jackh726
bors [Fri, 17 Dec 2021 02:03:10 +0000 (02:03 +0000)]
Auto merge of #91672 - b-naber:merge-normalize-erasing-regions-queries, r=jackh726

Implement normalize_erasing_regions queries in terms of 'try' version

Attempt to lessen performance regression caused by https://github.com/rust-lang/rust/pull/91255

r? `@jackh726`

2 years agoAuto merge of #92003 - matthiaskrgr:rollup-obgv0rt, r=matthiaskrgr
bors [Thu, 16 Dec 2021 23:08:02 +0000 (23:08 +0000)]
Auto merge of #92003 - matthiaskrgr:rollup-obgv0rt, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #91172 (Warn when a `#[test]`-like built-in attribute macro is present multiple times.)
 - #91796 (Fix since attribute for const_manually_drop feature)
 - #91879 (Remove `in_band_lifetimes` from `rustc_borrowck`)
 - #91947 (Add `io::Error::other`)
 - #91967 (Pull in libdevstat on FreeBSD)
 - #91987 (Add module documentation for rustdoc passes)
 - #92001 (Fix default_method_body_is_const when used across crates)

Failed merges:

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

2 years agoAuto merge of #91616 - saethlin:sort_unchecked-sb-fix, r=Mark-Simulacrum
bors [Thu, 16 Dec 2021 19:56:45 +0000 (19:56 +0000)]
Auto merge of #91616 - saethlin:sort_unchecked-sb-fix, r=Mark-Simulacrum

Fix #91306 by deriving all access from a single *mut T

Fixes #91306.

The previous code is invalid because the first argument to `copy_nonoverlapping` is invalidated by the mutable borrow taken out to construct the second argument.

I believe this patch fixes that, and this code should now pass Miri with `-Ztag-raw-pointers`, ~~but I'm currently stuck trying to run my reproducer with a this patched version of the standard library (alternatively, running Miri on the standard library tests itself would suffice).~~ Ralf walked me through this on Zulip.

I've also added fixes for 7 more problems other than those I reported. Most of them are easy to hit by calling sort_unstable on random arrays. I don't have reproducers for every change, but they seem pretty clear-cut to me. But I did only start learning stacked borrows 2 days ago so that might be a large dash of Dunning-Kruger.

2 years agoRollup merge of #92001 - fee1-dead:dmbic-xcrate-fix, r=oli-obk
Matthias Krüger [Thu, 16 Dec 2021 16:23:13 +0000 (17:23 +0100)]
Rollup merge of #92001 - fee1-dead:dmbic-xcrate-fix, r=oli-obk

Fix default_method_body_is_const when used across crates

r? `@oli-obk`

unblocks #91439.

2 years agoRollup merge of #91987 - jsha:docdocgoose, r=jyn514
Matthias Krüger [Thu, 16 Dec 2021 16:23:12 +0000 (17:23 +0100)]
Rollup merge of #91987 - jsha:docdocgoose, r=jyn514

Add module documentation for rustdoc passes

These are currently documented at https://rustc-dev-guide.rust-lang.org/rustdoc-internals.html#hot-potato but can easily go out of date. We'd like to document them in place and link to https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/passes/index.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/moving.20pass.20docs/near/265058351).

r? `@camelid`

2 years agoRollup merge of #91967 - lnicola:freebsd-devstat, r=kennytm
Matthias Krüger [Thu, 16 Dec 2021 16:23:11 +0000 (17:23 +0100)]
Rollup merge of #91967 - lnicola:freebsd-devstat, r=kennytm

Pull in libdevstat on FreeBSD

Similar to https://github.com/rust-lang/rust/pull/90495, spotted in https://github.com/rust-lang/rust/pull/91909.

2 years agoRollup merge of #91947 - ibraheemdev:io-error-other, r=joshtriplett
Matthias Krüger [Thu, 16 Dec 2021 16:23:10 +0000 (17:23 +0100)]
Rollup merge of #91947 - ibraheemdev:io-error-other, r=joshtriplett

Add `io::Error::other`

This PR adds a small utility constructor, `io::Error::other`, a shorthand for `io::Error::new(io::ErrorKind::Other, err)`, something I find myself writing often.

For some concrete stats, a quick search on [grep.app](https://grep.app) shows that more than half of the uses of `io::Error::new` use `ErrorKind::Other`:
```
Error::new\((?:std::)?(?:io::)?ErrorKind:: => 3,898 results
Error::new\((?:std::)?(?:io::)?ErrorKind::Other => 2,186 results
```

2 years agoRollup merge of #91879 - bugadani:in_band_borrowck, r=wesleywiser
Matthias Krüger [Thu, 16 Dec 2021 16:23:09 +0000 (17:23 +0100)]
Rollup merge of #91879 - bugadani:in_band_borrowck, r=wesleywiser

Remove `in_band_lifetimes` from `rustc_borrowck`

See #91867 for more information.

2 years agoRollup merge of #91796 - not-my-profile:fix-const_manually_drop-since, r=kennytm
Matthias Krüger [Thu, 16 Dec 2021 16:23:08 +0000 (17:23 +0100)]
Rollup merge of #91796 - not-my-profile:fix-const_manually_drop-since, r=kennytm

Fix since attribute for const_manually_drop feature

const_manually_drop was stabilized in 1.32 as mentioned in
https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1320-2019-01-17

2 years agoRollup merge of #91172 - Ethiraric:ethiraric/fix90979, r=petrochenkov
Matthias Krüger [Thu, 16 Dec 2021 16:23:07 +0000 (17:23 +0100)]
Rollup merge of #91172 - Ethiraric:ethiraric/fix90979, r=petrochenkov

Warn when a `#[test]`-like built-in attribute macro is present multiple times.

Fixes #90979.

2 years agoFix SB problems in slice sorting
Ben Kimock [Tue, 7 Dec 2021 01:44:02 +0000 (20:44 -0500)]
Fix SB problems in slice sorting

Most of these problems originate in use of get_unchecked_mut.

When calling ptr::copy_nonoverlapping, using get_unchecked_mut for both
arguments causes the borrow created to make the second pointer to invalid the
first.

The pairs of identical MaybeUninit::slice_as_mut_ptr calls similarly
invalidate each other.

There was also a similar borrow invalidation problem with the use of
slice::get_unchecked_mut to derive the pointer for the CopyOnDrop.

2 years agoAuto merge of #91833 - klensy:rd-minus-alloc, r=jyn514
bors [Thu, 16 Dec 2021 15:18:08 +0000 (15:18 +0000)]
Auto merge of #91833 - klensy:rd-minus-alloc, r=jyn514

rustdoc: don't clone already owned `Path` and modify it inplace

2 years agoFix default_method_body_is_const when used across crates
Deadbeef [Thu, 16 Dec 2021 13:38:54 +0000 (21:38 +0800)]
Fix default_method_body_is_const when used across crates

2 years agoAuto merge of #91996 - matthiaskrgr:rollup-8pdt8x7, r=matthiaskrgr
bors [Thu, 16 Dec 2021 11:35:37 +0000 (11:35 +0000)]
Auto merge of #91996 - matthiaskrgr:rollup-8pdt8x7, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #91901 (Remove `in_band_lifetimes` from `rustc_symbol_mangling`)
 - #91904 (Remove `in_band_lifetimes` from `rustc_trait_selection`)
 - #91951 (update stdarch)
 - #91958 (Apply rust-logo class only on default logo)
 - #91972 (link to pref_align_of tracking issue)
 - #91986 (Bump compiler-builtins to 0.1.66)

Failed merges:

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

2 years agoRollup merge of #91986 - ayrtonm:bump-builtins, r=Amanieu
Matthias Krüger [Thu, 16 Dec 2021 09:12:47 +0000 (10:12 +0100)]
Rollup merge of #91986 - ayrtonm:bump-builtins, r=Amanieu

Bump compiler-builtins to 0.1.66

Adds intrinsics for truncdfsf2 and truncdfsf2vsp on ARM.

r? `@Amanieu`

2 years agoRollup merge of #91972 - RalfJung:pref-align-of, r=Mark-Simulacrum
Matthias Krüger [Thu, 16 Dec 2021 09:12:46 +0000 (10:12 +0100)]
Rollup merge of #91972 - RalfJung:pref-align-of, r=Mark-Simulacrum

link to pref_align_of tracking issue

If we are not going to remove this intrinsic (https://github.com/rust-lang/rust/pull/90877), I think we should at least have a place to centralize discussion around it, so here we go. Intrinsics don't have their own separate features and usually we instead use the public method for tracking it, but this one does not have such a method... so the tracking issue is just a regular link. (And then we sue it for the const part as well.)

2 years agoRollup merge of #91958 - jsha:rust-logo, r=GuillaumeGomez
Matthias Krüger [Thu, 16 Dec 2021 09:12:45 +0000 (10:12 +0100)]
Rollup merge of #91958 - jsha:rust-logo, r=GuillaumeGomez

Apply rust-logo class only on default logo

Fixes #91653.

![image](https://user-images.githubusercontent.com/220205/146138145-a7a62ea6-3205-4bc7-8460-e985284d93ea.png)

Demo: https://rustdoc.crud.net/jsha/hashes/sha2/

r? ``@GuillaumeGomez``

2 years agoRollup merge of #91951 - SparrowLii:master, r=Amanieu
Matthias Krüger [Thu, 16 Dec 2021 09:12:43 +0000 (10:12 +0100)]
Rollup merge of #91951 - SparrowLii:master, r=Amanieu

update stdarch

2 commits in d219ad63c5075098fc224a57deb4852b9734327d..0716b22e902207efabe46879cbf28d0189ab7924
2021-12-9 23:50:37 +0000 to 2021-12-14 16:17:57 +0100
 * Fix a bunch of typos ([Fix a bunch of typos stdarch#1267](https://github.com/rust-lang/stdarch/pull/1267))
 * Stabilize armv8 neon instruction set on aarch64 ([Stabilize armv8 neon instruction set on aarch64 stdarch#1266](https://github.com/rust-lang/stdarch/pull/1266))

The update stabilizes armv8 neon instructions on aarch64. #90972

2 years agoRollup merge of #91904 - SylvanB:remove_in_band_lifetimes_rustc_trait_selection,...
Matthias Krüger [Thu, 16 Dec 2021 09:12:42 +0000 (10:12 +0100)]
Rollup merge of #91904 - SylvanB:remove_in_band_lifetimes_rustc_trait_selection, r=petrochenkov

Remove `in_band_lifetimes` from `rustc_trait_selection`

Another one for #91867

2 years agoRollup merge of #91901 - SylvanB:remove_in_band_lifetimes_rustc_symbol_mangling,...
Matthias Krüger [Thu, 16 Dec 2021 09:12:42 +0000 (10:12 +0100)]
Rollup merge of #91901 - SylvanB:remove_in_band_lifetimes_rustc_symbol_mangling, r=jackh726

Remove `in_band_lifetimes` from `rustc_symbol_mangling`

Helping out with  #91867

2 years agoAuto merge of #91527 - the8472:retain-opt, r=dtolnay
bors [Thu, 16 Dec 2021 07:58:36 +0000 (07:58 +0000)]
Auto merge of #91527 - the8472:retain-opt, r=dtolnay

Optimize `vec::retain` performance

This simply moves the loops into the inner function which leads to better results.

```
old:

test vec::bench_retain_100000                            ... bench:     203,828 ns/iter (+/- 2,101)
test vec::bench_retain_iter_100000                       ... bench:      63,324 ns/iter (+/- 12,305)
test vec::bench_retain_whole_100000                      ... bench:      42,989 ns/iter (+/- 291)

new:

test vec::bench_retain_100000                            ... bench:      42,180 ns/iter (+/- 451)
test vec::bench_retain_iter_100000                       ... bench:      65,167 ns/iter (+/- 11,971)
test vec::bench_retain_whole_100000                      ... bench:      33,736 ns/iter (+/- 12,404)
```

Measured on x86_64-unknown-linux-gnu, Zen2

Fixes #91497

2 years agoAdd module documentation for rustdoc passes
Jacob Hoffman-Andrews [Thu, 16 Dec 2021 02:59:00 +0000 (18:59 -0800)]
Add module documentation for rustdoc passes

These are currently documented at
https://rustc-dev-guide.rust-lang.org/rustdoc-internals.html#hot-potato
but can easily go out of date. We'd like to document them in place and
link to
https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/passes/index.html

2 years agoAuto merge of #89836 - pierwill:fix-85142-crate-hash, r=wesleywiser
bors [Thu, 16 Dec 2021 02:21:30 +0000 (02:21 +0000)]
Auto merge of #89836 - pierwill:fix-85142-crate-hash, r=wesleywiser

Include rustc version in `rustc_span::StableCrateId`

`rustc_span::def_id::StableCrateId` is a hash of various data about a crate during compilation. This PR includes the version of `rustc` in the input when computing this hash. From a cursory reading of [RFC 2603](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html), this appears to be acceptable within that design.

In order to pass the `mir-opt` and `ui` test suites, this adds new [normalization for hashes and symbol names in `compiletest`](https://github.com/rust-lang/rust/pull/89836/files#diff-03a0567fa80ca04ed5a55f9ac5c711b4f84659be2d0ac4a984196d581c04f76b). These are enabled by default, but we might prefer it to be configurable.

In the UI tests, I had to truncate a significant amount of error annotations in v0 symbols (and maybe some legacy) in order to get the normalization to work correctly. (See https://github.com/rust-lang/rust/issues/90116.)

Closes #85142.

2 years agoBump compiler-builtins to 0.1.66
Ayrton [Thu, 16 Dec 2021 02:00:06 +0000 (21:00 -0500)]
Bump compiler-builtins to 0.1.66

Adds intrinsics for truncdfsf2 and truncdfsf2vsp on ARM.

2 years agoAdd a lint for duplicated attributes.
Ethiraric [Wed, 24 Nov 2021 09:20:23 +0000 (10:20 +0100)]
Add a lint for duplicated attributes.

2 years agoAuto merge of #86986 - lcnr:simplify_type, r=nikomatsakis,oli-obk
bors [Wed, 15 Dec 2021 22:32:56 +0000 (22:32 +0000)]
Auto merge of #86986 - lcnr:simplify_type, r=nikomatsakis,oli-obk

extend `simplify_type`

might cause a slight perf inprovement and imo more accurately represents what types there are.

considering that I was going to use this in #85048 it seems like we might need this in the future anyways :shrug:

2 years agoRemove `in_band_lifetimes` from `rustc_symbol_mangling`
Sylvan Bowdler [Tue, 14 Dec 2021 08:01:32 +0000 (08:01 +0000)]
Remove `in_band_lifetimes` from `rustc_symbol_mangling`

2 years agoRemove `in_band_lifetimes` from `rustc_trait_selection`
Sylvan Bowdler [Tue, 14 Dec 2021 09:44:49 +0000 (09:44 +0000)]
Remove `in_band_lifetimes` from `rustc_trait_selection`

2 years agoApply rust-logo class only on default logo
Jacob Hoffman-Andrews [Wed, 15 Dec 2021 06:54:42 +0000 (22:54 -0800)]
Apply rust-logo class only on default logo

Also replace ' with " in rustdoc template

2 years agolink to pref_align_of tracking issue
Ralf Jung [Wed, 15 Dec 2021 17:38:51 +0000 (18:38 +0100)]
link to pref_align_of tracking issue

2 years agoPull in libdevstat on FreeBSD
Laurențiu Nicola [Wed, 15 Dec 2021 14:16:26 +0000 (16:16 +0200)]
Pull in libdevstat on FreeBSD

2 years agoAuto merge of #91962 - matthiaskrgr:rollup-2g082jw, r=matthiaskrgr
bors [Wed, 15 Dec 2021 12:41:42 +0000 (12:41 +0000)]
Auto merge of #91962 - matthiaskrgr:rollup-2g082jw, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #91880 (fix clippy::single_char_pattern perf findings)
 - #91885 (Remove `in_band_lifetimes` from `rustc_codegen_ssa`)
 - #91898 (Make `TyS::is_suggestable` check for non-suggestable types structually)
 - #91915 (Add another regression test for unnormalized fn args with Self)
 - #91916 (Fix a bunch of typos)
 - #91918 (Constify `bool::then{,_some}`)
 - #91920 (Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp`)

Failed merges:

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

2 years agoAuto merge of #7978 - smoelius:master, r=llogiq
bors [Wed, 15 Dec 2021 10:46:43 +0000 (10:46 +0000)]
Auto merge of #7978 - smoelius:master, r=llogiq

Add `unnecessary_to_owned` lint

This PR adds a lint to check for unnecessary calls to `ToOwned::to_owned` and other similar functions (e.g., `Cow::into_owned`, `ToString::to_string`, etc.).

The lint checks for expressions of the form `&receiver.to_owned_like()` used in a position requiring type `&T` where one of the following is true:
* `receiver`'s type is `T` exactly
* `receiver`'s type implements `Deref<Target = T>`
* `receiver`'s type implements `AsRef<T>`

The lint additionally checks for expressions of the form `receiver.to_owned_like()` used as arguments of type `impl AsRef<T>`.

It would be nice if the lint could also check for expressions used as arguments to functions like the following:
```
fn foo<T: AsRef<str>>(x: T) { ... }
```
However, I couldn't figure out how to determine whether a function input type was instantiated from a parameter with a trait bound.

If someone could offer me some guidance, I would be happy to add such functionality.

Closes #7933

changelog: Add [`unnecessary_to_owned`] lint

2 years agoExpand `is_clone_like` comment
Samuel E. Moelius III [Wed, 15 Dec 2021 10:25:47 +0000 (05:25 -0500)]
Expand `is_clone_like` comment

2 years agoRollup merge of #91920 - Aaron1011:pred-stable-cmp, r=oli-obk
Matthias Krüger [Wed, 15 Dec 2021 09:57:04 +0000 (10:57 +0100)]
Rollup merge of #91920 - Aaron1011:pred-stable-cmp, r=oli-obk

Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp`

This avoids a needless query invocation

2 years agoRollup merge of #91918 - fee1-dead:constification0-the-great-constification-begins...
Matthias Krüger [Wed, 15 Dec 2021 09:57:03 +0000 (10:57 +0100)]
Rollup merge of #91918 - fee1-dead:constification0-the-great-constification-begins, r=oli-obk

Constify `bool::then{,_some}`

Note on `~const Drop`: it has no effect when called from runtime functions, when called from const contexts, the trait system ensures that the type can be dropped in const contexts.

2 years agoRollup merge of #91916 - steffahn:fix-typos, r=dtolnay
Matthias Krüger [Wed, 15 Dec 2021 09:57:02 +0000 (10:57 +0100)]
Rollup merge of #91916 - steffahn:fix-typos, r=dtolnay

Fix a bunch of typos

I hope that none of these files is not supposed to be modified.

FYI, I opened separate PRs for typos in submodules, in the respective repositories
* https://github.com/rust-lang/stdarch/pull/1267
* https://github.com/rust-lang/backtrace-rs/pull/455

2 years agoRollup merge of #91915 - jackh726:issue-91899, r=Mark-Simulacrum
Matthias Krüger [Wed, 15 Dec 2021 09:57:01 +0000 (10:57 +0100)]
Rollup merge of #91915 - jackh726:issue-91899, r=Mark-Simulacrum

Add another regression test for unnormalized fn args with Self

Closes #91899

2 years agoRollup merge of #91898 - compiler-errors:dont_suggest_closure_return_type, r=lcnr
Matthias Krüger [Wed, 15 Dec 2021 09:57:00 +0000 (10:57 +0100)]
Rollup merge of #91898 - compiler-errors:dont_suggest_closure_return_type, r=lcnr

Make `TyS::is_suggestable` check for non-suggestable types structually

Not sure if I went overboard checking substs in dyn types, etc. Let me know if I should simplify this function.

Fixes #91832

2 years agoRollup merge of #91885 - LegionMammal978:less-inband-codegen_ssa, r=workingjubilee
Matthias Krüger [Wed, 15 Dec 2021 09:56:59 +0000 (10:56 +0100)]
Rollup merge of #91885 - LegionMammal978:less-inband-codegen_ssa, r=workingjubilee

Remove `in_band_lifetimes` from `rustc_codegen_ssa`

See #91867 for more information.

In `compiler/rustc_codegen_ssa/src/coverageinfo/map.rs`, there are several functions with an explicit `'a` lifetime but only a single `&'a self` parameter. These lifetimes should be redundant given lifetime elision, unless the existential `impl Iterator` has weird issues regarding that. Should the redundant lifetimes be removed?

2 years agoRollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514
Matthias Krüger [Wed, 15 Dec 2021 09:56:58 +0000 (10:56 +0100)]
Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514

fix clippy::single_char_pattern perf findings

2 years agoAuto merge of #91959 - matthiaskrgr:rollup-rhajuvw, r=matthiaskrgr
bors [Wed, 15 Dec 2021 09:31:59 +0000 (09:31 +0000)]
Auto merge of #91959 - matthiaskrgr:rollup-rhajuvw, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #90521 (Stabilize `destructuring_assignment`)
 - #91479 (Add `[T]::as_simd(_mut)`)
 - #91584 (Improve code for rustdoc-gui tester)
 - #91886 (core: minor `Option` doc correction)
 - #91888 (Handle unordered const/ty generics for object lifetime defaults)
 - #91905 (Fix source code page sidebar on mobile)
 - #91906 (Removed `in_band_lifetimes` from `library\proc_macro`)

Failed merges:

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

2 years agoupdate tests
lcnr [Wed, 15 Dec 2021 08:54:27 +0000 (09:54 +0100)]
update tests

2 years agoRemove in_band_lifetimes from borrowck
Dániel Buga [Wed, 15 Dec 2021 07:38:12 +0000 (08:38 +0100)]
Remove in_band_lifetimes from borrowck

2 years agoRollup merge of #91906 - anuvratsingh:remove_in_band_lifetimes_library_proc_macro...
Matthias Krüger [Wed, 15 Dec 2021 07:36:25 +0000 (08:36 +0100)]
Rollup merge of #91906 - anuvratsingh:remove_in_band_lifetimes_library_proc_macro, r=petrochenkov

Removed `in_band_lifetimes` from `library\proc_macro`

Issue [#91867](https://github.com/rust-lang/rust/issues/91867)

This is my first try, I followed the instructions given. Fixed all the errors that were thrown while compiling.
Compiled with stage 0,1, and 2 all of them compiled successfully.

2 years agoRollup merge of #91905 - GuillaumeGomez:source-code-page-sidebar, r=jsha
Matthias Krüger [Wed, 15 Dec 2021 07:36:24 +0000 (08:36 +0100)]
Rollup merge of #91905 - GuillaumeGomez:source-code-page-sidebar, r=jsha

Fix source code page sidebar on mobile

Current broken behaviour:

https://user-images.githubusercontent.com/3050060/145984316-35c82353-5bab-4dc6-9ac6-63ea7e5c27d8.mp4

Fixed:

https://user-images.githubusercontent.com/3050060/145984329-8be1127b-d707-424d-ac3c-c1fb3c48a093.mp4

r? `@jsha`

2 years agoRollup merge of #91888 - BoxyUwU:generic_arg_infer_aaaa, r=lcnr
Matthias Krüger [Wed, 15 Dec 2021 07:36:23 +0000 (08:36 +0100)]
Rollup merge of #91888 - BoxyUwU:generic_arg_infer_aaaa, r=lcnr

Handle unordered const/ty generics for object lifetime defaults

*feel like I should have a PR description but cant think of what to put here*

r? ```@lcnr```

2 years agoRollup merge of #91886 - euclio:option-doc, r=dtolnay
Matthias Krüger [Wed, 15 Dec 2021 07:36:22 +0000 (08:36 +0100)]
Rollup merge of #91886 - euclio:option-doc, r=dtolnay

core: minor `Option` doc correction

2 years agoRollup merge of #91584 - GuillaumeGomez:improve-rustdoc-gui-tester-code, r=jsha
Matthias Krüger [Wed, 15 Dec 2021 07:36:21 +0000 (08:36 +0100)]
Rollup merge of #91584 - GuillaumeGomez:improve-rustdoc-gui-tester-code, r=jsha

Improve code for rustdoc-gui tester

Following advice given in #91391.

It nicely improves the code readability. :)

r? `@jsha`

2 years agoRollup merge of #91479 - scottmcm:slice-as-simd, r=workingjubilee
Matthias Krüger [Wed, 15 Dec 2021 07:36:20 +0000 (08:36 +0100)]
Rollup merge of #91479 - scottmcm:slice-as-simd, r=workingjubilee

Add `[T]::as_simd(_mut)`

SIMD-style optimizations are the most common use for `[T]::align_to(_mut)`, but that's `unsafe`.  So these are *safe* wrappers around it, now that we have the `Simd` type available, to make it easier to use.

```rust
impl [T] {
    pub fn as_simd<const LANES: usize>(&self) -> (&[T], &[Simd<T, LANES>], &[T]);
    pub fn as_simd_mut<const LANES: usize>(&mut self) -> (&mut [T], &mut [Simd<T, LANES>], &mut [T]);
}
```

They're `cfg`'d out for miri because the `simd` module as a whole is unavailable there.

2 years agoRollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix
Matthias Krüger [Wed, 15 Dec 2021 07:36:19 +0000 (08:36 +0100)]
Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix

Stabilize `destructuring_assignment`

Closes #71126

- [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058)
- [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819)

`@rustbot` label +F-destructuring-assignment +T-lang
Also needs +relnotes but I don't have permission to add that tag.

2 years agoRollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix
Matthias Krüger [Wed, 15 Dec 2021 07:36:19 +0000 (08:36 +0100)]
Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix

Stabilize `destructuring_assignment`

Closes #71126

- [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058)
- [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819)

`@rustbot` label +F-destructuring-assignment +T-lang
Also needs +relnotes but I don't have permission to add that tag.

2 years agoAuto merge of #91752 - yaahc:track-caller-result, r=cuviper
bors [Wed, 15 Dec 2021 06:34:00 +0000 (06:34 +0000)]
Auto merge of #91752 - yaahc:track-caller-result, r=cuviper

Readd track_caller to Result::from_residual

This is a followup on https://github.com/rust-lang/rust/issues/87401 in and an attempt to move the issue towards resolution.

As part of the overhaul of the Try trait we removed the ability for errors to grab location information during propagation via `?` with the builtin `std::result::Result`. The previously linked issue has a fair bit of discussion into the reasons for and against the usage of `#[track_caller]` on the `FromResidual` impl on `Result` that I will do my best to summarize.

---
### For

- https://github.com/rust-lang/rust/issues/87401#issuecomment-915053533: Difficulties with using non `std::result::Result` like types
- https://github.com/rust-lang/rust/issues/87401#issuecomment-978355102: Inconsistency with functionality provided for recoverable (Result) and non-recoverable errors (panic), where panic provides a location and Result does not, pushing some users towards using panic

### Against

- https://github.com/rust-lang/rust/issues/84277#issuecomment-885322833: concern that this will bloat callers that never use this data

---

Personally, I want to quantify the performance / bloat impact of re-adding this attribute, and fully evaluate the pros and cons before deciding if I need to switch `eyre` to have a custom `Result` type, which would also mean I need `try_trait_v2` to be stabilized, cc `@scottmcm.` If the performance impact is minor enough in the general case I think I would prefer that the default `Result` type has the ability to track location information for consistency with `panic` error reporting, and leave it to applications that need particularly high performance to handle the micro optimizations of introducing their own efficient custom Result type or matching manually.

Alternatively, I wonder if the performance penalty on code that doesn't use the location information on `FromResidual` could be mitigated via new optimizations.

2 years agoRemove `in_band_lifetimes` from `rustc_codegen_ssa`
LegionMammal978 [Tue, 14 Dec 2021 02:52:35 +0000 (21:52 -0500)]
Remove `in_band_lifetimes` from `rustc_codegen_ssa`

See #91867 for more information.

2 years agoStabilize `destructuring_assignment`
Jacob Pratt [Wed, 3 Nov 2021 06:50:57 +0000 (02:50 -0400)]
Stabilize `destructuring_assignment`

2 years agoStabilize `destructuring_assignment`
Jacob Pratt [Wed, 3 Nov 2021 06:50:57 +0000 (02:50 -0400)]
Stabilize `destructuring_assignment`

2 years agoAuto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgr
bors [Wed, 15 Dec 2021 03:28:55 +0000 (03:28 +0000)]
Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring)
 - #91859 (Iterator::cycle() — document empty iterator special case)
 - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`)
 - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking)
 - #91881 (Stabilize `iter::zip`)
 - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`)
 - #91940 (Update cargo)

Failed merges:

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

2 years agoupdate stdarch
SparrowLii [Wed, 15 Dec 2021 02:22:03 +0000 (10:22 +0800)]
update stdarch

2 years agoadd `io::Error::other` constructor
Ibraheem Ahmed [Wed, 15 Dec 2021 01:00:59 +0000 (20:00 -0500)]
add `io::Error::other` constructor

2 years agoRollup merge of #91940 - ehuss:update-cargo, r=ehuss
Matthias Krüger [Wed, 15 Dec 2021 00:28:10 +0000 (01:28 +0100)]
Rollup merge of #91940 - ehuss:update-cargo, r=ehuss

Update cargo

14 commits in 40dc281755137ee804bc9b3b08e782773b726e44..a359ce16073401f28b84840da85b268aa3d37c88
2021-12-06 21:54:44 +0000 to 2021-12-14 18:40:22 +0000
- Support `term.quiet` configuration (rust-lang/cargo#10152)
- Display alias target on 'cargo help &lt;alias&gt;` (rust-lang/cargo#10193)
- delete --host command and message (rust-lang/cargo#10145)
- Improve I/O error message for fingerprint of build script (rust-lang/cargo#10191)
- Explicitly mark aliases in `cargo list`. (rust-lang/cargo#10177)
- Don't emit "executable" JSON field for non-executables. (rust-lang/cargo#10171)
- Move scrape-examples docs to correct section. (rust-lang/cargo#10166)
- Do not suggest source config if nothing to vendor (rust-lang/cargo#10161)
- Bump versions of local deps. (rust-lang/cargo#10155)
- Bump to 0.60.0, update changelog (rust-lang/cargo#10154)
- Fix some profile documentation. (rust-lang/cargo#10153)
- Document lib before bin. (rust-lang/cargo#10172)
- Sync cargo-the-cli version with rustc. (rust-lang/cargo#10178)
- Remove `-Z future-incompat-report` from message displayed to user (rust-lang/cargo#10185)

2 years agoRollup merge of #91882 - Patrick-Poitras:remove-in-band-lifetimes-from-rustc-typeck...
Matthias Krüger [Wed, 15 Dec 2021 00:28:09 +0000 (01:28 +0100)]
Rollup merge of #91882 - Patrick-Poitras:remove-in-band-lifetimes-from-rustc-typeck, r=jackh726

Remove `in_band_lifetimes` from `rustc_typeck`

Joining in on the effort to remove the `in_band_lifetimes` features, as described in issue #91867.

2 years agoRollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Matthias Krüger [Wed, 15 Dec 2021 00:28:08 +0000 (01:28 +0100)]
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm

Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).

2 years agoRollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Matthias Krüger [Wed, 15 Dec 2021 00:28:08 +0000 (01:28 +0100)]
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm

Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).

2 years agoRollup merge of #91870 - rusticstuff:macosx_min_version_revert, r=Mark-Simulacrum
Matthias Krüger [Wed, 15 Dec 2021 00:28:07 +0000 (01:28 +0100)]
Rollup merge of #91870 - rusticstuff:macosx_min_version_revert, r=Mark-Simulacrum

Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking

This reverts commit b376f5621b801460b911a75048a70698021bbc69, which is the main part of #90499, because it turns out that this causes a good amount of breakage in crates relying on the old behavior. In particular `winit`, `coreaudio` and crates that depend on them are affected. Fixes #91372.

Background:
Before #90499 the behavior was the following: If MACOSX_DEPLOYMENT_TARGET is not set,  we pass the minimum supported OS version to LLVM but not to the linker. The linker default depends on the Xcode version and the version of the OS it is running on. That caused one known problem in libcurl with the most recent Xcode versions. #90499 passed the minumum supported version (10.7 for Macos x86-64) to the linker instead. This has shown to be problematic because some crates such as winit, coreaudio implicitly expect a newer minimum OS version. The libcurl issue has been fixed independently (see https://github.com/alexcrichton/curl-rust/issues/417), so a revert should not really be problematic.

Eventually we should probably mimic clang's behavior and fall back to the default of the currently configured Macos SDK for both the LLVM min os target version and MACOSX_DEPLOYMENT_TARGET for linking. That would entail looking at the `Version` property of the `SDKSettings.json` in the currently configured SDK.

2 years agoRollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obk
Matthias Krüger [Wed, 15 Dec 2021 00:28:06 +0000 (01:28 +0100)]
Rollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obk

Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`

The resulting profile will include the crate name and will be stored in
the `--out-dir` directory.

This implementation makes it convenient to use LLVM time trace together
with cargo, in the contrast to the previous implementation which would
overwrite profiles or store them in `.cargo/registry/..`.

2 years agoRollup merge of #91859 - xkr47:patch-2, r=yaahc
Matthias Krüger [Wed, 15 Dec 2021 00:28:05 +0000 (01:28 +0100)]
Rollup merge of #91859 - xkr47:patch-2, r=yaahc

Iterator::cycle() — document empty iterator special case

2 years agoRollup merge of #90939 - estebank:wg-af-polish, r=tmandry
Matthias Krüger [Wed, 15 Dec 2021 00:28:04 +0000 (01:28 +0100)]
Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry

Tweak errors coming from `for`-loop, `?` and `.await` desugaring

 * Suggest removal of `.await` on non-`Future` expression
 * Keep track of obligations introduced by desugaring
 * Remove span pointing at method for obligation errors coming from desugaring
 * Point at called local sync `fn` and suggest making it `async`

```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:9:10
   |
LL |     boo().await;
   |     -----^^^^^^ `()` is not a future
   |     |
   |     this call returns `()`
   |
   = help: the trait `Future` is not implemented for `()`
help: do not `.await` the expression
   |
LL -     boo().await;
LL +     boo();
   |
help: alternatively, consider making `fn boo` asynchronous
   |
LL | async fn boo () {}
   | +++++
```

Fix #66731.

2 years agoRollup merge of #90939 - estebank:wg-af-polish, r=tmandry
Matthias Krüger [Wed, 15 Dec 2021 00:28:04 +0000 (01:28 +0100)]
Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry

Tweak errors coming from `for`-loop, `?` and `.await` desugaring

 * Suggest removal of `.await` on non-`Future` expression
 * Keep track of obligations introduced by desugaring
 * Remove span pointing at method for obligation errors coming from desugaring
 * Point at called local sync `fn` and suggest making it `async`

```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:9:10
   |
LL |     boo().await;
   |     -----^^^^^^ `()` is not a future
   |     |
   |     this call returns `()`
   |
   = help: the trait `Future` is not implemented for `()`
help: do not `.await` the expression
   |
LL -     boo().await;
LL +     boo();
   |
help: alternatively, consider making `fn boo` asynchronous
   |
LL | async fn boo () {}
   | +++++
```

Fix #66731.

2 years agoAuto merge of #91933 - matthiaskrgr:rollup-cw9qolb, r=matthiaskrgr
bors [Wed, 15 Dec 2021 00:23:44 +0000 (00:23 +0000)]
Auto merge of #91933 - matthiaskrgr:rollup-cw9qolb, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #89825 (Make split_inclusive() on an empty slice yield an empty output)
 - #91239 (regression test for issue 87490)
 - #91597 (Recover on invalid operators `<>` and `<=>`)
 - #91774 (Fix typo for MutVisitor)
 - #91786 (Return an error when `eval_rvalue_with_identities` fails)
 - #91798 (Avoid suggest adding `self` in visibility spec)
 - #91856 (Looser check for overflowing_binary_op)

Failed merges:

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

2 years agoUpdate comments per review feedback
Scott McMurray [Tue, 14 Dec 2021 23:48:46 +0000 (15:48 -0800)]
Update comments per review feedback

2 years agoAddress review comments
Samuel E. Moelius III [Tue, 14 Dec 2021 23:36:19 +0000 (18:36 -0500)]
Address review comments

2 years agoUpdate cargo
Eric Huss [Tue, 14 Dec 2021 23:24:41 +0000 (15:24 -0800)]
Update cargo

2 years agoRemove iter::zip feature gate from clippy
PFPoitras [Tue, 14 Dec 2021 22:10:57 +0000 (18:10 -0400)]
Remove iter::zip feature gate from clippy

2 years agoRemove iter::zip feature gate from clippy
PFPoitras [Tue, 14 Dec 2021 22:10:57 +0000 (18:10 -0400)]
Remove iter::zip feature gate from clippy

2 years agoStabilize iter::zip.
PFPoitras [Mon, 13 Dec 2021 23:18:50 +0000 (19:18 -0400)]
Stabilize iter::zip.

2 years agoAuto merge of #91728 - Amanieu:stable_asm, r=joshtriplett
bors [Tue, 14 Dec 2021 21:15:22 +0000 (21:15 +0000)]
Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett

Stabilize asm! and global_asm!

Tracking issue: #72016

It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature!

The main changes in this PR are:
- Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228.
- Stabilizing the `asm` and `global_asm` features.
- Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483).
  - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example.
- Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`.
- Updating `stdarch` and `compiler-builtins`.
- Updating all the tests.

r? `@joshtriplett`

2 years agoAuto merge of #91728 - Amanieu:stable_asm, r=joshtriplett
bors [Tue, 14 Dec 2021 21:15:22 +0000 (21:15 +0000)]
Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett

Stabilize asm! and global_asm!

Tracking issue: #72016

It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature!

The main changes in this PR are:
- Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228.
- Stabilizing the `asm` and `global_asm` features.
- Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483).
  - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example.
- Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`.
- Updating `stdarch` and `compiler-builtins`.
- Updating all the tests.

r? `@joshtriplett`

2 years agoDo array-slice equality via arrays, rather than always via slices
Scott McMurray [Sat, 11 Dec 2021 23:29:52 +0000 (15:29 -0800)]
Do array-slice equality via arrays, rather than always via slices

This'll still go via slices eventually for large arrays, but this way slice comparisons to short arrays can use the same memcmp-avoidance tricks.

Added some tests for all the combinations to make sure I didn't accidentally infinitely-recurse something.

2 years agoRollup merge of #91856 - ouz-a:master, r=oli-obk
Matthias Krüger [Tue, 14 Dec 2021 19:47:31 +0000 (20:47 +0100)]
Rollup merge of #91856 - ouz-a:master, r=oli-obk

Looser check for overflowing_binary_op

Fix for issue #91636 tight check resulted in ICE, this makes the check a little looser. It seems `eq` allows comparing of `supertype` and `subtype` if `lhs = supertype` and `rhs = subtype` but not vice versa, is this intended behavior ?

2 years agoRollup merge of #91798 - bugadani:issue-91783, r=michaelwoerister
Matthias Krüger [Tue, 14 Dec 2021 19:47:30 +0000 (20:47 +0100)]
Rollup merge of #91798 - bugadani:issue-91783, r=michaelwoerister

Avoid suggest adding `self` in visibility spec

Fixes #91783

2 years agoRollup merge of #91786 - tmiasko:const-prop, r=oli-obk
Matthias Krüger [Tue, 14 Dec 2021 19:47:30 +0000 (20:47 +0100)]
Rollup merge of #91786 - tmiasko:const-prop, r=oli-obk

Return an error when `eval_rvalue_with_identities` fails

Previously some code paths would fail to evaluate the rvalue, while
incorrectly indicating success with `Ok`. As a result the previous value
of lhs could have been incorrectly const propagated.

Fixes #91725.

r? `@oli-obk`

2 years agoRollup merge of #91774 - surechen:fix_typo_1, r=wesleywiser
Matthias Krüger [Tue, 14 Dec 2021 19:47:28 +0000 (20:47 +0100)]
Rollup merge of #91774 - surechen:fix_typo_1, r=wesleywiser

Fix typo for MutVisitor

Fix typo for MutVisitor.

2 years agoRollup merge of #91597 - r00ster91:lessthangreaterthan, r=oli-obk
Matthias Krüger [Tue, 14 Dec 2021 19:47:27 +0000 (20:47 +0100)]
Rollup merge of #91597 - r00ster91:lessthangreaterthan, r=oli-obk

Recover on invalid operators `<>` and `<=>`

Thanks to #89871 for showing me how to do this.
Next, I think it'd be nice to recover on `<=>` too, like #89871 intended, if this even works.

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 agoMake TyS::is_suggestable more structual
Michael Goulet [Tue, 14 Dec 2021 05:22:02 +0000 (21:22 -0800)]
Make TyS::is_suggestable more structual

2 years agoRecover on invalid operators <> and <=>
r00ster91 [Mon, 6 Dec 2021 17:55:58 +0000 (18:55 +0100)]
Recover on invalid operators <> and <=>