Commit Graph

11065 Commits

Author SHA1 Message Date
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
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
Mads Ravn
3b196fb391 Updating Wake example to use new 'pin!' macro 2023-04-25 13:50:50 +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
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
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
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