Commit Graph

16349 Commits

Author SHA1 Message Date
GnomedDev
43b8e04d46
[Clippy] Swap non_octal_unix_permissions to use diagnostic item instead of path 2024-09-19 13:13:43 +01:00
GnomedDev
5f85f73f63
[Clippy] Swap unnecessary_owned_empty_strings to use diagnostic item instead of path 2024-09-19 13:13:43 +01:00
GnomedDev
5f42ae13c1
[Clippy] Swap manual_strip to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev
89532c0f30
[Clippy] Swap unnecessary_to_owned to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
1890620b26
[Clippy] Swap instant_subtraction to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
372f68b6a6
[Clippy] Swap waker_clone_wake to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
5b55270225
[Clippy] Swap filter_map_bool_then to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
25da0e2e5d
[Clippy] Swap manual_while_let_some to use diagnostic items instead of paths 2024-09-19 13:13:42 +01:00
GnomedDev
15240a93c9
[Clippy] Swap repeat_vec_with_capacity to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
846ae57fc1
[Clippy] Swap VecArgs::hir to use diagnostic items instead of paths 2024-09-19 13:13:40 +01:00
GnomedDev
28f4c8293a
[Clippy] Swap single_char_add_str/format_push_string to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
037b9784b6
[Clippy] Swap manual_main_separator_str to use diagnostic item instead of path 2024-09-19 13:13:20 +01:00
GnomedDev
afe7907914
[Clippy] Swap redundant_clone to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
c891082029
[Clippy] Swap float_equality_without_abs to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
5e4716888a
[Clippy] Swap option_as_ref_deref to use diagnostic items instead of paths 2024-09-19 13:13:19 +01:00
GnomedDev
3ebff28f80
[Clippy] Swap lines_filter_map_ok to use a diagnostic item instead of path 2024-09-19 08:26:41 +01:00
GnomedDev
a786be5d06
[Clippy] Swap map_entry to use diagnostic items instead of paths 2024-09-19 08:26:37 +01:00
bors
f8192ba0d0 Auto merge of #130511 - bjoernager:const-char-encode-utf8, r=dtolnay
Support `char::encode_utf8` in const scenarios.

This PR implements [`rust-lang/rfcs#3696`](https://github.com/rust-lang/rfcs/pull/3696/).

This assumes [`const_slice_from_raw_parts_mut`](https://github.com/rust-lang/rust/issues/67456/).
2024-09-19 04:17:04 +00:00
Gabriel Bjørnager Jensen
fb475e4759
Mark and implement 'char::encode_utf8' as const. 2024-09-18 14:56:01 -07:00
Jubilee
4bd9de5512
Rollup merge of #130522 - GnomedDev:clippy-manual-retain-paths, r=compiler-errors
[Clippy] Swap `manual_retain` to use diagnostic items instead of paths

Part of https://github.com/rust-lang/rust-clippy/issues/5393, just a chore.
2024-09-18 14:32:28 -07:00
Jubilee
4d9ce4b4b3
Rollup merge of #130513 - shekhirin:fs-write-doc-comment, r=cuviper
Clarify docs for std::fs::File::write

This PR fixes the doc comment for `std::fs::File::write` method.
2024-09-18 14:32:27 -07:00
Jubilee
d972605735
Rollup merge of #130487 - cuviper:min-llvm-18, r=nikic
Update the minimum external LLVM to 18

With this change, we'll have stable support for LLVM 18 and 19.
For reference, the previous increase to LLVM 17 was #122649.

cc `@rust-lang/wg-llvm`
r? nikic
2024-09-18 14:32:27 -07:00
Jubilee
12b59e52bc
Rollup merge of #130476 - workingjubilee:more-lazy-methods-take-2, r=Amanieu
Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`

Tracking issue for `lazy_get`: https://github.com/rust-lang/rust/issues/129333
2024-09-18 14:32:26 -07:00
Jubilee
591ec6c9ce
Rollup merge of #129934 - ChrisDenton:remove-dir-all3, r=Amanieu
Win: Open dir for sync access in remove_dir_all

A small follow up to #129800.

We should explicitly open directories for synchronous access. We ultimately use `GetFileInformationByHandleEx` to read directories which should paper over any issues caused by using async directory reads (or else return an error) but it's better to do the right thing in the first place. Note though that `delete` does not read or write any data so it's not necessary there.
2024-09-18 14:32:25 -07:00
Jubilee
4722ad149e
Rollup merge of #97524 - ibraheemdev:thread-raw, r=ibraheemdev
Add `Thread::{into_raw, from_raw}`

Public API:
```rust
#![unstable(feature = "thread_raw", issue = "97523")]

impl Thread {
    pub fn into_raw(self) -> *const ();
    pub unsafe fn from_raw(ptr: *const ()) -> Thread;
}
```

ACP: https://github.com/rust-lang/libs-team/issues/200
2024-09-18 14:32:23 -07:00
Josh Stone
8bab397835 Revert "Add a hack to prevent proc_macro misopt in CI"
This reverts commit da8ac73d91.
2024-09-18 13:53:33 -07:00
Jubilee Young
f22797d3db library: Call it really_init_mut to avoid name collisions 2024-09-18 11:39:24 -07:00
Jubilee Young
d9cdb71497 library: Destabilize Lazy{Cell,Lock}::{force,deref}_mut 2024-09-18 11:39:21 -07:00
GnomedDev
a18564c198
[Clippy] Swap manual_retain to use diagnostic items instead of paths 2024-09-18 17:20:44 +01:00
bors
7fc70f870a Auto merge of #130497 - saethlin:alloc-zeroed-is-unstable, r=bjorn3
read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed

It was pointed out in https://github.com/rust-lang/rust/issues/128854#issuecomment-2278919897 that the magic volatile read was probably missing from `alloc_zeroed`. I can't find any mention of `alloc_zeroed` on https://github.com/rust-lang/rust/pull/86844, so it looks like this was just missed initially.
2024-09-18 14:48:50 +00:00
Alexey Shekhirin
96a3b48197
Clarify docs for std::fs::File::write 2024-09-18 15:15:54 +01:00
bors
aaed38b2a6 Auto merge of #129491 - StackOverflowExcept1on:master, r=m-ou-se
Pass `fmt::Arguments` by reference to `PanicInfo` and `PanicMessage`

Resolves #129330

For some reason after #115974 and #126732 optimizations applied to panic handler became worse and compiler stopped removing panic locations if they are not used in the panic message. This PR fixes that and maybe we can merge it into beta before rust 1.81 is released.

Note: optimization only works with `lto = "fat"`.

r? libs-api
2024-09-18 11:57:31 +00:00
bors
f68c28b6ce Auto merge of #129845 - scottmcm:redo-layout, r=Noratrieb
Take more advantage of the `isize::MAX` limit in `Layout`

Things like `padding_needed_for` are current implemented being super careful to handle things like `Layout::size` potentially being `usize::MAX`.

But now that #95295 has happened, that's no longer a concern.  It's possible to add two `Layout::size`s together without risking overflow now.

So take advantage of that to remove a bunch of checked math that's not actually needed.  For example, the round-up-and-add-next-size in `extend` doesn't need any overflow checks at all, just the final check for compatibility with the alignment.

(And while I was doing that I made it all unstably const, because there's nothing in `Layout` that's fundamentally runtime-only.)
2024-09-18 07:05:14 +00:00
Scott McMurray
18ca8bf8ee Take more advantage of the isize::MAX limit in Layout
Things like `padding_needed_for` are current implemented being super careful to handle things like `Layout::size` potentially being `usize::MAX`.

But now that 95295 has happened, that's no longer a concern.  It's possible to add two `Layout::size`s together without risking overflow now.

So take advantage of that to remove a bunch of checked math that's not actually needed.  For example, the round-up-and-add-next-size in `extend` doesn't need any overflow checks at all, just the final check for compatibility with the alignment.

(And while I was doing that I made it all unstably const, because there's nothing in `Layout` that's fundamentally runtime-only.)
2024-09-17 20:05:57 -07:00
Ben Kimock
46761442b0 read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed 2024-09-17 22:26:21 -04:00
Ibraheem Ahmed
0fa92b4159 add Thread::{into_raw, from_raw} 2024-09-17 18:50:06 -04:00
Matthias Krüger
0a35418d34
Rollup merge of #130481 - krtab:clamp_partial_ord, r=cuviper
Remove uneeded PartialOrd bound in cmp::Ord::clamp

There is a `Self: PartialOrd` bound in `Ord::clamp`, but it is already required by the trait itself. Likely a left-over from the const trait deletion in 76dbe29104.

Reported-by: `@noeensarguet`
2024-09-18 00:12:19 +02:00
bors
28e8f01c2a Auto merge of #130483 - matthiaskrgr:rollup-q1r0g0y, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #129477 (Fix fluent diagnostics)
 - #129674 (Add new_cyclic_in for Rc and Arc)
 - #130452 (Update Trusty target maintainers)
 - #130467 (Miri subtree update)
 - #130477 (Revert #129749 to fix segfault in LLVM)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-17 19:37:03 +00:00
Arthur Carcano
0c9a17689a Remove uneeded PartialOrd bound in cmp::Ord::clamp
There is a Self: PartialOrd bound in Ord::clamp, but it is already
required by the trait itself. Likely a left-over from the const trait
deletion in 76dbe29104.

Reported-by: @noeensarguet
2024-09-17 21:16:12 +02:00
Matthias Krüger
f6fd305282
Rollup merge of #129674 - matthewpipie:rc-arc-new-cyclic-in, r=dtolnay
Add new_cyclic_in for Rc and Arc

Currently, new_cyclic_in does not exist for Rc and Arc. This is an oversight according to https://github.com/rust-lang/wg-allocators/issues/132.

This PR adds new_cyclic_in for Rc and Arc. The implementation is almost the exact same as new_cyclic with some small differences to make it allocator-specific. new_cyclic's implementation has been replaced with a call to `new_cyclic_in(data_fn, Global)`.

Remaining questions:
* ~~Is requiring Allocator to be Clone OK? According to https://github.com/rust-lang/wg-allocators/issues/88, Allocators should be cheap to clone. I'm just hesitant to add unnecessary constraints, though I don't see an obvious workaround for this function since many called functions in new_cyclic_in expect an owned Allocator. I see Allocator.by_ref() as an option, but that doesn't work on when creating Weak { ptr: init_ptr, alloc: alloc.clone() }, because the type of Weak then becomes Weak<T, &A> which is incompatible.~~ Fixed, thank you `@zakarumych!` This PR no longer requires the allocator to be Clone.
* Currently, new_cyclic_in's documentation is almost entirely copy-pasted from new_cyclic, with minor tweaks to make it more accurate (e.g. Rc<T> -> Rc<T, A>). The example section is removed to mitigate redundancy and instead redirects to cyclic_in. Is this appropriate?
* ~~The comments in new_cyclic_in (and much of the implementation) are also copy-pasted from new_cyclic. Would it be better to make a helper method new_cyclic_in_internal that both functions call, with either Global or the custom allocator? I'm not sure if that's even possible, since the internal method would have to return Arc<T, Global> and I don't know if it's possible to "downcast" that to an Arc<T>. Maybe transmute would work here?~~ Done, thanks `@zakarumych`
* Arc::new_cyclic is #[inline], but Rc::new_cyclic is not. Which is preferred?
* nit: does it matter where in the impl block new_cyclic_in is defined?
2024-09-17 20:45:50 +02:00
Chayim Refael Friedman
d0a2ca4867 Implement ACP 429: add Lazy{Cell,Lock}::get[_mut] and force_mut
In the implementation of `force_mut`, I chose performance over safety.
For `LazyLock` this isn't really a choice; the code has to be unsafe.
But for `LazyCell`, we can have a full-safe implementation, but it will
be a bit less performant, so I went with the unsafe approach.
2024-09-17 09:40:34 -07:00
Matthias Krüger
11fe22c3fb
Rollup merge of #128535 - mmvanheusden:master, r=workingjubilee
Format `std::env::consts` docstrings with markdown backticks

This clarifies possible outputs the constants might be.

**Before:**
--
<img src="https://github.com/user-attachments/assets/8ee8772a-7562-42a2-89be-f8772b76dbd5" width="500px">

**After:**
--
<img src="https://github.com/user-attachments/assets/4632e5e2-db3e-4372-b13e-006cc1701eb1" width="500px">
2024-09-17 17:28:31 +02:00
bors
2e367d94f0 Auto merge of #130145 - fee1-dead-contrib:repeatn, r=lcnr,workingjubilee
`RepeatN`: use MaybeUninit

Closes #130140. Closes #130141.

Use `MaybeUninit` instead of `ManuallyDrop` for soundness.
2024-09-17 06:29:37 +00:00
Matthias Krüger
558b302af7
Rollup merge of #130448 - alilleybrinker:master, r=workingjubilee
fix: Remove duplicate `LazyLock` example.

The top-level docs for `LazyLock` included two lines of code, each with an accompanying comment, that were identical and with nearly- identical comments. This looks like an oversight from a past edit which was perhaps trying to rewrite an existing example but ended up duplicating rather than replacing, though I haven't gone back through the Git history to check.

This commit removes what I personally think is the less-clear of the two examples.
2024-09-17 03:58:47 +02:00
matthewpipie
6750f042ca
Update library/alloc/src/sync.rs
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2024-09-16 20:05:15 -05:00
bors
bde6bf2b07 Auto merge of #127633 - SamuelMarks:eq-exit-code, r=dtolnay
[library/std/src/process.rs] `PartialEq` for `ExitCode`

Converting a third-party CLI to a library so started passing around [`std::process::ExitCode`](https://doc.rust-lang.org/std/process/struct.ExitCode.html) in an `Either`. Then I realised the tests can't be modified to compare equality of `ExitCode`s.

This PR fixes this oversight.
2024-09-16 22:55:33 +00:00
Andrew Lilley Brinker
23e4e98d2c fix: Remove duplicate LazyLock example.
The top-level docs for `LazyLock` included two lines of code, each
with an accompanying comment, that were identical and with nearly-
identical comments. This looks like an oversight from a past edit
which was perhaps trying to rewrite an existing example but ended
up duplicating rather than replacing, though I haven't gone back
through the Git history to check.

This commit removes what I personally think is the less-clear of
the two examples.

Signed-off-by: Andrew Lilley Brinker <alilleybrinker@gmail.com>
2024-09-16 14:21:05 -07:00
Jubilee
0151cbe6e8
Rollup merge of #127879 - kornelski:bad-pointer-printf, r=workingjubilee
Document futility of printing temporary pointers

In the user forum I've seen a few people trying to understand how borrowing and moves are implemented by peppering their code with printing of `{:p}` of references to variables and expressions. This is a bad idea. It gives misleading and confusing results, because of autoderef magic, printing pointers of temporaries on the stack, and/or causes LLVM to optimize code differently when values had their address exposed.
2024-09-15 23:51:24 -07:00
bors
39b7669347 Auto merge of #130220 - RalfJung:float-classify, r=workingjubilee
simplify float::classify logic

I played around with the float-classify test in the hope of triggering x87 bugs by strategically adding `black_box`, and still the exact expression `@beetrees` suggested [here](https://github.com/rust-lang/rust/pull/129835#issuecomment-2325661597) remains the only case I found where we get the wrong result on x87. Curiously, this bug only occurs when MIR optimizations are enabled -- probably the extra inlining that does is required for LLVM to hit the right "bad" case in the backend. But even for that case, it makes no difference whether `classify` is implemented in the simple bit-pattern-based version or the more complicated version we had before.

Without even a single testcase that can distinguish our `classify` from the naive version, I suggest we switch to the naive version.
2024-09-16 03:36:03 +00:00
Matthias Krüger
f0fb411969
Rollup merge of #130339 - CAD97:unwind-choice, r=dtolnay
Add `core::panic::abort_unwind`

`abort_unwind` is like `catch_unwind` except that it aborts the process if it unwinds, using the `#[rustc_nounwind]` mechanism also used by `extern "C" fn` to abort unwinding. The docs attempt to make it clear when to (rarely) and when not to (usually) use the function.

Although usage of the function is discouraged, having it available will help to normalize the experience when abort_unwind shims are hit, as opposed to the current ecosystem where there exist multiple common patterns for converting unwinding into a process abort.

For further information and justification, see the linked ACP.

- Tracking issue: https://github.com/rust-lang/rust/issues/130338
- ACP: https://github.com/rust-lang/libs-team/issues/441
2024-09-15 20:55:13 +02:00