Commit Graph

11323 Commits

Author SHA1 Message Date
Yuki Okushi
816e0295b5
Rollup merge of #111301 - JohnBobbo96:cleanup_option_insert_methods, r=scottmcm
Remove calls to `mem::forget` and `mem::replace` in `Option::get_or_insert_with`.

This removes the unneeded calls to `mem::forget` and `mem::replace` in `Option::get_or_insert_with`.
2023-05-07 14:12:17 +09:00
Yuki Okushi
aef008aa6d
Rollup merge of #110094 - lukas-code:less-transmute, r=thomcc
clean up `transmute`s in `core`

* Use `transmute_unchecked` instead of `transmute_copy` for `MaybeUninit::transpose`.
* Use manual transmute for `Option<Ordering>` → `i8`.
2023-05-07 14:12:15 +09:00
Urgau
0b9feea0a4 Update hashbrown from 0.12.3 to 0.13.1 for std 2023-05-07 00:35:55 +02:00
John Bobbo
ec7fcdc959
Remove unneeded calls to mem::forget
and `mem::replace` in `Option::get_or_insert_with`.
2023-05-06 14:42:07 -07:00
ozkanonur
4e7c14fe9f enable rust_2018_idioms for doctests
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-07 00:12:29 +03:00
bors
31a4f2da57 Auto merge of #110907 - Bryanskiy:privacy_ef, r=petrochenkov
Populate effective visibilities in 'rustc_privacy'

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
2023-05-06 17:48:24 +00:00
Markus Everling
b5ee324d79 Always const-eval the gcd in slice::align_to_offsets 2023-05-06 17:31:51 +00:00
Lukas Markeffsky
7e3b93417c clean up transmutes in core 2023-05-06 13:28:38 +02:00
Scott McMurray
ec3a9bcdb7 Remove some assumes from slice iterators that don't do anything 2023-05-06 00:33:32 -07:00
Yuki Okushi
ea1a0d76af
Rollup merge of #111139 - fortanix:raoul/fix_mxcsr_configuration_dependent_timing, r=thomcc
Fix MXCSR configuration dependent timing

Dependent on the (potentially secret) data some vector instructions operate on, and the content in MXCSR, instruction retirement may be delayed by one cycle. This is a potential side channel.

This PR fixes this vulnerability for the `x86_64-fortanix-unknown-sgx` platform by loading MXCSR with `0x1fbf` through an `xrstor` instruction when the enclave is entered and executing an `lfence` immediately after. Other changes of the MXCSR happen only when the enclave is about to be exited and no vector instructions will be executed before it will actually do so. Users of EDP who change the MXCSR and do wish to defend against this side channel, will need to implement the software mitigation described [here](https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/mxcsr-configuration-dependent-timing.html).

cc: `@jethrogb` `@monokles`
2023-05-06 09:09:32 +09:00
Yuki Okushi
3d9a1de690
Rollup merge of #110830 - Freaky:freebsd-cpuset, r=thomcc
Add FreeBSD cpuset support to `std:🧵:available_concurrency`

Use libc::cpuset_getaffinity to determine the CPUs available to the current process.

The existing sysconf and sysctl paths are left as fallback.
2023-05-06 09:09:32 +09:00
Chris Denton
e314a3b21f
Sort windows_sys.lst alphabetically 2023-05-05 20:48:17 +01:00
Chris Denton
3ffb27ff89
Use new bindings 2023-05-05 20:48:16 +01:00
Chris Denton
e92ee03559
Generate windows-sys bindings 2023-05-05 20:48:16 +01:00
est31
5eb29c7f49 Migrate offset_of from a macro to builtin # syntax 2023-05-05 21:44:13 +02:00
bors
81c2459af6 Stabilize const_ptr_read 2023-05-05 20:36:21 +02:00
bors
4b94c23219 Auto merge of #111248 - Dylan-DPC:rollup-lbp0ui3, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #103056 (Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds)
 - #108801 (Implement RFC 3348, `c"foo"` literals)
 - #110773 (Reduce MIR dump file count for MIR-opt tests)
 - #110876 (Added default target cpu to `--print target-cpus` output and updated docs)
 - #111068 (Improve check-cfg implementation)
 - #111238 (btree_map: `Cursor{,Mut}::peek_prev` must agree)

Failed merges:

 - #110694 (Implement builtin # syntax and use it for offset_of!(...))

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-05 15:59:20 +00:00
Bryanskiy
cff85f22f5 Populate effective visibilities in rustc_privacy 2023-05-05 17:33:10 +03:00
Dylan DPC
c99ab29e6b
Rollup merge of #111238 - workingjubilee:fix-btree-cursormut-peek-prev, r=Amanieu
btree_map: `Cursor{,Mut}::peek_prev` must agree

Our `Cursor::peek_prev` and `CursorMut::peek_prev` must agree on how to behave when they are called on the "null element". This will fix rust-lang#111228.

r? `@Amanieu`
2023-05-05 18:40:36 +05:30
Dylan DPC
4891f02cff
Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors
Implement RFC 3348, `c"foo"` literals

RFC: https://github.com/rust-lang/rfcs/pull/3348
Tracking issue: #105723
2023-05-05 18:40:33 +05:30
Dylan DPC
3502e48321
Rollup merge of #103056 - beetrees:timespec-bug-fix, r=thomcc
Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds

Use `checked_{add,sub}_unsigned` in `checked_{add,sub}_duration` so that the correct result is returned when adding/subtracting durations with more than `i64::MAX` seconds.
2023-05-05 18:40:32 +05:30
bors
4a18324a4d Auto merge of #111113 - scottmcm:assume-align-offset, r=thomcc
`assume` the runtime range of `align_offset`

Found when I saw code with `align_to` having extraneous checks.

Demo that LLVM can't do this today: <https://rust.godbolt.org/z/6dnG749bq>

(It's filed as https://github.com/llvm/llvm-project/issues/62502.)
2023-05-05 12:50:59 +00:00
Scott McMurray
a1e5c65aa4 assume the runtime range of align_offset
Found when I saw code with `align_to` having extraneous checks.
2023-05-05 04:22:51 -07:00
Jubilee Young
00cb59b53b btree_map: Cursor{,Mut}::peek_prev must agree
Our `Cursor::peek_prev` and `CursorMut::peek_prev` must agree
on how to behave when they are called on the "null element".
2023-05-04 23:56:04 -07:00
Yuki Okushi
17a6c08718
Rollup merge of #111213 - WaffleLapkin:fixup_dates, r=scottmcm
Fixup "since" dates for `array_tuple_conv` feature

Fixes a mistake from #97594
2023-05-05 12:46:28 +09:00
Yuki Okushi
d98e174497
Rollup merge of #110946 - RalfJung:tls-realstd, r=m-ou-se
avoid duplicating TLS state between test std and realstd

This basically re-lands https://github.com/rust-lang/rust/pull/100201 and https://github.com/rust-lang/rust/pull/106638, which got reverted by https://github.com/rust-lang/rust/pull/110861. This works around 2 Miri limitations:
- Miri doesn't support the magic linker section that our Windows TLS support relies on, and instead knows where in std to find the symbol that stores the thread callback.
- For macOS, Miri only supports at most one destructor to be registered per thread.

The 2nd would not be very hard to fix (though the intended destructor order is unclear); the first would be a lot of work to fix. Neither of these is a problem for regular Rust code, but in the std test suite we have essentially 2 copies of the std code and then these both become issues. To avoid that we have the std test crate import the TLS code from the real std instead of having its own copy.

r? ``````@m-ou-se``````
2023-05-05 12:46:25 +09:00
John Millikin
bfa3e8add4 Stabilize feature nonzero_negation_ops 2023-05-05 08:33:51 +09:00
Scott McMurray
1cfcf71e04 Add an example that depends on is_ascii in a const 2023-05-04 14:46:17 -07:00
Scott McMurray
370d31b93d Constify [u8]::is_ascii (unstably)
UTF-8 checking in `const fn`-stabilized back in 1.63, but apparently somehow ASCII checking was never const-ified, despite being simpler.
2023-05-04 14:30:20 -07:00
Maybe Waffle
ad0388df5e Fixup "since" dates for array_tuple_conv feature 2023-05-04 18:25:21 +00:00
Matthias Krüger
ab80b7a53d
Rollup merge of #111186 - jmillikin:nonzero-is-positive, r=dtolnay
Add `is_positive` method for signed non-zero integers.

ACP: https://github.com/rust-lang/libs-team/issues/105
2023-05-04 19:18:22 +02:00
Matthias Krüger
ea0b6504fa
Rollup merge of #111009 - scottmcm:ascii-char, r=BurntSushi
Add `ascii::Char` (ACP#179)

ACP second: https://github.com/rust-lang/libs-team/issues/179#issuecomment-1527900570
New tracking issue: https://github.com/rust-lang/rust/issues/110998

For now this is an `enum` as `@kupiakos` [suggested](https://github.com/rust-lang/libs-team/issues/179#issuecomment-1527959724), with the variants under a different feature flag.

There's lots more things that could be added here, and place for further doc updates, but this seems like a plausible starting point PR.

I've gone through and put an `as_ascii` next to every `is_ascii`: on `u8`, `char`, `[u8]`, and `str`.

As a demonstration, made a commit updating some formatting code to use this: https://github.com/scottmcm/rust/commit/ascii-char-in-fmt (I don't want to include that in this PR, though, because that brings in perf questions that don't exist if this is just adding new unstable APIs.)
2023-05-04 19:18:21 +02:00
Matthias Krüger
bf72b64b96
Rollup merge of #110651 - durin42:xunit-stdout, r=cuviper
libtest: include test output in junit xml reports

Fixes #110336.
2023-05-04 19:18:18 +02:00
Matthias Krüger
0098cd4e83
Rollup merge of #108865 - Zoxc:library-dummy-crate, r=jyn514
Add a `sysroot` crate to represent the standard library crates

This adds a dummy crate named `sysroot` to represent the standard library target instead of using the `test` crate. This allows the removal of `proc_macro` as a dependency of `test` allowing these 2 crates to build in parallel saving around 9 seconds locally.
2023-05-04 19:18:17 +02:00
John Millikin
70523fb0b1 Add is_positive method for signed non-zero integers. 2023-05-04 19:37:33 +09:00
Scott McMurray
8c781b0906 Add the basic ascii::Char type 2023-05-03 22:09:33 -07:00
Kisaragi Marine
4cab0dce2f
stdarch: update submodule, take 4 2023-05-04 13:52:21 +09:00
Manish Goregaokar
54cf561889
Rollup merge of #111127 - xfix:const-slice-flatten, r=scottmcm
Constify slice flatten method

ACP: https://github.com/rust-lang/libs-team/issues/218
2023-05-03 16:42:51 -07:00
Manish Goregaokar
3fa0c087e4
Rollup merge of #105695 - joboet:remove_generic_parker, r=m-ou-se
Replace generic thread parker with explicit no-op parker

With #98391 merged, all platforms supporting threads now have their own parking implementations. Therefore, the generic implementation can be removed. On the remaining platforms (really just WASM without atomics), parking is not supported, so calls to `thread::park` now return instantly, which is [allowed by their API](https://doc.rust-lang.org/nightly/std/thread/fn.park.html). This is a change in behaviour, as spurious wakeups do not currently occur since all platforms guard against them. It is invalid to depend on this, but I'm still going to tag this as libs-api for confirmation.

````@rustbot```` label +T-libs +T-libs-api +A-atomic

r? rust-lang/libs
2023-05-03 16:42:48 -07:00
Manish Goregaokar
38bbc39895
Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3
Add cross-language LLVM CFI support to the Rust compiler

This PR adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395).

It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653.

Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto).

Thank you again, ``@bjorn3,`` ``@nikic,`` ``@samitolvanen,`` and the Rust community for all the help!
2023-05-03 16:42:48 -07:00
Manish Goregaokar
84d8159ebf
Rollup merge of #97594 - WaffleLapkin:array_tuple_conv, r=ChrisDenton
Implement tuple<->array convertions via `From`

This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths:
```rust
impl<T> From<[T; 1]> for (T,) { ... }
impl<T> From<[T; 2]> for (T, T) { ... }
/* ... */
impl<T> From<[T; 12]> for (T, T, T, T, T, T, T, T, T, T, T, T) { ... }

impl<T> From<(T,)> for [T; 1] { ... }
impl<T> From<(T, T)> for [T; 2] { ... }
/* ... */
impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for [T; 12] { ... }
```

IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.
2023-05-03 16:42:47 -07:00
DaniPopes
fd80ab7f13
Specialize ToString implementation for fmt::Arguments 2023-05-04 00:43:17 +02:00
Ramon de C Valle
004aa15b47 Add cross-language LLVM CFI support to the Rust compiler
This commit adds cross-language LLVM Control Flow Integrity (CFI)
support to the Rust compiler by adding the
`-Zsanitizer-cfi-normalize-integers` option to be used with Clang
`-fsanitize-cfi-icall-normalize-integers` for normalizing integer types
(see https://reviews.llvm.org/D139395).

It provides forward-edge control flow protection for C or C++ and Rust
-compiled code "mixed binaries" (i.e., for when C or C++ and Rust
-compiled code share the same virtual address space). For more
information about LLVM CFI and cross-language LLVM CFI support for the
Rust compiler, see design document in the tracking issue #89653.

Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and
-Zsanitizer-cfi-normalize-integers, and requires proper (i.e.,
non-rustc) LTO (i.e., -Clinker-plugin-lto).
2023-05-03 22:41:29 +00:00
Maybe Waffle
de105164ea Mention array<->tuple convs in docs 2023-05-03 20:34:47 +00:00
Raoul Strackx
97eab4db84 Fix MXCSR configuration dependent timing
Some data-independent timing vector instructions may have subtle data-dependent
timing due to MXCSR configuration; dependent on (potentially secret) data
instruction retirement may be delayed by one cycle.
2023-05-03 17:11:15 +02:00
Gil Shoshan
af5de855a3 Remove unnecessary Send bound 2023-05-03 15:47:11 +03:00
Konrad Borowski
4fec8a35b6 Constify slice flatten method 2023-05-03 12:33:15 +02:00
Chris Denton
109a47fc9d
Use from_wide_to_user_path in read_link 2023-05-03 11:31:41 +01:00
Konrad Borowski
4603f0b8af Inline SocketAddr methods 2023-05-03 11:56:55 +02:00
Chris Denton
6e377849c0
Correctly convert an NT path to a Win32 path
This can be done by simply changing the `\??\` prefix to `\\?\` and then attempting to convert to a user path.

Currently it simply strips off the prefix which could lead to the wrong path being returned (e.g. if it's not a drive path or if the path contains trailing spaces, etc).
2023-05-03 10:24:56 +01:00
bors
b4571bed99 Auto merge of #109729 - fortanix:raoul/bugfix_libtest_json_synchronization, r=pietroalbini
Ensure test library issues json string line-by-line

#108659 introduces a custom test display implementation. It does so by using libtest to output json. The stdout is read line by line and parsed. The code trims the line read and checks whether it starts with a `{` and ends with a `}`.

Unfortunately, there is a race condition in how json data is written to stdout. The `write_message` function calls `self.out.write_all` repeatedly to write a buffer that contains (partial) json data, or a new line. There is no lock around the `self.out.write_all` functions. Similarly, the `write_message` function itself is called with only partial json data. As these functions are called from concurrent threads, this may result in json data ending up on the same stdout line. This PR avoids this by buffering the complete json data before issuing a single `self.out.write_all`.

(#109484 implemented a partial fix for this issue; it only avoids that failed json parsing would result in a panic.)

cc: `@jethrogb,` `@pietroalbini`
2023-05-02 21:28:53 +00:00
Maybe Waffle
04305c05d3 Remove [] <-> () From convertions
... with this convertions some tests fail :(
2023-05-02 14:37:40 +00:00
Maybe Waffle
4d04a062c8 Use metavar ${count(x)} instead of reimplementing it 2023-05-02 14:37:40 +00:00
Maybe Waffle
9fba2622a0 implement tuple<->array convertions via From 2023-05-02 14:37:40 +00:00
Deadbeef
d5e7206ca6 rm diag item, use lang item 2023-05-02 10:32:07 +00:00
Deadbeef
a49570fd20 fix TODO comments 2023-05-02 10:32:07 +00:00
Deadbeef
8ff3903643 initial step towards implementing C string literals 2023-05-02 10:30:09 +00:00
Dylan DPC
40c4ed4994
Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`

Split from #109842.

r? ``@compiler-errors``
2023-05-02 11:44:52 +05:30
Dylan DPC
f47a63ca3d
Rollup merge of #110895 - Ayush1325:thread-local-fix, r=thomcc
Remove `all` in target_thread_local cfg

I think it was left there by mistake after the previous refactoring. I just came across it while rebasing to master.
2023-05-02 11:44:52 +05:30
Dylan DPC
b727132e23
Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwU
Add `ConstParamTy` trait

This is a bit sketch, but idk.
r? `@BoxyUwU`

Yet to be done:
- [x] ~~Figure out if it's okay to implement `StructuralEq` for primitives / possibly remove their special casing~~ (it should be okay, but maybe not in this PR...)
- [ ] Maybe refactor the code a little bit
- [x] Use a macro to make impls a bit nicer

Future work:
- [ ] Actually™ use the trait when checking if a `const` generic type is allowed
- [ ] _Really_ refactor the surrounding code
- [ ] Refactor `marker.rs` into multiple modules for each "theme" of markers
2023-05-02 11:44:50 +05:30
Dylan DPC
f916c44aec
Rollup merge of #105076 - mina86:a, r=scottmcm
Refactor core::char::EscapeDefault and co. structures

Change core::char::{EscapeUnicode, EscapeDefault and EscapeDebug}
structures from using a state machine to computing escaped sequence
upfront and during iteration just going through the characters.

This is arguably simpler since it’s easier to think about having
a buffer and start..end range to iterate over rather than thinking
about a state machine.

This also harmonises implementation of aforementioned iterators and
core::ascii::EscapeDefault struct.  This is done by introducing a new
helper EscapeIterInner struct which holds the buffer and offers simple
methods for iterating over range.

As a side effect, this probably optimises Display implementation for
those types since rather than calling write_char repeatedly, write_str
is invoked once.  On 64-bit platforms, it also reduces size of some of
the structs:

    | Struct                     | Before | After |
    |----------------------------+--------+-------+
    | core::char::EscapeUnicode  |     16 |    12 |
    | core::char::EscapeDefault  |     16 |    12 |
    | core::char::EscapeDebug    |     16 |    16 |

My ulterior motive and reason why I started looking into this is
addition of as_str method to the iterators.  With this change this
will became trivial.  It’s also going to be trivial to implement
DoubleEndedIterator if that’s ever desired.
2023-05-02 11:44:50 +05:30
bors
1cb63572d2 Auto merge of #106075 - nbdd0121:ffi-unwind, r=joshtriplett
Partial stabilisation of `c_unwind`

The stabilisation report is at https://github.com/rust-lang/rust/issues/74990#issuecomment-1363473645

cc `@rust-lang/wg-ffi-unwind`
2023-05-02 00:45:04 +00:00
bors
d6ddee637b Auto merge of #111066 - matthiaskrgr:rollup-4k6rj23, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109540 (std docs: edit `PathBuf::set_file_name` example)
 - #110093 (Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`)
 - #110987 (update wasi_clock_time_api ref.)
 - #111038 (Leave promoteds untainted by errors when borrowck fails)
 - #111042 (Add `#[no_coverage]` to the test harness's `fn main`)
 - #111057 (Make sure the implementation of TcpStream::as_raw_fd is fully inlined)
 - #111065 (Explicitly document how Send and Sync relate to references)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-01 20:35:53 +00:00
Matthias Krüger
15eebac9d9
Rollup merge of #111065 - est31:send_mut_ref, r=m-ou-se
Explicitly document how Send and Sync relate to references

Some of these relations were already mentioned in the text, but that Send is implemented for &mut impl Send was not mentioned, neither did the docs list when &T is Sync. Inspired by the discussion in #110961.

[Proof](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ed77bfc3c77ba664400ebc2734f500e6) based on `@lukas-code` 's [example](https://github.com/rust-lang/rust/pull/110961#discussion_r1181220662).
2023-05-01 17:10:25 +02:00
Matthias Krüger
02134611ce
Rollup merge of #111057 - xfix:tcpstream-as-raw-fd-inline, r=m-ou-se
Make sure the implementation of TcpStream::as_raw_fd is fully inlined

Currently the following function:

```rust
use std::os::fd::{AsRawFd, RawFd};
use std::net::TcpStream;

pub fn as_raw_fd(socket: &TcpStream) -> RawFd {
    socket.as_raw_fd()
}
```

Is optimized to the following:

```asm
example::as_raw_fd:
        push    rax
        call    qword ptr [rip + <std::net::tcp::TcpStream as std::sys_common::AsInner<std::sys_common::net::TcpStream>>::as_inner@GOTPCREL]
        mov     rdi, rax
        call    qword ptr [rip + std::sys_common::net::TcpStream::socket@GOTPCREL]
        mov     rdi, rax
        pop     rax
        jmp     qword ptr [rip + _ZN73_$LT$std..sys..unix..net..Socket$u20$as$u20$std..os..fd..raw..AsRawFd$GT$9as_raw_fd17h633bcf7e481df8bbE@GOTPCREL]
```

I think it would make more sense to inline trivial functions used within `TcpStream::AsRawFd`.
2023-05-01 17:10:25 +02:00
Matthias Krüger
8a9e696f43
Rollup merge of #110987 - infdahai:wasi_clock_time, r=m-ou-se
update wasi_clock_time_api ref.

Closes #110809

>Preview0 corresponded to the import module name wasi_unstable. It was also called snapshot_0 in some places. It was short-lived, and the changes to preview1 were minor, so the focus here is on preview1.

we use the `preview1` doc according to the above quote form [WASI legacy Readme](https://github.com/WebAssembly/WASI/blob/main/legacy/README.md) .
2023-05-01 17:10:23 +02:00
Matthias Krüger
9e863aefba
Rollup merge of #110093 - beetrees:set-times-32-bit, r=joshtriplett
Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`

Add support to `set_times` for 64-bit `time_t` on 32-bit glibc Linux platforms which have a 32-bit `time_t`. Split from #109773.

Tracking issue: #98245
2023-05-01 17:10:22 +02:00
Matthias Krüger
4da8a7a370
Rollup merge of #109540 - marcospb19:edit-Path-with_file_name-example, r=m-ou-se
std docs: edit `PathBuf::set_file_name` example

To make explicit that `set_file_name` might replace or remove the
extension, not just the file stem.

Also edit docs for `Path::with_file_name`, which calls `set_file_name`.
2023-05-01 17:10:22 +02:00
est31
09c50a0ae3 Explicitly document how Send and Sync relate to references
Some of these relations were already mentioned in the text, but that
Send is implemented for &mut impl Send was not mentioned,
neither did the docs list when &T is Sync.
2023-05-01 16:41:06 +02:00
bors
6db1e5e771 Auto merge of #111010 - scottmcm:mem-replace-simpler, r=WaffleLapkin
Make `mem::replace` simpler in codegen

Since they'd mentioned more intrinsics for simplifying stuff recently,
r? `@WaffleLapkin`

This is a continuation of me looking at foundational stuff that ends up with more instructions than it really needs.  Specifically I noticed this one because `Range::next` isn't MIR-inlining, and one of the largest parts of it is a `replace::<usize>` that's a good dozen instructions instead of the two it could be.

So this means that `ptr::write` with a `Copy` type no longer generates worse IR than manually dereferencing (well, at least in LLVM -- MIR still has bonus pointer casts), and in doing so means that we're finally down to just the two essential `memcpy`s when emitting `mem::replace` for a large type, rather than the bonus-`alloca` and three `memcpy`s we emitted before this ([or the 6 we currently emit in 1.69 stable](https://rust.godbolt.org/z/67W8on6nP)).  That said, LLVM does _usually_ manage to optimize the extra code away.  But it's still nice for it not to have to do as much, thanks to (for example) not going through an `alloca` when `replace`ing a primitive like a `usize`.

(This is a new intrinsic, but one that's immediately lowered to existing MIR constructs, so not anything that MIRI or the codegen backends or MIR semantics needs to do work to handle.)
2023-05-01 14:29:15 +00:00
Maybe Waffle
c31754651d Fix StructuralEq impls for &T, [T] and [T; N]
(`StructuralEq` is shallow for some reason...)
2023-05-01 11:45:51 +00:00
Konrad Borowski
500a8e1336 Inline AsRawFd implementations 2023-05-01 13:28:19 +02:00
Konrad Borowski
3abc30719e Inline socket function implementations 2023-05-01 13:27:02 +02:00
Konrad Borowski
174c0e86ca Inline AsInner implementations 2023-05-01 13:25:09 +02:00
Raoul Strackx
a18b750de2 Ensure test library issues json string line-by-line 2023-05-01 10:27:37 +02:00
Scott McMurray
5292d48b85 Codegen fewer instructions in mem::replace 2023-04-30 22:33:04 -07:00
John Millikin
5a0419352c Stabilize feature cstr_is_empty 2023-05-01 11:00:16 +09:00
Matthias Krüger
1b262b8b56
Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber
Tweak await span to not contain dot

Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue.

Fixes #110761

This mostly touches a bunch of tests to tighten their `await` span.
2023-05-01 01:09:47 +02:00
bors
f2eb9f85b9 Auto merge of #111017 - matthiaskrgr:rollup-yy9updi, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110118 (download-rustc: Give a better error message if artifacts can't be dowloaded)
 - #110631 (rustdoc: catch and don't blow up on impl Trait cycles)
 - #110732 (Make ConstProp some tests unit.)
 - #110996 (bootstrap: Fix compile error: unused-mut)
 - #110999 (Output some bootstrap messages on stderr)
 - #111000 (Remove unneeded function call in `core::option`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-30 16:54:16 +00:00
Matthias Krüger
d8d24d498f
Rollup merge of #111000 - JohnBobbo96:core_option_unneeded_function, r=jyn514
Remove unneeded function call in `core::option`.

r? `@jyn514`
2023-04-30 16:25:48 +02:00
bors
831c9298c8 Auto merge of #103406 - Jules-Bertholet:from_clone_slice_to_box, r=dtolnay
Loosen `From<&[T]> for Box<[T]>` bound to `T: Clone`

Also loosens `From<Cow<'_, [T]>> for Box<[T]>`'s bound.

[Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/From.3C.26.5BT.5D.3E.20impls.20consistency)
2023-04-30 13:58:00 +00:00
Michal Nazarewicz
76c9947024 a bit more usize::from 2023-04-30 15:40:54 +02:00
bors
c1bb0e0911 Auto merge of #110935 - scottmcm:always-ord, r=Mark-Simulacrum
`inline(always)` for `lt`/`le`/`ge`/`gt` on integers and floats

I happened to notice one of these not getting inlined as part of `Range::next` in <https://rust.godbolt.org/z/4WKWWxj1G>
```rust
    bb1: {
        StorageLive(_5);
        _6 = &mut _4;
        StorageLive(_21);
        StorageLive(_14);
        StorageLive(_15);
        _15 = &((*_6).0: usize);
        StorageLive(_16);
        _16 = &((*_6).1: usize);
        _14 = <usize as PartialOrd>::lt(move _15, move _16) -> bb7;
    }
```

So since a call for something that's just one instruction is never the right choice, `#[inline(always)]` seems appropriate, like we have it on things like the rotate methods on integers.
2023-04-30 07:43:18 +00:00
Michal Nazarewicz
4d0f7e2f39 review 2023-04-30 03:59:11 +02:00
Matthias Krüger
f7208139de
Rollup merge of #110997 - scottmcm:slice-iter-comments, r=the8472
Improve internal field comments on `slice::Iter(Mut)`

I wrote these in a previous PR that I ended up withdrawing, so might as well submit them separately.

`@bors` rollup=always
2023-04-30 01:14:59 +02:00
John Bobbo
a4f391d4de
Remove unneeded function call in core::option. 2023-04-29 15:38:04 -07:00
Jules Bertholet
18d2c60975
cfg-gate BoxFromSlice trait
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2023-04-29 18:10:10 -04:00
Scott McMurray
57aac3f671 Improve internal field comments on slice::Iter(Mut)
I wrote these in a previous PR that I ended up withdrawing, so might as well submit them separately.
2023-04-29 12:50:53 -07:00
Gary Guo
723aee2e56 Partial stabilisation of c_unwind 2023-04-29 13:01:44 +01:00
clundro
bca9387e1c update wasi_clock_time_api ref.
Signed-off-by: clundro <859287553@qq.com>
2023-04-29 19:04:16 +08:00
Deadbeef
e92806704b fix rustdoc and core test 2023-04-29 08:50:56 +00:00
Dylan DPC
339786e012
Rollup merge of #110958 - compiler-errors:stdlib-refinement, r=cuviper
Make sure that some stdlib method signatures aren't accidental refinements

In the process of implementing https://rust-lang.github.io/rfcs/3245-refined-impls.html, I found a bunch of stdlib implementations that accidentally "refined" their method signatures by dropping  (unnecessary) bounds.

This isn't currently a problem, but may become one if/when method  signature refining is stabilized in the future. Shouldn't hurt to make these signatures a bit more accurate anyways.

NOTE (just to be clear lol): This does not affect behavior at all, since we don't actually take advantage of refined implementations yet!
2023-04-29 11:27:55 +05:30
Augie Fackler
58537cde06 junit: fix typo in comment and don't include output for passes when not requested 2023-04-28 18:37:26 -04:00
Michael Goulet
33871c97ab Make sure that signatures aren't accidental refinements 2023-04-28 17:36:49 +00:00
Pietro Albini
a7bb8c7851 handle cfg(bootstrap) 2023-04-28 08:47:55 -07:00
Pietro Albini
4e04da6183 replace version placeholders 2023-04-28 08:47:55 -07:00
Ralf Jung
d5e7ac53c7 avoid duplicating TLS state between test std and realstd 2023-04-28 17:24:16 +02:00
bors
43a78029b4 Auto merge of #110837 - scottmcm:offset-for-add, r=compiler-errors
Use MIR's `Offset` for pointer `add` too

~~Status: draft while waiting for #110822 to land, since this is built atop that.~~
~~r? `@ghost~~`

Canonical Rust code has mostly moved to `add`/`sub` on pointers, which take `usize`, instead of `offset` which takes `isize`.  (And, relatedly, when `sub_ptr` was added it turned out it replaced every single in-tree use of `offset_from`, because `usize` is just so much more useful than `isize` in Rust.)

Unfortunately, `intrinsics::offset` could only accept `*const` and `isize`, so there's a *huge* amount of type conversions back and forth being done.  They're identity conversions in the backend, but still end up producing quite a lot of unhelpful MIR.

This PR changes `intrinsics::offset` to accept `*const` *and* `*mut` along with `isize` *and* `usize`.  Conveniently, the backends and CTFE already handle this, since MIR's `BinOp::Offset` [already supports all four combinations](adaac6b166/compiler/rustc_const_eval/src/transform/validate.rs (L523-L528)).

To demonstrate the difference, I added some `mir-opt/pre-codegen/` tests around slice indexing.  Here's the difference to `[T]::get_mut`, since it uses `<*mut _>::add` internally:
```diff
`@@` -79,30 +70,21 `@@` fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
         StorageLive(_12);                // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         StorageLive(_9);                 // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         _9 = _8 as *mut u32 (PtrToPtr);  // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageLive(_13);                // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _13 = _2 as isize (IntToInt);    // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageLive(_14);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageLive(_15);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _15 = _9 as *const u32 (Pointer(MutToConstPointer)); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _14 = Offset(move _15, _13);     // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageDead(_15);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        _7 = move _14 as *mut u32 (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageDead(_14);                // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-        StorageDead(_13);                // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
+        _7 = Offset(_9, _2);             // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
         StorageDead(_9);                 // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         StorageDead(_12);                // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
         StorageDead(_11);                // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
```
1c1c8e442a (diff-a841b6a4538657add3f39bc895744331453d0625e7aace128b1f604f0b63c8fdR80)
2023-04-28 09:26:59 +00:00
Scott McMurray
8857cc2131 inline(always) for lt/le/ge/gt on integers and floats
I happened to notice one of these not getting inlined as part of `Range::next` in <https://rust.godbolt.org/z/4WKWWxj1G>
```rust
    bb1: {
        StorageLive(_5);
        _6 = &mut _4;
        StorageLive(_21);
        StorageLive(_14);
        StorageLive(_15);
        _15 = &((*_6).0: usize);
        StorageLive(_16);
        _16 = &((*_6).1: usize);
        _14 = <usize as PartialOrd>::lt(move _15, move _16) -> bb7;
    }
```

So since a call for something this trivial is never the right choice, `#[inline(always)]` seems appropriate.
2023-04-27 23:44:45 -07:00
bors
2fce229086 Auto merge of #110924 - matthiaskrgr:rollup-jvznpq2, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110766 (More core::fmt::rt cleanup.)
 - #110873 (Migrate trivially translatable `rustc_parse` diagnostics)
 - #110904 (rustdoc: rebind bound vars to type-outlives predicates)
 - #110913 (Add some missing built-in lints)
 - #110918 (`remove_dir_all`: try deleting the directory even if `FILE_LIST_DIRECTORY` access is denied)
 - #110920 (Fix unavailable url)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-28 06:32:01 +00:00
Scott McMurray
e1da77c76d Also use mir::Offset for pointer add 2023-04-27 22:44:42 -07:00
Matthias Krüger
6476b79df7
Rollup merge of #110918 - ChrisDenton:on-error-resume-next, r=cuviper
`remove_dir_all`: try deleting the directory even if `FILE_LIST_DIRECTORY` access is denied

If opening a directory with `FILE_LIST_DIRECTORY` access fails then we should try opening without requesting that access. We may still be able to delete it if it's empty or a link.

Fixes https://github.com/rust-lang/cargo/issues/12042
2023-04-28 07:34:04 +02:00
Matthias Krüger
cf911ac757
Rollup merge of #110766 - m-ou-se:fmt-rt, r=jyn514
More core::fmt::rt cleanup.

- Removes the `V1` suffix from the `Argument` and `Flag` types.

- Moves more of the format_args lang items into the `core::fmt::rt` module. (The only remaining lang item in `core::fmt` is `Arguments` itself, which is a public type.)

Part of https://github.com/rust-lang/rust/issues/99012

Follow-up to https://github.com/rust-lang/rust/pull/110616
2023-04-28 07:34:02 +02:00
Yuki Okushi
75be558071
Rollup merge of #110898 - m-ou-se:remove-unused-thread-local-key, r=cuviper
Remove unused std::sys_common::thread_local_key::Key

Part of https://github.com/rust-lang/rust/issues/110897

This `Key` type seems unused. Let's remove it and see if anything explodes. :)
2023-04-28 10:52:01 +09:00
Yuki Okushi
085fbe9098
Rollup merge of #110620 - Nilstrieb:document-the-undocumented, r=thomcc
Document `const {}` syntax for `std::thread_local`.

It exists and is pretty cool. More people should use it.

It was added in #83416 and stabilized in #91355 with the tracking issue #84223.
2023-04-28 10:51:59 +09:00
Chris Denton
ddff7f0e50
remove_dir_all: delete directory with fewer perms
If opening a directory with `FILE_LIST_DIRECTORY` access fails then we should try opening without requesting that access. We may still be able to delete it if it's empty or a link.
2023-04-28 02:30:45 +01:00
Matthias Krüger
2148942757
Rollup merge of #106599 - MikailBag:patch-1, r=jyn514
Change memory ordering in System wrapper example

Currently, the `SeqCst` ordering is used, which seems unnecessary:
+ Even `Relaxed` ordering guarantees that all updates are atomic and are executed in total order
+ User code only reads atomic for monitoring purposes, no "happens-before" relationships with actual allocations and deallocations are needed for this

If argumentation above is correct, I propose changing ordering to `Relaxed` to clarify that no synchronization is required here, and improve performance (if somebody copy-pastes this example into their code).
2023-04-27 21:34:14 +02:00
Matthias Krüger
aa22867caf
Rollup merge of #106456 - kadiwa4:std-prelude-comment, r=jyn514
Correct `std::prelude` comment

(Read the changed file first for context.)

First, `alloc` has no prelude.

Second, the docs for `v1` don't matter since the [prelude module] already has all the doc links. The `rust_2021` module for instance also doesnt have a convenient doc page. However as I understand glob imports still cant be used because the items dont have the same stabilisation versions.

[prelude module]: https://doc.rust-lang.org/std/prelude/index.html
2023-04-27 21:34:13 +02:00
Matthias Krüger
e13b7f73c3
Rollup merge of #105745 - philpax:patch-1, r=jyn514
docs(std): clarify remove_dir_all errors

When using `remove_dir_all`, I assumed that the function was idempotent and that I could always call it to remove a directory if it existed. That's not the case and it bit me in production, so I figured I'd submit this to clarify the docs.
2023-04-27 21:34:13 +02:00
Nilstrieb
b56d85dc09 Document const {} syntax for std::thread_local.
It exists and is pretty cool. More people should use it.
2023-04-27 20:24:18 +02:00
Michael Goulet
6c9249f689 Don't call await a method 2023-04-27 17:18:12 +00:00
Maybe Waffle
bdb5502aa8 Fix some marker impls 2023-04-27 15:59:07 +00:00
Maybe Waffle
2c5e7160f3 Add FIXMEs 2023-04-27 15:59:07 +00:00
Maybe Waffle
1bf6bbb1bd Impl StructuralEq & ConstParamTy for str, &T, [T; N] and [T] 2023-04-27 15:59:07 +00:00
Maybe Waffle
2205c3fa5f Add a macro to conveniently implement marker traits 2023-04-27 15:58:46 +00:00
Maybe Waffle
81a2b856c8 Remove feature(const_param_ty_trait), use adt_const_params instead 2023-04-27 15:46:23 +00:00
Maybe Waffle
9a716dafbe Add a ConstParamTy trait 2023-04-27 15:46:21 +00:00
Mara Bos
52ff751aa4 pub -> pub(super). 2023-04-27 16:42:17 +02:00
Maybe Waffle
518d348f87 Implement StructuralEq for integers, bool and char
(how did this work before??)
2023-04-27 14:37:42 +00:00
KaDiWa
60ab69d168
correct std::prelude comment 2023-04-27 15:56:57 +02:00
Mara Bos
0b3073abb1 Update test. 2023-04-27 15:25:48 +02:00
Mara Bos
94c855153a Remove unused std::sys_common::thread_local_key::Key. 2023-04-27 15:25:48 +02:00
Ayush Singh
be413ae527
Remove all in target_thread_local cfg
I think it was left there by mistake after previous refactoring.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-04-27 18:21:14 +05:30
Jules Bertholet
075ee26b68
Loosen From<&[T]> for Box<[T]> bound to T: Clone 2023-04-26 23:41:07 -04:00
bors
e3ccd4b9a5 Auto merge of #110562 - ComputerDruid:riscv, r=tmandry
Add definitions for riscv64gc-unknown-fuchsia

To compile, also requires a libc update with https://github.com/rust-lang/libc/pull/3204
2023-04-27 01:29:50 +00:00
Philpax
d5d2785c86 docs(std): clarify remove_dir_all errors 2023-04-27 03:19:14 +02:00
bors
cb9aa8c9c1 Auto merge of #110861 - m-ou-se:thread-local-restructure, r=workingjubilee
Restructure and rename std thread_local internals to make it less of a maze

Every time I try to work on std's thread local internals, it feels like I'm trying to navigate a confusing maze made of macros, deeply nested modules, and types with multiple names/aliases. Time to clean it up a bit.

This PR:

- Exports `Key` with its own name (`Key`), instead of `__LocalKeyInner`
- Uses `pub macro` to put `__thread_local_inner` into a (unstable, hidden) module, removing `#[macro_export]`, removing it from the crate root.
- Removes the `__` from `__thread_local_inner`.
- Removes a few unnecessary `allow_internal_unstable` features from the macros
- Removes the `libstd_thread_internals` feature. (Merged with `thread_local_internals`.)
    - And removes it from the unstable book
- Gets rid of the deeply nested modules for the `Key` definitions (`mod fast` / `mod os` / `mod statik`).
- Turns a `#[cfg]` mess into a single `cfg_if`, now that there's no `#[macro_export]` anymore that breaks with `cfg_if`.
- Simplifies the `cfg_if` conditions to not repeat the conditions.
- Removes useless `normalize-stderr-test`, which were left over from when the `Key` types had different names on different platforms.
- Removes a seemingly unnecessary `realstd` re-export on `cfg(test)`.

This PR changes nothing about the thread local implementation. That's for a later PR. (Which should hopefully be easier once all this stuff is a bit cleaned up.)
2023-04-26 22:07:17 +00:00
Mara Bos
fba5cfe482 Restructure and rename thread local things in std. 2023-04-26 21:02:29 +02:00
Matthias Krüger
8fe7a4937c
Rollup merge of #110819 - tamird:flattencompat-trustedlen, r=the8472
simplify TrustedLen impls

Implement on FlattenCompat and delegate from Flatten and FlatMap.

/cc ``@the8472``
2023-04-26 18:51:43 +02:00
Matthias Krüger
9babe98562
Rollup merge of #110419 - jsoref:spelling-library, r=jyn514
Spelling library

Split per https://github.com/rust-lang/rust/pull/110392

I can squash once people are happy w/ the changes. It's really uncommon for large sets of changes to be perfectly acceptable w/o at least some changes.

I probably won't have time to respond until tomorrow or the next day
2023-04-26 18:51:41 +02:00
Loïc BRANSTETT
95a383bebd Implement midpoint for all unsigned NonZeroU{8,16,32,64,128,size} 2023-04-26 10:18:53 +02:00
Loïc BRANSTETT
bf73234d92 Implement midpoint for all floating point f32 and f64 2023-04-26 10:18:53 +02:00
Loïc BRANSTETT
1a72d7c7c4 Implement midpoint for all signed and unsigned integers 2023-04-26 10:18:53 +02:00
jyn
3fbaf789bd
Rollup merge of #110587 - tomaka:fix-109727, r=jyn514
Fix `std` compilation error for wasi+atomics

Fix https://github.com/rust-lang/rust/issues/109727

It seems that the `unsupported/once.rs` module isn't meant to exist at the same time as the `futex` module, as they have conflicting definitions.

I've solved this by defining the `once` module only if `not(target_feature = "atomics")`.
The `wasm32-unknown-unknown` target [similarly only defines the `once` module if `not(target_feature = "atomics")`](01c4f31927/library/std/src/sys/wasm/mod.rs (L69-L70)).

As show in [this block of code](01c4f31927/library/std/src/sys_common/once/mod.rs (L10-L34)), the `sys::once` module doesn't need to exist if `all(target_arch = "wasm32", target_feature = "atomics")`.
2023-04-26 01:55:52 -05:00
jyn
ce30232f16
Rollup merge of #110266 - tgross35:try-exists-wording, r=jyn514
Update documentation wording on path 'try_exists' functions

Just eliminate the quadruple negation in `doesn't silently ignore errors unrelated to ... not existing.`
2023-04-26 01:55:50 -05:00
jyn
ab7e01e8b6
Rollup merge of #108416 - pat-nel87:Issue-107957-black_box_docs, r=jyn514
black_box doc corrections for clarification - Issue #107957

Made a complete pass through the docs to help resolve https://github.com/rust-lang/rust/issues/107957

No code changes, just documentation

`@rustbot` label +T-libs-api -T-libs
2023-04-26 01:55:49 -05:00
Josh Soref
9a55e9edc5 rewrite: line_long_tail_not_flushed description
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-26 02:11:13 -04:00
Josh Soref
1042b2c7ff rewrite: long_line_flushed description
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-26 02:11:13 -04:00
Josh Soref
9cb9346005 Spelling library/
* advance
* aligned
* borrowed
* calculate
* debugable
* debuggable
* declarations
* desugaring
* documentation
* enclave
* ignorable
* initialized
* iterator
* kaboom
* monomorphization
* nonexistent
* optimizer
* panicking
* process
* reentrant
* rustonomicon
* the
* uninitialized

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-26 02:10:22 -04:00
Dan Johnson
e7ed5ba773 Add definitions for riscv64gc-unknown-fuchsia 2023-04-25 16:42:59 -07:00
Thomas Hurst
e5e640cace Add FreeBSD cpuset support to std:🧵:available_concurrency
Use libc::cpuset_getaffinity to determine the CPUs available to the current process.

The existing sysconf and sysctl paths are left as fallback.
2023-04-25 20:59:50 +00:00
Matthias Krüger
77752a0db3
Rollup merge of #110796 - madsravn:wake-example, r=Mark-Simulacrum
Updating Wake example to use new 'pin!' macro

Closes: https://github.com/rust-lang/rust/issues/109965

I have already had this reviewed and approved here: https://github.com/rust-lang/rust/pull/110026 . But because I had some git issues and chose the "nuke it" option as my solution it didn't get merged. I nuked it too quickly. I am sorry for trouble of reviewing twice.
2023-04-25 21:06:35 +02:00
Matthias Krüger
94dfb3ba78
Rollup merge of #110649 - arlosi:fix_no_global_oom_handling, r=Mark-Simulacrum
Fix no_global_oom_handling build

`provide_sorted_batch` in core is incorrectly marked with `#[cfg(not(no_global_oom_handling))]` which prevents core from building with the cfg enabled.

Nothing in `core` allocates memory (including this function). The `cfg` gate is incorrect.

cc ``@dpaoliello``
r? ``@wesleywiser``

The cfg was added by #107191
2023-04-25 21:06:33 +02:00
Tamir Duberstein
451e86c36e
simplify TrustedLen impls
Implement on FlattenCompat and delegate from Flatten and FlatMap.
2023-04-25 14:07:51 -04:00
Mads Ravn
3b196fb391 Updating Wake example to use new 'pin!' macro 2023-04-25 13:50:50 +02:00
John Kåre Alsaker
fd4c81f4c1 Add a sysroot crate to represent the standard library crates 2023-04-25 13:40:36 +02:00
bors
20d90b14ff Auto merge of #103093 - rytheo:linked-list-alloc-api, r=Mark-Simulacrum
Add support for allocators in `LinkedList`

Allows `LinkedList` to use a custom allocator
2023-04-25 11:34:58 +00:00
bors
91b61a4ad6 Auto merge of #110389 - mazong1123:add-shortcut-for-grisu3, r=Mark-Simulacrum
Add shortcut for Grisu3 algorithm.

While Grisu3 is way more faster for most numbers compare to Dragon4, the fall back to Dragon4 procedure for certain numbers could cause some performance regressions compare to use Dragon4 directly. Mitigating the regression caused by falling back is important for a largely used core library.

In Grisu3 algorithm implementation, there's a shortcut to jump out earlier when the fractional or integrals cannot meet the requirement of requested digits. This could significantly improve the performance of converting floating number to string as it falls back even without starting trying the algorithm.

The original idea is from the [.NET implementation](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Number.Grisu3.cs#L602-L615) and the code was originally added in [this PR](https://github.com/dotnet/coreclr/pull/14646#issuecomment-350942050). This shortcut has been shipped long time ago and has been proved working.

Fix #110129
2023-04-25 07:05:50 +00:00
Matthias Krüger
2d72abc8f2
Rollup merge of #110782 - matthiaskrgr:revert_panic_oom, r=Amanieu
Revert panic oom

This temporarily reverts https://github.com/rust-lang/rust/pull/109507 until https://github.com/rust-lang/rust/issues/110771 is addressed

r? `@Amanieu`
2023-04-25 06:46:50 +02:00
mazong1123
b0a85d614d Add shortcut for Grisu3 algorithm.
Check requested digit length and the fractional or integral parts of the number. Falls back earlier without trying the Grisu algorithm if the specific condition meets.

Fix #110129
2023-04-25 11:34:57 +08:00