Commit graph

10242 commits

Author SHA1 Message Date
Tobias Bucher 40916ef88f Add notes and examples about non-intuitive PathBuf::set_extension behavior
Basically, passing the empty string will actually remove the extension
instead of setting it to the empty string. This might change what is
considered to be an extension. Additionally, passing an extension that
contains dots will make the path only consider the last part of it to be
the new extension.
2022-12-31 00:56:43 +01:00
bors ce85c98575 Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-se
Add #[inline] markers to once_cell methods

Added inline markers to all simple methods under the `once_cell` feature. Relates to #74465 and  #105587

This should not block #105587
2022-12-30 19:22:33 +00:00
bors bbdca4c28f Auto merge of #106296 - matthiaskrgr:rollup-ukdbqwx, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #99244 (doc: clearer and more correct Iterator::scan)
 - #103707 (Replace libstd, libcore, liballoc terminology in docs)
 - #104182 (`IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation.)
 - #106273 (rustdoc: remove redundant CSS `.source .content { overflow: visible }`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-30 16:10:00 +00:00
Matthias Krüger bd20fc1fd6
Rollup merge of #104182 - gabhijit:ipv6-in6addr-any-doc-fix, r=m-ou-se
`IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation.

Added documentation for IPv6 Addresses `IN6ADDR_ANY_INIT` also known as `in6addr_any` and `IN6ADDR_LOOPBACK_INIT` also known as `in6addr_loopback` similar to `INADDR_ANY` for IPv4 Addresses.
2022-12-30 17:01:39 +01:00
Matthias Krüger 25b1f1c26d
Rollup merge of #103707 - jonathanCogan:master, r=m-ou-se
Replace libstd, libcore, liballoc terminology in docs

Fixes #103551.  I changed line comments containing the outdated terms as well.

It would be great if someone with more experience could weigh in on whether these changes introduce ambiguity as suggested in https://github.com/rust-lang/rust/issues/103551#issuecomment-1291225315.
2022-12-30 17:01:39 +01:00
Matthias Krüger 80e309f798
Rollup merge of #99244 - gthb:doc-improve-iterator-scan, r=m-ou-se
doc: clearer and more correct Iterator::scan

The `Iterator::scan` documentation seemed a little misleading to my newcomer
eyes, and this tries to address that.

* I found “similar to `fold`” unhelpful because (a) the similarity is only that
  they maintain state between iterations, and (b) the _dissimilarity_ is no less
  important: one returns a final value and the other an iterator. So this
  replaces that with “which, like `fold`, holds internal state, but unlike
  `fold`, produces a new iterator.

* I found “the return value from the closure, an `Option`, is yielded by the
  iterator” to be downright incorrect, because “yielded by the iterator” means
  “returned by the `next` method wrapped in `Some`”, so this implied that `scan`
  would convert an input iterator of `T` to an output iterator of `Option<T>`.
  So this replaces “yielded by the iterator” with “returned by the `next`
  method” and elaborates: “Thus the closure can return `Some(value)` to yield
  `value`, or `None` to end the iteration.”

* This also changes the example to illustrate the latter point by returning
  `None` to terminate the iteration early based on `state`.
2022-12-30 17:01:38 +01:00
Nilstrieb a8f50453d0 Use some more const_eval_select in pointer methods for compile times 2022-12-30 16:39:58 +01:00
joboet 898302e685
std: remove unnecessary #[cfg] on NetBSD 2022-12-30 15:50:31 +01:00
joboet 9abda03da6
std: rename Parker::new to Parker::new_in_place, add safe Parker::new constructor for SGX 2022-12-30 15:49:47 +01:00
jonathanCogan 78691e3589 Update paths in comments. 2022-12-30 14:00:42 +01:00
jonathanCogan db47071df2 Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
jonathanCogan 72067c77bd Replace libstd, libcore, liballoc in docs. 2022-12-30 14:00:40 +01:00
bors 7c991868c6 Auto merge of #105426 - flba-eb:fix_tls_destructor_unwinding, r=m-ou-se
Catch panics/unwinding in destruction of TLS values

`destroy_value` is/can be called from C code (libc). Unwinding from Rust to C code is undefined behavior, which is why unwinding is caught here.

This problem caused an infinite loop inside the unwinding code when running `src/test/ui/threads-sendsync/issue-24313.rs` on a tier 3 target (QNX/Neutrino) on aarch64.

See also https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Infinite.20unwinding.20bug.
2022-12-30 12:58:50 +00:00
Ezra Shaw 2c4ecffb77
docs: add link to Path::join in PathBuf::push 2022-12-30 14:24:12 +13:00
bors 973a4db8d5 Auto merge of #106210 - fee1-dead-contrib:const-closure-trait-method, r=compiler-errors
Allow trait method paths to satisfy const Fn bounds

r? `@oli-obk`
2022-12-30 01:09:31 +00:00
joboet 3076f4ec30
std: pass hint to id-based parking functions 2022-12-29 17:54:09 +01:00
joboet a9e5c1a309
std: unify id-based thread parking implementations 2022-12-29 17:45:07 +01:00
David Tolnay 06ec0bf8b0
Revert "Implement allow-by-default multiple_supertrait_upcastable lint"
This reverts commit 5e44a65517.
2022-12-29 00:47:23 -08:00
bors 6ad8383451 Auto merge of #105590 - solid-rs:patch/kmc-solid/thread-lifecycle-ordering, r=m-ou-se
kmc-solid: Fix memory ordering in thread operations

Fixes two memory ordering issues in the thread state machine (`ThreadInner::lifecycle`) of the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.

1. When detaching a thread that is still running (i.e., the owner updates `lifecycle` first, and the child updates it next), the first update did not synchronize-with the second update, resulting in a data race between the first update and the deallocation of `ThreadInner` by the child thread.
2. When joining on a thread, the joiner has to pass its own task ID to the joinee in order to be woken up later, but in doing so, it did not synchronize-with the read operation, creating possible sequences of execution where the joinee wakes up an incorrect or non-existent task.

Both issue are theoretical and most likely have never manifested in practice because of the stronger guarantees provided by the Arm memory model (particularly due to its barrier-based definition). Compiler optimizations could have subverted this, but the inspection of compiled code did not reveal such optimizations taking place.
2022-12-29 04:22:25 +00:00
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
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 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
Florian Bartels 04a6f22f79
Catch panics in destruction of TLS values
`destroy_value` is/can be called from C code (libc). Unwinding
from Rust to C code is undefined behavior, which is why unwinding
is caught here.
2022-12-28 18:32:41 +01: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
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 f6762c2035 update stabilization version numbers 2022-12-28 09:18:42 -05: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
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
Deadbeef 983606d367 Allow trait method paths to satisfy const Fn bounds 2022-12-28 09:06:31 +00: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 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
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
bors 739d68a76e Auto merge of #106193 - compiler-errors:rollup-0l54wka, r=compiler-errors
Rollup of 9 pull requests

Successful merges:

 - #103718 (More inference-friendly API for lazy)
 - #105765 (Detect likely `.` -> `..` typo in method calls)
 - #105852 (Suggest rewriting a malformed hex literal if we expect a float)
 - #105965 (Provide local extern function arg names)
 - #106064 (Partially fix `explicit_outlives_requirements` lint in macros)
 - #106179 (Fix a formatting error in Iterator::for_each docs)
 - #106181 (Fix doc comment parsing description in book)
 - #106187 (Update the documentation of `Vec` to use `extend(array)` instead of `extend(array.iter().copied())`)
 - #106189 (Fix UnsafeCell Documentation Spelling Error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-27 20:54:06 +00:00
Albert Larsan 6d332c4a71
Fix core::any mod-level docs 2022-12-27 21:42:42 +01:00
Michael Goulet 49d43468a8
Rollup merge of #106189 - alexhrao:master, r=Nilstrieb
Fix UnsafeCell Documentation Spelling Error

This fixes the spelling of "deallocated" (instead of the original "deallocted") In the `cell.rs` source file. Honestly probably not worth the time to evaluate, but since it doesn't involve any code change, I figure why not?
2022-12-27 12:33:38 -08:00
Michael Goulet 79730d6e32
Rollup merge of #106187 - ChayimFriedman2:patch-4, r=compiler-errors
Update the documentation of `Vec` to use `extend(array)` instead of `extend(array.iter().copied())`

Another option is to use `extend_from_slice()` (that may be faster), but I find this approach cleaner.
2022-12-27 12:33:37 -08:00
Michael Goulet 7f5f31bc37
Rollup merge of #106179 - RetroSeven:typo_fix, r=compiler-errors
Fix a formatting error in Iterator::for_each docs

There is a formatting error (extra space in an assignment) in the documentation of `core::iter::Iterator::for_each`, which I have fixed in this pull request.
2022-12-27 12:33:36 -08:00
Michael Goulet 4b668a1fee
Rollup merge of #103718 - matklad:infer-lazy, r=dtolnay
More inference-friendly API for lazy

The signature for new was

```
fn new<F>(f: F) -> Lazy<T, F>
```

Notably, with `F` unconstrained, `T` can be literally anything, and just `let _ = Lazy::new(|| 92)` would not typecheck.

This historiacally was a necessity -- `new` is a `const` function, it couldn't have any bounds. Today though, we can move `new` under the `F: FnOnce() -> T` bound, which gives the compiler enough data to infer the type of T from closure.
2022-12-27 12:33:33 -08:00
Alex Rao b026167eb9
Fix UnsafeCell Documentation Spelling Error
This fixes the spelling of "deallocated" (instead of the original "deallocted") In the `cell.rs` source file
2022-12-27 12:17:56 -06:00
bors 92c1937a90 Auto merge of #97176 - kraktus:cmd_debug, r=the8472
More verbose `Debug` implementation of `std::process:Command`

Mainly based on commit: ccc019aabf from https://github.com/zackmdavis

close https://github.com/rust-lang/rust/issues/42200
2022-12-27 18:13:23 +00:00
Chayim Refael Friedman 4df5459dd1
Update the documentation of Vec to use extend(array) instead of extend(array.iter().copied()) 2022-12-27 19:44:58 +02:00
RetroSeven 9f18cc9e51
Fix a formatting error 2022-12-27 11:07:44 +01:00
kraktus eb63dea57f More verbose Debug implementation of std::process:Command
based on commit: ccc019aabf from https://github.com/zackmdavis

close https://github.com/rust-lang/rust/issues/42200

Add env variables and cwd to the shell-like debug output.

Also use the alternate syntax to display a more verbose display, while not showing internal fields and hiding fields when they have their default value.
2022-12-27 09:50:01 +01:00
Esteban Küber 1b341fe8a1 Suggest impl Iterator when possible for _ return type
Address #106096.
2022-12-26 18:21:45 -08:00
Maja Kądziołka 37b88c842a
Iterator::find: link to Iterator::position in docs for discoverability 2022-12-26 22:49:22 +01:00
bors 8dfb339541 Auto merge of #105997 - RalfJung:immediate-abort, r=eholk
abort immediately on bad mem::zeroed/uninit

Now that we have non-unwinding panics, let's use them for these assertions. This re-establishes the property that `mem::uninitialized` and `mem::zeroed` will never unwind -- the earlier approach of causing panics here sometimes led to hard-to-debug segfaults when the surrounding code was not able to cope with the unexpected unwinding.

Cc `@bjorn3` I did not touch cranelift but I assume it needs a similar patch. However it has a `codegen_panic` abstraction that I did not want to touch since I didn't know how else it is used.
2022-12-25 20:51:37 +00:00
bors d9ee0f468f Auto merge of #106112 - RalfJung:into-iter, r=thomcc
add lib tests for vec::IntoIter alignment issues

This adds non-Miri tests for the issue fixed in https://github.com/rust-lang/rust/pull/106084

r? `@thomcc`
2022-12-25 04:26:14 +00:00
bors 7e4f4660eb Auto merge of #104977 - RalfJung:ptr-from-ref, r=dtolnay
add ptr::from_{ref,mut}

We have methods to avoid almost all `as` casts around raw pointer handling, except for the initial cast from reference to raw pointer. These new methods close that gap.

(I also moved `null_mut` next to `null` to keep the file consistently organized.)

r? libs-api

Tracking issue: https://github.com/rust-lang/rust/issues/106116
2022-12-24 17:14:26 +00:00
bors 8766bbdc30 Auto merge of #106111 - matthiaskrgr:rollup-nnpoe5h, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #105465 (Improve top-level docs)
 - #105872 (Suggest remove last method call when type coerce with expected  type)
 - #106032 (std: only use LFS function on glibc)
 - #106078 (Provide more context on FileCheck failures)
 - #106100 (Codegen test for derived `<` on trivial newtype [TEST ONLY])
 - #106109 (rustdoc: make line number CSS for doc comment and scraped the same)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-24 10:46:43 +00:00
Ralf Jung 15f72dd29d add tracking issue, fix typo 2022-12-24 10:47:31 +01:00
Ralf Jung 6fb314ed7d add lib tests for vec::IntoIter alignment issues 2022-12-24 10:08:27 +01:00
Matthias Krüger 74a9b08517
Rollup merge of #106032 - mcha-forks:lfs-musl-fix, r=thomcc
std: only use LFS function on glibc

see #94173 and commit 27011b4185.
2022-12-24 08:53:47 +01:00
bors 5e8bab91d3 Auto merge of #106081 - mina86:c, r=Mark-Simulacrum
char: µoptimise UTF-16 surrogates decoding

According to Godbolt¹, on x86_64 using binary and produces slightly
better code than using subtraction.  Readability of both is pretty
much equivalent so might just as well use the shorter option.

¹ https://rust.godbolt.org/z/9jM3ejbMx
2022-12-24 07:35:23 +00:00
Ralf Jung a48d2e1783 fix one more unaligned self.ptr, and add tests 2022-12-23 15:49:23 +01:00
Ralf Jung d0f404d77a fix IntoIter::drop on high-alignment ZST 2022-12-23 15:18:18 +01:00
Michal Nazarewicz 28162ad970 char: µoptimise UTF-16 surrogates decoding
According to Godbolt¹, on x86_64 using binary and produces slightly
better code than using subtraction.  Readability of both is pretty
much equivalent so might just as well use the shorter option.

¹ https://rust.godbolt.org/z/9jM3ejbMx
2022-12-23 14:15:33 +01:00
Ralf Jung 9f241b3a26 abort immediately on bad mem::zeroed/uninit 2022-12-22 16:37:42 +01:00
mochaaP 3e35b39d9d
std: only use LFS function on glibc
see #94173 and commit 27011b4185.
2022-12-22 16:01:27 +08:00
bors 75f4ee8b44 Auto merge of #106025 - matthiaskrgr:rollup-vz5rqah, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #105837 (Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity)
 - #105932 (Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15)
 - #105960 (Various cleanups)
 - #105985 (Method chain nitpicks)
 - #105996 (Test that async blocks are `UnwindSafe`)
 - #106012 (Clarify that raw retags are not permitted in Mir)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-22 05:30:00 +00:00
bors 8574880108 Auto merge of #106023 - JohnTitor:rollup-k8mettz, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #105584 (add assert messages if chunks/windows are length 0)
 - #105602 (interpret: add read_machine_[ui]size convenience methods)
 - #105824 (str.lines() docstring: clarify that line endings are not returned)
 - #105980 (Refer to "Waker" rather than "RawWaker" in `drop` comment)
 - #105986 (Fix typo in reading_half_a_pointer.rs)
 - #105995 (Add regression test for #96530)
 - #106008 (Sort lint_groups in no_lint_suggestion)
 - #106014 (Add comment explaining what the scrape-examples-toggle.goml GUI test is about)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-22 02:16:59 +00:00
Matthias Krüger d0d0ccdca2
Rollup merge of #106012 - JakobDegen:retag-raw, r=RalfJung
Clarify that raw retags are not permitted in Mir

Not sure when this changed, but documentation and the validator needed to be updated. This also removes raw retags from custom mir.

cc rust-lang/miri#2735

r? `@RalfJung`
2022-12-22 01:01:15 +01:00
Matthias Krüger ec7eb5b5ad
Rollup merge of #105960 - oli-obk:effect_cleanup, r=fee1-dead
Various cleanups

This PR pulls changes out of https://github.com/rust-lang/rust/pull/101900 that can land on master immediately

r? ``@fee1-dead``
2022-12-22 01:01:13 +01:00
Yuki Okushi 03a763c5c8
Rollup merge of #105980 - goffrie:waker-drop, r=thomcc
Refer to "Waker" rather than "RawWaker" in `drop` comment

In my view this is technically more correct as `Waker` actually implements `Drop` (which calls the `drop` method) whereas `RawWaker` does not.
2022-12-22 08:32:11 +09:00
Yuki Okushi 257edf2de5
Rollup merge of #105824 - zacchiro:patch-1, r=JohnTitor
str.lines() docstring: clarify that line endings are not returned

Previously, the str.lines() docstring stated that lines are split at line endings, but not whether those were returned or not.  This new version of the docstring states this explicitly, avoiding the need of getting to doctests to get an answer to this FAQ.
2022-12-22 08:32:10 +09:00
Yuki Okushi 342d1b7f01
Rollup merge of #105584 - raffimolero:patch-1, r=JohnTitor
add assert messages if chunks/windows are length 0
2022-12-22 08:32:09 +09:00
bors bdbe392a13 Auto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJung
Rename `assert_uninit_valid` intrinsic

It's not about "uninit" anymore but about "filling with 0x01 bytes" so the name should at least try to reflect that.

This is actually not fully correct though, as it does still panic for all uninit with `-Zstrict-init-checks`. I'm not sure what the best way is to deal with that not causing confusion. I guess we could just remove the flag? I don't think having it makes a lot of sense anymore with the direction that we have chose to go. It could be relevant again if #100423 lands so removing it may be a bit over eager.

r? `@RalfJung`
2022-12-21 23:20:04 +00:00
Jakob Degen cb2c7bb833 Clarify that raw retags are not permitted in Mir 2022-12-21 10:32:01 -08:00
bors 49143814e1 Auto merge of #100390 - jhpratt:float-from-bool, r=dtolnay
Implement `From<bool>` for f32, f64

As is required for trait implementations, these are insta-stable. Given there is a release tomorrow and this needs FCP, I set 1.65 as the stable version.

`@rustbot` label +A-floating-point +C-feature-request +needs-fcp +relnotes +S-waiting-on-review +T-libs-api -T-libs
2022-12-21 14:27:57 +00:00
Ralf Jung 6f21ba4a06
less specific wording 2022-12-21 11:06:20 +01:00
Geoffry Song f5e776c3f7
Refer to "Waker" rather than "RawWaker" in drop comment 2022-12-20 14:51:24 -08:00
bors 1d12c3cea3 Auto merge of #105127 - Sp00ph:const_new, r=dtolnay
Make `VecDeque::new` const

(See #105072)
2022-12-20 20:25:42 +00:00
bors d6da428f34 Auto merge of #105381 - uweigand:s390x-ffi-vaarg, r=nikic
Implement va_list and va_arg for s390x FFI

Following the s390x ELF ABI and based on the clang implementation, provide appropriate definitions of va_list in library/core/src/ffi/mod.rs and va_arg handling in compiler/rustc_codegen_llvm/src/va_arg.rs.

Fixes the following test cases on s390x:
src/test/run-make-fulldeps/c-link-to-rust-va-list-fn src/test/ui/abi/variadic-ffi.rs

Fixes https://github.com/rust-lang/rust/issues/84628.
2022-12-20 17:09:11 +00:00
Oli Scherer c787de3bbd Fix some ~const usage in libcore 2022-12-20 15:01:37 +00:00
Anders Kaseorg 8c73ce6611 Update coerce_unsized tracking issue from #27732 to #18598
Issue #27732 was closed as a duplicate of #18598.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-12-19 23:09:47 -08:00
Ulrich Weigand eb22d70aed Implement va_list and va_arg for s390x FFI
Following the s390x ELF ABI and based on the clang implementation,
provide appropriate definitions of va_list in library/core/src/ffi/mod.rs
and va_arg handling in compiler/rustc_codegen_llvm/src/va_arg.rs.

Fixes the following test cases on s390x:
src/test/run-make-fulldeps/c-link-to-rust-va-list-fn
src/test/ui/abi/variadic-ffi.rs

Fixes https://github.com/rust-lang/rust/issues/84628.
2022-12-19 21:07:57 +01:00
Matthias Krüger 575b2a2232
Rollup merge of #105915 - andrewpollack:revert-105250-async-rm-resumety, r=tmandry
Revert "Replace usage of `ResumeTy` in async lowering with `Context`"

Reverts rust-lang/rust#105250
Fixes: #105501

Following instructions from [forge](https://forge.rust-lang.org/compiler/reviews.html#reverts).

This change introduced a breaking change that is not actionable nor relevant, and is blocking updates to our toolchain. Along with other comments on the CL marking issues that are fixed by reverts, reverting is best until these issues can be resolved

cc. `@Swatinem`
2022-12-19 20:55:00 +01:00
Matthias Krüger a81d0dc3cd
Rollup merge of #105902 - vincenzopalazzo:macros/pin_docs, r=eholk
docs: improve pin docs

Override https://github.com/rust-lang/rust/pull/104195 with a full cleanup of the git history, now it should be ready to be merged.

r? ``@eholk``

``@rustbot`` label +A-async-await
2022-12-19 20:54:59 +01:00
Matthias Krüger 3af45eeb98
Rollup merge of #105801 - zertosh:path_mut_os_str_doc_test, r=dtolnay
Realistic `Path::as_mut_os_str` doctest

With "Implement DerefMut for PathBuf" (#105018) now merged, it's
possible to exercise `Path::as_mut_os_str` (#105002) without going
through `into_boxed_path`.
2022-12-19 20:54:57 +01:00
Andrew Pollack 8441ca5d81
Revert "Replace usage of ResumeTy in async lowering with Context" 2022-12-19 11:24:59 -08:00
bors 7ab803891d Auto merge of #105698 - joboet:unsupported_threads_once, r=thomcc
Use a more efficient `Once` on platforms without threads

The current implementation uses an atomic queue and spins rather than panicking when calling `call_once` recursively. Since concurrency is not supported on platforms like WASM, `Once` can be implemented much more efficiently using just a single non-atomic state variable.
2022-12-19 16:46:57 +00:00
ch-iv 7fc6b0c9f3
docs: improve pin docs
Co-authored-by: <@ch-iv>
2022-12-19 15:46:44 +01:00
Dylan DPC 2a57493fa1
Rollup merge of #105889 - Nilstrieb:fmt-libtest, r=thomcc
Fix `uninlined_format_args` in libtest

Done using clippy with a quick manual review.
2022-12-19 14:41:37 +05:30
Dylan DPC f74bcfbdb1
Rollup merge of #105682 - thomcc:expose-ptr-fmt, r=RalfJung
Use `expose_addr()` in `fmt::Pointer`

Discussion in https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Should.20.60fmt.3A.3APointer.60.20expose.20the.20argument.3F on whether or not we should do this (still undecided).

CC `@RalfJung`
2022-12-19 14:41:34 +05:30
nils 5fb2d63d07
Fix uninlined_format_args in libtest 2022-12-19 08:58:40 +01:00
Matthias Krüger 63fdc9a857
Rollup merge of #105858 - scottmcm:extra-as-chunks-example, r=the8472
Another `as_chunks` example

I really liked this structure that dtolney brought up in #105316, so wanted to put it in the docs to help others use it.
2022-12-18 18:57:04 +01:00
bors 48b3c46126 Auto merge of #105638 - tavianator:fix-50619-again, r=Mark-Simulacrum
fs: Fix #50619 (again) and add a regression test

Bug #50619 was fixed by adding an end_of_stream flag in #50630.
Unfortunately, that fix only applied to the readdir_r() path.  When I
switched Linux to use readdir() in #92778, I inadvertently reintroduced
the bug on that platform.  Other platforms that had always used
readdir() were presumably never fixed.

This patch enables end_of_stream for all platforms, and adds a
Linux-specific regression test that should hopefully prevent the bug
from being reintroduced again.
2022-12-18 05:04:04 +00:00
Scott McMurray a37d42133c Another as_chunks example
I really liked this structure that dtolney brought up in #105316, so wanted to put it in the docs to help others use it.
2022-12-17 18:41:14 -08:00