Commit Graph

17211 Commits

Author SHA1 Message Date
bors
7442931d49 Auto merge of #133684 - RalfJung:rollup-j2tmrg7, r=RalfJung
Rollup of 6 pull requests

Successful merges:

 - #131698 (use stores of the correct size to set discriminants)
 - #133571 (Mark visionOS as supporting `std`)
 - #133655 (Eliminate print_expr_maybe_paren function from pretty printers)
 - #133667 (Remove unused code)
 - #133670 (bump hashbrown version)
 - #133673 (replace hard coded error id with `ErrorKind::DirectoryNotEmpty`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-30 21:08:45 +00:00
Ralf Jung
ec000a7e85
Rollup merge of #133670 - RalfJung:hashbrown, r=Amanieu
bump hashbrown version

This pulls in https://github.com/rust-lang/hashbrown/pull/586, in preparation for https://github.com/rust-lang/rust/issues/102575.

Cc ``@Amanieu``
2024-11-30 19:24:43 +01:00
bors
f981b2e27a Auto merge of #133659 - jieyouxu:rollup-576gh4p, r=jieyouxu
Rollup of 6 pull requests

Successful merges:

 - #131551 (Support input/output in vector registers of PowerPC inline assembly)
 - #132515 (Fix and undeprecate home_dir())
 - #132721 (CI: split x86_64-mingw job)
 - #133106 (changes old intrinsic declaration to new declaration)
 - #133496 (thread::available_parallelism for wasm32-wasip1-threads)
 - #133548 (Add `BTreeSet` entry APIs to match `HashSet`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-30 17:18:00 +00:00
Ralf Jung
67a29ac73d bump hashbrown version 2024-11-30 10:06:58 +01:00
许杰友 Jieyou Xu (Joe)
132fcd89b3
Rollup merge of #133548 - cuviper:btreeset-entry-api, r=Mark-Simulacrum
Add `BTreeSet` entry APIs to match `HashSet`

The following methods are added, along with the corresponding `Entry` implementation.

```rust
impl<T, A: Allocator + Clone> BTreeSet<T, A> {
    pub fn get_or_insert(&mut self, value: T) -> &T
    where
        T: Ord,
    {...}
    pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T
    where
        T: Borrow<Q> + Ord,
        Q: Ord,
        F: FnOnce(&Q) -> T,
    {...}

    pub fn entry(&mut self, value: T) -> Entry<'_, T, A>
    where
        T: Ord,
    {...}
}
```

Tracking issue #133549
Closes https://github.com/rust-lang/rfcs/issues/1490
2024-11-30 12:57:35 +08:00
许杰友 Jieyou Xu (Joe)
70b107910b
Rollup merge of #133496 - rust-wasi-web:wasi-available-parallelism, r=Amanieu
thread::available_parallelism for wasm32-wasip1-threads

The target has limited POSIX support and provides the `libc::sysconf` function which allows querying the number of available CPUs.
2024-11-30 12:57:35 +08:00
许杰友 Jieyou Xu (Joe)
9e716c2788
Rollup merge of #133106 - BLANKatGITHUB:intrinsic, r=RalfJung
changes old intrinsic declaration to new declaration

This pr is for issue #132735

It changes old `extern "intrinsic"` code block with new declaration.

There are other blocks that use old declaration but as the changes needed in single block is quite large I do them in parts
2024-11-30 12:57:34 +08:00
许杰友 Jieyou Xu (Joe)
9eeae42de2
Rollup merge of #132515 - kornelski:home_fix, r=jhpratt
Fix and undeprecate home_dir()

`home_dir()` has been deprecated for 6 years due to using `HOME` env var on Windows.

It's been a long time, and having a perpetually buggy and deprecated function in the standard library is not useful. I propose fixing and undeprecating it.

6 years seems more than long enough to warn users against relying on this function. The change in behavior is minor, and it's more of a bug fix than breakage. The old behavior is unlikely to be useful, and even if anybody actually needed to specifically use the non-standard `HOME` on Windows, they can trivially mitigate this change by reading the env var themselves.

----

Use of `USERPROFILE` is in line with the `home` crate: 37bc5f0232/crates/home/src/windows.rs (L12)

The `home` crate uses `SHGetKnownFolderPath` instead of `GetUserProfileDirectoryW`. AFAIK it doesn't make any difference in practice, because `SHGetKnownFolderPath` merely adds support for more kinds of folders, including virtual (non-filesystem) folders identified by a GUID, but the specific case of [`FOLDERID_Profile`](https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid#FOLDERID_Profile) is documented as a FIXED folder (a regular filesystem path). Just in case, I've added a note to documentation that the use of `GetUserProfileDirectoryW` can change.

I've used `CURRENT_RUSTC_VERSION` in a doccomment. `replace-version-placeholder` tool seems to perform a simple string replacement, so hopefully it'll get updated.
2024-11-30 12:57:33 +08:00
许杰友 Jieyou Xu (Joe)
6512836be0
Rollup merge of #133625 - RalfJung:custom-mir-debug-info, r=compiler-errors
custom MIR: add doc comment for debuginfo

This is a revival of https://github.com/rust-lang/rust/pull/117015
2024-11-30 12:56:55 +08:00
许杰友 Jieyou Xu (Joe)
dd99f11ef8
Rollup merge of #116161 - Soveu:varargs2, r=cjgillot
Stabilize `extended_varargs_abi_support`

I think that is everything? If there is any documentation regarding `extern` and/or varargs to correct, let me know, some quick greps suggest that there might be none.

Tracking issue: https://github.com/rust-lang/rust/issues/100189
2024-11-30 12:56:50 +08:00
bors
1fc691e6dd Auto merge of #133533 - BoxyUwU:bump-boostrap, r=jieyouxu,Mark-Simulacrum
Bump boostrap compiler to new beta

Currently failing due to something about the const stability checks and `panic!`. I'm not sure why though since I wasn't able to see any PRs merged in the past few days that would result in a `cfg(bootstrap)` that shouldn't be removed. cc `@RalfJung` #131349
2024-11-29 22:39:10 +00:00
Ralf Jung
6e449e18ad refine mir debuginfo docs 2024-11-29 14:01:53 +01:00
Camille GILLOT
c76f1f0b9b Doc comment custom MIR debuginfo.
and add a test for the constant case
2024-11-29 12:32:55 +01:00
Matthias Krüger
8ca5a907a5
Rollup merge of #133530 - timvisee:master, r=jhpratt
Use consistent wording in docs, use is zero instead of is 0

In documentation, wording of _"`rhs` is zero"_ and _"`rhs` is 0"_ is intermixed. This is especially visible [here](https://doc.rust-lang.org/std/primitive.usize.html#method.div_ceil).

This changes all occurrences to _"`rhs` is zero"_ for better readability.
2024-11-29 10:18:58 +01:00
Matthias Krüger
370fc13298
Rollup merge of #133466 - aksh1618:patch-1, r=thomcc
Fix typos in pin.rs
2024-11-29 10:18:56 +01:00
bors
d53f0b1d8e Auto merge of #123244 - Mark-Simulacrum:share-inline-never-generics, r=saethlin
Enable -Zshare-generics for inline(never) functions

This avoids inlining cross-crate generic items when possible that are
already marked inline(never), implying that the author is not intending
for the function to be inlined by callers. As such, having a local copy
may make it easier for LLVM to optimize but mostly just adds to binary
bloat and codegen time. In practice our benchmarks indicate this is
indeed a win for larger compilations, where the extra cost in dynamic
linking to these symbols is diminished compared to the advantages in
fewer copies that need optimizing in each binary.

It might also make sense it expand this with other heuristics (e.g.,
`#[cold]`) in the future, but this seems like a good starting point.

FWIW, I expect that doing cleanup in where we make the decision
what should/shouldn't be shared is also a good idea. Way too
much code needed to be tweaked to check this. But I'm hoping
to leave that for a follow-up PR rather than blocking this on it.
2024-11-28 21:44:34 +00:00
Mark Rousskov
4a216a25d1 Share inline(never) generics across crates
This reduces code sizes and better respects programmer intent when
marking inline(never). Previously such a marking was essentially ignored
for generic functions, as we'd still inline them in remote crates.
2024-11-28 13:43:05 -05:00
timvisee
89b20e95fd
Also use zero when referencing to capacity or length 2024-11-28 09:47:11 +01:00
timvisee
74cf503341
Use consistent wording in docs, use zero instead of 0 2024-11-28 09:39:33 +01:00
bors
f005c7437d Auto merge of #133561 - GuillaumeGomez:rollup-g4upmv4, r=GuillaumeGomez
Rollup of 12 pull requests

Successful merges:

 - #129409 (Expand std::os::unix::fs::chown() doc with a warning)
 - #133320 (Add release notes for Rust 1.83.0)
 - #133368 (Delay a bug when encountering an impl with unconstrained generics in `codegen_select`)
 - #133428 (Actually use placeholder regions for trait method late bound regions in `collect_return_position_impl_trait_in_trait_tys`)
 - #133512 (Add `as_array` and `as_mut_array` conversion methods to slices.)
 - #133519 (Check `xform_ret_ty` for WF in the new solver to improve method winnowing)
 - #133520 (Structurally resolve before applying projection in borrowck)
 - #133534 (extend group-forbid-always-trumps-cli test)
 - #133537 ([rustdoc] Fix new clippy lints)
 - #133543 ([AIX] create shim for lgammaf_r)
 - #133547 (rustc_span: Replace a `HashMap<_, ()>` with `HashSet`)
 - #133550 (print generated doc paths)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-28 03:36:03 +00:00
Guillaume Gomez
82d4eaeaff
Rollup merge of #133543 - mustartt:aix-lgammaf_r-shim, r=cuviper
[AIX] create shim for lgammaf_r

On AIX, we don't have 32bit floating point for re-entrant `lgammaf_r` but we do have the 64bit floating point re-entrant `lgamma_r` so we can use the 64bit version instead and truncate back to a 32bit float.

This solves the linker missing symbol for `.lgammaf_r` when testing and using these parts of the `std`.
2024-11-28 03:14:51 +01:00
Guillaume Gomez
b1c33f4f09
Rollup merge of #133512 - bjoernager:slice-as-array, r=Amanieu
Add `as_array` and `as_mut_array` conversion methods to slices.

Tracking issue: #133508

This PR unstably implements the `as_array` and `as_mut_array` converters to `[T]`, `*const [T]`, and `*mut [T]`.
2024-11-28 03:14:48 +01:00
Guillaume Gomez
10193a347a
Rollup merge of #129409 - grinapo:patch-1, r=Amanieu
Expand std::os::unix::fs::chown() doc with a warning

Include warning about losing setuid/gid when chowning, per POSIX.

It is about the underlying system call but it is rather useful to mention it in the help in case someone accidentally forgets (don't look at me :)).
2024-11-28 03:14:45 +01:00
Matthias Krüger
a8b690fada
Rollup merge of #133498 - GuillaumeGomez:missing-examples, r=joboet
Add missing code examples on `LocalKey`

r? ``@Amanieu``
2024-11-27 22:23:25 +01:00
Soveu
685f189b43 Stabilize extended_varargs_abi_support 2024-11-27 22:21:33 +01:00
Josh Stone
21b1ab1779 Fill in a BTreeSet::entry example 2024-11-27 12:22:21 -08:00
Josh Stone
82b8ea8a7a Add a tracking issue for btree_set_entry 2024-11-27 11:43:05 -08:00
Josh Stone
b0f8bd7438 Add BTreeSet entry APIs to match HashSet
* `fn get_or_insert(&mut self, value: T) -> &T`
* `fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T`
* `fn entry(&mut self, value: T) -> Entry<'_, T, A>` (+ `Entry` APIs)
2024-11-27 10:51:24 -08:00
Henry Jiang
527b6065ba
fmt 2024-11-27 12:02:02 -05:00
Boxy
22998f0785 update cfgs 2024-11-27 15:14:54 +00:00
Sebastian Urban
4342ec0cf2 Implement code review 2024-11-27 13:30:18 +01:00
Boxy
174ad448c7 replace placeholder version 2024-11-27 12:10:21 +00:00
bors
39cb3386dd Auto merge of #133369 - Zalathar:profiler-builtins-no-core, r=jieyouxu
Allow injecting a profiler runtime into `#![no_core]` crates

An alternative to #133300, allowing `-Cinstrument-coverage` to be used with `-Zbuild-std`.

The incompatibility between `profiler_builtins` and `#![no_core]` crates appears to have been caused by profiler_builtins depending on core, and therefore conflicting with core (or minicore).

But that's a false dependency, because the profiler doesn't contain any actual Rust code. So we can just mark the profiler itself as `#![no_core]`, and remove the incompatibility error.

---

For context, the error was originally added by #79958.
2024-11-27 10:19:38 +00:00
Matthias Krüger
dcebc5eddd
Rollup merge of #133449 - joboet:io_const_error, r=tgross35
std: expose `const_io_error!` as `const_error!`

ACP: https://github.com/rust-lang/libs-team/issues/205
Tracking issue: https://github.com/rust-lang/rust/issues/133448

Probably best reviewed commit-by-commit, the first one does the API change, the second does the mass-rename.
2024-11-27 08:13:47 +01:00
Michael Goulet
8a2f57f0c4
Rollup merge of #133402 - compiler-errors:drop-and-destruct, r=lcnr
Constify `Drop` and `Destruct`

r? `@lcnr` or `@fee1-dead`
2024-11-26 20:35:38 -05:00
bors
dd2837ec5d Auto merge of #133505 - compiler-errors:rollup-xjp8hdi, r=compiler-errors
Rollup of 12 pull requests

Successful merges:

 - #133042 (btree: add `{Entry,VacantEntry}::insert_entry`)
 - #133070 (Lexer tweaks)
 - #133136 (Support ranges in `<[T]>::get_many_mut()`)
 - #133140 (Inline ExprPrecedence::order into Expr::precedence)
 - #133155 (Yet more `rustc_mir_dataflow` cleanups)
 - #133282 (Shorten the `MaybeUninit` `Debug` implementation)
 - #133326 (Remove the `DefinitelyInitializedPlaces` analysis.)
 - #133362 (No need to re-sort existential preds in relate impl)
 - #133367 (Simplify array length mismatch error reporting (to not try to turn consts into target usizes))
 - #133394 (Bail on more errors in dyn ty lowering)
 - #133410 (target check_consistency: ensure target feature string makes some basic sense)
 - #133435 (miri: disable test_downgrade_observe test on macOS)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-26 21:57:32 +00:00
Gabriel Bjørnager Jensen
4b8ca28a1e Add '<[T]>::as_array', '<[T]>::as_mut_array', '<*const [T]>::as_array', and '<*mut [T]>::as_mut_array' conversion methods; 2024-11-26 21:49:28 +01:00
joboet
c14d137bfc
std: update internal uses of io::const_error! 2024-11-26 18:38:24 +01:00
Michael Goulet
c4e2b0c605
Rollup merge of #133435 - RalfJung:test_downgrade_observe, r=tgross35
miri: disable test_downgrade_observe test on macOS

Due to https://github.com/rust-lang/rust/issues/121950, this test can fail on Miri. The test is also quite slow on Miri (taking more than 30s) due to the high iteration count (a total of 2000), so let's reduce that a little.

Fixes https://github.com/rust-lang/rust/issues/133421
2024-11-26 12:03:45 -05:00
Michael Goulet
3013cd83cc
Rollup merge of #133282 - tgross35:maybe-uninit-debug, r=Amanieu
Shorten the `MaybeUninit` `Debug` implementation

Currently the `Debug` implementation for `MaybeUninit` winds up being pretty verbose. This struct:

```rust
#[derive(Debug)]
pub struct Foo {
    pub a: u32,
    pub b: &'static str,
    pub c: MaybeUninit<u32>,
    pub d: MaybeUninit<String>,
}
```

Prints as:

    Foo {
        a: 0,
        b: "hello",
        c: core::mem::maybe_uninit::MaybeUninit<u32>,
        d: core::mem::maybe_uninit::MaybeUninit<alloc::string::String>,
    }

The goal is just to be a standin for content so the path prefix doesn't add any useful information. Change the implementation to trim `MaybeUninit`'s leading path, meaning the new result is now:

    Foo {
        a: 0,
        b: "hello",
        c: MaybeUninit<u32>,
        d: MaybeUninit<alloc::string::String>,
    }
2024-11-26 12:03:42 -05:00
Michael Goulet
42459a7971
Rollup merge of #133136 - ChayimFriedman2:get-many-mut, r=Amanieu
Support ranges in `<[T]>::get_many_mut()`

As per T-libs-api decision in #104642.

I implemented that with a separate trait and not within `SliceIndex`, because doing that via `SliceIndex` requires adding support for range types that are (almost) always overlapping e.g. `RangeFrom`, and also adding fake support code for `impl SliceIndex<str>`.

An inconvenience that I ran into was that slice indexing takes the index by value, but I only have it by reference. I could change slice indexing to take by ref, but this is pretty much the hottest code ever so I'm afraid to touch it. Instead I added a requirement for `Clone` (which all index types implement anyway) and cloned. This is an internal requirement the user won't see and the clone should always be optimized away.

I also implemented `Clone`, `PartialEq` and `Eq` for the error type, since I noticed it does not do that when writing the tests and other errors in std seem to implement them. I didn't implement `Copy` because maybe we will want to put something non-`Copy` there.
2024-11-26 12:03:40 -05:00
Michael Goulet
5915190fed
Rollup merge of #133042 - cuviper:btreemap-insert_entry, r=Amanieu
btree: add `{Entry,VacantEntry}::insert_entry`

This matches the recently-stabilized methods on `HashMap` entries. I've
reused tracking issue #65225 for now, but we may want to split it.
2024-11-26 12:03:39 -05:00
Guillaume Gomez
a06532e639
Rollup merge of #133464 - RalfJung:whitespace-panic, r=joboet
std:🧵 avoid leading whitespace in some panic messages

This:
```
        panic!(
            "use of std:🧵:current() is not possible after the thread's
         local data has been destroyed"
        )
```
will print a newline followed by a bunch of spaces, since the entire string literal is interpreted literally.

I think the intention was to print the message without the newline and the spaces, so let's add some `\` to make that happen.

r? ``@joboet``
2024-11-26 15:32:17 +01:00
Guillaume Gomez
ddb6904ee4
Rollup merge of #133419 - CromFr:add-path-strip_prefix-test-example, r=Amanieu
Added a doc test for std::path::strip_prefix

I was about 90% sure `Path::new("/test/haha/foo.txt").strip_prefix("/te")` would return an Err, but I couldn't find an example to confirm this behaviour.

This should be an easy merge :)
2024-11-26 15:32:13 +01:00
Guillaume Gomez
02c3e6d087 Add missing code examples on LocalKey 2024-11-26 15:29:47 +01:00
Sebastian Urban
f0b7008648 thread::available_parallelism for wasm32-wasip1-threads
The target has limited POSIX support and provides the sysconf
function which allows querying the number of available
CPUs.
2024-11-26 14:06:05 +01:00
Aakarshit Uppal
f5216ee586
Fix typos in pin.rs 2024-11-25 17:37:30 +00:00
Ralf Jung
8bc8adb8dc std:🧵 avoid leading whitespace in some panic messages 2024-11-25 18:31:49 +01:00
Michael Goulet
bd44b632a8 Constify Drop and Destruct 2024-11-25 17:27:41 +00:00
joboet
d39afacbdf
std: expose const_io_error! as const_error!
ACP: rust-lang/libs-team#205
Tracking issue: #133448
2024-11-25 15:23:31 +01:00