Commit Graph

11740 Commits

Author SHA1 Message Date
Matthias Krüger
adf759bf6a fix couple of clippy findings:
filter_map_identity
iter_kv_map
needless_question_mark
redundant_at_rest_pattern
filter_next
derivable_impls
2023-07-23 10:50:14 +02:00
bors
8164cdb9ee Auto merge of #113746 - clarfonthey:ip_bits, r=thomcc
Add BITS, from_bits, to_bits to IP addresses

ACP: rust-lang/libs-team#235
Tracking issue: #113744
2023-07-22 13:18:50 +00:00
bors
42f5419dd2 Auto merge of #113954 - matthiaskrgr:rollup-e2r9suz, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #112490 (Remove `#[cfg(all())]` workarounds from `c_char`)
 - #113252 (Update the tracking issue for `const_cstr_from_ptr`)
 - #113442 (Allow limited access to `OsString` bytes)
 - #113876 (fix docs & example for `std::os::unix::prelude::FileExt::write_at`)
 - #113898 (Fix size_hint for EncodeUtf16)
 - #113934 (Multibyte character removal in String::pop and String::remove doctests)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-22 11:30:18 +00:00
Matthias Krüger
37cd63431c
Rollup merge of #113934 - ajtribick:string-pop-remove-multibyte, r=thomcc
Multibyte character removal in String::pop and String::remove doctests

I think it would be useful to have the doctests for the `String::pop()` and `String::remove()` methods demonstrate that they work on multibyte UTF-8 sequences.
2023-07-22 11:48:55 +02:00
Matthias Krüger
65b5cba0dd
Rollup merge of #113898 - ajtribick:encode_utf16_size_hint, r=cuviper
Fix size_hint for EncodeUtf16

More realistic upper and lower bounds, and handle the case where the iterator is located within a surrogate pair.

Resolves #113897
2023-07-22 11:48:54 +02:00
Matthias Krüger
746d507c72
Rollup merge of #113876 - darklyspaced:master, r=cuviper
fix docs & example for `std::os::unix::prelude::FileExt::write_at`

 Changelog:
 * used `File::create` instead of `File::read` to get a writeable file
 * explicity mentioned the bug with `pwrite64` in docs

Unfortunately, I don't think that there is really much we can do about this since the feature has already been stabilised.

We could potentially add a clippy lint warning people on Linux that using `write_at` with the `O_APPEND` flag does not exhibit the behaviour that they would have assumed.

fixes #113627
2023-07-22 11:48:54 +02:00
Matthias Krüger
0877d11e8d
Rollup merge of #113442 - epage:osstring, r=cuviper
Allow limited access to `OsString` bytes

This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString` as suggested in feedback from `os_str_bytes` crate in #111544.
2023-07-22 11:48:53 +02:00
Matthias Krüger
58a4be1dfb
Rollup merge of #113252 - tgross35:const-cstr-from-ptr-tracking-issue, r=ChrisDenton
Update the tracking issue for `const_cstr_from_ptr`

Tracking issue #101719 was for `const_cstr_methods`, #113219 is a new issue specific for `const_cstr_from_ptr`.

(I believe #101719 could also be closed)

```@rustbot``` label +T-libs-api +A-docs
2023-07-22 11:48:53 +02:00
Matthias Krüger
6003d6b60b
Rollup merge of #112490 - Alexendoo:c-char-cfg-all, r=cuviper
Remove `#[cfg(all())]` workarounds from `c_char`

Casts to type aliases are now ignored by Clippy https://github.com/rust-lang/rust-clippy/pull/8596

Closes https://github.com/rust-lang/rust-clippy/issues/8093
2023-07-22 11:48:52 +02:00
bors
dcb810414e Auto merge of #113224 - zachs18:vec_extend_remove_allocator_lifetime, r=cuviper
Remove lifetime bound for A for `impl Extend<&'a T> for Vec<T, A>`.

The lifetime of the references being copied from is unrelated to the allocator.

Compare with [`impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque<T, A>`](https://doc.rust-lang.org/alloc/collections/vec_deque/struct.VecDeque.html#impl-Extend%3C%26'a+T%3E-for-VecDeque%3CT,+A%3E) which does not have the `A: 'a` bound already.

Since `Allocator` is unstable, the only possible `A` on stable is `Global`, and `Global: 'static`, so this change is not (should not be) observable on stable (or without `#![feature(allocator_api)]`). [This is observable on nightly](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8c4aa166c6116a90593d2934d30cfeb3).
2023-07-22 09:44:50 +00:00
bors
e0922fba67 Auto merge of #113033 - JohnTitor:stabilize-unix-chown, r=cuviper
Stabilize chown functions (`unix_chown`)

Closes #88989
FCP is complete here: https://github.com/rust-lang/rust/issues/88989#issuecomment-1561125635
2023-07-22 07:27:01 +00:00
bors
a5e2eca40e Auto merge of #112699 - bluebear94:mf/more-is-sorted-tests, r=cuviper
Add more comprehensive tests for is_sorted and friends

See #53485 and #55045.
2023-07-21 23:25:04 +00:00
Andrew Tribick
f777339af3 Clarify logic on bytes:code units ratio 2023-07-21 23:49:31 +02:00
Andrew Tribick
2c145982a5 Demonstrate multibyte character removal in String::pop and String::remove doctests 2023-07-21 23:40:55 +02:00
bors
78f97c9b25 Auto merge of #113911 - matthiaskrgr:rollup-wk6cr7v, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #113380 (style-guide: clean up "must"/"should"/"may")
 - #113723 (Resurrect: rustc_llvm: Add a -Z `print-codegen-stats` option to expose LLVM statistics.)
 - #113780 (Support `--print KIND=PATH` command line syntax)
 - #113810 (Make {Rc,Arc}::allocator associated functions)
 - #113907 (Minor improvements to Windows TLS dtors)

Failed merges:

 - #113392 (style-guide: Some cleanups from the fmt-rfcs repo history)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-21 05:36:01 +00:00
Matthias Krüger
8c6ef1d2bc
Rollup merge of #113907 - ChrisDenton:tls, r=thomcc
Minor improvements to Windows TLS dtors

This does a few things:

* Moves keyless dtors into the same module as the `on_tls_callback` function because of dylib mess. We keep the `inline(never)` hints as a precaution (see also the issue they link to).
* Introduces the `HAS_DTORS` atomic as an optimization hint. This allows removing (most) of the TLS dtor code if no dtors are ever run. Otherwise it's always included because of a `#[used]`.
* Only run either keyed dtors or keyless dtors but not both. They should be mutually exclusive as keyed dtors are a fallback. I've also added an `assert` to make sure this is true.
2023-07-21 06:52:29 +02:00
Matthias Krüger
5ac3684abd
Rollup merge of #113810 - glandium:allocator-fn, r=Amanieu
Make {Rc,Arc}::allocator associated functions
2023-07-21 06:52:28 +02:00
bors
1a44b45987 Auto merge of #113106 - marcospb19:improve-path-with-extension-function, r=thomcc
std: remove an allocation in `Path::with_extension`

`Path::with_extension` used to reallocate (and copy) paths twice per call, now it does it once, by checking the size of the previous and new extensions it's possible to call `PathBuf::with_capacity` and pass the exact capacity required.

This also reduces the memory consumption of the path returned from `Path::with_extension` by using exact capacity instead of using amortized exponential growth.
2023-07-21 03:47:29 +00:00
bors
d26f0b79d5 Auto merge of #105571 - kadiwa4:remove_atomic_init_consts, r=Amanieu
remove the unstable `core::sync::atomic::ATOMIC_*_INIT` constants

Tracking issue: #99069

It would be weird to ever stabilise these as they are already deprecated.
2023-07-21 01:59:34 +00:00
Chris Denton
40e116489f
Minor improvements to Windows TLS dtors 2023-07-20 23:27:24 +01:00
Andrew Tribick
e6fa5c18b5 Fix size_hint for EncodeUtf16 2023-07-20 21:52:33 +02:00
Scott McMurray
34732e8560 Get !nonnull metadata consistently in slice iterators, without needing assumes 2023-07-20 11:33:49 -07:00
bors
6b53175b5d Auto merge of #113861 - ibraheemdev:mpsc-tls-bug, r=Mark-Simulacrum
Avoid tls access while iterating through mpsc thread entries

Upstream fix: https://github.com/crossbeam-rs/crossbeam/pull/802. Possibly fixes https://github.com/rust-lang/rust/issues/113726.
2023-07-20 12:30:12 +00:00
darklyspaced
7d17a263d1
added a problematic example 2023-07-20 14:25:50 +08:00
Matthias Krüger
538dcdad31
Rollup merge of #113787 - sanchopanca:process-command-windows-docs, r=ChrisDenton
Update documentation for std::process::Command's new method

In the current documentation, it's not specified that when creating a Command, the .exe extension can be omitted for Windows executables. However, for other types of executable files like .bat or .cmd, the complete filename including the extension must be provided.

I encountered it by noticing that `Command::new("wt").spawn().unwrap()` succeeds on my machine while `Command::new("code").spawn().unwrap()` panics. Turns out VS Code's entrypoint is .cmd file.

`resolve_exe` method mentions this behaviour in [a comment](e7fda447e7/library/std/src/sys/windows/process.rs (L425)), but it makes sense to mention it at a more visible place.

I've added this clarification to the documentation, which should make it more accurate and helpful for Rust developers working on the Windows platform.
2023-07-20 07:08:42 +02:00
darklyspaced
e7dc177442
fix docs & example for FileExt::write_at 2023-07-20 11:27:13 +08:00
Ibraheem Ahmed
fb31a1ac21 avoid tls access while iterating through mpsc thread entries 2023-07-19 11:50:29 -04:00
Esteban Küber
8eb5843a59 On nightly, dump ICE backtraces to disk
Implement rust-lang/compiler-team#578.

When an ICE is encountered on nightly releases, the new rustc panic
handler will also write the contents of the backtrace to disk. If any
`delay_span_bug`s are encountered, their backtrace is also added to the
file. The platform and rustc version will also be collected.
2023-07-19 14:10:07 +00:00
ltdk
b307014d48 Link methods in From impls 2023-07-18 20:58:35 -04:00
chenx97
d3727148a0 support for mips32r6 as a target_arch value 2023-07-18 18:58:18 +08:00
chenx97
c6e03cd951 support for mips64r6 as a target_arch value 2023-07-18 18:58:18 +08:00
Aleksandr Kovalev
5dea766dc9 Update documentation for std::process::Command's new method
In the current documentation, it's not specified that when creating
a Command, the .exe extension can be omitted for Windows executables.
However, for other types of executable files like .bat or .cmd,
the complete filename including the extension must be provided.

I encountered it by noticing that `Command::new("wt").spawn().unwrap()`
succeeds on my machine while `Command::new("code").spawn().unwrap()`
panics. Turns out VS Code's entrypoint is .cmd file.

`resolve_exe` method mentions this behaviour in a comment[1], but it
makes sense to mention it at more visible place.

I've added this clarification to the documentation, which should
make it more accurate and helpful for Rust developers
working on the Windows platform.

[1] e7fda447e7/library/std/src/sys/windows/process.rs (L425)
2023-07-18 11:32:04 +02:00
KaDiWa
c3462a0676
remove the unstable core::sync::atomic::ATOMIC_*_INIT constants 2023-07-18 09:45:52 +02:00
Mike Hommey
b1398cac9d Make {Rc,Arc}::allocator associated functions 2023-07-18 09:58:27 +09:00
bors
da6b55cc5e Auto merge of #89132 - Cyborus04:rc_allocator_support, r=Amanieu
Add support for allocators in `Rc` & `Arc`

Adds the ability for `std::rc:Rc`, `std::rc::Weak`, `std::sync::Arc`, and `std::sync::Weak` to live in custom allocators
2023-07-17 21:51:46 +00:00
Matthias Krüger
a7d31deb1d
Rollup merge of #113762 - alexpovel:master, r=Nilstrieb
Fix typo

Typo in a docstring, noticed [here](https://doc.rust-lang.org/std/result/enum.Result.html#method.map_or).
2023-07-17 00:14:07 +02:00
Matthias Krüger
80599b93a4
Rollup merge of #113750 - nipzu:italicize-sort-complexity, r=workingjubilee
Add missing italicization to `sort_unstable_by_key` complexity

Other methods like `sort_by_key` already had `m` italicized.
2023-07-17 00:14:05 +02:00
Alex Povel
d4184dde6a
Fix typo 2023-07-16 19:55:03 +02:00
nipzu
782bdfd791
Fix sort_unstable_by_key italicization 2023-07-16 12:07:04 +03:00
ltdk
30710c3ec4 Add BITS, from_bits, to_bits to IP addresses 2023-07-15 23:20:09 -04:00
Tshepang Mbambo
f05dc95346
collect.rs: remove "Basic usage" text where not useful 2023-07-16 05:08:25 +02:00
Matthias Krüger
a42b04c408
Rollup merge of #113662 - pedroclobo:vec-deque-rotate, r=thomcc
Rename VecDeque's `rotate_left` and `rotate_right` parameters

This pull request introduces a modification to the `VecDeque` collection, specifically the `rotate_left` and `rotate_right` functions, by renaming the parameter associated with these functions.

The rationale behind this change is to provide clearer and more consistent naming for the parameter that specifies the number of places to rotate the double-ended queue. By using `n` as the parameter name in both functions, it becomes easier to understand and remember the purpose of the parameter.
2023-07-14 19:33:26 +02:00
João M. Bezerra
6ffca76e9b std: add tests for Path::with_extension 2023-07-14 13:19:45 -03:00
bors
cca3373706 Auto merge of #113113 - Amanieu:box-vec-zst, r=Mark-Simulacrum
Eliminate ZST allocations in `Box` and `Vec`

This PR fixes 2 issues with `Box` and `RawVec` related to ZST allocations. Specifically, the `Allocator` trait requires that:
- If you allocate a zero-sized layout then you must later deallocate it, otherwise the allocator may leak memory.
- You cannot pass a ZST pointer to the allocator that you haven't previously allocated.

These restrictions exist because an allocator implementation is allowed to allocate non-zero amounts of memory for a zero-sized allocation. For example, `malloc` in libc does this.

Currently, ZSTs are handled differently in `Box` and `Vec`:
- `Vec` never allocates when `T` is a ZST or if the vector capacity is 0.
- `Box` just blindly passes everything on to the allocator, including ZSTs.

This causes problems due to the free conversions between `Box<[T]>` and `Vec<T>`, specifically that ZST allocations could get leaked or a dangling pointer could be passed to `deallocate`.

This PR fixes this by changing `Box` to not allocate for zero-sized values and slices. It also fixes a bug in `RawVec::shrink` where shrinking to a size of zero did not actually free the backing memory.
2023-07-14 01:59:08 +00:00
Matthias Krüger
8d1dd7e67b
Rollup merge of #113618 - tshepang:patch-1, r=jyn514
update ancient note
2023-07-14 01:03:08 +02:00
Matthias Krüger
efc3c71c16
Rollup merge of #112525 - hermitcore:devel, r=m-ou-se
Adjustments for RustyHermit

The interface between `libstd` and the OS changed and some changes are not correctly merged for RustHermit. For instance, the crate `hermit_abi` isn't defined as public, although it provided the socket interface for the application.

In addition, the support of thread::available_parallelism is realized. It returns the number of available processors.
2023-07-14 01:03:07 +02:00
Pedro Lobo
30a029e51b
Fix VecDeque's rotate_left and rotate_right panic tests 2023-07-13 18:39:09 +01:00
Pedro Lobo
c0a105be7c
Rename VecDeque's rotate_left and rotate_right parameters 2023-07-13 18:10:52 +01:00
Amanieu d'Antras
d24be14276 Eliminate ZST allocations in Box and Vec 2023-07-13 15:00:53 +01:00
Mark Rousskov
cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00