]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett
bors [Sat, 21 May 2022 06:38:49 +0000 (06:38 +0000)]
Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett

Remove `crate` visibility modifier

FCP to remove this syntax is just about complete in #53120. Once it completes, this should be merged ASAP to avoid merge conflicts.

The first two commits remove usage of the feature in this repository, while the last removes the feature itself.

2 years agoRemove `crate` visibility modifier in libs, tests
Jacob Pratt [Sat, 21 May 2022 01:06:44 +0000 (21:06 -0400)]
Remove `crate` visibility modifier in libs, tests

2 years agoAuto merge of #96923 - eholk:fix-fake-read, r=nikomatsakis
bors [Sat, 21 May 2022 04:21:38 +0000 (04:21 +0000)]
Auto merge of #96923 - eholk:fix-fake-read, r=nikomatsakis

Drop Tracking: Implement `fake_read` callback

This PR updates drop tracking's use of `ExprUseVisitor` so that we treat `fake_read` events as borrows. Without doing this, we were not handling match expressions correctly, which showed up as a breakage in the `addassign-yield.rs` test. We did not previously notice this because we still had rather large temporary scopes that we held borrows for, which changed in #94309.

This PR also includes a variant of the `addassign-yield.rs` test case to make sure we continue to have correct behavior here with drop tracking.

r? `@nikomatsakis`

2 years agoAuto merge of #96605 - Urgau:string-retain-codegen, r=thomcc
bors [Sat, 21 May 2022 01:56:51 +0000 (01:56 +0000)]
Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc

Improve codegen of String::retain method

This pull-request improve the codegen of the `String::retain` method.

Using `unwrap_unchecked` helps the optimizer to not generate a panicking path that will never be taken for valid UTF-8 like string.

Using `encode_utf8` saves us from an expensive call to `memcpy`, as the optimizer is unable to realize that `ch_len <= 4` and so can generate much better assembly code.

https://rust.godbolt.org/z/z73ohenfc

2 years agoRemove `crate` visibility usage in compiler
Jacob Pratt [Fri, 20 May 2022 23:51:09 +0000 (19:51 -0400)]
Remove `crate` visibility usage in compiler

2 years agoAuto merge of #95824 - zx2c4-forks:grnd_insecure, r=thomcc
bors [Fri, 20 May 2022 23:11:12 +0000 (23:11 +0000)]
Auto merge of #95824 - zx2c4-forks:grnd_insecure, r=thomcc

Use GRND_INSECURE instead of /dev/urandom when possible

From reading the source code, it appears like the desired semantic of
std::unix::rand is to always provide some bytes and never block. For
that reason GRND_NONBLOCK is checked before calling getrandom(0), so
that getrandom(0) won't block. If it would block, then the function
falls back to using /dev/urandom, which for the time being doesn't
block. There are some drawbacks to using /dev/urandom, however, and so
getrandom(GRND_INSECURE) was created as a replacement for this exact
circumstance.

getrandom(GRND_INSECURE) is the same as /dev/urandom, except:

- It won't leave a warning in dmesg if used at early boot time, which is
  a common occurance (and the reason why I found this issue);

- It won't introduce a tiny delay at early boot on newer kernels when
  /dev/urandom tries to opportunistically create jitter entropy;

- It only requires 1 syscall, rather than 3.

Other than that, it returns the same "quality" of randomness as
/dev/urandom, and never blocks.

It's only available on kernels ≥5.6, so we try to use it, cache the
result of that attempt, and fall back to to the previous code if it
didn't work.

2 years agoUse GRND_INSECURE instead of /dev/urandom when possible
Jason A. Donenfeld [Fri, 8 Apr 2022 20:09:44 +0000 (22:09 +0200)]
Use GRND_INSECURE instead of /dev/urandom when possible

From reading the source code, it appears like the desired semantic of
std::unix::rand is to always provide some bytes and never block. For
that reason GRND_NONBLOCK is checked before calling getrandom(0), so
that getrandom(0) won't block. If it would block, then the function
falls back to using /dev/urandom, which for the time being doesn't
block. There are some drawbacks to using /dev/urandom, however, and so
getrandom(GRND_INSECURE) was created as a replacement for this exact
circumstance.

getrandom(GRND_INSECURE) is the same as /dev/urandom, except:

- It won't leave a warning in dmesg if used at early boot time, which is
  a common occurance (and the reason why I found this issue);

- It won't introduce a tiny delay at early boot on newer kernels when
  /dev/urandom tries to opportunistically create jitter entropy;

- It only requires 1 syscall, rather than 3.

Other than that, it returns the same "quality" of randomness as
/dev/urandom, and never blocks.

It's only available on kernels ≥5.6, so we try to use it, cache the
result of that attempt, and fall back to to the previous code if it
didn't work.

2 years agoUpdate libc dependency of std to 0.2.126
Jason A. Donenfeld [Fri, 20 May 2022 21:52:05 +0000 (23:52 +0200)]
Update libc dependency of std to 0.2.126

This is required for the next commit, which uses libc::GRND_INSECURE.

2 years agoAuto merge of #95418 - cjgillot:more-disk, r=davidtwco
bors [Fri, 20 May 2022 20:49:55 +0000 (20:49 +0000)]
Auto merge of #95418 - cjgillot:more-disk, r=davidtwco

Cache more queries on disk

One of the principles of incremental compilation is to allow saving results on disk to avoid recomputing them.
This PR investigates persisting a lot of queries whose result are to be saved into metadata.
Some of the queries are cheap reads from HIR, but we may also want to get rid of these reads for incremental lowering.

2 years agoUpdate compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed...
Niko Matsakis [Fri, 20 May 2022 19:54:22 +0000 (15:54 -0400)]
Update compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs

2 years agoAuto merge of #97224 - matthiaskrgr:rollup-it5nw68, r=matthiaskrgr
bors [Fri, 20 May 2022 18:21:26 +0000 (18:21 +0000)]
Auto merge of #97224 - matthiaskrgr:rollup-it5nw68, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #97109 (Fix misleading `cannot infer type for type parameter` error)
 - #97187 (Reverse condition in Vec::retain_mut doctest)
 - #97201 (Fix typo)
 - #97203 (Minor tweaks to rustc book summary formatting.)
 - #97208 (Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items)
 - #97215 (Add complexity estimation of iterating over HashSet and HashMap)
 - #97220 (Add regression test for#81827)

Failed merges:

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

2 years agoRollup merge of #97220 - JohnTitor:issue-81827, r=compiler-errors
Matthias Krüger [Fri, 20 May 2022 17:54:45 +0000 (19:54 +0200)]
Rollup merge of #97220 - JohnTitor:issue-81827, r=compiler-errors

Add regression test for#81827

Closes #81827
r? `@compiler-errors`

2 years agoRollup merge of #97215 - AngelicosPhosphoros:add_hashtable_iteration_complexity_note...
Matthias Krüger [Fri, 20 May 2022 17:54:44 +0000 (19:54 +0200)]
Rollup merge of #97215 - AngelicosPhosphoros:add_hashtable_iteration_complexity_note, r=thomcc

Add complexity estimation of iterating over HashSet and HashMap

It is not obvious (at least for me) that complexity of iteration over hash tables depends on capacity and not length. Especially comparing with other containers like Vec or String. I think, this behaviour is worth mentioning.

I run benchmark which tests iteration time for maps with length 50 and different capacities and get this results:
```
capacity - time
64       - 203.87 ns
256      - 351.78 ns
1024     - 607.87 ns
4096     - 965.82 ns
16384    - 3.1188 us
```

If you want to dig why it behaves such way, you can look current implementation in [hashbrown code](https://github.com/rust-lang/hashbrown/blob/f3a9f211d06f78c5beb81ac22ea08fdc269e068f/src/raw/mod.rs#L1933).

Benchmarks code would be presented in PR related to this commit.

2 years agoRollup merge of #97208 - fmease:fix-issue-97205, r=oli-obk
Matthias Krüger [Fri, 20 May 2022 17:54:43 +0000 (19:54 +0200)]
Rollup merge of #97208 - fmease:fix-issue-97205, r=oli-obk

Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items

Fixes #97205 (embarrassing oversight from #96008).

`@rustbot` label A-lint

2 years agoRollup merge of #97203 - ehuss:rustc-summary-formatting, r=Dylan-DPC
Matthias Krüger [Fri, 20 May 2022 17:54:42 +0000 (19:54 +0200)]
Rollup merge of #97203 - ehuss:rustc-summary-formatting, r=Dylan-DPC

Minor tweaks to rustc book summary formatting.

This includes a few minor tweaks to the summary/titles of chapters for the rustc book:

* Use a consistent chapter capitalization and hyphenation.
* Move "Codegen Options" underneath "Command-line Arguments". I feel like they are two closely related chapters, where codegen is just a subset of the total arguments.
* Move "Target Tier Policy" underneath "Platform Support". That chapter includes that policy for platform support, and thus I feel it is more closely related to that grouping.

2 years agoRollup merge of #97201 - ydah:fix_spelling, r=GuillaumeGomez
Matthias Krüger [Fri, 20 May 2022 17:54:41 +0000 (19:54 +0200)]
Rollup merge of #97201 - ydah:fix_spelling, r=GuillaumeGomez

Fix typo

This PR is fixes typo "avaiable" to "available".

2 years agoRollup merge of #97187 - ajtribick:patch-1, r=thomcc
Matthias Krüger [Fri, 20 May 2022 17:54:40 +0000 (19:54 +0200)]
Rollup merge of #97187 - ajtribick:patch-1, r=thomcc

Reverse condition in Vec::retain_mut doctest

I find that the doctest for `Vec::retain_mut` is easier to read and understand when the `if` block corresponds to the path that returns `true` and the `else` block returns `false`. Having the `if` block be the `false` path led me to stare at the example for somewhat longer than I probably had to.

2 years agoRollup merge of #97109 - TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter...
Matthias Krüger [Fri, 20 May 2022 17:54:39 +0000 (19:54 +0200)]
Rollup merge of #97109 - TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk

Fix misleading `cannot infer type for type parameter` error

closes #93198

2 years agoAdd regression test for #81827
Yuki Okushi [Fri, 20 May 2022 16:32:02 +0000 (01:32 +0900)]
Add regression test for #81827

2 years agoAdd complexity estimation of iterating over HashSet and HashMap
AngelicosPhosphoros [Fri, 20 May 2022 12:38:04 +0000 (15:38 +0300)]
Add complexity estimation of iterating over HashSet and HashMap

It is not obvious (at least for me) that complexity of iteration over hash tables depends on capacity and not length. Especially comparing with other containers like Vec or String. I think, this behaviour is worth mentioning.

I run benchmark which tests iteration time for maps with length 50 and different capacities and get this results:
```
capacity - time
64       - 203.87 ns
256      - 351.78 ns
1024     - 607.87 ns
4096     - 965.82 ns
16384    - 3.1188 us
```

If you want to dig why it behaves such way, you can look current implementation in [hashbrown code](https://github.com/rust-lang/hashbrown/blob/f3a9f211d06f78c5beb81ac22ea08fdc269e068f/src/raw/mod.rs#L1933).

Benchmarks code would be presented in PR related to this commit.

2 years agoAuto merge of #96833 - cjgillot:ast-lifetimes-single, r=petrochenkov
bors [Fri, 20 May 2022 15:40:33 +0000 (15:40 +0000)]
Auto merge of #96833 - cjgillot:ast-lifetimes-single, r=petrochenkov

Lint single-use lifetimes during AST resolution

This PR rewrites `single_use_lifetime` and `unused_lifetime` lints to be based on the AST.
We have more information at our disposal, so we can reduce the amount of false positives.

Remaining false positive: single-use lifetimes in argument-position impl-trait.
I'm waiting for https://github.com/rust-lang/rust/issues/96529 to be fixed to have a clean and proper solution here.

Closes https://github.com/rust-lang/rust/issues/54079
Closes https://github.com/rust-lang/rust/issues/55057
Closes https://github.com/rust-lang/rust/issues/55058
Closes https://github.com/rust-lang/rust/issues/60554
Closes https://github.com/rust-lang/rust/issues/69952

r? `@petrochenkov`

2 years agoreport ambiguous type parameters when their parents are impl or fn
Takayuki Maeda [Fri, 20 May 2022 04:49:41 +0000 (13:49 +0900)]
report ambiguous type parameters when their parents are impl or fn

fix ci error

emit err for `impl_item`

2 years agoAuto merge of #97211 - GuillaumeGomez:rollup-jul7x7e, r=GuillaumeGomez
bors [Fri, 20 May 2022 13:18:37 +0000 (13:18 +0000)]
Auto merge of #97211 - GuillaumeGomez:rollup-jul7x7e, r=GuillaumeGomez

Rollup of 6 pull requests

Successful merges:

 - #96565 (rustdoc: show implementations on `#[fundamental]` wrappers)
 - #97179 (Add new lint to enforce whitespace after keywords)
 - #97185 (interpret/validity: separately control checking numbers for being init and non-ptr)
 - #97188 (Remove unneeded null pointer asserts in ptr2int casts)
 - #97189 (Update .mailmap)
 - #97192 (Say "last" instead of "rightmost" in the documentation for `std::str:rfind`)

Failed merges:

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

2 years agoRollup merge of #97192 - sunfishcode:sunfishcode/rightmost, r=thomcc
Guillaume Gomez [Fri, 20 May 2022 12:03:06 +0000 (14:03 +0200)]
Rollup merge of #97192 - sunfishcode:sunfishcode/rightmost, r=thomcc

Say "last" instead of "rightmost" in the documentation for `std::str:rfind`

In the documentation comment for `std::str::rfind`, say "last" instead
of "rightmost" to describe the match that `rfind` finds. This follows the
spirit of #30459, for which `trim_left` and `trim_right` were replaced by
`trim_start` and `trim_end` to be more clear about how they work on
text which is displayed right-to-left.

2 years agoRollup merge of #97189 - pvdrz:patch-1, r=Mark-Simulacrum
Guillaume Gomez [Fri, 20 May 2022 12:03:05 +0000 (14:03 +0200)]
Rollup merge of #97189 - pvdrz:patch-1, r=Mark-Simulacrum

Update .mailmap

2 years agoRollup merge of #97188 - carbotaniuman:remove-null-assert, r=RalfJung
Guillaume Gomez [Fri, 20 May 2022 12:03:04 +0000 (14:03 +0200)]
Rollup merge of #97188 - carbotaniuman:remove-null-assert, r=RalfJung

Remove unneeded null pointer asserts in ptr2int casts

This removes an assert that a pointer with address 0 has no provenance. This change is needed to support permissive provenance work in Miri, and seems justified by `ptr.with_addr(0)` working and a discussion on Zulip regarding LLVM semantics.

r? `@RalfJung`

2 years agoRollup merge of #97185 - RalfJung:number-validity, r=oli-obk
Guillaume Gomez [Fri, 20 May 2022 12:03:03 +0000 (14:03 +0200)]
Rollup merge of #97185 - RalfJung:number-validity, r=oli-obk

interpret/validity: separately control checking numbers for being init and non-ptr

This lets Miri control this in a more fine-grained way.

r? `@oli-obk`

2 years agoRollup merge of #97179 - GuillaumeGomez:eslint-lint, r=notriddle
Guillaume Gomez [Fri, 20 May 2022 12:03:02 +0000 (14:03 +0200)]
Rollup merge of #97179 - GuillaumeGomez:eslint-lint, r=notriddle

Add new lint to enforce whitespace after keywords

r? `@notriddle`

2 years agoRollup merge of #96565 - notriddle:notriddle/impl-box, r=camelid
Guillaume Gomez [Fri, 20 May 2022 12:03:01 +0000 (14:03 +0200)]
Rollup merge of #96565 - notriddle:notriddle/impl-box, r=camelid

rustdoc: show implementations on `#[fundamental]` wrappers

Fixes #92940

2 years agoAuto merge of #95309 - lcnr:dropck-cleanup, r=nikomatsakis
bors [Fri, 20 May 2022 10:37:48 +0000 (10:37 +0000)]
Auto merge of #95309 - lcnr:dropck-cleanup, r=nikomatsakis

rewrite `ensure_drop_params_and_item_params_correspond`

actually relating types here seems like it's overkill

2 years agoLint single-use-lifetimes on the AST.
Camille GILLOT [Tue, 10 May 2022 19:15:30 +0000 (21:15 +0200)]
Lint single-use-lifetimes on the AST.

2 years agoIntroduce BareFnTy::decl_span and fix generics span.
Camille GILLOT [Tue, 10 May 2022 19:17:21 +0000 (21:17 +0200)]
Introduce BareFnTy::decl_span and fix generics span.

2 years agoIntroduce LifetimeCtxt.
Camille GILLOT [Tue, 10 May 2022 17:56:46 +0000 (19:56 +0200)]
Introduce LifetimeCtxt.

2 years ago`bool` to custom enum
lcnr [Mon, 4 Apr 2022 08:56:59 +0000 (10:56 +0200)]
`bool` to custom enum

2 years agoupdate error message
lcnr [Tue, 29 Mar 2022 05:29:59 +0000 (07:29 +0200)]
update error message

2 years agoupdate comments
lcnr [Fri, 25 Mar 2022 13:49:14 +0000 (14:49 +0100)]
update comments

2 years agorewrite `ensure_drop_params_and_item_params_correspond`
lcnr [Wed, 23 Mar 2022 09:06:29 +0000 (10:06 +0100)]
rewrite `ensure_drop_params_and_item_params_correspond`

2 years agomove unique param check into `rustc_middle`
lcnr [Wed, 23 Mar 2022 08:41:31 +0000 (09:41 +0100)]
move unique param check into `rustc_middle`

2 years agoDo not warn on inherent doc(hidden) assoc items
León Orell Valerian Liehr [Fri, 20 May 2022 08:19:23 +0000 (10:19 +0200)]
Do not warn on inherent doc(hidden) assoc items

2 years agoAuto merge of #96422 - tmccombs:mutex-unpoison, r=m-ou-se
bors [Fri, 20 May 2022 08:06:56 +0000 (08:06 +0000)]
Auto merge of #96422 - tmccombs:mutex-unpoison, r=m-ou-se

Add functions to un-poison Mutex and RwLock

See discussion at https://internals.rust-lang.org/t/unpoisoning-a-mutex/16521/3

2 years agoRemove references to guards in documentation for clear_poison
Thayne McCombs [Fri, 20 May 2022 06:15:26 +0000 (00:15 -0600)]
Remove references to guards in documentation for clear_poison

2 years agoAuto merge of #97147 - Mark-Simulacrum:stage0-bump, r=pietroalbini
bors [Fri, 20 May 2022 05:44:52 +0000 (05:44 +0000)]
Auto merge of #97147 - Mark-Simulacrum:stage0-bump, r=pietroalbini

stage0 bootstrap bump

r? `@pietroalbini`

2 years agoAuto merge of #97029 - eholk:drop-tracking-yielding-in-match-guard, r=nikomatsakis
bors [Fri, 20 May 2022 03:27:01 +0000 (03:27 +0000)]
Auto merge of #97029 - eholk:drop-tracking-yielding-in-match-guard, r=nikomatsakis

generator_interior: Count match pattern bindings as borrowed for the whole guard expression

The test case `yielding-in-match-guard.rs` was failing with `-Zdrop-tracking` enabled. The reason is that the copy of a local (`y`) was not counted as a borrow in typeck, while MIR did consider this as borrowed.

The correct thing to do here is to count pattern bindings are borrowed for the whole guard. Instead, what we were doing is to record the type at the use site of the variable and check if the variable comes from a borrowed pattern. Due to the fix for #57017, we were considering too small of a scope for this variable, which meant it was not counted as borrowed.

Because we now unconditionally record the borrow, rather than only for bindings that are used, this PR is also able to remove a lot of the logic around match bindings that was there before.

r? `@nikomatsakis`

2 years agoMinor tweaks to rustc book summary formatting.
Eric Huss [Fri, 20 May 2022 02:06:01 +0000 (19:06 -0700)]
Minor tweaks to rustc book summary formatting.

2 years agoFix typo
ydah [Fri, 20 May 2022 01:39:10 +0000 (10:39 +0900)]
Fix typo

This PR is fixes typo "avaiable" to "available".

2 years agoAuto merge of #97027 - cuviper:yesalias-refcell, r=thomcc
bors [Fri, 20 May 2022 01:05:53 +0000 (01:05 +0000)]
Auto merge of #97027 - cuviper:yesalias-refcell, r=thomcc

Use pointers in `cell::{Ref,RefMut}` to avoid `noalias`

When `Ref` and `RefMut` were based on references, they would get LLVM `noalias` attributes that were incorrect, because that alias guarantee is only true until the guard drops. A `&RefCell` on the same value can get a new borrow that aliases the previous guard, possibly leading to miscompilation. Using `NonNull` pointers in `Ref` and `RefCell` avoids `noalias`.

Fixes the library side of #63787, but we still might want to explore language solutions there.

2 years agoUpdate IfLet syntax
Eric Holk [Thu, 19 May 2022 23:32:06 +0000 (16:32 -0700)]
Update IfLet syntax

2 years agoRemove old match guard pattern tracking code
Eric Holk [Tue, 17 May 2022 23:00:53 +0000 (16:00 -0700)]
Remove old match guard pattern tracking code

This is subsumed by the new changes that count pattern variables as
bound for the whole guard expression.

2 years agoBorrow guard patterns for the body of the guard
Eric Holk [Tue, 17 May 2022 22:36:39 +0000 (15:36 -0700)]
Borrow guard patterns for the body of the guard

2 years agoRevert "Count copies of locals as borrowed temporaries"
Eric Holk [Tue, 17 May 2022 22:04:05 +0000 (15:04 -0700)]
Revert "Count copies of locals as borrowed temporaries"

This reverts commit 0d270b5e9f48268735f9a05462df65c9d1039855.

2 years agoCount copies of locals as borrowed temporaries
Eric Holk [Fri, 13 May 2022 21:24:41 +0000 (14:24 -0700)]
Count copies of locals as borrowed temporaries

2 years agoFurther reduce test case
Eric Holk [Fri, 13 May 2022 20:38:36 +0000 (13:38 -0700)]
Further reduce test case

Thanks to @tmiasko for this one!

2 years agoAdd drop tracking version of yielding-in-match-guard.rs
Eric Holk [Wed, 11 May 2022 00:58:18 +0000 (17:58 -0700)]
Add drop tracking version of yielding-in-match-guard.rs

2 years agoAuto merge of #97180 - Dylan-DPC:rollup-aa5j2yw, r=Dylan-DPC
bors [Thu, 19 May 2022 22:43:00 +0000 (22:43 +0000)]
Auto merge of #97180 - Dylan-DPC:rollup-aa5j2yw, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #96539 (Add release notes for 1.61.0)
 - #97142 (move processing of `source_scope_data` into `MutVisitor`'s impl of `Integrator` when inline)
 - #97155 (Fix doc typo)
 - #97169 (Improve `u32 as char` cast diagnostic)
 - #97170 (Remove unnecessay .report() on ExitCode)
 - #97171 (Add regression test for #88119)

Failed merges:

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

2 years agoSay "last" instead of "rightmost" in the documentation for `std::str::rfind`.
Dan Gohman [Thu, 19 May 2022 22:26:34 +0000 (15:26 -0700)]
Say "last" instead of "rightmost" in the documentation for `std::str::rfind`.

In the documentation comment for `std::str::rfind`, say "last" instead
of "rightmost" to describe the match that `rfind` finds. This follows the
spirit of #30459, for which `trim_left` and `trim_right` were replaced by
`trim_start` and `trim_end` to be more clear about how they work on
text which is displayed right-to-left.

2 years agoUpdate .mailmap
Christian Poveda [Thu, 19 May 2022 19:13:13 +0000 (14:13 -0500)]
Update .mailmap

2 years agoReverse condition in Vec::retain_mut doctest
ajtribick [Thu, 19 May 2022 18:54:16 +0000 (20:54 +0200)]
Reverse condition in Vec::retain_mut doctest

2 years agoRemove unneeded asserts
carbotaniuman [Thu, 19 May 2022 18:51:53 +0000 (13:51 -0500)]
Remove unneeded asserts

2 years agofmt
Ralf Jung [Thu, 19 May 2022 18:34:37 +0000 (20:34 +0200)]
fmt

2 years agobless 32bit
Ralf Jung [Thu, 19 May 2022 18:20:36 +0000 (20:20 +0200)]
bless 32bit

2 years agointerpret/validity: separately control checking numbers for being init and non-ptr
Ralf Jung [Thu, 19 May 2022 18:16:25 +0000 (20:16 +0200)]
interpret/validity: separately control checking numbers for being init and non-ptr

2 years agoRollup merge of #97171 - JohnTitor:issue-88119, r=compiler-errors
Dylan DPC [Thu, 19 May 2022 15:22:51 +0000 (17:22 +0200)]
Rollup merge of #97171 - JohnTitor:issue-88119, r=compiler-errors

Add regression test for #88119

Closes #88119

2 years agoRollup merge of #97170 - benediktwerner:master, r=JohnTitor
Dylan DPC [Thu, 19 May 2022 15:22:51 +0000 (17:22 +0200)]
Rollup merge of #97170 - benediktwerner:master, r=JohnTitor

Remove unnecessay .report() on ExitCode

Since #93442, the return type is `ExitCode` anyway so there's no need to do a conversion using `.report()` (which is now just a no-op).

2 years agoRollup merge of #97169 - gimbles:u32-diagnostic, r=petrochenkov
Dylan DPC [Thu, 19 May 2022 15:22:50 +0000 (17:22 +0200)]
Rollup merge of #97169 - gimbles:u32-diagnostic, r=petrochenkov

Improve `u32 as char` cast diagnostic

Fixes #97160

2 years agoRollup merge of #97155 - alygin:patch-1, r=JohnTitor
Dylan DPC [Thu, 19 May 2022 15:22:49 +0000 (17:22 +0200)]
Rollup merge of #97155 - alygin:patch-1, r=JohnTitor

Fix doc typo

Fixes a minor doc typo for `atomic::fence()`.

2 years agoRollup merge of #97142 - SparrowLii:inline, r=tmiasko
Dylan DPC [Thu, 19 May 2022 15:22:48 +0000 (17:22 +0200)]
Rollup merge of #97142 - SparrowLii:inline, r=tmiasko

move processing of `source_scope_data` into `MutVisitor`'s impl of `Integrator` when inline

This PR fixes the FIXME in the inline mir-opt which moves processing of `source_scope_data` into `MutVisitor`'s impl of `Integrator` when inline

2 years agoRollup merge of #96539 - tmandry:relnotes-1.61, r=Mark-Simulacrum
Dylan DPC [Thu, 19 May 2022 15:22:47 +0000 (17:22 +0200)]
Rollup merge of #96539 - tmandry:relnotes-1.61, r=Mark-Simulacrum

Add release notes for 1.61.0

cc `@rust-lang/release`

2 years agoAdd new lint to enforce whitespace after keywords
Guillaume Gomez [Thu, 19 May 2022 15:19:08 +0000 (17:19 +0200)]
Add new lint to enforce whitespace after keywords

2 years agoImprove u32 to char diagnostic
gimbles [Thu, 19 May 2022 14:33:40 +0000 (20:03 +0530)]
Improve u32 to char diagnostic

2 years agoAuto merge of #97024 - lcnr:simplify_type-sus, r=<try>
bors [Thu, 19 May 2022 13:08:51 +0000 (13:08 +0000)]
Auto merge of #97024 - lcnr:simplify_type-sus, r=<try>

`simplify_type` improvements and cursed docs

the existing `TreatParams` enum pretty much mixes everything up. Not sure why this looked right to me in #94057

This also includes two changes which impact perf:
- `ty::Projection` with inference vars shouldn't be treated as a rigid type, even if fully normalized
- `ty::Placeholder` only unifies with itself, so actually return `Some` for them

r? `@nikomatsakis`

2 years agoAdd regression test for #88119
Yuki Okushi [Thu, 19 May 2022 11:51:32 +0000 (20:51 +0900)]
Add regression test for #88119

2 years agoRemove unnecessay .report() on ExitCode
benediktwerner [Thu, 19 May 2022 09:47:36 +0000 (11:47 +0200)]
Remove unnecessay .report() on ExitCode

2 years agoAuto merge of #97114 - klensy:cursor-ref, r=petrochenkov
bors [Thu, 19 May 2022 09:27:55 +0000 (09:27 +0000)]
Auto merge of #97114 - klensy:cursor-ref, r=petrochenkov

use CursorRef more

This allows skipping clone of `TreeAndSpacing` (and `TokenTree`).

2 years agoChange clear_poison to take the lock instead of a guard
Thayne McCombs [Thu, 19 May 2022 07:53:41 +0000 (01:53 -0600)]
Change clear_poison to take the lock instead of a guard

2 years agoAuto merge of #97103 - luqmana:asm-unwind-cleanup, r=Amanieu,tmiasko
bors [Thu, 19 May 2022 06:57:59 +0000 (06:57 +0000)]
Auto merge of #97103 - luqmana:asm-unwind-cleanup, r=Amanieu,tmiasko

Update MIR passes to handle unwinding Inline Asm

Some more follow up fixes from https://github.com/rust-lang/rust/pull/95864#issuecomment-1094165398

r? `@Amanieu`

2 years agoAdd mir-opt test for asm_unwind + panic=abort
Luqman Aden [Tue, 17 May 2022 04:51:20 +0000 (21:51 -0700)]
Add mir-opt test for asm_unwind + panic=abort

2 years agoAuto merge of #97033 - nbdd0121:unwind3, r=Amanieu
bors [Thu, 19 May 2022 04:04:40 +0000 (04:04 +0000)]
Auto merge of #97033 - nbdd0121:unwind3, r=Amanieu

Remove libstd's calls to `C-unwind` foreign functions

Remove all libstd and its dependencies' usage of `extern "C-unwind"`.

This is a prerequiste of a WIP PR which will forbid libraries calling `extern "C-unwind"` functions to be compiled in `-Cpanic=unwind` and linked against `panic_abort` (this restriction is necessary to address soundness bug #96926).
Cargo will ensure all crates are compiled with the same `-Cpanic` but the std is only compiled `-Cpanic=unwind` but needs the ability to be linked into `-Cpanic=abort`.

Currently there are two places where `C-unwind` is used in libstd:
* `__rust_start_panic` is used for interfacing to the panic runtime. This could be `extern "Rust"`
* `_{rdl,rg}_oom`: a shim `__rust_alloc_error_handler` will be generated by codegen to call into one of these; they can also be `extern "Rust"` (in fact, the generated shim is used as `extern "Rust"`, so I am not even sure why these are not, probably because they used to `extern "C"` and was changed to `extern "C-unwind"` when we allow alloc error hooks to unwind, but they really should just be using Rust ABI).

For dependencies, there is only one `extern "C-unwind"` function call, in `unwind` crate. This can be expressed as a re-export.

More dicussions can be seen in the Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/soundness.20in.20mixed.20panic.20mode

`@rustbot` label: T-libs F-c_unwind

2 years agoAuto merge of #97159 - JohnTitor:rollup-ibl51vw, r=JohnTitor
bors [Thu, 19 May 2022 01:41:07 +0000 (01:41 +0000)]
Auto merge of #97159 - JohnTitor:rollup-ibl51vw, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #96866 (Switch CI bucket uploads to intelligent tiering)
 - #97062 (Couple of refactorings to cg_ssa::base::codegen_crate)
 - #97127 (Revert "Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se")
 - #97131 (Improve println! documentation)
 - #97139 (Move some settings DOM generation out of JS)
 - #97152 (Update cargo)

Failed merges:

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

2 years agoRollup merge of #97152 - ehuss:update-cargo, r=ehuss
Yuki Okushi [Wed, 18 May 2022 23:22:45 +0000 (08:22 +0900)]
Rollup merge of #97152 - ehuss:update-cargo, r=ehuss

Update cargo

3 commits in 3f052d8eed98c6a24f8b332fb2e6e6249d12d8c1..a4c1cd0eb6b18082a7e693f5a665548fe1534be4
2022-05-12 15:19:04 +0000 to 2022-05-18 01:52:07 +0000
- Add notes about pre-stabilization to contributor unstable docs (rust-lang/cargo#10675)
- reference: Update syntax supported by `rustc-link-lib` (rust-lang/cargo#10674)
- Correct the release dates for 1.61 and 1.62 (rust-lang/cargo#10665)

2 years agoRollup merge of #97139 - GuillaumeGomez:move-dom-settings-generation, r=notriddle
Yuki Okushi [Wed, 18 May 2022 23:22:44 +0000 (08:22 +0900)]
Rollup merge of #97139 - GuillaumeGomez:move-dom-settings-generation, r=notriddle

Move some settings DOM generation out of JS

The first commit reduce the JS size a bit by moving some DOM content generation into the HTML file directly.

The second commit is an update of the `browser-ui-test` version which improves `wait-for-*` command (if the element doesn't exist, it'll wait for it instead of failing).

r? ``@notriddle``

2 years agoRollup merge of #97131 - gimbles:patch-2, r=Dylan-DPC
Yuki Okushi [Wed, 18 May 2022 23:22:43 +0000 (08:22 +0900)]
Rollup merge of #97131 - gimbles:patch-2, r=Dylan-DPC

Improve println! documentation

2 years agoRollup merge of #97127 - Mark-Simulacrum:revert-96441, r=m-ou-se
Yuki Okushi [Wed, 18 May 2022 23:22:43 +0000 (08:22 +0900)]
Rollup merge of #97127 - Mark-Simulacrum:revert-96441, r=m-ou-se

Revert "Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se"

This reverts commit ddb7fbe8434be481607ae199fe2aee976ee2fc2e.

Partially addresses https://github.com/rust-lang/rust/issues/97124, but not marking as fixed as we're still pending on a beta backport (for 1.62, which is happening in https://github.com/rust-lang/rust/pull/97088).

r? ``@m-ou-se`` ``@ChrisDenton``

2 years agoRollup merge of #97062 - bjorn3:cg_ssa_driver_refactor, r=compiler-errors
Yuki Okushi [Wed, 18 May 2022 23:22:42 +0000 (08:22 +0900)]
Rollup merge of #97062 - bjorn3:cg_ssa_driver_refactor, r=compiler-errors

Couple of refactorings to cg_ssa::base::codegen_crate

This makes the code simpler and easier to read.

2 years agoRollup merge of #96866 - Mark-Simulacrum:intelligent-tiering-ci, r=pietroalbini
Yuki Okushi [Wed, 18 May 2022 23:22:41 +0000 (08:22 +0900)]
Rollup merge of #96866 - Mark-Simulacrum:intelligent-tiering-ci, r=pietroalbini

Switch CI bucket uploads to intelligent tiering

We currently upload approximately 166 GB/day into this bucket (estimate based on
duration of storage and total current size). My estimate is that this change
should decrease our costs (which are currently in credits) and is in the worst
case (if all objects are brought into hot storage due to unanticipated frequent
access) only going to add an additional ~$4 to the monthly bill. If access is
rare (as expected) to most objects then we expect to save approximately
~$350/month (after this change takes full effect in ~168 days).

r? ``@pietroalbini``

2 years agoAuto merge of #95643 - WaffleLapkin:ptr_convenience, r=joshtriplett
bors [Wed, 18 May 2022 23:18:03 +0000 (23:18 +0000)]
Auto merge of #95643 - WaffleLapkin:ptr_convenience, r=joshtriplett

Add convenience byte offset/check align functions to pointers

This PR adds the following APIs:
```rust
impl *const T {
    // feature gates `pointer_byte_offsets` and `const_pointer_byte_offsets
    pub const unsafe fn byte_offset(self, count: isize) -> Self;
    pub const fn wrapping_byte_offset(self, count: isize) -> Self;
    pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize;
    pub const unsafe fn byte_add(self, count: usize) -> Self;
    pub const unsafe fn byte_sub(self, count: usize) -> Self;
    pub const fn wrapping_byte_add(self, count: usize) -> Self;
    pub const fn wrapping_byte_sub(self, count: usize) -> Self;

    // feature gate `pointer_is_aligned`
    pub fn is_aligned(self) -> bool where T: Sized;
    pub fn is_aligned_to(self, align: usize) -> bool;
}
// ... and the same for` *mut T`
```

Note that all functions except `is_aligned` do **not** require `T: Sized` as their pointee-sized-offset counterparts.

cc `@oli-obk` (you may want to check that I've correctly placed `const`s)
cc `@RalfJung`

2 years agoFix doc typo
Andrew Lygin [Wed, 18 May 2022 21:25:14 +0000 (00:25 +0300)]
Fix doc typo

2 years agoUpdate cargo
Eric Huss [Wed, 18 May 2022 20:52:43 +0000 (13:52 -0700)]
Update cargo

2 years agoUpdate MIR passes that assumed inline can never unwind.
Luqman Aden [Tue, 17 May 2022 04:46:20 +0000 (21:46 -0700)]
Update MIR passes that assumed inline can never unwind.

2 years agoAuto merge of #97019 - b-naber:transition-to-valtrees-pt1, r=oli-obk
bors [Wed, 18 May 2022 20:12:07 +0000 (20:12 +0000)]
Auto merge of #97019 - b-naber:transition-to-valtrees-pt1, r=oli-obk

Transition to valtrees pt1

Compartmentalising https://github.com/rust-lang/rust/pull/96591 as much as possible.

r? `@oli-obk`

2 years agoAuto merge of #96863 - SparrowLii:let, r=michaelwoerister
bors [Wed, 18 May 2022 17:48:46 +0000 (17:48 +0000)]
Auto merge of #96863 - SparrowLii:let, r=michaelwoerister

use `hir::Let` in `hir::Guard::IfLet`

This PR fixes the FIXME about using `hir::Let` in `hir::Guard::IfLet`

2 years agofix rustfmt
klensy [Wed, 18 May 2022 16:02:06 +0000 (19:02 +0300)]
fix rustfmt

2 years agoBump RLS to latest master
Mark Rousskov [Wed, 18 May 2022 16:16:27 +0000 (12:16 -0400)]
Bump RLS to latest master

2 years agoStage-step cfgs
Mark Rousskov [Wed, 18 May 2022 16:05:26 +0000 (12:05 -0400)]
Stage-step cfgs

2 years agouse `CursorRef` more, to not to clone `Tree`s
klensy [Mon, 16 May 2022 15:58:15 +0000 (18:58 +0300)]
use `CursorRef` more, to not to clone `Tree`s

2 years agoBump stage 0 to new beta
Mark Rousskov [Wed, 18 May 2022 15:38:34 +0000 (11:38 -0400)]
Bump stage 0 to new beta

2 years agoAuto merge of #96800 - nbdd0121:const, r=nagisa
bors [Wed, 18 May 2022 15:07:47 +0000 (15:07 +0000)]
Auto merge of #96800 - nbdd0121:const, r=nagisa

Permit `asm_const` and `asm_sym` to reference generic params

Related #96557

These constructs will be allowed:
```rust
fn foofoo<const N: usize>() {}

unsafe fn foo<const N: usize>() {
    asm!("/* {0} */", const N);
    asm!("/* {0} */", const N + 1);
    asm!("/* {0} */", sym foofoo::<N>);
}

fn barbar<T>() {}

unsafe fn bar<T>() {
    asm!("/* {0} */", const std::mem::size_of::<T>());
    asm!("/* {0} */", const std::mem::size_of::<(T, T)>());
    asm!("/* {0} */", sym barbar::<T>);
    asm!("/* {0} */", sym barbar::<(T, T)>);
}
```

`@Amanieu,` I didn't switch inline asms to use `DefKind::InlineAsm`, as I see little value doing that; given that no type inference is needed, it will only make typecking slower and more complex but will have no real gains. I did switch them to follow the same code path as inline asm during symbol resolution, though.
The `error: unconstrained generic constant` you mentioned in #76001 is due to the fact that `to_const` will actually add a wfness obligation to the constant, which we don't need for `asm_const`, so I have that removed.

`@rustbot` label: +A-inline-assembly +F-asm

2 years agomove processing of `source_scope_data` into `MutVisitor`'s impl of Integrator when...
SparrowLii [Wed, 18 May 2022 12:58:11 +0000 (20:58 +0800)]
move processing of `source_scope_data` into `MutVisitor`'s impl of Integrator when inline mir-opt

2 years agoAuto merge of #96867 - michaelwoerister:path-prefix-fixes-2, r=davidtwco
bors [Wed, 18 May 2022 12:45:44 +0000 (12:45 +0000)]
Auto merge of #96867 - michaelwoerister:path-prefix-fixes-2, r=davidtwco

--remap-path-prefix: Fix duplicated path components in debuginfo

This PR fixes an issue with `--remap-path-prefix` where path components could appear twice in the remapped version of the path (e.g. https://github.com/rust-lang/rust/issues/78479). The underlying problem was that `--remap-path-prefix` is often used to map an absolute path to something that looks like a relative path, e.g.:

```
--remap-path-prefix=/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823=crates.io",
```

and relative paths in debuginfo are interpreted as being relative to the compilation directory. So if Cargo invokes the compiler with `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0/src/lib.rs` as input and `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0` as the compiler's working directory, then debuginfo will state that the working directory was `crates.io/some_crate-0.1.0` and the file is question was `crates.io/some_crate-0.1.0/src/lib.rs`, which combined gives the path:

```
crates.io/some_crate-0.1.0/crates.io/some_crate-0.1.0/src/lib.rs
```

With this PR the compiler will detect this situation and set up debuginfo in LLVM in a way that makes it strip the duplicated path components when emitting DWARF.

The PR also extracts the logic for making remapped paths absolute into a common helper function that is now used by debuginfo too (instead of just during crate metadata generation).

2 years agoProperly apply path prefix remapping paths emitted into debuginfo.
Michael Woerister [Thu, 5 May 2022 15:26:22 +0000 (17:26 +0200)]
Properly apply path prefix remapping paths emitted into debuginfo.

2 years agoAuto merge of #97110 - Kobzol:pgo-pid-in-profile, r=lqd
bors [Wed, 18 May 2022 09:53:01 +0000 (09:53 +0000)]
Auto merge of #97110 - Kobzol:pgo-pid-in-profile, r=lqd

Add PID to PGO profile data filename

After experimenting with PGO, it looks like the generated profile data files can be sometimes overwritten if there is a race condition, because multiple `rustc` processes are usually invoked in parallel by `cargo`. Adding the PID to the resulting profile filename pattern makes sure that the profiles will be stored in separate files.

This generates ~20 GiB more space on disk on the CI run, but that seems harmless (?). Merging the profiles is not a bottleneck, the perf. run took the same amount of time as usually (~1h 24m).

r? `@lqd`