Commit graph

11321 commits

Author SHA1 Message Date
Maybe Waffle 4d04a062c8 Use metavar ${count(x)} instead of reimplementing it 2023-05-02 14:37:40 +00:00
Maybe Waffle 9fba2622a0 implement tuple<->array convertions via From 2023-05-02 14:37:40 +00:00
Deadbeef d5e7206ca6 rm diag item, use lang item 2023-05-02 10:32:07 +00:00
Deadbeef a49570fd20 fix TODO comments 2023-05-02 10:32:07 +00:00
Deadbeef 8ff3903643 initial step towards implementing C string literals 2023-05-02 10:30:09 +00:00
Dylan DPC 40c4ed4994
Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`

Split from #109842.

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

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

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

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

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

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

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

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

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

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

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

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

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

Successful merges:

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

Failed merges:

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

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

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

Currently the following function:

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

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

Is optimized to the following:

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

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

Closes #110809

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

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

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

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

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

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

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

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

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

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

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

Fixes #110761

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

Successful merges:

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

Failed merges:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Successful merges:

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

Failed merges:

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

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

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

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

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

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

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

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

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

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

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

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

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

(Read the changed file first for context.)

First, `alloc` has no prelude.

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

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

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

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

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

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

This PR:

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

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

Implement on FlattenCompat and delegate from Flatten and FlatMap.

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

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

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

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

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

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

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

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

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

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

No code changes, just documentation

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fix #110129
2023-04-25 11:34:57 +08:00
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