Commit Graph

11343 Commits

Author SHA1 Message Date
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
Ryan Lowe 34136ab598 Add support for allocators in LinkedList 2023-04-24 22:30:16 -04:00
bors fdeef3ed18 Auto merge of #106152 - SUPERCILEX:lazycell, r=Amanieu
Add LazyCell::into_inner

This enables uses cases that need to extract the evaluated value and do something owned with it.
2023-04-24 23:47:32 +00:00
Matthias Krüger 23a363821d Revert "Report allocation errors as panics"
This reverts commit c9a6e41026.
2023-04-25 00:08:37 +02:00
Matthias Krüger f54dbe6e31 Revert "Remove #[alloc_error_handler] from the compiler and library"
This reverts commit abc0660118.
2023-04-25 00:08:35 +02:00
Matthias Krüger 33253fa6a4 Revert "Rename -Zoom=panic to -Zoom=unwind"
This reverts commit 4b981c2648.
2023-04-25 00:08:33 +02:00
Kisaragi Marine 1042b65997
stdarch: update submodule, take 3 2023-04-25 05:30:20 +09:00
Mara Bos 0a28977740 Restructure std::fmt::rt a bit.
This moves more of the internal/lang items into the private rt module.
2023-04-24 16:16:14 +02:00
Mara Bos 5cf3cbf3b7 Remove "V1" from ArgumentsV1 and FlagsV1. 2023-04-24 16:16:14 +02:00
Matthias Krüger 3ecae2932c
Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk
Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also https://github.com/rust-lang/rust/pull/108442#issuecomment-1474777273, where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
2023-04-24 07:53:25 +02:00
Kisaragi Marine 49413bb619
stdarch: update submodule, take 2 2023-04-24 05:36:49 +09:00
Matthias Krüger 96acbd8e28
Rollup merge of #110689 - Spartan2909:fix-grammar, r=JohnTitor
Fix grammar in core::hint::unreachable_unchecked() docs

Fixes a minor grammar error in the docs for core::hint::unreachable_unchecked()
2023-04-23 20:06:32 +02:00
bors 9de7d9169c Auto merge of #110655 - ChrisDenton:read-to-end, r=joshtriplett
Limit read size in `File::read_to_end` loop

Fixes #110650.

Windows file reads have perf overhead that's proportional to the buffer size. When we have a reasonable expectation that we know the file size, we can set a reasonable upper bound for the size of the buffer in one read call.
2023-04-23 06:58:28 +00:00
Scott McMurray 1de2257c3f Add `intrinsics::transmute_unchecked`
This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.
2023-04-22 17:22:03 -07:00
Caleb Robson 0cc1b86a3a
Fix grammar 2023-04-22 15:58:44 +01:00
bors 39cf520299 Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwco
Report allocation errors as panics

OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`.

This should be review one commit at a time:
- The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics.
- The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API.

ACP: https://github.com/rust-lang/libs-team/issues/192

Closes #51540
Closes #51245
2023-04-22 12:27:45 +00:00
bors 3128fd8ddf Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #109949 (rustdoc: migrate `document_type_layout` to askama)
 - #110622 (Stable hash tag (discriminant) of `GenericArg`)
 - #110635 (More `IS_ZST` in `library`)
 - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020)
 - #110657 (nit: consistent naming for SimplifyConstCondition)
 - #110659 (rustdoc: clean up JS)
 - #110660 (Print ty placeholders pretty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-22 05:35:08 +00:00
Yuki Okushi 581e7417ce
Rollup merge of #110635 - scottmcm:zst-checks, r=the8472
More `IS_ZST` in `library`

I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways

d19b64fb54/library/core/src/slice/iter/macros.rs (L76-L93)

so started making this PR, then added a few more I found since I was already making changes anyway.
2023-04-22 10:33:57 +09:00
bors 80a2ec49a4 Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
Scott McMurray 56613f8c38 More `IS_ZST` in `library`
I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways

d19b64fb54/library/core/src/slice/iter/macros.rs (L76-L93)

so started making this PR, then added a few more I found since I was already making changes anyway.
2023-04-21 16:29:27 -07:00
Chris Denton f74fe8bf4c
Limit read size in `File::read_to_end` loop
This works around performance issues on  Windows by limiting reads the size of reads when the expected size is known.
2023-04-21 20:54:12 +01:00
Augie Fackler 610f827261 junit: also include per-case stdout in xml
By placing the stdout in a CDATA block we avoid almost all escaping, as
there's only two byte sequences you can't sneak into a CDATA and you can
handle that with some only slightly regrettable CDATA-splitting. I've
done this in at least two other implementations of the junit xml format
over the years and it's always worked out. The only quirk new to this
(for me) is smuggling newlines as &#xA; to avoid literal newlines in the
output.
2023-04-21 13:15:04 -04:00
Arlo Siemsen 57316559e4 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, so
the `cfg` gate is incorrect.
2023-04-21 10:45:06 -05:00
Dylan DPC 482e407a1f
Rollup merge of #110633 - scottmcm:more-take, r=thomcc
More `mem::take` in `library`

A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-21 20:35:29 +05:30
Dylan DPC f971264fd7
Rollup merge of #110608 - a1phyr:specialize_io_methods, r=thomcc
Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`

This improves implementation of:
- `<&[u8]>::read_to_string`
- `VecDeque<u8>::read_to_end`
- `VecDeque<u8>::read_to_string`
- `VecDeque<u8>::write_vectored`
2023-04-21 20:35:28 +05:30
bors 1151ea6006 Auto merge of #109002 - michaelvanstraten:master, r=petrochenkov
Added byte position range for `proc_macro::Span`

Currently, the [`Debug`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#impl-Debug-for-Span) implementation for [`proc_macro::Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) calls the debug function implemented in the trait implementation of `server::Span` for the type `Rustc` in the `rustc-expand` crate.

The current implementation, of the referenced function, looks something like this:
```rust
fn debug(&mut self, span: Self::Span) -> String {
    if self.ecx.ecfg.span_debug {
        format!("{:?}", span)
    } else {
        format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
    }
}
```

It returns the byte position of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) as an interpolated string.

Because this is currently the only way to get a spans position in the file, I might lead someone, who is interested in this information, to parsing this interpolated string back into a range of bytes, which I think is a very non-rusty way.

The proposed `position()`, method implemented in this PR, gives the ability to directly get this info.
It returns a [`std::ops::Range`](https://doc.rust-lang.org/std/ops/struct.Range.html#) wrapping the lowest and highest byte of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#).

I put it behind the `proc_macro_span` feature flag because many of the other functions that have a similar footprint also are annotated with it, I don't actually know if this is right.

It would be great if somebody could take a look at this, thank you very much in advanced.
2023-04-21 10:47:27 +00:00
DrMeepster a642563d49 major test improvements 2023-04-21 02:45:48 -07:00
DrMeepster 3206960ec6 minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster 2bcb018253 fmt 2023-04-21 02:14:03 -07:00
DrMeepster b92c2f792c fix incorrect param env in dead code lint 2023-04-21 02:14:03 -07:00
DrMeepster b95852b93c test improvements 2023-04-21 02:14:03 -07:00
DrMeepster 511e457c4b offset_of 2023-04-21 02:14:02 -07:00
Scott McMurray 8055bb87c5 More `mem::take` in `library`
A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-20 19:54:46 -07:00
Mara Bos bd917bbcd2
Add reason to #![unstable] tag.
Co-authored-by: jyn <github@jyn.dev>
2023-04-20 19:38:33 +02:00
Mara Bos 687b3fa439 Remove doc link to private item. 2023-04-20 18:47:47 +02:00
Mara Bos bca80d811c Get rid of core::fmt::FormatSpec. 2023-04-20 18:07:34 +02:00
Mara Bos 938efe6f49 Rename fmt::rt::Argument to Placeholder. 2023-04-20 18:05:35 +02:00
Mara Bos bc11b459af Turn core::fmt::rt::v1 into a private module. 2023-04-20 18:04:28 +02:00
Mara Bos a77159341e Use fmt::Alignment instead of fmt::rt::v1::Alignment. 2023-04-20 18:03:47 +02:00
Mara Bos debf305d9e Don't reexport core::fmt::rt from alloc::fmt. 2023-04-20 18:01:59 +02:00
Benoît du Garreau 1e6a7b4580 Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]` 2023-04-20 16:33:01 +02:00
Pierre Krieger 01c4f31927
Fix `std` compilation error for wasi+atomics 2023-04-20 10:19:42 +02:00
Yuki Okushi 9dbd25c705
Rollup merge of #110448 - ripytide:master, r=cuviper
cmp doc examples improvements

Most changes are for stylistic consistency, with some changes to provide more clarity.
2023-04-20 17:03:24 +09:00
John Millikin 4e2797dd76 Implement `Neg` for signed non-zero integers.
Negating a non-zero integer currently requires unpacking to a
primitive and re-wrapping. Since negation of non-zero signed
integers always produces a non-zero result, it is safe to
implement `Neg` for `NonZeroI{N}`.

The new `impl` is marked as stable because trait implementations
for two stable types can't be marked unstable.
2023-04-20 14:27:29 +09:00
bors 39c6804b92 Auto merge of #106704 - ecnelises:big_archive, r=bjorn3
Support AIX-style archive type

Reading facility of AIX big archive has been supported by `object` since 0.30.0.

Writing facility of AIX big archive has already been supported by `ar_archive_writer`, but we need to bump the version to support the new archive type enum.
2023-04-19 21:21:17 +00:00
bors 3a5c8e91f0 Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk
Rm const traits in libcore

See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework)

* [x] Bless ui tests
* [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-19 13:03:40 +00:00
Qiu Chaofan 7c8c9cf470 Bump version of object and related crates 2023-04-19 12:42:20 +08:00
Matthias Krüger 3320b2a59a
Rollup merge of #110432 - compiler-errors:unsatisfied-index-impl, r=cjgillot
Report more detailed reason why `Index` impl is not satisfied

Fixes #110373
2023-04-19 06:35:34 +02:00
Michael Goulet d84b5f9b3d Use a diagnostic item instead of filtering for Index::Output 2023-04-18 18:55:17 +00:00
Guillaume Gomez e6b607335a
Rollup merge of #110441 - kadiwa4:typos, r=thomcc
5 little typos
2023-04-18 14:50:51 +02:00
ripytide f540548fa1
cmp doc examples consistency improvements 2023-04-17 11:14:09 +01:00
Deadbeef dd025c3b56 fix codegen difference 2023-04-17 09:27:07 +00:00
kadiwa 85653831f7
typos 2023-04-17 09:16:07 +02:00
Matthias Krüger 35e63890bd
Rollup merge of #110433 - ChrisDenton:notfound, r=thomcc
Windows: map a few more error codes to ErrorKind

NotFound errors:

* `ERROR_INVALID_DRIVE`: The system cannot find the drive specified
* `ERROR_BAD_NETPATH`: The network path was not found
* `ERROR_BAD_NET_NAME`: The network name cannot be found.

InvalidFilename:

* `ERROR_BAD_PATHNAME`: The specified path is invalid.

Source: [System Error Codes (0-499)](https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)
2023-04-17 08:09:42 +02:00
Matthias Krüger 6e9a52cdc0
Rollup merge of #110388 - JohnBobbo96:remove-intrinsic-unwrap, r=the8472
Add a message for if an overflow occurs in `core::intrinsics::is_nonoverlapping`.
2023-04-17 08:09:40 +02:00
Chris Denton db8dfbdb75
Windows: map a few more error codes to ErrorKind
NotFound errors:

* `ERROR_INVALID_DRIVE`: The system cannot find the drive specified
* `ERROR_BAD_NETPATH`: The network path was not found
* `ERROR_BAD_NET_NAME`: The network name cannot be found.

InvalidFilename:

* `ERROR_BAD_PATHNAME`: The specified path is invalid.
2023-04-16 23:42:59 +01:00
Amanieu d'Antras 4b981c2648 Rename -Zoom=panic to -Zoom=unwind 2023-04-16 11:50:32 -07:00
Amanieu d'Antras abc0660118 Remove #[alloc_error_handler] from the compiler and library 2023-04-16 08:35:50 -07:00
Amanieu d'Antras c9a6e41026 Report allocation errors as panics 2023-04-16 08:35:44 -07:00
John Bobbo 3dba5872a3
Add a message indicating overflow in
`core::intrinsics::is_nonoverlapping`.
2023-04-16 07:35:18 -07:00
Deadbeef 4c6ddc036b fix library and rustdoc tests 2023-04-16 11:38:52 +00:00
Deadbeef eac922e721 readd `const_trait` to `Drop`, `Destruct`, and `Fn*` 2023-04-16 09:25:23 +00:00
Deadbeef 34097b2f33 fix tidy 2023-04-16 07:27:28 +00:00
Deadbeef 4ecbd3be52 fix alloc 2023-04-16 07:21:33 +00:00
Deadbeef 63e0ddbf1d core is now compilable 2023-04-16 07:20:26 +00:00
Deadbeef e80c020445 more hacks 2023-04-16 07:20:15 +00:00
Deadbeef ddc02b0f32 hack cstr is_empty 2023-04-16 07:05:54 +00:00
Deadbeef d88f979437 hack signum as well 2023-04-16 07:04:17 +00:00
Deadbeef 8cda8df578 memchr hack 2023-04-16 07:00:52 +00:00
Deadbeef 76dbe29104 rm const traits in libcore 2023-04-16 06:49:27 +00:00
est31 77821b2eb9 Remove unused unused_macros
The macro is always used
2023-04-16 08:35:39 +02:00
John Bobbo d0603fdafa
Use a `saturating_mul` instead of a `checked_mul`
and `unwrap` in `core::intrinsics`.
2023-04-15 22:40:26 -07:00
Yuki Okushi 1c228d122f
Rollup merge of #110347 - est31:size_of_links, r=jyn514
Add intra-doc links to size_of_* functions

Also some smaller doc improvements.
2023-04-16 06:55:22 +09:00
est31 504a47b16d Add intra-doc links to size_of_* functions 2023-04-15 14:07:18 +02:00
João M. Bezerra 4eb4e1022a edit docs of `PathBuf::set_file_name`
to show this method might replace or remove the extension, not just the
file stem

also edit docs of `Path::with_file_name` because it calls
`PathBuf::set_file_name`
2023-04-14 18:06:20 -03:00
Alex Saveau d9256f94a9
Add Lazy{Cell,Lock}::into_inner
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-04-14 13:15:11 -07:00
Matthias Krüger d5c7237400
Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitor
Remove some unneeded imports / qualified paths

Continuation of #105537.
2023-04-14 21:11:13 +02:00
Matthias Krüger d1c480f986
Rollup merge of #110154 - DaniPopes:library-typos, r=JohnTitor
Fix typos in library

I ran [`typos -w library`](https://github.com/crate-ci/typos) to fix typos in the `library` directory.

Refs #110150
2023-04-14 21:11:12 +02:00
Matthias Krüger 5107c4c556
Rollup merge of #110110 - lukas-code:display-panic-info, r=JohnTitor
Use `Display` in top-level example for `PanicInfo`

Addresses https://github.com/rust-lang/rust/issues/110098.

This confused me as well, when I was writing a `no_std` panic handler for the first time, so here's a better top-level example.

`Display` is stable, prints the `.message()` if available, and falls back to `.payload().downcast_ref<&str>()` if the message is not available. So this example should provide strictly more information and also work for formatted panics.

The old example still exists on the `payload` method.
2023-04-14 21:11:12 +02:00
Matthias Krüger 4b8351f62e
Rollup merge of #109947 - clubby789:cmp-macro-crosslink, r=JohnTitor
Add links from `core::cmp` derives to their traits

Fixes #109946
Adds intra-doc links from the `core::cmp` derives to their respective traits, and a link to their derive behaviour

`@rustbot` label +A-docs
2023-04-14 21:11:11 +02:00
Matthias Krüger 13790bec6a
Rollup merge of #109272 - schneems:schneems/add-docs-to-command-env-methods, r=Amanieu
Add Command environment variable inheritance docs

The interaction between the environment variable methods can be confusing. Specifically `env_clear` and `remove_env` have a side effects not mentioned: they disable inheriting environment variables from the parent process. I wanted to fully document this behavior as well as explain relevant edge cases in each of the `Command` env methods.

This is further confused by the return of `get_envs` which will return key/None if `remove_env` has been used, but an empty iterator if `env_clear` has been called. Or a non-empty iterator if `env_clear` was called and later explicit mappings are added. Currently there is no way (that I'm able to find) of observing whether or not the internal `env_clear=true` been toggled on the `Command` struct via its public API.

Ultimately environment variable mappings can be in one of several states:

- Explicitly set value (via `envs` / `env`) will take precedence over parent mapping
- Not explicitly set, will inherit mapping from parent
- Explicitly removed via `remove_env`, this single mapping will not inherit from parent
- Implicitly removed via `env_clear`, no mappings will inherit from parent

I tried to represent this in the relevant sections of the docs.

This is my second-ever doc PR (whoop!). I'm happy to take specific or general doc feedback. Also happy to explain the logic behind any changes or additions I made.
2023-04-14 21:11:11 +02:00
Yuki Okushi ad0a9350ad
Rollup merge of #110292 - scottmcm:sort-features-2, r=jyn514
Add `tidy-alphabetical` to features in `alloc` & `std`

So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often.

Follow-up to #110269
cc `@jyn514`
2023-04-14 23:00:35 +09:00
Yuki Okushi e79fc5b729
Rollup merge of #110269 - scottmcm:sort-features, r=jyn514
Add `tidy-alphabetical` to features in `core`

So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often.
2023-04-14 23:00:34 +09:00
Yuki Okushi 7361b17740
Rollup merge of #110047 - skaunov:patch-1, r=ChrisDenton
Add link to `collections` docs to `extend` trait

I believe it would be useful here.
2023-04-14 23:00:34 +09:00
bors 3e565f1a27 Auto merge of #101959 - Xaeroxe:clamp-better-assert, r=ChrisDenton
Add better assert messages for f32/f64 clamps
2023-04-14 10:44:36 +00:00
Sergey Kaunov 18ca509e99 Add links to docs to `Iterator`
and couple of its methods
2023-04-14 11:28:24 +03:00
bors 71ef9ecbde Auto merge of #110311 - matthiaskrgr:rollup-kn2k5bq, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #109225 (Clarify that RUST_MIN_STACK may be internally cached)
 - #109800 (Improve safe transmute error reporting)
 - #110158 (Remove obsolete test case)
 - #110180 (don't uniquify regions when canonicalizing)
 - #110207 (Assemble `Unpin` candidates specially for generators in new solver)
 - #110276 (Remove all but one of the spans in `BoundRegionKind::BrAnon`)
 - #110279 (rustdoc: Correctly handle built-in compiler proc-macros as proc-macro and not macro)
 - #110298 (Cover edge cases for {f32, f64}.hypot() docs)
 - #110299 (Switch to `EarlyBinder` for `impl_subject` query)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-14 08:08:52 +00:00
Matthias Krüger a7889d1730
Rollup merge of #110298 - jmaargh:jmaargh/hypot-docs-edge-cases, r=thomcc
Cover edge cases for {f32, f64}.hypot() docs

Fixes #88944

The Euclidean distance is a more general way to express what these functions do, and covers the edge cases of zero and negative inputs.

Does not cover the case of non-normal input values (as the [POSIX docs](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/) do), but the docs for the rest of the functions in these modules do not address this, I assumed it was not desired.
2023-04-14 07:58:42 +02:00
Matthias Krüger 2e39e15e40
Rollup merge of #110158 - TDecking:obsolete_test, r=ChrisDenton
Remove obsolete test case

This test case was supposed to cover issue #31109 at some point.
It never did anything, as the issue was still open at the time of its creation.
When the issue was resolved, the `issue31109` test case was created,
making the existence of this test pointless.
2023-04-14 07:58:39 +02:00
Matthias Krüger c6223e198d
Rollup merge of #109800 - bryangarza:safe-transmute-improved-errors, r=compiler-errors
Improve safe transmute error reporting

This patch updates the error reporting when Safe Transmute is not possible between 2 types by including the reason.

Also, fix some small bugs that occur when computing the `Answer` for transmutability.
2023-04-14 07:58:39 +02:00
Matthias Krüger ec08676716
Rollup merge of #109225 - seanlinsley:patch-1, r=ChrisDenton
Clarify that RUST_MIN_STACK may be internally cached

For larger applications it's important that users set `RUST_MIN_STACK` at the start of their program because [`min_stack`](7d3e03666a/library/std/src/sys_common/thread.rs) caches the value. Not doing so can lead to their `env::set_var` call surprisingly not having any effect.

In my own testing `RUST_MIN_STACK` had no effect until I moved it to the top of `main()`. Hopefully this clarification in the docs will help others going forward.
2023-04-14 07:58:38 +02:00
bors edcbb295c9 Auto merge of #105007 - dlaugt:solaris-fs-link, r=ChrisDenton
linkat() not available in the system headers of Solaris 10

I've installed rustup on x86_64-unknown-linux-gnu and would like to use the target sparcv9-sun-solaris. For this, I have built a gcc from the source code for cross-compiling to sparcv9-sun-solaris2.10 with system headers of Solaris 10.

With the following hello word example:
main.rs:
```rust
fn main() {
    println!("Hello, world!");
}
```
I had a compilation error:
```
$ rustc -v --target sparcv9-sun-solaris -C linker=/opt/cross-solaris/gcc730/bin/sparcv9-sun-solaris2.10-gcc main.rs
error: linking with `/opt/cross-solaris/gcc730/bin/sparcv9-sun-solaris2.10-gcc` failed: exit status: 1
  |
  = note: "/opt/cross-solaris/gcc730/bin/sparcv9-sun-solaris2.10-gcc" "-m64" "/tmp/rustcgebYgj/symbols.o" "main.main.89363361-cgu.0.rcgu.o" "main.main.89363361-cgu.1.rcgu.o" "main.main.89363361-cgu.2.rcgu.o" "main.main.89363361-cgu.3.rcgu.o" "main.main.89363361-cgu.4.rcgu.o" "main.main.89363361-cgu.5.rcgu.o" "main.csypsau9u2r8348.rcgu.o" "-Wl,-z,ignore" "-L" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib" "-Wl,-Bstatic" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libstd-fa47c8247d587714.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libpanic_unwind-5c87bbe223e6c2a3.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libobject-d484934062ff9fbb.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libmemchr-e8dbd5835abcbf43.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libaddr2line-909ad09329bde2f9.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libgimli-4d74a3be929697ac.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/librustc_demangle-47cbe1d7f7271ae1.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libstd_detect-239fd2d25fb32a00.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libhashbrown-c4a7ce45fb9dec19.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libminiz_oxide-fa6bc3d9bfb4e402.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libadler-419f5a82ddd339a3.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/librustc_std_workspace_alloc-7672b378962c11be.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libunwind-0f9e07f0a032c000.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libcfg_if-ede7757c356dfb28.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/liblibc-808d56fbc668148a.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/liballoc-784767fe059ad3fe.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/librustc_std_workspace_core-aa31d7ef0556bbe1.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libcore-81d07df07db18847.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libcompiler_builtins-313a510e63006db2.rlib" "-Wl,-Bdynamic" "-lsocket" "-lposix4" "-lpthread" "-lresolv" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lsendfile" "-llgrp" "-L" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib" "-o" "main" "-nodefaultlibs"
  = note: /opt/cross-solaris/gcc730/lib/gcc/sparcv9-sun-solaris2.10/7.3.0/../../../../sparcv9-sun-solaris2.10/bin/ld: warning: -z ignore ignored.
          /home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libstd-fa47c8247d587714.rlib(std-fa47c8247d587714.std.5c42d2c1-cgu.0.rcgu.o): In function `std::sys::unix::fs:🔗:h3683dfbfbb4995cb':
          /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys/unix/fs.rs:1407: undefined reference to `linkat'
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
```

linkat() is not available in the system headers of Solaris 10. The hello word example works fine when I build/use rust with this PR change.
2023-04-14 05:57:33 +00:00
Trevor Gross 9c567fdaee Update documentation wording on path 'try_exists' functions 2023-04-13 23:36:26 -04:00
Bryan Garza 36febe1f4d Improve safe transmute error reporting
This patch updates the error reporting when Safe Transmute is not
possible between 2 types by including the reason.

Also, fix some small bugs that occur when computing the `Answer` for
transmutability.
2023-04-13 21:57:08 +00:00
jmaargh cd868dcf98 Cover edge cases for {f32, f64}.hypot() docs
Re-phrase in a way that handles input values being either 0 or
negative.
2023-04-13 22:41:55 +01:00
Matthias Krüger e413c2e770
Rollup merge of #110259 - ndrewxie:issue-109964-fix-gitstuff, r=cjgillot
Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented

I made a PR earlier, but accidentally renamed a branch and that deleted the PR... sorry for the duplicate

Currently, if an operation on `Pin<T>` is performed that requires `T` to implement `Unpin`, the diagnostic suggestion is to use `Box::pin` ("note: consider using `Box::pin`").

This PR suggests pin! as well, as that's another valid way of pinning a value, and avoids a heap allocation. Appropriate diagnostic suggestions were included to highlight the difference in semantics (local pinning for pin! vs non-local for Box::pin).

Fixes #109964
2023-04-13 21:58:37 +02:00
Matthias Krüger e85ecbbcdc
Rollup merge of #110233 - nbdd0121:intrinsic, r=tmiasko
Make rust-intrinsic ABI unwindable

Fix #104451, fix https://github.com/rust-lang/miri/issues/2839

r? `@RalfJung`
2023-04-13 21:58:37 +02:00
Scott McMurray d374620de4 Add `tidy-alphabetical` to features in `alloc` & `std`
So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often.
2023-04-13 11:05:02 -07:00
Kisaragi Marine d5357c1b39
stdarch: update submodule 2023-04-13 22:24:33 +09:00
Gary Guo 731c6dcb60 Document catch_fn in r#try cannot unwind 2023-04-13 11:36:22 +01:00
Matthias Krüger b14730f667
Rollup merge of #110262 - justincredible:patch-1, r=ChrisDenton
Update unwind_safe.rs

Typo in the documentation.
2023-04-13 11:21:06 +02:00
Matthias Krüger 209e6d99e9
Rollup merge of #110234 - marc0246:btree-insert-after-fix, r=cuviper
Fix btree `CursorMut::insert_after` check

Fixes a check inside `BTreeMap`'s `CursorMut::insert_after`, where it would peek the previous element to check whether the inserted key is below the next one, instead of peeking the next element.
2023-04-13 11:21:06 +02:00
Matthias Krüger 6161fb8c65
Rollup merge of #110072 - joshtriplett:stabilize-is-terminal, r=Mark-Simulacrum
Stabilize IsTerminal

FCP completed in https://github.com/rust-lang/rust/issues/98070 .

closes: https://github.com/rust-lang/rust/issues/98070
2023-04-13 11:21:00 +02:00
Scott McMurray 74076684a2 Add `tidy-alphabetical` to features in `core`
So that people have to keep them sorted in future.
2023-04-13 00:36:40 -07:00
bors a29dada983 Auto merge of #108283 - the8472:remove-splice-into-pipe, r=ChrisDenton
don't splice from files into pipes in io::copy

This fixes potential data ordering issue where a write performed after a copy operation could become visible in the copy even though it signaled completion.

I assumed that by not setting `SPLICE_F_MOVE` we would be safe and the kernel would do a copy in kernel space and we could avoid the read-write syscall and copy-to/from-userspace costs. But apparently that flag only makes a difference when splicing from a pipe, but not when splicing into it.

Context: https://lkml.org/lkml/2023/2/9/673
2023-04-13 04:03:10 +00:00
Justin Symonds 9b0ceb4395
Update unwind_safe.rs
Typo in the documentation.
2023-04-12 18:21:56 -07:00
Andrew Xie 9e0e4c31aa Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented 2023-04-12 18:03:11 -04:00
Matthias Krüger f56a265105
Rollup merge of #110089 - petrosagg:mpsc-ub, r=m-ou-se
sync::mpsc: synchronize receiver disconnect with initialization

Receiver disconnection relies on the incorrect assumption that `head.index != tail.index` implies that the channel is initialized (i.e `head.block` and `tail.block` point to allocated blocks). However, it can happen that `head.index != tail.index` and `head.block == null` at the same time which leads to a segfault when a channel is dropped in that state.

This can happen because initialization is performed in two steps. First, the tail block is allocated and the `tail.block` is set. If that is successful `head.block` is set to the same pointer. Importantly, initialization is skipped if `tail.block` is not null.

Therefore we can have the following situation:

1. Thread A starts to send the first value of the channel, observes that `tail.block` is null and begins initialization. It sets `tail.block` to point to a newly allocated block and then gets preempted. `head.block` is still null at this point.
2. Thread B starts to send the second value of the channel, observes that `tail.block` *is not* null and proceeds with writing its value in the allocated tail block and sets `tail.index` to 1.
3. Thread B drops the receiver of the channel which observes that `head.index != tail.index` (0 and 1 respectively), therefore there must be messages to drop. It starts traversing the linked list from `head.block` which is still a null pointer, leading to a segfault.

This PR fixes this problem by waiting for initialization to complete when `head.index != tail.index` and the `head.block` is still null. A similar check exists in `start_recv` for similar reasons.

Fixes #110001
2023-04-12 22:04:33 +02:00
KaDiWa ad2b34d0e3
remove some unneeded imports 2023-04-12 19:27:18 +02:00
marc0246 cdd9829556
Fix btree `CursorMut::insert_after` check 2023-04-12 19:21:40 +02:00
Matthias Krüger bb037e6fa7
Rollup merge of #110190 - cbeuw:mir-offset, r=oli-obk
Custom MIR: Support `BinOp::Offset`

Since offset doesn't have an infix operator, a new function `Offset` is added which is lowered to `Rvalue::BinaryOp(BinOp::Offset, ..)`

r? ```@oli-obk``` or ```@tmiasko``` or ```@JakobDegen```
2023-04-12 17:04:32 +02:00
Gary Guo 229b0a0fdc Make rust-intrinsic ABI unwindable
Stick `#[rustc_nounwind]` to all except `const_eval_select` to undo the
change for all other intrinsics.
2023-04-12 14:05:05 +01:00
Michael Goulet 4c9cd9e739
Rollup merge of #110173 - solid-rs:patch/kmc-solid/socket-read-buf, r=cuviper
kmc-solid: Implement `Socket::read_buf`

Follow-up to #108326. Implements `Socket::read_buf` for the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.
2023-04-11 20:28:50 -07:00
Michael Goulet 4f2f7fda10
Rollup merge of #110104 - kormosi:todo_typo, r=cuviper
Reword the docstring in todo! macro definition, fixing a typo
2023-04-11 20:28:47 -07:00
Michael Goulet 8a7a66572e
Rollup merge of #109894 - fleetingbytes:109893-var_os-never-returns-an-error, r=cuviper
Remove Errors section from var_os docs

Remove `Errors` section from `var_os` documentation, fixes #109893
2023-04-11 20:28:46 -07:00
Michael Goulet 4a24aab220
Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiser
Initial support for loongarch64-unknown-linux-gnu

Hi, We hope to add a new port in rust for LoongArch.

LoongArch intro
LoongArch is a RISC style ISA which is independently designed by Loongson
Technology in China. It is divided into two versions, the 32-bit version (LA32)
and the 64-bit version (LA64). LA64 applications have application-level
backward binary compatibility with LA32 applications. LoongArch is composed of
a basic part (Loongson Base) and an expanded part. The expansion part includes
Loongson Binary Translation (LBT), Loongson VirtualiZation (LVZ), Loongson SIMD
EXtension (LSX) and Loongson Advanced SIMD EXtension(LASX).

Currently the LA464 processor core supports LoongArch ISA and the Loongson
3A5000 processor integrates 4 64-bit LA464 cores. LA464 is a four-issue 64-bit
high-performance processor core. It can be used as a single core for high-end
embedded and desktop applications, or as a basic processor core to form an
on-chip multi-core system for server and high-performance machine applications.

Documentations:
ISA:
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html
ABI:
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
More docs can be found at:
https://loongson.github.io/LoongArch-Documentation/README-EN.html

Since last year, we have locally adapted two versions of rust, rust1.41 and rust1.57, and completed the test locally.
I'm not sure if I'm submitting all the patches at once, so I split up the patches and here's one of the commits
2023-04-11 20:28:45 -07:00
Patrik Kormosi 4e84d695f3 Reword the docstring in todo! macro definition 2023-04-11 16:29:48 +02:00
Andy Wang cecb901e68
Add Offset binary op to custom mir 2023-04-11 16:23:35 +02:00
Yuki Okushi 75a46252ba
Rollup merge of #110070 - scottmcm:wrapping-neg, r=cuviper
The `wrapping_neg` example for unsigned types shouldn't use `i8`

Probably it should have at least one example with an unsigned type.
2023-04-11 12:18:51 +09:00
Tomoaki Kawada 72bfd55d4b kmc-solid: Implement `Socket::read_buf` 2023-04-11 12:00:36 +09:00
fleetingbytes 7d269633b1
Break up long first paragraph
Further referring to `var_os` as a "function" (like in `var`), rather than "method".
2023-04-11 04:13:35 +02:00
Tobias Decking 65c9c79d3f
remove obsolete test 2023-04-10 21:57:45 +02:00
DaniPopes a0daf22b95
Fix typos in library 2023-04-10 21:07:29 +02:00
bors a73288371e Auto merge of #107007 - TDecking:float_parsing_improvments, r=Mark-Simulacrum
Improve the floating point parser in dec2flt.

Greetings everyone,

I've benn studying the rust floating point parser recently and made the following tweaks:

* Remove all remaining traces of `unsafe`. The parser is now 100% safe Rust.
* The trick in which eight digits are processed in parallel is now in a loop.
* Parsing of inf/NaN values has been reworked.

On my system, the changes result in performance improvements for some input values.
2023-04-10 14:09:09 +00:00
Dylan DPC b6633ffaf7
Rollup merge of #110044 - scottmcm:more-size-of-val, r=ChrisDenton
Avoid some manual slice length calculation

No need for us to write the multiplication when `size_of_val` does exactly what we need.

(https://github.com/rust-lang/rust-clippy/pull/10601)
2023-04-10 14:13:14 +05:30
Josh Triplett afd45c2e10 Stabilize IsTerminal
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-10 17:24:23 +09:00
Tobias Decking 0f96c71792 Improve the floating point parser in `dec2flt`.
* Remove all remaining traces of unsafe.
* Put `parse_8digits` inside a loop.
* Rework parsing of inf/NaN values.
2023-04-10 00:47:08 +02:00
bors 1c39afb375 Auto merge of #109684 - fee1-dead-contrib:rv_const_range, r=Mark-Simulacrum
Revert #104100, Allow using `Range` as an `Iterator` in const contexts.

This fixes #109632.
2023-04-09 15:42:27 +00:00
Richard Schneeman e612d785d7
Apply suggestions from code review
Fixes documentation. I wrote `env_clear` when I meant `env_remove`. Good catch.

Co-authored-by: Josh Stone <cuviper@gmail.com>
2023-04-09 09:21:19 -05:00
bors 7201301df6 Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore
Fixes https://github.com/rust-lang/rust/issues/109631
Fixes https://github.com/rust-lang/rust/issues/109614
Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09 13:05:56 +00:00
Lukas Markeffsky d9f99c36fe Use `Display` in top-level example for `PanicInfo` 2023-04-09 14:29:16 +02:00
Patrik Kormosi 53fa6fe56f Fix typo in todo! macro docstring 2023-04-09 10:38:35 +02:00
bors 7cd6f55323 Auto merge of #110101 - JohnTitor:rollup-ol20aw7, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #110058 (Remove `box_syntax` usage)
 - #110059 (ignore_git → omit_git_hash)
 - #110060 (Document that `&T` and `&mut T` are `Sync` if `T` is)
 - #110074 (Make the "codegen" profile of `config.toml` download and build llvm from source.)
 - #110086 (Add `max_line_length` to `.editorconfig`, matching rustfmt)
 - #110096 (Tweak tuple indexing suggestion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-09 05:00:24 +00:00
Yuki Okushi 1e4361a23f
Rollup merge of #110060 - WaffleLapkin:sync_refs, r=jyn514
Document that `&T` and `&mut T` are `Sync` if `T` is

Proof: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fec8dc9ec36e873bf2962a2367d67045
2023-04-09 12:35:54 +09:00
Michael Goulet 920c51c526 Enforce that PointerLike requires a pointer-like ABI 2023-04-08 21:11:16 +00:00
beetrees d530473744
Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times` 2023-04-08 19:33:28 +01:00
Petros Angelatos f0d487dce5 sync::mpsc: synchronize receiver disconnect with initialization
Receiver disconnection relies on the incorrect assumption that
`head.index != tail.index` implies that the channel is initialized (i.e
`head.block` and `tail.block` point to allocated blocks). However, it
can happen that `head.index != tail.index` and `head.block == null` at
the same time which leads to a segfault when a channel is dropped in
that state.

This can happen because initialization is performed in two steps. First,
the tail block is allocated and the `tail.block` is set. If that is
successful `head.block` is set to the same pointer. Importantly,
initialization is skipped if `tail.block` is not null.

Therefore we can have the following situation:

1. Thread A starts to send the first value of the channel, observes that
   `tail.block` is null and begins initialization. It sets `tail.block`
   to point to a newly allocated block and then gets preempted.
   `head.block` is still null at this point.
2. Thread B starts to send the second value of the channel, observes
   that `tail.block` *is not* null and proceeds with writing its value
   in the allocated tail block and sets `tail.index` to 1.
3. Thread B drops the receiver of the channel which observes that
   `head.index != tail.index` (0 and 1 respectively), therefore there
   must be messages to drop. It starts traversing the linked list from
   `head.block` which is still a null pointer, leading to a segfault.

This PR fixes this problem by waiting for initialization to complete
when `head.index != tail.index` and the `head.block` is still null. A
similar check exists in `start_recv` for similar reasons.

Fixes #110001

Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2023-04-08 19:57:22 +02:00
Vadim Petrochenkov 612ddd2196 std: Mark two reexports that should be inlined as `doc(inline)` 2023-04-08 13:29:16 +03:00
bors 9e124c4f7a Auto merge of #110076 - Nilstrieb:rollup-22yp01c, r=Nilstrieb
Rollup of 5 pull requests

Successful merges:

 - #110030 (rustdoc: clean up JS)
 - #110037 (rustdoc: add test and bug fix for theme defaults)
 - #110065 (Fix wrong type in docs: i16 -> u16)
 - #110068 (Temporarily remove myself from reviewers list)
 - #110075 (Fix a typo in `config.example.toml`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-08 09:06:34 +00:00
Deadbeef 0cd49018d1 Revert "Make the `Step` implementations const."
This reverts commit 7bc67ef6e0.
2023-04-08 08:18:29 +00:00
Deadbeef 04a5d61161 Revert "Mark DoubleEndedIterator as #[const_trait] using rustc_do_not_const_check, implement const Iterator and DoubleEndedIterator for Range."
This reverts commit 8a9d6bf4fd.
2023-04-08 08:18:29 +00:00
bors c49c4fba11 Auto merge of #109995 - enkron:u/enkron/substitute-hardcoded-port-num-in-listen-on-fn, r=the8472
chore(tcp): change a hardcoded port number in a doctest to `port` var

The `listen_on` function in the example has a `port` option but doesn't use it
2023-04-08 06:54:40 +00:00
Scott McMurray ed0b8af505 The `wrapping_neg` example for unsigned types shouldn't use `i8` 2023-04-07 20:09:15 -07:00
Sergei Belokon 081e222d99 fix(tcp): remove redundant `format!` macro call 2023-04-08 08:20:05 +10:00
Jörn Bethune 7e9e91c3d3 Fix wrong type in docs: i16 -> u16
@rustbot label +A-docs

r? docs
2023-04-07 23:49:20 +02:00
Maybe Waffle 5f50c0f7ac Document that `&T` and `&mut T` are `Sync` if `T` is 2023-04-07 18:36:48 +00:00
zhaixiaojuan bf1758d229 Define UNWIND_DATA_REG for loongarch64 2023-04-08 00:09:54 +08:00
Giacomo Stevanato 2563fbeab3 Don't claim LocalKey::with prevents a reference to be sent across threads 2023-04-07 14:57:50 +02:00
Scott McMurray 1042b5df9b Avoid some manual slice length calculation
No need for us to write the multiplication when `size_of_val` does exactly what we need.
2023-04-07 01:32:12 -07:00
bors b6f6104a1f Auto merge of #110019 - jplatte:jplatte/stabilize-is-some-and, r=Amanieu
Stabilize is_some_and

This stabilizes the following public API:

```rust
impl<T> Option<T> {
    pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool;
}

impl<T, E> Result<T, E> {
    pub fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool;
    pub fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool;
}
```

Closes #93050 (tracking issue).

`@rustbot` label +T-libs-api -T-libs
2023-04-07 08:09:20 +00:00
bors 97879ce24b Auto merge of #109990 - gwy15:remove-bufwriter-useless-mut-pointer, r=jyn514
Remove an unnecessary `mut` in `BufWriter::into_parts`.

`ptr::read` takes `*const T` so `&mut` is not necessary.
2023-04-07 05:49:34 +00:00
Tomasz Miąsko 67b4614180 Inline try_from and try_into
To avoid link time dependency between core and compiler-builtins, when
using opt-level that implicitly enables -Zshare-generics.

While compiler-builtins should be compiled with -Zshare-generics
disabled, the -Zbuild-std does not ensure this at the moment.
2023-04-07 14:59:10 +02:00
Matthias Krüger 17ed06aad2
Rollup merge of #109960 - thomcc:symlink-junction-buffer-overrun, r=ChrisDenton
Fix buffer overrun in bootstrap and (test-only) symlink_junction

I don't think these can be hit in practice, due to their inputs being valid paths. It's also not security-sensitive code, but just... bad vibes.

I think this is still not really the right way to do this (in terms of path correctness), but is no worse than it was.

r? `@ChrisDenton`
2023-04-07 00:00:25 +02:00
Matthias Krüger b7e6973287
Rollup merge of #109806 - Zoxc:gnu-tls, r=pnkfelix
Workaround #109797 on windows-gnu

The addition of `#[inline]` here in https://github.com/rust-lang/rust/pull/108089 caused an unrelated linking issue (https://github.com/rust-lang/rust/issues/109797). This PR removes this attribute again on Windows to avoid regressions.
2023-04-07 00:00:23 +02:00
Jonas Platte 443928f7e3
Stabilize is_some_and 2023-04-06 23:14:23 +02:00
Sergei Belokon 502cb6f4b9 chore(tcp): change the hardcoded port number to `port` var
The `listen_on` function in the example has a `port` option but doesn't
use it
2023-04-06 18:32:01 +10:00
管唯宇 9169107c1c Remove an unnecessary `mut` in `BufWriter::into_parts`.
`ptr::read` takes `*const T` so `&mut` is not necessary.
2023-04-06 11:48:16 +08:00
Konrad Borowski 279f35ce50 Derive String's PartialEq implementation 2023-04-05 20:58:21 +02:00
Michal Nazarewicz 45104397e5 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-04-05 19:09:55 +02:00
Thom Chiovoloni 6861750e66
Fix buffer overrun in (test-only) symlink_junction 2023-04-05 00:37:30 -07:00
bors f98a271814 Auto merge of #94786 - joshlf:patch-5, r=dtolnay
Document NonZeroXxx layout guarantees

Document that `NonZeroXxx` has the same layout and bit validity as `Xxx` with the exception of `0`.
2023-04-05 01:09:59 +00:00
clubby789 8d4cccd168 Add links from `core::cmp` derives to their traits 2023-04-04 21:59:06 +01:00
zhaixiaojuan 50be2a30cb library/unwind: Add definitions for loongarch64 2023-04-04 17:05:08 +08:00
zhaixiaojuan a5e23115bd library/std: Add support for loongarch64 2023-04-04 17:05:08 +08:00
Yuki Okushi ed5e2ddeed
Rollup merge of #109883 - skaunov:patch-1, r=thomcc
Add links to <cell.rs>

`UnsafeCell` page could benefit too from having links to these most popular structs in the module.
2023-04-04 05:52:34 +09:00
The 8472 171ccb54f0 avoid zero-copy ops for File->Pipe and File->Socket in io::copy 2023-04-03 21:10:02 +02:00
The 8472 c96c30aeed test that modifications to the source don't become visible after io::copy 2023-04-03 21:10:02 +02:00
fleetingbytes 4cb73cc7d0
Preserve potential mood for equal or NUL sign
Original `var_os` description said that it _may_ return an error if the value contains `=` or NUL. Let's make no promises on the `None` return value in these situation either, keep it in the [potential mood](https://en.wikipedia.org/wiki/Grammatical_mood#Potential).
2023-04-03 19:30:20 +02:00
fleetingbytes a450557a54
Remove redundant empty line
one is enough
2023-04-03 17:17:43 +02:00
fleetingbytes 5618c8efd7
remove self-reference in var_os doc
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2023-04-03 17:13:30 +02:00
fleetingbytes c252f0d404
add situation where var_os returns None
Re-introduced some of the former errors as situations where `None` is returned.
2023-04-03 16:46:43 +02:00
fleetingbytes 9f1a3a131b
Update env.rs
Remove `Errors` section from `var_os` documentation
2023-04-03 16:09:15 +02:00
bors 1767585509 Auto merge of #109756 - cr1901:msp-shift, r=Mark-Simulacrum
Update compiler-builtins to 0.1.91 to bring in msp430 shift primitive…

… fixes.

This fixes unsoundness on MSP430 where `compiler-builtins` and LLVM didn't agree on the width of the shift amount argument of the shifting primitives (4 bytes vs 2 bytes). See https://github.com/rust-lang/compiler-builtins/pull/522 for more details.
2023-04-03 13:09:08 +00:00
bors f13ccefb5b Auto merge of #108448 - ishitatsuyuki:binary-heap, r=Mark-Simulacrum
binary_heap: Optimize Extend implementation.

This PR makes the `Extend` implementation for `BinaryHeap` no longer rely on specialization, so that it always use the bulk rebuild optimization that was previously only available for the `Vec` specialization.
2023-04-03 10:30:20 +00:00
Matthias Krüger f2f5efce9c
Rollup merge of #109722 - hermitcore:read, r=Mark-Simulacrum
Implement read_buf for RustHermit

In principle, this PR extends rust-lang/rust#108326 for RustyHermit.
2023-04-03 08:58:53 +02:00
Sergey Kaunov abc61d23de
Add links to <cell.rs>
`UnsafeCell` page could benefit too from having links to these most popular structs in the module.
2023-04-03 09:18:14 +03:00
bors 11cd4ff34d Auto merge of #109852 - Nilstrieb:rollup-g3mgxxw, r=Nilstrieb
Rollup of 4 pull requests

Successful merges:

 - #109839 (Improve grammar of Iterator.partition_in_place)
 - #109840 (Fix typo in std/src/os/fd/owned.rs)
 - #109844 (a couple clippy::complexity fixes)
 - #109846 (more clippy::complexity fixes (iter_kv_map, map_flatten, nonminimal_bool))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-02 09:39:41 +00:00
Nilstrieb 099f3469a9
Rollup merge of #109840 - taiki-e:typo, r=ChrisDenton
Fix typo in std/src/os/fd/owned.rs
2023-04-02 10:08:34 +02:00
Nilstrieb a38bdd4439
Rollup merge of #109839 - sartak:iter-grammar, r=scottmcm
Improve grammar of Iterator.partition_in_place

This is my first PR against Rust, please let me know if there's anything I should be providing here! I didn't find any instructions specific to documentation grammar in the [std-dev guide](https://std-dev-guide.rust-lang.org/documentation/summary.html).
2023-04-02 10:08:33 +02:00
bors 637d7fdb23 Auto merge of #109701 - Amanieu:binaryheap_retain, r=ChrisDenton
Stabilize `binary_heap_retain`

FCP finished in tracking issue: #71503
2023-04-02 07:04:01 +00:00
bors 0599b6b931 Auto merge of #109483 - joboet:optimize_lazycell, r=Mark-Simulacrum
Optimize `LazyCell` size

`LazyCell` can only store either the initializing function or the data it produces, so it does not need to reserve the space for both. Similar to #107329, but uses an `enum` instead of a `union`.
2023-04-01 20:11:49 +00:00