Commit Graph

213561 Commits

Author SHA1 Message Date
bors
b15ca6635f Auto merge of #105741 - pietroalbini:pa-1.68-nightly, r=Mark-Simulacrum
Bump master bootstrap compiler

This PR bumps the bootstrap compiler to the beta created earlier this week, cherry-picks the stabilization version number updates, and updates the `cfg(bootstrap)`s.

r? `@Mark-Simulacrum`
2022-12-29 01:24:26 +00:00
bors
9709a43872 Auto merge of #106228 - matthiaskrgr:rollup-jsznhww, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104402 (Move `ReentrantMutex` to `std::sync`)
 - #104493 (available_parallelism: Gracefully handle zero value cfs_period_us)
 - #105359 (Make sentinel value configurable in `library/std/src/sys_common/thread_local_key.rs`)
 - #105497 (Clarify `catch_unwind` docs about panic hooks)
 - #105570 (Properly calculate best failure in macro matching)
 - #105702 (Format only modified files)
 - #105998 (adjust message on non-unwinding panic)
 - #106161 (Iterator::find: link to Iterator::position in docs for discoverability)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-28 22:15:27 +00:00
Matthias Krüger
89ccd704f0
Rollup merge of #106161 - meithecatte:iter-find-position, r=Mark-Simulacrum
Iterator::find: link to Iterator::position in docs for discoverability
2022-12-28 22:22:21 +01:00
Matthias Krüger
d28ef9dbf1
Rollup merge of #105998 - RalfJung:no-unwind-panic-msg, r=thomcc
adjust message on non-unwinding panic

"thread panicked while panicking" is just plain wrong in case this is a non-unwinding panic, such as
- a panic out of a `nounwind` function
- the sanity checks we have in `mem::uninitialized` and `mem::zeroed`
- the optional debug assertion in various unsafe std library functions
2022-12-28 22:22:21 +01:00
Matthias Krüger
06306770f8
Rollup merge of #105702 - albertlarsan68:x-fmt-opt, r=jyn514
Format only modified files

As discussed on #105688, this makes x fmt only format modified files.

Fixes #105688
2022-12-28 22:22:20 +01:00
Matthias Krüger
c52d58f346
Rollup merge of #105570 - Nilstrieb:actual-best-failure, r=compiler-errors
Properly calculate best failure in macro matching

Previously, we used spans. This was not good. Sometimes, the span of the token that failed to match may come from a position later in the file which has been transcribed into a token stream way earlier in the file. If precisely this token fails to match, we think that it was the best match because its span is so high, even though other arms might have gotten further in the token stream.

We now try to properly use the location in the token stream.

This needs a little cleanup as the `best_failure` field is getting out of hand but it should be mostly good to go. I hope I didn't violate too many abstraction boundaries..
2022-12-28 22:22:19 +01:00
Matthias Krüger
0b7ed65c13
Rollup merge of #105497 - albertlarsan68:doc-panic-hook-and-catch-unwind, r=m-ou-se
Clarify `catch_unwind` docs about panic hooks

Makes it clear from `catch_unwind` docs that the panic hook will be called before the panic is caught.

Fixes #105432
2022-12-28 22:22:19 +01:00
Matthias Krüger
22060f20ae
Rollup merge of #105359 - flba-eb:thread_local_key_sentinel_value, r=m-ou-se
Make sentinel value configurable in `library/std/src/sys_common/thread_local_key.rs`

This is an excerpt of a changeset for the QNX/Neutrino OS. To make the patch for QNX smaller and easier to review, I've extracted this change (which is OS independent). I would be surprised if no other OS is also affected.

All this patch does is to define a `const` for a sentinel value instead of using it directly at several places.

There are OSs that always return the lowest free value. The algorithm in `lazy_init` always avoids keys with the sentinel value.
In affected OSs, this means that each call to `lazy_init` will always request two keys from the OS and returns/frees the first one (with sentinel value) immediately afterwards.

By making the sentinel value configurable, affected OSs can use a different value than zero to prevent this performance issue.

On QNX/Neutrino, it is planned to use a different sentinel value:
```rust
// Define a sentinel value that is unlikely to be returned
// as a TLS key (but it may be returned).
#[cfg(not(target_os = "nto"))]
const KEY_SENTVAL: usize = 0;
// On QNX/Neutrino, 0 is always returned when currently not in use.
// Using 0 would mean to always create two keys and remote the first
// one (with value of 0) immediately afterwards.
#[cfg(target_os = "nto")]
const KEY_SENTVAL: usize = libc::PTHREAD_KEYS_MAX + 1;
```

It seems like no other OS defines `PTHREAD_KEYS_MAX` in Rusts libc, but `limits.h` on unix systems does.
2022-12-28 22:22:18 +01:00
Matthias Krüger
2dd2fb728e
Rollup merge of #104493 - adamncasey:cgroupzeroperiod, r=m-ou-se
available_parallelism: Gracefully handle zero value cfs_period_us

There seem to be some scenarios where the cgroup cpu quota field `cpu.cfs_period_us` can contain `0`. This field is used to determine the "amount" of parallelism suggested by the function `std:🧵:available_parallelism`

A zero value of this field cause a panic when `available_parallelism()` is invoked. This issue was detected by the call from binaries built by `cargo test`. I really don't feel like `0` is a good value for `cpu.cfs_period_us`, but I also don't think applications should panic if this value is seen.

This panic started happening with rust 1.64.0.

This case is gracefully handled by other projects which read this information: [num_cpus](e437b9d908/src/linux.rs (L207-L210)), [ninja](https://github.com/ninja-build/ninja/pull/2174/files), [dotnet](c4341d45ac/src/coreclr/pal/src/misc/cgroup.cpp (L481-L483))

Before this change, running `cargo test` in environments configured as described above would trigger this panic:
```
$ RUST_BACKTRACE=1 cargo test
    Finished test [unoptimized + debuginfo] target(s) in 3.55s
     Running unittests src/main.rs (target/debug/deps/x-9a42e145aca2934d)
thread 'main' panicked at 'attempt to divide by zero', library/std/src/sys/unix/thread.rs:546:70
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: std::sys::unix:🧵:cgroups::quota
   4: std::sys::unix:🧵:available_parallelism
   5: std:🧵:available_parallelism
   6: test::helpers::concurrency::get_concurrency
   7: test::console::run_tests_console
   8: test::test_main
   9: test::test_main_static
  10: x::main
             at ./src/main.rs:1:1
  11: core::ops::function::FnOnce::call_once
             at /tmp/rust-1.64-1.64.0-1/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: test failed, to rerun pass '--bin x'
```

I've tested this change in an environment which has the bad (questionable?) setup and rebuilding the test executable against a fixed std library fixes the panic.
2022-12-28 22:22:18 +01:00
Matthias Krüger
d91432832e
Rollup merge of #104402 - joboet:sync_remutex, r=m-ou-se
Move `ReentrantMutex` to `std::sync`

If I understand #84187 correctly, `sys_common` should not contain platform-independent code, even if it is private.
2022-12-28 22:22:17 +01:00
Mark Rousskov
cc4e434854 Skip LTO in stage0 (again) 2022-12-28 15:29:21 -05:00
bors
270c94e484 Auto merge of #106215 - matthiaskrgr:rollup-53r89ww, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #106028 (docs/test: add UI test and long-form error docs for `E0461`)
 - #106172 (Suggest `impl Iterator` when possible for `_` return type)
 - #106173 (Deduplicate `op` methods)
 - #106176 (Recover `fn` keyword as `Fn` trait in bounds)
 - #106194 (rustdoc: combine common sidebar background color CSS rules)
 - #106199 (Silence knock-down errors on `[type error]` bindings)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-28 17:00:00 +00:00
Albert Larsan
cb7c8993b9
Clarify catch_unwind docs about panic hooks
Makes it clear from catch_unwind docs that the panic hook will be called
before the panic is caught.
2022-12-28 16:54:42 +01:00
Mark Rousskov
fbe0450251 -Zrustdoc-scrape-examples no longer takes arguments 2022-12-28 09:20:57 -05:00
Lukas Markeffsky
9480314416 fix custom mir doc tests 2022-12-28 09:18:43 -05:00
Lukas Markeffsky
f4ff423d67 fix documenting private items of standard library 2022-12-28 09:18:43 -05:00
Lukas Markeffsky
fdf6cc34b2 delete more cfg(bootstrap) 2022-12-28 09:18:43 -05:00
Pietro Albini
11191279b7 Update bootstrap cfg 2022-12-28 09:18:43 -05:00
Pietro Albini
060a6ead83 bump stage0 2022-12-28 09:18:43 -05:00
Pietro Albini
f6762c2035 update stabilization version numbers 2022-12-28 09:18:42 -05:00
Matthias Krüger
d37cb3ff89
Rollup merge of #106199 - estebank:quiet-type-err-in-binding, r=compiler-errors
Silence knock-down errors on `[type error]` bindings

Fix #56036, fix #76589.
2022-12-28 14:40:03 +01:00
Matthias Krüger
08e2e4e4e4
Rollup merge of #106194 - notriddle:notriddle/sidebar-background, r=GuillaumeGomez
rustdoc: combine common sidebar background color CSS rules
2022-12-28 14:40:02 +01:00
Matthias Krüger
d07be1a304
Rollup merge of #106176 - compiler-errors:fn-kw-as-fn-trait, r=estebank
Recover `fn` keyword as `Fn` trait in bounds

`impl fn()` -> `impl Fn()`

Fixes #82515
2022-12-28 14:40:01 +01:00
Matthias Krüger
c991c243b7
Rollup merge of #106173 - compiler-errors:deduplicate-op-methods, r=jackh726
Deduplicate `op` methods

There are some operator-checking flavored methods in `FnCtxt` that can be deduplicated.
2022-12-28 14:40:01 +01:00
Matthias Krüger
31f5e753fb
Rollup merge of #106172 - estebank:suggest-impl-trait, r=compiler-errors
Suggest `impl Iterator` when possible for `_` return type

Address #106096.
2022-12-28 14:40:00 +01:00
Matthias Krüger
f33ea418e2
Rollup merge of #106028 - Ezrashaw:add-docs+test-e0461, r=GuillaumeGomez
docs/test: add UI test and long-form error docs for `E0461`

Might take a couple of tries to pass CI. The UI test is x86-linux only; I'm not sure how to generalize it to other architectures.

r? ``@GuillaumeGomez``
2022-12-28 14:40:00 +01:00
bors
83a28ef095 Auto merge of #106129 - compiler-errors:compare_method-tweaks, r=BoxyUwU
Some `compare_method` tweaks

1. Make some of the comparison functions' names more regular
2. Reduce pub scope of some of the things in `compare_method`
~3. Remove some unnecessary opaque type handling code -- `InferCtxt` already is in a mode that doesn't define opaque types~
  * moved to a different PR
4. Bubble up `ErrorGuaranteed` for region constraint errors in `compare_method` - Improves a redundant error message in one unit test.
5. Move the `compare_method` module to have a more general name, since it's more like `compare_impl_item` :)
6. Rename `collect_trait_impl_trait_tys`
2022-12-28 13:07:30 +00:00
bors
6a20f7df57 Auto merge of #106209 - fee1-dead-contrib:rollup-47ysdcu, r=fee1-dead
Rollup of 9 pull requests

Successful merges:

 - #94145 (Test leaking of BinaryHeap Drain iterators)
 - #103945 (Remove `iter::Empty` hack)
 - #104024 (Fix `unused_must_use` warning for `Box::from_raw`)
 - #104708 (Fix backoff doc to match implementation)
 - #105347 (Account for `match` expr in single line)
 - #105484 (Implement allow-by-default `multiple_supertrait_upcastable` lint)
 - #106184 (Fix `core::any` docs)
 - #106201 (Emit fewer errors on invalid `#[repr(transparent)]` on `enum`)
 - #106205 (Remove some totally duplicated files in `rustc_infer`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-28 10:10:09 +00:00
Ralf Jung
b804c0d5a5 adjust message on non-unwinding panic 2022-12-28 10:38:04 +01:00
fee1-dead
5e9c91c6dd
Rollup merge of #106205 - compiler-errors:oopsy, r=fee1-dead
Remove some totally duplicated files in `rustc_infer`

I have no idea why or how I duplicated these files from `compiler/rustc_infer/src/infer/error_reporting/note.rs`, but I did by accident, and nothing caught it 🤦
2022-12-28 15:51:43 +08:00
fee1-dead
f837da736f
Rollup merge of #106201 - estebank:verbose-transparent, r=compiler-errors
Emit fewer errors on invalid `#[repr(transparent)]` on `enum`

Fix #68420.
2022-12-28 15:51:42 +08:00
fee1-dead
45d6f02ea5
Rollup merge of #106184 - albertlarsan68:docs-106154, r=Nilstrieb
Fix `core::any` docs

Thanks to ``@pbevin`` in #106154

Closes #106154

``@rustbot`` labels +A-docs
2022-12-28 15:51:42 +08:00
fee1-dead
8b3d0c4cf9
Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errors
Implement allow-by-default `multiple_supertrait_upcastable` lint

The lint detects when an object-safe trait has multiple supertraits.

Enabled in libcore and liballoc as they are low-level enough that many embedded programs will use them.

r? `@nikomatsakis`
2022-12-28 15:51:41 +08:00
fee1-dead
ade9605a08
Rollup merge of #105347 - estebank:single-line-match, r=compiler-errors
Account for `match` expr in single line

When encountering `match Some(42) { Some(x) => x, None => "" };`, output

```
error[E0308]: `match` arms have incompatible types
 --> f53.rs:2:52
  |
2 |     let _ = match Some(42) { Some(x) => x, None => "" };
  |             --------------              -          ^^ expected integer, found `&str`
  |             |                           |
  |             |                           this is found to be of type `{integer}`
  |             `match` arms have incompatible types
  ```
2022-12-28 15:51:40 +08:00
fee1-dead
0818ba43a4
Rollup merge of #104708 - jonasspinner:fix-backoff-doc-to-match-implementation, r=compiler-errors
Fix backoff doc to match implementation

The commit 8dddb22943 in the crossbeam-channel PR (#93563) changed the backoff strategy to be quadratic instead of exponential. This updates the doc to prevent confusion.
2022-12-28 15:51:40 +08:00
fee1-dead
58233e90b8
Rollup merge of #104024 - noeddl:unused-must-use, r=compiler-errors
Fix `unused_must_use` warning for `Box::from_raw`
2022-12-28 15:51:39 +08:00
fee1-dead
d1193ad1e6
Rollup merge of #103945 - H4x5:remove-iter-empty-hack, r=compiler-errors
Remove `iter::Empty` hack

`iter::Empty` uses a newtype to work around `#![feature(const_fn_fn_ptr_basics)]`, which has been stable since 1.61.0.
2022-12-28 15:51:38 +08:00
fee1-dead
dc98aa681f
Rollup merge of #94145 - ssomers:binary_heap_tests, r=jyn514
Test leaking of BinaryHeap Drain iterators

Add test cases about forgetting the `BinaryHeap::Drain` iterator, and slightly fortifies some other test cases.

Consists of separate commits that I don't think are relevant on their own (but I'll happily turn these into more PRs if desired).
2022-12-28 15:51:37 +08:00
bors
9b889e53e7 Auto merge of #103881 - ChayimFriedman2:patch-2, r=compiler-errors
Clarify docs of `RefCell`

Comparison operators only panic if the `RefCell` is mutably borrowed, and `RefCell::swap()` can also panic if swapping a `RefCell` with itself.
2022-12-28 06:56:02 +00:00
Michael Goulet
605ad65f6a Remove some totally duplicated files 2022-12-28 05:45:12 +00:00
Michael Goulet
96d8011fa8 better names and a comment 2022-12-28 04:18:37 +00:00
Michael Goulet
c7b414adb6 Rename module compare_method -> compare_impl_item 2022-12-28 04:18:37 +00:00
Michael Goulet
91613c5030 make some things less pub 2022-12-28 04:18:37 +00:00
bors
6a4624d73b Auto merge of #100539 - joboet:horizon_timeout_clock, r=thomcc
Use correct clock in `park_timeout` on Horizon

Horizon does not support using `CLOCK_MONOTONIC` with condition variables, so use the system time instead.
2022-12-28 03:56:46 +00:00
Esteban Küber
50c1be1d19 Emit fewer errors on invalid #[repr(transparent)] on enum
Fix #68420.
2022-12-27 18:28:02 -08:00
Esteban Küber
8e039b6948 Silence knock-down errors on [type error] bindings
Fix #56036, fix #76589.
2022-12-27 18:26:54 -08:00
Esteban Küber
05e8ba126c Account for match expr in single line
When encountering `match Some(42) { Some(x) => x, None => "" };`, output

```
error[E0308]: `match` arms have incompatible types
 --> f53.rs:2:52
  |
2 |     let _ = match Some(42) { Some(x) => x, None => "" };
  |             --------------              -          ^^ expected integer, found `&str`
  |             |                           |
  |             |                           this is found to be of type `{integer}`
  |             `match` arms have incompatible types
  ```
2022-12-27 16:45:55 -08:00
Esteban Küber
b400bde52a Shorten type in note 2022-12-27 15:36:10 -08:00
Esteban Küber
df2a35ea3d review comments 2022-12-27 13:44:39 -08:00
Albert Larsan
0b942a879d
Add changelog entry 2022-12-27 22:19:56 +01:00