Commit Graph

12111 Commits

Author SHA1 Message Date
bors
9d311f9e2d Auto merge of #114967 - japaric:ja-gh114966, r=Mark-Simulacrum
QNX: pass a truncated thread name to the OS

The maximum length the thread name can have is `_NTO_THREAD_NAME_MAX`

fixes #114966
2023-09-10 23:55:38 +00:00
bors
559421e8e3 Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnay
Allow redirecting subprocess stdout to our stderr etc. (redux)

This is the code from #88561, tidied up, including review suggestions, and with the for-testing-only CI commit removed.  FCP for the API completed in #88561.

I have made a new MR to facilitate review.  The discussion there is very cluttered and the branch is full of changes (in many cases as a result of changes to other Rust stdlib APIs since then).  Assuming this MR is approvedl we should close that one.

### Reviewer doing a de novo review

Just code review these four commits..  FCP discussion starts here: https://github.com/rust-lang/rust/pull/88561#issuecomment-1640527595

Portability tests: you can see that this branch works on Windows too by looking at the CI results in #88561, which has the same code changes as this branch but with an additional "DO NOT MERGE" commit to make the Windows tests run.

### Reviewer doing an incremental review from some version of #88561

Review the new commits since your last review.  I haven't force pushed the branch there.

git diff the two branches (eg `git diff 176886197d6..0842b69c219`).  You'll see that the only difference is in gitlab CI files.  You can also see that *this* MR doesn't touch those files.
2023-09-09 19:56:51 +00:00
Ian Jackson
436fe01895
std::process (unsupported): Implement From<io::Stdout> etc. for imp::Stdio
This implementation is wrong.  Like the impl for From<File>, it is
forced to panic because process::Stdio in unsupported/process.rs
doesn't have a suitable variant.

The root cause of the problem is that process::Stdio in
unsupported/process.rs has any information in it at all.

I'm pretty sure that it should just be a unit struct.  However,
making that build on all platforms is going to be a lot of work,
iterating through CI and/or wrestling Docker.

I don't think this extra panic is making things significantly worse.
For now I have added some TODOs.
2023-09-09 11:24:53 +01:00
Guillaume Gomez
1fb672c738
Rollup merge of #115201 - notriddle:notriddle/type-alias-impl-list, r=GuillaumeGomez
rustdoc: list matching impls on type aliases

Fixes https://github.com/rust-lang/rust/issues/32077

Fixes #99952

Remake of https://github.com/rust-lang/rust/pull/112429

Partially reverts https://github.com/rust-lang/rust/pull/112543, but keeps the test case.

This version of the PR avoids the infinite loop by structurally matching types instead of using full unification. This version does not support type alias trait bounds, but the compiler does not enforce those anyway (https://github.com/rust-lang/rust/issues/21903).

r? `@GuillaumeGomez`

CC `@lcnr`
2023-09-08 14:10:51 +02:00
Guillaume Gomez
2cceedd0ef
Rollup merge of #104299 - mkrasnitski:discriminant-transmute-docs, r=oli-obk
Clarify stability guarantee for lifetimes in enum discriminants

Since `std::mem::Discriminant` erases lifetimes, it should be clarified that changing the concrete value of a lifetime parameter does not change the value of an enum discriminant for a given variant. This is useful as it guarantees that it is safe to transmute `Discriminant<Foo<'a>>` to `Discriminant<Foo<'b>>` for any combination of `'a` and `'b`. This also holds for type-generics as long as the type parameters do not change, e.g. `Discriminant<Foo<T, 'a>>` can be transmuted to `Discriminant<Foo<T, 'b>>`.

Side note: Is what I've written actually enough to imply soundness (or rather codify it), or should it specifically be spelled out that it's OK to transmute in the above way?
2023-09-08 14:10:49 +02:00
bors
feb06732c0 Auto merge of #114299 - clarfonthey:char-min, r=dtolnay,BurntSushi
Add char::MIN

ACP: rust-lang/libs-team#252
Tracking issue: #114298

r? `@rust-lang/libs-api`
2023-09-08 00:02:48 +00:00
bors
4e5b31c2b0 Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, r=est31
Lint on invalid usage of `UnsafeCell::raw_get` in reference casting

This PR proposes to take into account `UnsafeCell::raw_get` method call for non-Freeze types for the `invalid_reference_casting` lint.

The goal of this is to catch those kind of invalid reference casting:
```rust
fn as_mut<T>(x: &T) -> &mut T {
    unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
    //~^ ERROR casting `&T` to `&mut T` is undefined behavior
}
```

r? `@est31`
2023-09-07 00:24:45 +00:00
bors
b0d45536ac Auto merge of #115580 - eduardosm:stdarch-intrinsics, r=davidtwco,bjorn3
Update stdarch submodule and remove special handling in cranelift codegen for some AVX and SSE2 LLVM intrinsics

https://github.com/rust-lang/stdarch/pull/1463 reimplemented some x86 intrinsics to avoid using some x86-specific LLVM intrinsics:

* Store unaligned (`_mm*_storeu_*`) use `<*mut _>::write_unaligned` instead of `llvm.x86.*.storeu.*`.
* Shift by immediate (`_mm*_s{ll,rl,ra}i_epi*`) use `if` (srl, sll) or `min` (sra) to simulate the behaviour when the RHS is out of range. RHS is constant, so the `if`/`min` will be optimized away.

This PR updates the stdarch submodule to pull these changes and removes special handling for those LLVM intrinsics from cranelift codegen. I left gcc codegen untouched because there are some autogenerated lists.
2023-09-06 22:26:37 +00:00
Darius Wiles
408dca7241
Fix minor grammar typo 2023-09-06 09:47:22 -07:00
bors
24bece8420 Auto merge of #115453 - ibraheemdev:patch-16, r=joshtriplett
Stabilize `io_error_other` feature

Per the FCP for https://github.com/rust-lang/rust/issues/91946.
2023-09-06 08:00:25 +00:00
Matthias Krüger
14c57f1adb
Rollup merge of #114794 - RalfJung:swap-safety, r=m-ou-se
clarify safety documentation of ptr::swap and ptr::copy

Closes https://github.com/rust-lang/rust/issues/81005
2023-09-05 20:15:01 +02:00
Eduardo Sánchez Muñoz
537edd0be4 Bump stdarch submodule 2023-09-05 19:56:20 +02:00
Ralf Jung
4684ffaf2a
if -> when 2023-09-05 17:20:31 +02:00
Matthias Krüger
9381e5bf58
Rollup merge of #115540 - cjgillot:custom-debuginfo, r=oli-obk
Support debuginfo for custom MIR.
2023-09-05 15:16:51 +02:00
Matthias Krüger
781253bc32
Rollup merge of #114813 - RalfJung:fpu-control, r=Amanieu
explain why we can mutate the FPU control word

This is usually not allowed (see https://github.com/rust-lang/stdarch/pull/1454), but here we have a special case.
2023-09-05 15:16:48 +02:00
Matthias Krüger
cbab5adf8a
Rollup merge of #114412 - RalfJung:libc-symbols, r=pnkfelix
document our assumptions about symbols provided by the libc

LLVM makes assumptions about `memcmp`, `memmove`, and `memset` that go beyond what the C standard guarantees -- see https://reviews.llvm.org/D86993. Since we use LLVM, we are inheriting these assumptions.

With https://github.com/rust-lang/rust/pull/114382 we are also making a similar assumption about `memcmp`, so I added that to the list.

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/426.
2023-09-05 15:16:47 +02:00
Matthias Krüger
a23f216136
Rollup merge of #113510 - ink-feather-org:const_ptr_transmute_docs, r=RalfJung
Document soundness of Integer -> Pointer -> Integer conversions in `const` contexts.

see this [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Soundness.20of.20Integer.20-.3E.20Pointer.20-.3E.20Integer.20conversions)

r? `@RalfJung`

With this slice `Iterator`'s should be able to be made const once the const Trait reimplementation is done.
2023-09-05 15:16:47 +02:00
bors
ce798a52c3 Auto merge of #115493 - Ayush1325:raw-os-error, r=workingjubilee
Move RawOsError defination to sys

This was originally a part of https://github.com/rust-lang/rust/pull/105861, but I feel it should be its own PR since the raw os error is still unstable.
2023-09-04 08:04:00 +00:00
bors
abfc6c4438 Auto merge of #115491 - Zoxc:refcell-tweak, r=Mark-Simulacrum
Outline panicking code for `RefCell::borrow` and `RefCell::borrow_mut`

This outlines panicking code for `RefCell::borrow` and `RefCell::borrow_mut` to reduce code size.
2023-09-03 23:03:03 +00:00
Matthias Krüger
487fe2e5ad
Rollup merge of #115512 - Fulgen301:startupinfow, r=ChrisDenton
Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of size_of

Fixes #115511.
2023-09-03 21:38:43 +02:00
Matthias Krüger
33e2e71502
Rollup merge of #115489 - saethlin:is-interrupted, r=thomcc
Use std::io::Error::is_interrupted everywhere

In https://github.com/rust-lang/rust/pull/115228 I introduced this helper and started using it, this PR uses it to replace all applicable uses of `std::io::Error::kind`. The justification is the same; for whatever reason LLVM totally flops optimizing `Error::kind` so it's nice to use it less.

FYI ``@mkroening`` I swear the hermit changes look good, but I was so sure about the previous PR.
2023-09-03 21:38:43 +02:00
Matthias Krüger
50aea927f5
Rollup merge of #115279 - schuelermine:patch/doc/RangeFull/remote-parens, r=Mark-Simulacrum
RangeFull: Remove parens around .. in documentation snippet

I’ve removed unnecessary parentheses in a documentation snippet documenting `RangeFull`. It could’ve lead people to believe the parentheses were necessary.
2023-09-03 21:38:41 +02:00
Fulgen301
a8b0e44e86
Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of size_of 2023-09-03 17:04:42 +02:00
Ben Kimock
642251b71f Use std::io::Error::is_interrupted everywhere 2023-09-03 09:21:10 -04:00
Ayush Singh
56df6b8189
Move RawOsError defination to sys
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-09-03 12:35:03 +05:30
John Kåre Alsaker
00c251134d Outline panicking code for RefCell::borrow and RefCell::borrow_mut 2023-09-03 05:10:58 +02:00
bors
c4f25777a0 Auto merge of #115273 - the8472:take-fold, r=cuviper
Optimize Take::{fold, for_each} when wrapping TrustedRandomAccess iterators
2023-09-02 12:40:16 +00:00
Matthias Krüger
1bbd307349
Rollup merge of #115449 - scottmcm:stable-const-is-ascii, r=ChrisDenton
Const-stabilize `is_ascii`

Resolves #111090

FCP completed in https://github.com/rust-lang/rust/issues/111090#issuecomment-1688490049
2023-09-02 07:48:23 +02:00
Matthias Krüger
43e15613d1
Rollup merge of #115443 - epage:os_str, r=cuviper
feat(std): Stabilize 'os_str_bytes' feature

Closes #111544
2023-09-02 07:48:22 +02:00
Matthias Krüger
b44bf0d117
Rollup merge of #115427 - solid-rs:patch/kmc-solid/is-interrupted, r=cuviper
kmc-solid: Fix `is_interrupted`

Follow-up to #115228. Fixes a build error in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.

```
error[E0603]: function `is_interrupted` is private
  --> library\std\src\sys\solid\mod.rs:77:12
   |
77 |     error::is_interrupted(code)
   |            ^^^^^^^^^^^^^^ private function
   |
note: the function `is_interrupted` is defined here
  --> library\std\src\sys\solid\error.rs:35:1
   |
35 | fn is_interrupted(er: abi::ER) -> bool {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2023-09-02 07:48:22 +02:00
Matthias Krüger
1df0c21af1
Rollup merge of #114845 - scottmcm:npo-align, r=WaffleLapkin
Add alignment to the NPO guarantee

This PR [changes](https://github.com/rust-lang/rust/pull/114845#discussion_r1294363357) "same size" to "same size and alignment" in the option module's null pointer optimization docs in <https://doc.rust-lang.org/std/option/#representation>.

As far as I know, this has been true for a long time in the actual rustc implementation, but it's not in the text of those docs, so I figured I'd bring this up to FCP it.

I also see no particular reason that we'd ever *want* to have higher alignment on these.  In many of the cases it's impossible, as the minimum alignment is already the size of the type, but even if we *could* do things like on 32-bit we could say that `NonZeroU64` is 4-align but `Option<NonZeroU64>` is 8-align, I just don't see any value in doing that, so feel completely fine closing this door for the few things on which the NPO is already guaranteed.  These are basically all primitives, and should end up with the same size & alignment as those primitives.

(There's no layout guarantee for something like `Option<[u8; 3]>`, where it'd be at least plausible to consider raising the alignment from 1 to 4 on, say, some hypothetical target that doesn't have efficient unaligned 4-byte load/stores.  And even if we ever did start to offer some kind of guarantee around such a type, I doubt we'd put it under the "null pointer" optimization header.)

Screenshots for the new examples:
![image](https://github.com/rust-lang/rust/assets/18526288/a7dbff42-50b4-462e-9e27-00d511b58763)
![image](https://github.com/rust-lang/rust/assets/18526288/dfd55288-80fb-419a-bc11-26198c27f9f9)
2023-09-02 07:48:21 +02:00
Ed Page
30292bb68e fix(std): Rename os_str_bytes to encoded_bytes 2023-09-01 19:33:16 -05:00
bors
f9ba43ce14 Auto merge of #113295 - clarfonthey:ascii-step, r=cuviper
Implement Step for ascii::Char

This allows iterating over ranges of `ascii::Char`, similarly to ranges of `char`.

Note that `ascii::Char` is still unstable, tracked in #110998.
2023-09-02 00:02:50 +00:00
Ibraheem Ahmed
7abfc57ea1
stabilize io_error_other feature 2023-09-01 16:04:41 -04:00
Scott McMurray
570c312bc5 Const-stabilize is_ascii 2023-09-01 11:02:09 -07:00
Camille GILLOT
905fd1ba17 Support bootstrap. 2023-09-01 16:18:50 +00:00
Camille GILLOT
6cec91d647 Support debuginfo for custom MIR. 2023-09-01 16:16:31 +00:00
Ed Page
9aee1de612 feat(std): Stabilize 'os_str_bytes' feature
Closes #111544
2023-09-01 11:13:45 -05:00
bors
361f8ba847 Auto merge of #114065 - lukas-code:u16_from_char, r=dtolnay
`impl TryFrom<char> for u16`

This PR implements the final missing `char` -> unsigned integer conversion.

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

r? libs-api
`@rustbot` label +T-libs-api +needs-fcp -T-libs
2023-09-01 16:01:06 +00:00
Caio
0164f7e8b2
[clippy] Use symbols intended for arithmetic_side_effects 2023-09-01 10:28:55 +02:00
bors
dc348dbd90 Auto merge of #114448 - SteveLauC:std_fs_read_doc, r=Mark-Simulacrum
docs: improve std::fs::read doc

#### What does this PR do

1. Rephrase a confusing sentence in the document of `std::fs::read()`

-----

Closes #114432

cc `@Dexus0` `@saethlin`
2023-09-01 05:25:44 +00:00
Tomoaki Kawada
eb627ea339 kmc-solid: Refactor is_interrupted to avoid integer overflow 2023-09-01 11:55:48 +09:00
Steve Lau
0e270b1a97 docs: improve std::fs::read doc 2023-09-01 10:54:37 +08:00
Tomoaki Kawada
dc37959ce8 kmc-solid: Directly delegate to net::is_interrupted in std::sys::solid::is_interrupted 2023-09-01 11:53:15 +09:00
bors
f6faef4475 Auto merge of #114795 - RalfJung:cell-swap, r=dtolnay
make Cell::swap panic if the Cells partially overlap

The following function ought to be sound:
```rust
fn as_cell_of_array<T, const N: usize>(c: &[Cell<T>; N]) -> &Cell<[T; N]> {
    unsafe { transmute(c) }
}
```
However, due to `Cell::swap`, it currently is not -- safe code can [cause a use-after-free](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c9415799722d985ff7d2c2c997b724ca). This PR fixes that.

Fixes https://github.com/rust-lang/rust/issues/80778
2023-08-29 07:53:56 +00:00
bors
cedbe5c715 Auto merge of #113859 - Manishearth:vec-as-mut-ptr-stacked-borrow, r=dtolnay
Add note that Vec::as_mut_ptr() does not materialize a reference to the internal buffer

See discussion on https://github.com/thomcc/rust-typed-arena/issues/62 and [t-opsem](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/is.20this.20typed_arena.20code.20sound.20under.20stacked.2Ftree.20borrows.3F)

This method already does the correct thing here, but it is worth guaranteeing that it does so it can be used more freely in unsafe code without having to worry about potential Stacked/Tree Borrows violations. This moves one more unsafe usage pattern from the "very likely sound but technically not fully defined" box into "definitely sound", and currently our surface area of the latter is woefully small.

I'm not sure how best to word this, opening this PR as a way to start discussion.
2023-08-29 06:04:55 +00:00
bors
a517049d8c Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomcc
fix(sys/hermit): add is_interrupted

https://github.com/rust-lang/rust/pull/115228 broke compilation for Hermit by not adding a Hermit implementation of is_interrupted.
2023-08-29 04:11:13 +00:00
bors
fef2f5907f Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviper
fix(sys/hermit): remove obsolete network initialization

This function does not exist as of hermit-sys 0.4.1 ([`e38f246`]). Once std does not call this function, we can remove it entirely.

CC: `@stlankes`

[`e38f246`]: e38f246e04 (diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10)
2023-08-29 00:37:48 +00:00
Matthias Krüger
9b0abe3537
Rollup merge of #115311 - dtolnay:usearcself, r=compiler-errors
Revert "Suggest using `Arc` on `!Send`/`!Sync` types"

Closes https://github.com/rust-lang/rust/issues/114687. This is a clean revert of https://github.com/rust-lang/rust/pull/88936 + https://github.com/rust-lang/rust/pull/115210. The suggestion to Arc\<{Self}\> when Self does not implement Send is *always* wrong.

https://github.com/rust-lang/rust/pull/114842 is considering a way to make a more refined suggestion.
2023-08-28 19:53:57 +02:00
Matthias Krüger
2eff0deca3
Rollup merge of #115310 - RalfJung:panic-and-format, r=scottmcm
Document panic behavior across editions, and improve xrefs

This revives (parts of) https://github.com/rust-lang/rust/pull/96518.
r? `@scottmcm`
Cc `@ijackson`
2023-08-28 19:53:56 +02:00