Commit Graph

11288 Commits

Author SHA1 Message Date
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
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
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
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