]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #89793 - ibraheemdev:from_ptr_range, r=m-ou-se
Matthias Krüger [Mon, 28 Feb 2022 11:57:44 +0000 (12:57 +0100)]
Rollup merge of #89793 - ibraheemdev:from_ptr_range, r=m-ou-se

Add `slice::{from_ptr_range, from_mut_ptr_range} `

Adds `slice::{from_ptr_range, from_mut_ptr_range}` as counterparts to `slice::{as_ptr_range, as_mut_ptr_range}`.

2 years agoAuto merge of #94427 - cjgillot:inline-fresh-expn, r=oli-obk
bors [Mon, 28 Feb 2022 08:25:26 +0000 (08:25 +0000)]
Auto merge of #94427 - cjgillot:inline-fresh-expn, r=oli-obk

Only create a single expansion for each inline integration.

The inlining integrator used to create one expansion for each span from the callee body.
This PR reverses the logic to create a single expansion for the whole call,
which is more consistent with how macro expansions work for macros.

This should remove the large memory regression in #91743.

2 years agoAuto merge of #94158 - erikdesjardins:more-more-noundef, r=nikic
bors [Mon, 28 Feb 2022 06:11:20 +0000 (06:11 +0000)]
Auto merge of #94158 - erikdesjardins:more-more-noundef, r=nikic

Apply noundef metadata to loads of types that do not permit raw init

This matches the noundef attributes we apply on arguments/return types.

Fixes (partially) #74378.

2 years agoAuto merge of #94437 - RalfJung:miri, r=RalfJung
bors [Mon, 28 Feb 2022 03:44:19 +0000 (03:44 +0000)]
Auto merge of #94437 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/94318
r? `@ghost`

2 years agoupdate Miri
Ralf Jung [Mon, 28 Feb 2022 03:04:00 +0000 (22:04 -0500)]
update Miri

2 years agoAuto merge of #94431 - matthiaskrgr:rollup-1jsj0wu, r=matthiaskrgr
bors [Mon, 28 Feb 2022 01:18:01 +0000 (01:18 +0000)]
Auto merge of #94431 - matthiaskrgr:rollup-1jsj0wu, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #94396 (1 - Make more use of `let_chains`)
 - #94397 (Document that pre-expansion lint passes are softly deprecated)
 - #94399 (Add test for #79465 to prevent regression)
 - #94409 (avoid rebuilding bootstrap when PATH changes)
 - #94415 (Use the first codegen backend in the config.toml as default)
 - #94417 (Fix duplicated impl links)
 - #94420 (3 - Make more use of `let_chains`)

Failed merges:

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

2 years agoadd `slice::{from_ptr_range, from_mut_ptr_range}`
Ibraheem Ahmed [Mon, 11 Oct 2021 21:41:25 +0000 (17:41 -0400)]
add `slice::{from_ptr_range, from_mut_ptr_range}`

2 years agoAuto merge of #94157 - erikdesjardins:more-noundef, r=nikic
bors [Sun, 27 Feb 2022 21:41:06 +0000 (21:41 +0000)]
Auto merge of #94157 - erikdesjardins:more-noundef, r=nikic

Apply noundef attribute to all scalar types which do not permit raw init

Beyond `&`/`&mut`/`Box`, this covers `char`, enum discriminants, `NonZero*`, etc.
All such types currently cause a Miri error if left uninitialized,
and an `invalid_value` lint in cases like `mem::uninitialized::<char>()`.

Note that this _does not_ change whether or not it is UB for `u64` (or
other integer types with no invalid values) to be undef.

Fixes (partially) #74378.

r? `@ghost` (blocked on #94127)

`@rustbot` label S-blocked

2 years agoRollup merge of #94420 - c410-f3r:more-let-chains, r=Dylan-DPC
Matthias Krüger [Sun, 27 Feb 2022 20:46:38 +0000 (21:46 +0100)]
Rollup merge of #94420 - c410-f3r:more-let-chains, r=Dylan-DPC

3 - Make more use of `let_chains`

Continuation of #94376.

cc #53667

2 years agoRollup merge of #94417 - GuillaumeGomez:fix-duplicated-impl-links, r=notriddle
Matthias Krüger [Sun, 27 Feb 2022 20:46:37 +0000 (21:46 +0100)]
Rollup merge of #94417 - GuillaumeGomez:fix-duplicated-impl-links, r=notriddle

Fix duplicated impl links

Fixes #78701.

The problem is that the blanket impl has the same ID as the other impl, except that we don't derive IDs when we generate the sidebar. We now do.

r? ``@notriddle``

2 years agoRollup merge of #94415 - bjorn3:cfg_default_backend, r=Mark-Simulacrum
Matthias Krüger [Sun, 27 Feb 2022 20:46:36 +0000 (21:46 +0100)]
Rollup merge of #94415 - bjorn3:cfg_default_backend, r=Mark-Simulacrum

Use the first codegen backend in the config.toml as default

It is currently hard coded to llvm if enabled and cranelift otherwise.
This made some sense when cranelift was the only alternative codegen
backend. Since the introduction of the gcc backend this doesn't make
much sense anymore. Before this PR bootstrapping rustc using a backend
other than llvm or cranelift required changing the source of
rustc_interface. With this PR it becomes a matter of putting the right
backend as first enabled backend in config.toml.

cc ```@antoyo```

2 years agoRollup merge of #94409 - RalfJung:path, r=Mark-Simulacrum
Matthias Krüger [Sun, 27 Feb 2022 20:46:35 +0000 (21:46 +0100)]
Rollup merge of #94409 - RalfJung:path, r=Mark-Simulacrum

avoid rebuilding bootstrap when PATH changes

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

r? ```@Mark-Simulacrum```

2 years agoRollup merge of #94399 - GuillaumeGomez:regression-test-79465, r=matthiaskrgr
Matthias Krüger [Sun, 27 Feb 2022 20:46:34 +0000 (21:46 +0100)]
Rollup merge of #94399 - GuillaumeGomez:regression-test-79465, r=matthiaskrgr

Add test for #79465 to prevent regression

Fixes #79465.

Like this we will be able to close the issue.

r? ````@matthiaskrgr````

2 years agoRollup merge of #94397 - xFrednet:69838-deprecate-pre-expansion, r=cjgillot
Matthias Krüger [Sun, 27 Feb 2022 20:46:34 +0000 (21:46 +0100)]
Rollup merge of #94397 - xFrednet:69838-deprecate-pre-expansion, r=cjgillot

Document that pre-expansion lint passes are softly deprecated

The pre-expansion lint pass has been softly deprecated since https://github.com/rust-lang/rust/pull/69838. Every once in a while I see someone mention it as a possibility, only get the feedback that it's deprecated. This PR officially documents that the method is soft deprecated to have a single point of truth for it.

That's it. Have a great rest of the day :upside_down_face:

---

* See [rust#69838](https://github.com/rust-lang/rust/pull/69838)
* See [rust-clippy#5518](https://github.com/rust-lang/rust-clippy/pull/5518)

2 years agoRollup merge of #94396 - c410-f3r:yet-more-let-chains, r=Dylan-DPC
Matthias Krüger [Sun, 27 Feb 2022 20:46:33 +0000 (21:46 +0100)]
Rollup merge of #94396 - c410-f3r:yet-more-let-chains, r=Dylan-DPC

1 - Make more use of `let_chains`

Continuation of #94376.

cc #53667

2 years agomake pgo-branch-weights test not dependent on argument attributes
Erik Desjardins [Sun, 27 Feb 2022 18:40:50 +0000 (13:40 -0500)]
make pgo-branch-weights test not dependent on argument attributes

2 years agoOnly create a single expansion for each inline integration.
Camille GILLOT [Sun, 27 Feb 2022 15:09:52 +0000 (16:09 +0100)]
Only create a single expansion for each inline integration.

2 years agoAuto merge of #94412 - scottmcm:cfg-out-miri-from-swap, r=oli-obk
bors [Sun, 27 Feb 2022 17:42:48 +0000 (17:42 +0000)]
Auto merge of #94412 - scottmcm:cfg-out-miri-from-swap, r=oli-obk

For MIRI, cfg out the swap vectorization logic from 94212

Because of #69488 the swap logic from #94212 doesn't currently work in MIRI.

Copying in smaller pieces is probably much worse for its performance anyway, so it'd probably rather just use the simple path regardless.

Part of #94371, though another PR will be needed for the CTFE aspect.

r? `@oli-obk`
cc `@RalfJung`

2 years agoApply noundef metadata to loads of types that do not permit raw init
Erik Desjardins [Sat, 12 Feb 2022 19:01:33 +0000 (14:01 -0500)]
Apply noundef metadata to loads of types that do not permit raw init

This matches the noundef attributes we apply on arguments/return types.

2 years ago3 - Make more use of let_chains
Caio [Sun, 27 Feb 2022 14:10:20 +0000 (11:10 -0300)]
3 - Make more use of let_chains

Continuation of #94376.

cc #53667

2 years agoAuto merge of #94084 - Mark-Simulacrum:drop-sharded, r=cjgillot
bors [Sun, 27 Feb 2022 14:04:07 +0000 (14:04 +0000)]
Auto merge of #94084 - Mark-Simulacrum:drop-sharded, r=cjgillot

Avoid query cache sharding code in single-threaded mode

In non-parallel compilers, this is just adding needless overhead at compilation time (since there is only one shard statically anyway). This amounts to roughly ~10 seconds reduction in bootstrap time, with overall neutral (some wins, some losses) performance results.

Parallel compiler performance should be largely unaffected by this PR; sharding is kept there.

2 years agoAuto merge of #94400 - c410-f3r:more-let-chains, r=Dylan-DPC
bors [Sun, 27 Feb 2022 11:45:55 +0000 (11:45 +0000)]
Auto merge of #94400 - c410-f3r:more-let-chains, r=Dylan-DPC

2 - Make more use of `let_chains`

Continuation of #94376.

cc #53667

2 years agoAdd test to ensure that links to impls are correctly generated
Guillaume Gomez [Sun, 27 Feb 2022 11:07:54 +0000 (12:07 +0100)]
Add test to ensure that links to impls are correctly generated

2 years agoCorrectly generate links in the sidebar for impls
Guillaume Gomez [Sun, 27 Feb 2022 11:07:38 +0000 (12:07 +0100)]
Correctly generate links in the sidebar for impls

2 years agoUse the first codegen backend in the config.toml as default
bjorn3 [Sun, 27 Feb 2022 09:59:10 +0000 (10:59 +0100)]
Use the first codegen backend in the config.toml as default

It is currently hard coded to llvm if enabled and cranelift otherwise.
This made some sense when cranelift was the only alternative codegen
backend. Since the introduction of the gcc backend this doesn't make
much sense anymore. Before this PR bootstrapping rustc using a backend
other than llvm or cranelift required changing the source of
rustc_interface. With this PR it becomes a matter of putting the right
backend as first enabled backend in config.toml.

2 years agoAuto merge of #94221 - erikdesjardins:addattr, r=nikic
bors [Sun, 27 Feb 2022 09:23:24 +0000 (09:23 +0000)]
Auto merge of #94221 - erikdesjardins:addattr, r=nikic

Add LLVM attributes in batches instead of individually

This should improve performance.

~r? `@ghost` (blocked on #94127)~

2 years agoAuto merge of #94144 - est31:let_else_trait_selection, r=cjgillot
bors [Sun, 27 Feb 2022 07:02:46 +0000 (07:02 +0000)]
Auto merge of #94144 - est31:let_else_trait_selection, r=cjgillot

rustc_trait_selection: adopt let else in more places

Continuation of #89933, #91018, #91481, #93046, #93590, #94011.

I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles rustc_trait_selection.

2 years agoAuto merge of #94361 - nikic:s390x-update, r=Mark-Simulacrum
bors [Sun, 27 Feb 2022 04:08:50 +0000 (04:08 +0000)]
Auto merge of #94361 - nikic:s390x-update, r=Mark-Simulacrum

Update dist-s390x-dist image

Update to Ubuntu 20.04 and crosstool-ng 1.24.0. I've upgraded the
ct-ng config and then manually reset the kernel and glibc versions
to the oldest supported.

Specifically, we're updating from kernel 2.6.32.68 to 2.6.32.71
and glibc 2.11.1 to 2.12.1 here. The compiler toolchain is also
updated, but I don't think that's relevant for compatibility.

I've also enabled LLD, so this fixes #94324.

r? `@Mark-Simulacrum` cc `@uweigand`

2 years agoFor MIRI, cfg out the swap logic from 94212
Scott McMurray [Sun, 27 Feb 2022 02:57:15 +0000 (18:57 -0800)]
For MIRI, cfg out the swap logic from 94212

2 years agoAuto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum
bors [Sun, 27 Feb 2022 01:23:48 +0000 (01:23 +0000)]
Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum

Make TLS __getit #[inline(always)] on non-Windows

This may improve perf, and/or stop `externs` perf benchmarks from being flaky.

r? `@ghost`

2 years agoavoid rebuilding bootstrap when PATH changes
Ralf Jung [Sun, 27 Feb 2022 00:07:02 +0000 (19:07 -0500)]
avoid rebuilding bootstrap when PATH changes

2 years agoUpdate dist-s390x-dist image
Nikita Popov [Fri, 25 Feb 2022 13:31:12 +0000 (14:31 +0100)]
Update dist-s390x-dist image

Update to Ubuntu 20.04 and crosstool-ng 1.24.0. I've updated the
ct-ng config and then manually reset the kernel and glibc versions
to the oldest supported.

Specifically, we're updating from kernel 2.6.32.68 to 2.6.32.71
and glibc 2.11.1 to 2.12.1 here. The compiler toolchain is also
updated, but I don't think that's relevant for compatibility.

2 years agoAttrBuilder doesn't take a context in old LLVM
Erik Desjardins [Sat, 26 Feb 2022 22:16:01 +0000 (17:16 -0500)]
AttrBuilder doesn't take a context in old LLVM

2 years agouse attrbuilder to remove attrs in old LLVM
Erik Desjardins [Sat, 26 Feb 2022 21:58:45 +0000 (16:58 -0500)]
use attrbuilder to remove attrs in old LLVM

2 years agojust put smallvec lengths in the signature
Erik Desjardins [Sat, 26 Feb 2022 21:58:17 +0000 (16:58 -0500)]
just put smallvec lengths in the signature

2 years agoAuto merge of #93516 - nagisa:branch-protection, r=cjgillot
bors [Sat, 26 Feb 2022 21:53:03 +0000 (21:53 +0000)]
Auto merge of #93516 - nagisa:branch-protection, r=cjgillot

No branch protection metadata unless enabled

Even if we emit metadata disabling branch protection, this metadata may
conflict with other modules (e.g. during LTO) that have different branch
protection metadata set.

This is an unstable flag and feature, so ideally the flag not being
specified should act as if the feature wasn't implemented in the first
place.

Additionally this PR also ensures we emit an error if
`-Zbranch-protection` is set on targets other than the supported
aarch64. For now the error is being output from codegen, but ideally it
should be moved to earlier in the pipeline before stabilization.

2 years agoApply noundef attribute to all scalar types which do not permit raw init
Erik Desjardins [Sat, 12 Feb 2022 06:38:24 +0000 (01:38 -0500)]
Apply noundef attribute to all scalar types which do not permit raw init

Beyond `&`/`&mut`/`Box`, this covers `char`, discriminants, `NonZero*`, etc.
All such types currently cause a Miri error if left uninitialized,
and an `invalid_value` lint in cases like `mem::uninitialized::<char>()`

Note that this _does not_ change whether or not it is UB for `u64` (or
other integer types with no invalid values) to be undef.

2 years agoAuto merge of #93449 - JakobDegen:restrict-hasdrop-optimization, r=cjgillot
bors [Sat, 26 Feb 2022 19:25:04 +0000 (19:25 +0000)]
Auto merge of #93449 - JakobDegen:restrict-hasdrop-optimization, r=cjgillot

Restrict query recursion in `needs_significant_drop`

Overly aggressive use of the query system to improve caching lead to query cycles and consequently ICEs. This patch fixes this by restricting the use of the query system as a cache to those cases where it is definitely correct.

Closes #92725 .

This is essentially a revert of #90845 for the significant drop case only. The general `needs_drop` still does the same thing. The hope is that this is enough to preserve the performance improvements of that PR while fixing the ICE. Should get a perf run to verify that this is the case.

cc `@cjgillot`

2 years agoAdd LLVM attributes in batches instead of individually
Erik Desjardins [Mon, 21 Feb 2022 16:19:16 +0000 (11:19 -0500)]
Add LLVM attributes in batches instead of individually

This should improve performance.

2 years ago2 - Make more use of let_chains
Caio [Sat, 26 Feb 2022 16:45:36 +0000 (13:45 -0300)]
2 - Make more use of let_chains

Continuation of #94376.

cc #53667

2 years agoAuto merge of #94329 - flip1995:clippyup, r=Manishearth
bors [Sat, 26 Feb 2022 16:44:17 +0000 (16:44 +0000)]
Auto merge of #94329 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoAdd test for #79465 to prevent regression
Guillaume Gomez [Sat, 26 Feb 2022 15:58:21 +0000 (16:58 +0100)]
Add test for #79465 to prevent regression

2 years agoAuto merge of #94376 - c410-f3r:more-let-chains, r=petrochenkov
bors [Sat, 26 Feb 2022 14:23:27 +0000 (14:23 +0000)]
Auto merge of #94376 - c410-f3r:more-let-chains, r=petrochenkov

Initiate the inner usage of `let_chains`

The intention here is create a strong and robust foundation for a possible future stabilization so please, do not let the lack of any external tool support prevent the merge of this PR. Besides, `let_chains` is useful by itself.

cc #53667

2 years agoUpdate Cargo.lock (Clippy version bump)
flip1995 [Sat, 26 Feb 2022 13:43:58 +0000 (14:43 +0100)]
Update Cargo.lock (Clippy version bump)

2 years agoMerge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyup
flip1995 [Sat, 26 Feb 2022 13:26:21 +0000 (14:26 +0100)]
Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyup

2 years agoAuto merge of #94078 - TaKO8Ki:suggest-float-literal-for-float-divided-by-integer...
bors [Sat, 26 Feb 2022 11:58:12 +0000 (11:58 +0000)]
Auto merge of #94078 - TaKO8Ki:suggest-float-literal-for-float-divided-by-integer, r=estebank

Suggest a float literal when dividing a floating-point type by `{integer}`

closes #93829

2 years agoMake more use of `let_chains`
Caio [Sat, 26 Feb 2022 10:43:47 +0000 (07:43 -0300)]
Make more use of `let_chains`

2 years agoDocument that pre-expansion lint passes are deprecated
xFrednet [Sat, 26 Feb 2022 10:32:07 +0000 (11:32 +0100)]
Document that pre-expansion lint passes are deprecated

2 years agoAuto merge of #94127 - erikdesjardins:debugattr, r=nikic
bors [Sat, 26 Feb 2022 09:41:19 +0000 (09:41 +0000)]
Auto merge of #94127 - erikdesjardins:debugattr, r=nikic

At opt-level=0, apply only ABI-affecting attributes to functions

This should provide a small perf improvement for debug builds,
and should more than cancel out the perf regression from adding noundef (https://github.com/rust-lang/rust/pull/93670#issuecomment-1038347581, #94106).

r? `@nikic`

2 years agoAuto merge of #94392 - matthiaskrgr:rollup-npscf95, r=matthiaskrgr
bors [Sat, 26 Feb 2022 07:00:33 +0000 (07:00 +0000)]
Auto merge of #94392 - matthiaskrgr:rollup-npscf95, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #93400 (Do not suggest using a const parameter when there are bounds on an unused type parameter)
 - #93982 (Provide extra note if synthetic type args are specified)
 - #94087 (Remove unused `unsound_ignore_borrow_on_drop`)
 - #94235 (chalk: Fix wrong debrujin index in opaque type handling.)
 - #94306 (Avoid exhausting stack space in dominator compression)

Failed merges:

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

2 years agoRollup merge of #94306 - Mark-Simulacrum:dom-fixups, r=jackh726
Matthias Krüger [Sat, 26 Feb 2022 06:52:44 +0000 (07:52 +0100)]
Rollup merge of #94306 - Mark-Simulacrum:dom-fixups, r=jackh726

Avoid exhausting stack space in dominator compression

Doesn't add a test case -- I ended up running into this while playing with the generated example from #43578, which we could do with a run-make test (to avoid checking a large code snippet into tree), but I suspect we don't want to wait for it to compile (locally it takes ~14s -- not terrible, but doesn't seem worth it to me). In practice stack space exhaustion is difficult to test for, too, since if we set the bound too low a different call structure above us (e.g., a nearer ensure_sufficient_stack call) would let the test pass even with the old impl, most likely.

Locally it seems like this manages to perform approximately equivalently to the recursion, but will run perf to confirm.

2 years agoRollup merge of #94235 - Dirbaio:fix-chalk-opaque-debrujin, r=jackh726
Matthias Krüger [Sat, 26 Feb 2022 06:52:43 +0000 (07:52 +0100)]
Rollup merge of #94235 - Dirbaio:fix-chalk-opaque-debrujin, r=jackh726

chalk: Fix wrong debrujin index in opaque type handling.

A folder in opaque type lowering was substituting all opaque type references with a variable with debrujin index 0 ignoring how many binders deep we are.

This caused an ICE with `Not enough bound vars: ^0 not found in []` ([full logs](https://gist.github.com/Dirbaio/2b9374ff4fce37afb9d665dc9f0000df)) with the following code.

```rust
fn main() -> () {}
async fn foo(x: u32) -> u32 {
    x
}
```

With the fix, it no longer ICEs. It still doesn't typecheck due to generator issues. I've added a "known-bug" test so that at least it doesn't regress back to ICEing.

r? ``@jackh726``

2 years agoRollup merge of #94087 - tmiasko:rm-ignore-borrow-on-drop, r=jackh726
Matthias Krüger [Sat, 26 Feb 2022 06:52:42 +0000 (07:52 +0100)]
Rollup merge of #94087 - tmiasko:rm-ignore-borrow-on-drop, r=jackh726

Remove unused `unsound_ignore_borrow_on_drop`

2 years agoRollup merge of #93982 - nbdd0121:explicit-generic-args, r=jackh726
Matthias Krüger [Sat, 26 Feb 2022 06:52:41 +0000 (07:52 +0100)]
Rollup merge of #93982 - nbdd0121:explicit-generic-args, r=jackh726

Provide extra note if synthetic type args are specified

Implement the unresolved question in #83701 as suggested in https://github.com/rust-lang/rust/pull/86176#discussion_r680613890.

r? ``@jackh726``

2 years agoRollup merge of #93400 - ChayimFriedman2:dont-suggest-using-const-with-bounds-unused...
Matthias Krüger [Sat, 26 Feb 2022 06:52:41 +0000 (07:52 +0100)]
Rollup merge of #93400 - ChayimFriedman2:dont-suggest-using-const-with-bounds-unused-generic-param, r=jackh726

Do not suggest using a const parameter when there are bounds on an unused type parameter

The user wrote the bound, so it's obvious they want a type.

2 years agosuggest a float literal when dividing a floating-point type by {integer}
Takayuki Maeda [Thu, 17 Feb 2022 10:33:32 +0000 (19:33 +0900)]
suggest a float literal when dividing a floating-point type by {integer}

fix a message

implement a rustfix-applicable suggestion

implement `suggest_floating_point_literal`

add `ObligationCauseCode::BinOp`

remove duplicate code

fix function names in uitests

use `Diagnostic` instead of `DiagnosticBuilder`

2 years agoAuto merge of #92884 - compiler-errors:const-generic-expr-recovery, r=jackh726
bors [Sat, 26 Feb 2022 04:39:11 +0000 (04:39 +0000)]
Auto merge of #92884 - compiler-errors:const-generic-expr-recovery, r=jackh726

Suggest adding `{ .. }` around more bad const generic exprs

Fixes #92776

2 years agoProvide extra note if synthetic type args are specified
Gary Guo [Mon, 14 Feb 2022 03:27:33 +0000 (03:27 +0000)]
Provide extra note if synthetic type args are specified

2 years agoAuto merge of #8464 - Jarcho:ptr_arg_8463, r=camsteffen
bors [Sat, 26 Feb 2022 03:00:53 +0000 (03:00 +0000)]
Auto merge of #8464 - Jarcho:ptr_arg_8463, r=camsteffen

Fix `ptr_arg`

fixes: #8463

changelog: Fix `ptr_arg` when multiple arguments are being checked in one function

2 years agoAuto merge of #8453 - tamaroning:fix_large_enum_variant, r=camsteffen
bors [Sat, 26 Feb 2022 02:42:43 +0000 (02:42 +0000)]
Auto merge of #8453 - tamaroning:fix_large_enum_variant, r=camsteffen

fix false positives of large_enum_variant

fixes: #8321
The size of enums containing generic type was calculated to be 0.
I changed [large_enum_variant] so that such enums are not linted.

changelog: none

2 years agoAuto merge of #94385 - matthiaskrgr:rollup-4pwegqk, r=matthiaskrgr
bors [Sat, 26 Feb 2022 02:09:29 +0000 (02:09 +0000)]
Auto merge of #94385 - matthiaskrgr:rollup-4pwegqk, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #93603 (Populate liveness facts when calling `get_body_with_borrowck_facts` without `-Z polonius`)
 - #93870 (Fix switch on discriminant detection in a presence of coverage counters)
 - #94355 (Add one more case to avoid ICE)
 - #94363 (Remove needless borrows from core::fmt)
 - #94377 (`check_used` should only look at actual `used` attributes)

Failed merges:

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

2 years agoSuggest {} around more bad const generic exprs
Michael Goulet [Fri, 14 Jan 2022 07:03:10 +0000 (23:03 -0800)]
Suggest {} around more bad const generic exprs

2 years agoavoid test failure on targets where all functions are dso_local (e.g. wasm)
Erik Desjardins [Sat, 26 Feb 2022 00:24:59 +0000 (19:24 -0500)]
avoid test failure on targets where all functions are dso_local (e.g. wasm)

2 years agoRollup merge of #94377 - cynecx:fix-used-with-args, r=nikic
Matthias Krüger [Fri, 25 Feb 2022 23:49:23 +0000 (00:49 +0100)]
Rollup merge of #94377 - cynecx:fix-used-with-args, r=nikic

`check_used` should only look at actual `used` attributes

cc? https://github.com/rust-lang/rust/issues/94348
r? ``@nikic``

2 years agoRollup merge of #94363 - aDotInTheVoid:fmt-needless-borrows, r=scottmcm
Matthias Krüger [Fri, 25 Feb 2022 23:49:23 +0000 (00:49 +0100)]
Rollup merge of #94363 - aDotInTheVoid:fmt-needless-borrows, r=scottmcm

Remove needless borrows from core::fmt

2 years agoRollup merge of #94355 - ouz-a:master, r=oli-bok
Matthias Krüger [Fri, 25 Feb 2022 23:49:22 +0000 (00:49 +0100)]
Rollup merge of #94355 - ouz-a:master, r=oli-bok

Add one more case to avoid ICE

Fix for the  #94291, added one more case to related function to avoid ICE.

Not sure if my test is in the correct place 😅

2 years agoRollup merge of #93870 - tmiasko:const-precise-live-drops-with-coverage, r=ecstatic...
Matthias Krüger [Fri, 25 Feb 2022 23:49:21 +0000 (00:49 +0100)]
Rollup merge of #93870 - tmiasko:const-precise-live-drops-with-coverage, r=ecstatic-morse

Fix switch on discriminant detection in a presence of coverage counters

Fixes #93848.

r? ``@ecstatic-morse``

2 years agoRollup merge of #93603 - connorff:compute-polonius-liveness-facts-flag, r=ecstatic...
Matthias Krüger [Fri, 25 Feb 2022 23:49:20 +0000 (00:49 +0100)]
Rollup merge of #93603 - connorff:compute-polonius-liveness-facts-flag, r=ecstatic-morse

Populate liveness facts when calling `get_body_with_borrowck_facts` without `-Z polonius`

For a new feature of [Flowistry](https://github.com/willcrichton/flowistry), a static-analysis tool, we need to obtain a `mir::Body`'s liveness facts using `get_body_with_borrowck_facts` (added in #86977). We'd like to do this without passing `-Z polonius` as a compiler arg to avoid borrow checking the entire crate.

Support for doing this was added in #88983, but the Polonius input facts used for liveness analysis are empty. This happens because the liveness input facts are populated in `liveness::generate` depending only on the value of `AllFacts::enabled` (which is toggled via compiler args).

This PR propagates the [`use_polonius`](https://github.com/rust-lang/rust/blob/8b09ba6a5d5c644fe0f1c27c7f9c80b334241707/compiler/rustc_borrowck/src/nll.rs#L168) flag to `liveness::generate` to support populating liveness facts without requiring the `-Z polonius` flag.

This fix is somewhat patchy - if it'd be better to add more widely-accessible state (like `AllFacts::enabled`) I'd be open to ideas!

2 years agoAuto merge of #94342 - ibraheemdev:swap-regression, r=Dylan-DPC
bors [Fri, 25 Feb 2022 23:47:00 +0000 (23:47 +0000)]
Auto merge of #94342 - ibraheemdev:swap-regression, r=Dylan-DPC

Revert implementation of `slice::swap`

Due to the perf regressions noticed here, possible due to inlining? https://github.com/rust-lang/rust/pull/88540#issuecomment-944344343

r? `@kennytm`

2 years agoAdd one more case to avoid ICE
ouz-a [Fri, 25 Feb 2022 11:40:41 +0000 (14:40 +0300)]
Add one more case to avoid ICE

2 years ago`check_used` should only look at actual `used` attributes
cynecx [Fri, 25 Feb 2022 21:52:17 +0000 (22:52 +0100)]
`check_used` should only look at actual `used` attributes

2 years agoAuto merge of #8253 - Alexendoo:print-in-fmt, r=camsteffen
bors [Fri, 25 Feb 2022 21:12:14 +0000 (21:12 +0000)]
Auto merge of #8253 - Alexendoo:print-in-fmt, r=camsteffen

Add `print_in_format_impl` lint

changelog: new lint: [`print_in_format_impl`]

Lints the use of `print`-like macros in manual `Display`/`Debug` impls. I feel like I make this mistake every time I write one 😄

r? `@camsteffen`

2 years agoAdd `print_in_format_impl` lint
Alex Macleod [Thu, 17 Feb 2022 15:33:07 +0000 (15:33 +0000)]
Add `print_in_format_impl` lint

2 years agoInitiate the inner usage of `let_chains`
Caio [Fri, 25 Feb 2022 21:03:27 +0000 (18:03 -0300)]
Initiate the inner usage of `let_chains`

2 years agoAuto merge of #94369 - matthiaskrgr:rollup-qtripm2, r=matthiaskrgr
bors [Fri, 25 Feb 2022 20:53:48 +0000 (20:53 +0000)]
Auto merge of #94369 - matthiaskrgr:rollup-qtripm2, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #93850 (Don't ICE when an extern static is too big for the current architecture)
 - #94154 (Wire up unstable rustc --check-cfg to rustdoc)
 - #94353 (Fix debug_assert in unused lint pass)
 - #94366 (Add missing item to release notes)

Failed merges:

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

2 years agoMake TLS __getit #[inline(always)] on non-Windows
Erik Desjardins [Fri, 25 Feb 2022 20:21:27 +0000 (15:21 -0500)]
Make TLS __getit #[inline(always)] on non-Windows

This may improve perf.

2 years agomake tests work on noopt builder
Erik Desjardins [Thu, 24 Feb 2022 23:16:10 +0000 (18:16 -0500)]
make tests work on noopt builder

2 years agoRollup merge of #94366 - jhpratt:release-notes, r=Mark-Simulacrum
Matthias Krüger [Fri, 25 Feb 2022 19:12:49 +0000 (20:12 +0100)]
Rollup merge of #94366 - jhpratt:release-notes, r=Mark-Simulacrum

Add missing item to release notes

Looks like `NonZeroUsize::is_power_of_two` was stabilized as well, but this didn't make the release notes.

2 years agoRollup merge of #94353 - flip1995:fix_debug_assert_unused, r=Dylan-DPC
Matthias Krüger [Fri, 25 Feb 2022 19:12:48 +0000 (20:12 +0100)]
Rollup merge of #94353 - flip1995:fix_debug_assert_unused, r=Dylan-DPC

Fix debug_assert in unused lint pass

This fixes a debug assertion in the unused lint pass. As a side effect, this also improves the span generated for tuples in the `unused_must_use` lint.

found in #94329

A reproducer for this would be

```rust
fn main() { (1, (3,)); }
```

Not sure, if I should add a regression test for a `debug_assert`.

2 years agoRollup merge of #94154 - Urgau:rustdoc-check-cfg, r=GuillaumeGomez
Matthias Krüger [Fri, 25 Feb 2022 19:12:47 +0000 (20:12 +0100)]
Rollup merge of #94154 - Urgau:rustdoc-check-cfg, r=GuillaumeGomez

Wire up unstable rustc --check-cfg to rustdoc

This pull-request wire up the new unstable `--check-cfg` option from `rustc` to `rustdoc` as [requested](https://github.com/rust-lang/rust/pull/93915#discussion_r807560445) in the [pull-request](https://github.com/rust-lang/rust/pull/93915) that introduce `--check-cfg`.

The motivation was describe in the original PR by ``@jyn514`` who wrote https://github.com/rust-lang/rust/pull/89346#issuecomment-930129761:
> > add plumbing to pass --check-cfg from rustdoc (do we want this one?)
>
> It would be useful, I think, it catches issues like cfg(doctst) or something (and in general I would like expansion to match rustc as closely as possible).

2 years agoRollup merge of #93850 - asquared31415:extern-static-size-ice, r=jackh726
Matthias Krüger [Fri, 25 Feb 2022 19:12:46 +0000 (20:12 +0100)]
Rollup merge of #93850 - asquared31415:extern-static-size-ice, r=jackh726

Don't ICE when an extern static is too big for the current architecture

Fixes #93760

Emit an error instead of ICEing when an `extern` static's size overflows the allowed maximum for the target.

Changes the error message in the existing `delay_span_bug` call to the true layout error, first for debugging purposes, but opted to leave in to potentially assist future developers as it was being reached in unexpected ways already.

2 years agoAuto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini
bors [Fri, 25 Feb 2022 18:34:02 +0000 (18:34 +0000)]
Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini

Bump bootstrap to 1.60

This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).

2 years agoAdd missing item to release notes
Jacob Pratt [Fri, 25 Feb 2022 18:32:21 +0000 (13:32 -0500)]
Add missing item to release notes

2 years agoRename RecursiveFormatImpl to FormatImpl
Alex Macleod [Thu, 17 Feb 2022 11:20:47 +0000 (11:20 +0000)]
Rename RecursiveFormatImpl to FormatImpl

2 years agoAuto merge of #94279 - tmiasko:write-print, r=Mark-Simulacrum
bors [Fri, 25 Feb 2022 16:09:56 +0000 (16:09 +0000)]
Auto merge of #94279 - tmiasko:write-print, r=Mark-Simulacrum

Print `ParamTy` and `ParamConst` instead of displaying them

Display for `ParamTy` and `ParamConst` is implemented in terms of print.
Using print avoids creating a new `FmtPrinter` just to display the
parameter name.

r? `@Mark-Simulacrum`

2 years agoAuto merge of #8474 - Alexendoo:paths, r=Manishearth
bors [Fri, 25 Feb 2022 16:07:59 +0000 (16:07 +0000)]
Auto merge of #8474 - Alexendoo:paths, r=Manishearth

Replace some more paths with diagnostic items

cc #5393

Replaces the macro & mem paths, and catches a couple others that were unused

changelog: none

2 years agoRemove needless borrows from core::fmt
Nixon Enraght-Moony [Fri, 25 Feb 2022 16:06:23 +0000 (16:06 +0000)]
Remove needless borrows from core::fmt

2 years agoAuto merge of #8472 - Mastermindaxe:#8152_new-without-default_should_not_trigger_on_d...
bors [Fri, 25 Feb 2022 15:51:37 +0000 (15:51 +0000)]
Auto merge of #8472 - Mastermindaxe:#8152_new-without-default_should_not_trigger_on_doc_hidden_items, r=flip1995

Disable ``[`new-without-default`]`` for new() methods that are marked…

… with '#[doc(hidden)]'

Fixes #8152

changelog: Disable ``[`new-without-default`]`` for new() methods that are marked with `#[doc(hidden)]`

2 years agoReplace some more paths with diagnostic items
Alex Macleod [Fri, 25 Feb 2022 15:38:06 +0000 (15:38 +0000)]
Replace some more paths with diagnostic items

2 years agoDisable ``[`new-without-default`]`` for new() methods that are marked with '#[doc...
Florian Nagel [Fri, 25 Feb 2022 13:36:23 +0000 (14:36 +0100)]
Disable ``[`new-without-default`]`` for new() methods that are marked with '#[doc(hidden)]'

Fixes issue #8152

2 years agoAuto merge of #94357 - matthiaskrgr:rollup-xrjaof3, r=matthiaskrgr
bors [Fri, 25 Feb 2022 13:28:49 +0000 (13:28 +0000)]
Auto merge of #94357 - matthiaskrgr:rollup-xrjaof3, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #93845 (Remove in band lifetimes)
 - #94155 (Extend toggle GUI test a bit)
 - #94252 (don't special case `DefKind::Ctor` in encoding)
 - #94305 (Remove an unnecessary restriction in `dest_prop`)
 - #94343 (Miri fn ptr check: don't use conservative null check)
 - #94344 (diagnostic: suggest parens when users want logical ops, but get closures)
 - #94352 (Fix SGX docs build)

Failed merges:

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

2 years agoRollup merge of #94352 - jethrogb:fix-sgx-docs-build, r=Mark-Simulacrum
Matthias Krüger [Fri, 25 Feb 2022 13:14:41 +0000 (14:14 +0100)]
Rollup merge of #94352 - jethrogb:fix-sgx-docs-build, r=Mark-Simulacrum

Fix SGX docs build

Without this, I get
```
error[E0432]: unresolved import `crate::sys::cvt`
  --> library/std/src/os/fd/owned.rs:12:5
   |
12 | use crate::sys::cvt;
   |     ^^^^^^^^^^^^^^^ no `cvt` in `sys`
```
when running rustdoc on `std` for the x86_64-fortanix-unknown-sgx target.

2 years agoRollup merge of #94344 - notriddle:notriddle/suggest-parens-more, r=oli-obk
Matthias Krüger [Fri, 25 Feb 2022 13:14:40 +0000 (14:14 +0100)]
Rollup merge of #94344 - notriddle:notriddle/suggest-parens-more, r=oli-obk

diagnostic: suggest parens when users want logical ops, but get closures

Fixes #93536

2 years agoRollup merge of #94343 - RalfJung:fn-ptr, r=oli-obk
Matthias Krüger [Fri, 25 Feb 2022 13:14:39 +0000 (14:14 +0100)]
Rollup merge of #94343 - RalfJung:fn-ptr, r=oli-obk

Miri fn ptr check: don't use conservative null check

In https://github.com/rust-lang/rust/pull/94270 I used the wrong NULL check for function pointers: `memory.ptr_may_be_null` is conservative even on machines that support ptr-to-int casts, leading to false errors in Miri.

This fixes that problem, and also replaces that foot-fun of a method with `scalar_may_be_null` which is never unnecessarily conservative.

r? `@oli-obk`

2 years agoRollup merge of #94305 - JakobDegen:dp-1, r=oli-obk
Matthias Krüger [Fri, 25 Feb 2022 13:14:38 +0000 (14:14 +0100)]
Rollup merge of #94305 - JakobDegen:dp-1, r=oli-obk

Remove an unnecessary restriction in `dest_prop`

I had asked about this [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Do.20unions.20have.20active.20fields.3F) but didn't receive a response, so putting up this PR that makes the change I think we can. If it turns out that this is wrong, hopefully I'll find out here. Reposting my Zulip comment:
> Not sure what channel to put this into, so using this as a fallback. The dest prop MIR opt has this comment:
>
> ```rust
> //!   Subtle case: If `dest` is a, or projects through a union, then we have to make sure that there
> //!   remains an assignment to it, since that sets the "active field" of the union. But if `src` is
> //!   a ZST, it might not be initialized, so there might not be any use of it before the assignment,
> //!   and performing the optimization would simply delete the assignment, leaving `dest`
> //!   uninitialized.
> ```
>
> In particular, the claim seems to be that we can't take
> ```
> x = ();
> y.field = x;
> ```
> where `y` is a union having `field: ()` as one of its variants, and optimize the entire thing away (assuming `x` is unused otherwise). As far as I know though, Rust unions don't have active fields. Is this comment correct and am I missing something? Is there a worry about this interacting poorly with FFI code/C unions/LTO or something?

This PR just removes that comment and the associated code. Also it fixes one unrelated comment that did not match the code it was commenting on.

r? rust-lang/mir-opt

2 years agoRollup merge of #94252 - lcnr:def_kind-encoding, r=cjgillot
Matthias Krüger [Fri, 25 Feb 2022 13:14:37 +0000 (14:14 +0100)]
Rollup merge of #94252 - lcnr:def_kind-encoding, r=cjgillot

don't special case `DefKind::Ctor` in encoding

considering that we still use `DefKind::Ctor` for these in `Res`, this seems weird and definitely felt like a bug when encountering it while working on #89862.

r? `@cjgillot`

2 years agoRollup merge of #94155 - GuillaumeGomez:extend-toggle-gui-test, r=jsha
Matthias Krüger [Fri, 25 Feb 2022 13:14:36 +0000 (14:14 +0100)]
Rollup merge of #94155 - GuillaumeGomez:extend-toggle-gui-test, r=jsha

Extend toggle GUI test a bit

Fixes #84422.

r? `@jsha`

2 years agoRollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillot
Matthias Krüger [Fri, 25 Feb 2022 13:14:35 +0000 (14:14 +0100)]
Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillot

Remove in band lifetimes

As discussed in t-lang backlog bonanza, the `in_band_lifetimes` FCP closed in favor for the feature not being stabilized. This PR removes `#![feature(in_band_lifetimes)]` in its entirety.

Let me know if this PR is too hasty, and if we should instead do something intermediate for deprecate the feature first.

r? `@scottmcm` (or feel free to reassign, just saw your last comment on #44524)
Closes #44524

2 years agoRe-add track_caller to panic_no_unwind in bootstrap
Mark Rousskov [Wed, 23 Feb 2022 13:24:20 +0000 (08:24 -0500)]
Re-add track_caller to panic_no_unwind in bootstrap

This function was updated in a recent PR (92911) to be called without the caller
information passed in, but the function signature itself was not altered with
cfg_attr at the time.

2 years agoEnable rustc_pass_by_value for Span
Mark Rousskov [Wed, 23 Feb 2022 13:11:17 +0000 (08:11 -0500)]
Enable rustc_pass_by_value for Span