Commit Graph

168725 Commits

Author SHA1 Message Date
Mara Bos
3b70c29103 Fix typo in futex RwLock::write_contended.
I wrote `state` where I should've used `s`.

This removes the unnecessary `s` variable to prevent that mistake.

Fortunately, this typo didn't affect the correctness of the lock, as the
second half of the condition (!has_writers_waiting) is enough for
correctness, which explains why this mistake didn't show up during
testing.
2022-05-21 11:15:28 +02:00
bors
5f33adce1b Auto merge of #93963 - GuillaumeGomez:reduce-clean-type-size, r=notriddle
rustdoc: Reduce clean::Type size

There is no need to keep the `DefId` around since it's allow used to compute if we should show a cast or not. As such, we can simply directly store the boolean.

I think it's not what you had in mind `@camelid` but I guess it's still an improvement? 😉

It was discussed in https://github.com/rust-lang/rust/pull/93941.

r? `@camelid`
2022-05-21 09:04:05 +00:00
Camille GILLOT
075429f76b Recover when resolution did not resolve lifetimes. 2022-05-21 09:39:41 +02:00
bors
4f372b14de 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.
2022-05-21 06:38:49 +00:00
lcnr
1fcbf0c368 update mir dumps 2022-05-21 08:13:17 +02:00
lcnr
db11c1939c update mir user type printing and apparently fix an ICE 2022-05-21 08:13:17 +02:00
lcnr
39a03779f8 correctly deal with user type ascriptions in pat 2022-05-21 08:13:17 +02:00
Jacob Pratt
6970246886
Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
bors
3b64fe953c 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`
2022-05-21 04:21:38 +00:00
bors
4a86c7907b 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
2022-05-21 01:56:51 +00:00
Jacob Pratt
49c82f31a8
Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
bors
e57884b6e9 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.
2022-05-20 23:11:12 +00:00
Mark Rousskov
7501995977 Bump LLVM fetched from CI to fix run-make 2022-05-20 18:56:21 -04:00
oberien
6491eb1e6c Add back thinking emoji 2022-05-21 00:38:37 +02:00
Jaro Fietz
d85ba01ecb Add a function returning itself to weird-exprs 2022-05-21 00:19:53 +02:00
Jaro Fietz
df0b0d4ae3 Add unicode identifier to weird-exprs
Use unicode identifiers and a unicode emoji in weird-exprs.rs
2022-05-21 00:18:36 +02:00
Jaro Fietz
51730fb171 Make the most special expression even more special
Add or-pattern syntax in argument position
2022-05-21 00:17:48 +02:00
Jason A. Donenfeld
18a9d58266 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.
2022-05-21 00:02:20 +02:00
Jason A. Donenfeld
204da52c34 Update libc dependency of std to 0.2.126
This is required for the next commit, which uses libc::GRND_INSECURE.
2022-05-21 00:02:20 +02:00
bors
b312ad7d0c Auto merge of #8856 - xFrednet:rustup, r=Manishearth,Alexendoo
Rustup

`@rust-lang/clippy,` `@Jarcho,` `@dswij,` `@Alexendoo.` Could someone review this? It should be pretty straight forward since it's just a sync. I think it's also fine if either one of `@Jarcho,` `@dswij,` `@Alexendoo` approves this, as these are usually not reviewed. I just want to make sure that I didn't break something obvious 🙃

It should be enough to look at the merge commit 🙃

changelog: none
changelog: move [`significant_drop_in_scrutinee`] to `suspicious`
2022-05-20 21:35:14 +00:00
xFrednet
7842dbc4f5
Remove duplicated code and ignore deadlock test 2022-05-20 23:32:58 +02:00
bors
f26f117d61 Auto merge of #8852 - Alexendoo:indirect-disallowed-methods, r=Manishearth
Lint indirect usages in `disallowed_methods`

Fixes #8849

changelog: Lint indirect usages in [`disallowed_methods`]
2022-05-20 20:50:01 +00:00
bors
e6a4afc3af 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.
2022-05-20 20:49:55 +00:00
Tshepang Lekhonkhobe
bb8a1205c6 typo 2022-05-20 22:02:20 +02:00
Niko Matsakis
bf21a81b15
Update compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs 2022-05-20 15:54:22 -04:00
Jon Gjengset
88126034a4
Omit stdarch workspace from rust-src
The path `library/stdarch/crates/Cargo.toml` does not exist.

This was introduced in #94907.
2022-05-20 12:25:05 -07:00
xFrednet
8283238973
Update clippy version 0.1.62 -> 0.1.63 2022-05-20 21:12:41 +02:00
xFrednet
5b72632c98
move to sus and fix dogfood 2022-05-20 21:03:24 +02:00
xFrednet
4e6cf0036e
Merge remote-tracking branch 'upstream/master' into rustup 2022-05-20 20:47:31 +02:00
Guillaume Gomez
116c5a25e7 Add eslint key-spacing check 2022-05-20 20:27:35 +02:00
Guillaume Gomez
b036fd378b Add eslint arrow-spacing check 2022-05-20 20:27:34 +02:00
bors
536020c5f9 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
2022-05-20 18:21:26 +00:00
Josh Stone
83abb7c18f Fix Display for cell::{Ref,RefMut}
These guards changed to pointers in #97027, but their `Display` was
formatting that field directly, which made it show the raw pointer
value. Now we go through `Deref` to display the real value again.
2022-05-20 11:16:30 -07:00
Matthias Krüger
6c0c7f1787
Rollup merge of #97220 - JohnTitor:issue-81827, r=compiler-errors
Add regression test for#81827

Closes #81827
r? `@compiler-errors`
2022-05-20 19:54:45 +02:00
Matthias Krüger
ac634bc811
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](f3a9f211d0/src/raw/mod.rs (L1933)).

Benchmarks code would be presented in PR related to this commit.
2022-05-20 19:54:44 +02:00
Matthias Krüger
2941434d1b
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
2022-05-20 19:54:43 +02:00
Matthias Krüger
7c46bb60d1
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.
2022-05-20 19:54:42 +02:00
Matthias Krüger
35986cd1fb
Rollup merge of #97201 - ydah:fix_spelling, r=GuillaumeGomez
Fix typo

This PR is fixes typo "avaiable" to "available".
2022-05-20 19:54:41 +02:00
Matthias Krüger
daf4f34fe3
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.
2022-05-20 19:54:40 +02:00
Matthias Krüger
76f662c963
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
2022-05-20 19:54:39 +02:00
Camille GILLOT
cd90406090 Remove quadratic behaviour from -Zunpretty=hir-tree. 2022-05-20 19:34:31 +02:00
Yuki Okushi
eab9240627
Add regression test for #81827 2022-05-21 02:17:29 +09:00
AngelicosPhosphoros
de97d7393f 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](f3a9f211d0/src/raw/mod.rs (L1933)).

Benchmarks code would be presented in PR related to this commit.
2022-05-20 18:46:24 +03:00
bors
b5caa5a842 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`
2022-05-20 15:40:33 +00:00
Ralf Jung
31c3c04498 make ptr::invalid not the same as a regular int2ptr cast 2022-05-20 17:16:41 +02:00
Takayuki Maeda
3d0f9fb544 report ambiguous type parameters when their parents are impl or fn
fix ci error

emit err for `impl_item`
2022-05-20 23:04:44 +09:00
Caio
d917112606 Stabilize core::array::from_fn 2022-05-20 11:04:13 -03:00
Caio
2550069ab3 Move tests 2022-05-20 10:53:58 -03:00
bors
22ee39504a 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
2022-05-20 13:18:37 +00:00
Alex Macleod
5730fd49fa Lint indirect usages in disallowed_methods 2022-05-20 12:39:15 +00:00