Commit Graph

12273 Commits

Author SHA1 Message Date
DaniPopes
58ed8ad0df
Stabilize const_maybe_uninit_assume_init_read 2023-09-28 16:19:33 +02:00
bors
c01d8d238c Auto merge of #114428 - ChaiTRex:master, r=dtolnay
Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ExitStatus` in `std::process`

Implementing suggestion from https://github.com/rust-lang/rust/issues/84908#issuecomment-912352902:

> I believe the impl on ExitStatusError should be
>
> ```rust
> impl From<ExitStatusError> for ExitStatus
> ```
>
> rather than
>
> ```rust
> impl Into<ExitStatus> for ExitStatusError
> ```
>
> (there is generally never anything implemented as `Into` first, because implementing `From` reflexively provides `Into`)
2023-09-28 11:47:54 +00:00
bors
e2d6aa77ed Auto merge of #98704 - vthib:impl-from-raw-for-childstd-structs, r=dtolnay
Implement From<OwnedFd/Handle> for ChildStdin/out/err object

## Summary

Comments in `library/std/src/process.rs` ( ab08639e59 ) indicates that `ChildStdin`, `ChildStdout`, `ChildStderr` implements some traits that are not actually implemented: `FromRawFd`, `FromRawHandle`, and the `From<OwnedFd>/From<OwnedHandle>` from the io_safety feature.

In this PR I implement `FromRawHandle` and `FromRawFd` for those 3 objects.

## Usecase

I have a usecase where those implementations are basically needed. I want to customize
in the `Command::spawn` API how the pipes for the parent/child communications are created (mainly to strengthen the security attributes on them). I can properly setup the pipes,
and the "child" handles can be provided to `Child::spawn` easily using `Stdio::from_raw_handle`. However, there is no way to generate the `ChildStd*` objects from the raw handle of the created name pipe, which would be very useful to still expose the same API
than in other OS (basically a `spawn(...) -> (Child, ChildStdin, ChildStdout, ChildSterr)`, where on windows this is customized), and to for example use `tokio::ChildStdin::from_std` afterwards.

## Questions

* Are those impls OK to add? I have searched to see if those impls were missing on purpose, or if it was just never implemented because never needed. I haven't found any indication on why they couldn't be added, although the user clearly has to be very careful that the handle provided makes sense (i think, mainly that it is in overlapped mode for windows).
* If this change is ok, adding the impls for the io_safety feature would probably be best, or should it be done in another PR?
* I just copy-pasted the `#[stable(...)]` attributes, but the `since` value has to be updated, I'm not sure to which value.
2023-09-28 09:59:03 +00:00
bors
6e09cff6d7 Auto merge of #116222 - matthiaskrgr:rollup-dnag90q, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #112959 (Change the wording in `std::fmt::Write::write_str`)
 - #115535 (format doc-comment code examples in std::process)
 - #115888 (fix a comment about assert_receiver_is_total_eq)
 - #116211 (more clippy complextity fixes )
 - #116213 (Document -Zlink-native-libraries)
 - #116215 (Tweak wording of missing angle backets in qualified path)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-28 08:05:39 +00:00
Matthias Krüger
698448c0cd
Rollup merge of #115888 - RalfJung:assert_receiver_is_total_eq, r=dtolnay
fix a comment about assert_receiver_is_total_eq

"a type implements #[deriving]" doesn't make any sense, so I assume they meant "implement `Eq`"? Also the attribute is called `derive`.
2023-09-28 09:14:06 +02:00
Matthias Krüger
0e338d7e23
Rollup merge of #115535 - tshepang:patch-2, r=dtolnay
format doc-comment code examples in std::process
2023-09-28 09:14:05 +02:00
Matthias Krüger
980fba7345
Rollup merge of #112959 - tbu-:pr_fmt_error_wording, r=dtolnay
Change the wording in `std::fmt::Write::write_str`

Refer to the error instead of expanding its name.
2023-09-28 09:14:05 +02:00
David Tolnay
9bdf9e754e
Update stability attribute for child stream From impls 2023-09-28 00:13:02 -07:00
bors
46da927abb Auto merge of #114041 - nvzqz:nvzqz/shared_from_array, r=dtolnay
Implement `From<[T; N]>` for `Rc<[T]>` and `Arc<[T]>`

Given that `Box<[T]>` already has this conversion, the shared counterparts should also have it.
2023-09-28 06:16:01 +00:00
David Tolnay
e2f7032408
Fix "unresolved link to std::fmt::Error"
error: unresolved link to `std::fmt::Error`
       --> library/core/src/fmt/mod.rs:115:52
        |
    115 |     /// This function will return an instance of [`std::fmt::Error`] on error.
        |
        |
        = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
2023-09-27 22:55:34 -07:00
bors
aeaa5c30e5 Auto merge of #111278 - EFanZh:implement-from-array-refs-for-vec, r=dtolnay
Implement `From<{&,&mut} [T; N]>` for `Vec<T>` where `T: Clone`

Currently, if `T` implements `Clone`, we can create a `Vec<T>` from an `&[T]` or an `&mut [T]`, can we also support creating a `Vec<T>` from an `&[T; N]` or an `&mut [T; N]`? Also, do I need to add `#[inline]` to the implementation?

ACP: rust-lang/libs-team#220. [Accepted]

Closes #100880.
2023-09-28 04:26:40 +00:00
bors
27b4eb96d1 Auto merge of #116125 - RalfJung:const-param-ty-eq, r=compiler-errors
ConstParamTy: require Eq as supertrait

As discussed with `@BoxyUwu` [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/.60ConstParamTy.60.20and.20.60Eq.60).

We want to say that valtree equality on const generic params agrees with `==`, but that only makes sense if `==` actually exists, hence we should have an appropriate bound. Valtree equality is an equivalence relation, so such a type can always be `Eq` and not just `PartialEq`.
2023-09-26 05:33:55 +00:00
bors
a6dce3bac5 Auto merge of #116124 - WaffleLapkin:fix-proc-macro-literal-to-string, r=compiler-errors
Properly print cstr literals in `proc_macro::Literal::to_string`

Previously we printed the contents of the string, rather than the actual string literal (e.g. `the c string` instead of `c"the c string"`).

Fixes #112820
cc #105723
2023-09-26 03:39:25 +00:00
bors
7bf47a4792 Auto merge of #116070 - eduardosm:IoSlice-advance_slices-checked_add, r=Mark-Simulacrum
Avoid overflow in `IoSlice::advance_slices`

Noticed in https://github.com/rust-lang/rust/issues/62726#issuecomment-1713997431.
2023-09-25 18:29:26 +00:00
bors
8c04c06317 Auto merge of #116074 - fzs111:clarify-pin-docs, r=Mark-Simulacrum
Clarify example in `Pin::new_unchecked` docs

This example in the docs of `Pin::new_unchecked` puzzled me for a relatively long time. Now I understand that it comes down to the difference between dropping the `Pin` vs dropping the pinned value.

I have extended the explanation to highlight this difference. In my opinion it is clearer now, and I hope it helps others understand `Pin` better.
2023-09-25 03:50:59 +00:00
bors
5105b1ec58 Auto merge of #116057 - RalfJung:io-safety, r=Mark-Simulacrum
fix OS-specific I/O safety docs since the io_safety feature is stable

Looks like this text was forgotten to be updated when `io_safety` got stabilized: it still says "once the io_safety feature is stable".

Also adjust the wording a bit for how these docs relate to the general concept of I/O safety.
2023-09-25 00:17:13 +00:00
Ralf Jung
ad509633a2 ConstParamTy: require Eq 2023-09-24 23:38:07 +02:00
Maybe Waffle
285e574b8e Fix .to_string() of proc_macro::Literal (properly print cstr literals) 2023-09-24 20:05:27 +00:00
bors
c7224e3c95 Auto merge of #105861 - Ayush1325:uefi-std-minimial, r=workingjubilee
Add Minimal Std implementation for UEFI

# Implemented modules:
1. alloc
2. os_str
3. env
4. math

# Related Links
Tracking Issue: https://github.com/rust-lang/rust/issues/100499
API Change Proposal: https://github.com/rust-lang/libs-team/issues/87

# Additional Information
This was originally part of https://github.com/rust-lang/rust/pull/100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from `@dvdhrm,` I have extracted a minimal std implementation to this PR.

The example in `src/doc/rustc/src/platform-support/unknown-uefi.md` has been tested for `x86_64-unknown-uefi` and `i686-unknown-uefi` in OVMF. It would be great if someone more familiar with AARCH64 can help with testing for that target.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-24 09:47:30 +00:00
bors
44bd31c216 Auto merge of #116075 - Colonial-Dev:issue-116063-fix, r=Mark-Simulacrum
Document panics on unsigned wrapping_div/rem calls (#116063)

Add missing `# Panics` sections to the `uint_impl!` macro, documenting that the `wrapping_rem/div` calls will panic if passed zero.
2023-09-24 07:59:00 +00:00
bors
8a6bae2824 Auto merge of #115416 - c410-f3r:match_cfg, r=Amanieu
Add the `cfg_match!` macro

# Movitation

Adds a match-like version of the `cfg_if` crate without a RFC [for the same reasons that caused `matches!` to be included in the standard library](https://github.com/rust-lang/rust/pull/65479).

* General-purpose (not domain-specific)
* Simple (the implementation is short) and useful (things can become difficult with several `cfg`s)
* Very popular [on crates.io ](https://crates.io/crates/cfg-if) (currently 3th in all-time downloads)
* The two previous points combined make it number three in [left-pad index](https://twitter.com/bascule/status/1184523027888988160) score

```rust
match_cfg! {
    cfg(unix) => {
        fn foo() { /* unix specific functionality */ }
    }
    cfg(target_pointer_width = "32") => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}
```

# Considerations

A match-like syntax feels more natural in the sense that each macro fragment resembles an arm but I personally don't mind switching to any other desired syntax.

The lack of `#[ ... ]` is intended to reduce typing, nevertheless, the same reasoning described above can also be applied to this aspect.

Since blocks are intended to only contain items, anything but `cfg` is not expected to be supported at the current or future time.

~~Credits goes to `@gnzlbg` because most of the code was shamelessly copied from https://github.com/gnzlbg/match_cfg.~~
Credits goes to `@alexcrichton` because most of the code was shamelessly copied from https://github.com/rust-lang/cfg-if.
2023-09-24 04:23:43 +00:00
bors
42ca6e4e57 Auto merge of #104385 - BlackHoleFox:apple-minimum-bumps, r=petrochenkov
Raise minimum supported Apple OS versions

This implements the proposal to raise the minimum supported Apple OS versions as laid out in the now-completed MCP (https://github.com/rust-lang/compiler-team/issues/556).

As of this PR, rustc and the stdlib now support these versions as the baseline:
- macOS: 10.12 Sierra
- iOS: 10
- tvOS: 10
- watchOS: 5 (Unchanged)

In addition to everything this breaks indirectly, these changes also erase the `armv7-apple-ios` target (currently tier 3) because the oldest supported iOS device now uses ARMv7s. Not sure what the policy around tier3 target removal is but shimming it is not an option due to the linker refusing.

[Per comment](https://github.com/rust-lang/compiler-team/issues/556#issuecomment-1297175073), this requires a FCP to merge. cc `@wesleywiser.`
2023-09-24 02:35:05 +00:00
BlackHoleFox
3b52befdce Raise minimum supported iOS version to 10.0
Drop the armv7-apple-ios target too because its no longer supported
with the hardware iOS 10 requires.
2023-09-23 19:14:25 -05:00
BlackHoleFox
58bbca958d Raise minimum supported macOS to 10.12 2023-09-23 19:14:25 -05:00
Emil Gardström
74f5261345
implement Literal::byte_character
without this, the only way to create a `LitKind::Byte` is by
doing `"b'a'".parse::<Literal>()`, this solves that by enabling
`Literal::byte_character(b'a')`
2023-09-23 23:29:47 +02:00
Caio
d63959f2fa Add the cfg_match! macro 2023-09-23 14:23:51 -03:00
FZs
0f248d8ea9 Clarify example in Pin::new_unchecked docs 2023-09-23 17:28:43 +02:00
Eduardo Sánchez Muñoz
93863383c8 Avoid overflow in IoSlice::advance_slices 2023-09-23 16:27:57 +02:00
James Haywood
f286a75692 Extend fix to wrapping_div, wrapping_div_euclid and wrapping_rem_euclid 2023-09-22 18:07:17 -04:00
James Haywood
1170b7b447 Resolve rust-lang/rust#116063 2023-09-22 15:52:07 -04:00
Ayush Singh
984ecefed8
Fixes from PR
- Hide Docs
- Use repr_unpacked error

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-09-22 23:56:51 +05:30
Ayush Singh
c7e5f3ca08
Rebase to master
- Update Example
- Add thread_parking to sys::uefi
- Fix unsafe in unsafe errors
- Improve docs
- Improve os/exit
- Some asserts
- Switch back to atomics

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-09-22 17:23:33 +05:30
Ayush Singh
40c3dacc76
Use RawOsError for UEFI
Some changes from this commit will probably be converted to its own PR.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:33 +05:30
Ayush Singh
7a956441a1
Fixes from PR
- Some comment fixes.
- Make some functions unsafe.
- Make helpers module private.
- Rebase on master
- Update r-efi to v4.2.0

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:33 +05:30
Ayush Singh
5df24d18b6
Add support for building std::os::uefi docs
Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:33 +05:30
Ayush Singh
032e3766d5
Handle ExitBootServices
- Make BootServices unavailable if ExitBootServices event is signaled.
- Use thread locals for SystemTable and ImageHandle

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:33 +05:30
Ayush Singh
8e56b33d59
Fixes from PR
Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:32 +05:30
Ayush Singh
48c6ae0611
Add Minimal Std implementation for UEFI
Implemented modules:
1. alloc
2. os_str
3. env
4. math

Tracking Issue: https://github.com/rust-lang/rust/issues/100499
API Change Proposal: https://github.com/rust-lang/libs-team/issues/87

This was originally part of https://github.com/rust-lang/rust/pull/100316. Since
that PR was becoming too unwieldy and cluttered, and with suggestion
from @dvdhrm, I have extracted a minimal std implementation to this PR.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:30 +05:30
Ralf Jung
813fed2904 fix OS-specific I/O safety docs since the io_safety feature is stable 2023-09-22 13:23:19 +02:00
bors
03c199af8e Auto merge of #116054 - matthiaskrgr:rollup-3pusno6, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114379 (Command: also print removed env vars)
 - #116034 (add UI test for delimiter errors)
 - #116036 (tests/ui: Split large_moves.rs and move to lint/large_assignments)
 - #116038 (Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty mask)
 - #116039 (Account for nested `impl Trait` in TAIT)
 - #116041 (Add note to `is_known_rigid`)
 - #116049 (give FutureIncompatibilityReason variants more explicit names)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-22 10:34:45 +00:00
Matthias Krüger
faf13dd112
Rollup merge of #116038 - the8472:panic-on-sched_getaffinity-bug, r=cuviper
Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty mask

Followup to #115946
A gentler fix for #115868, one that doesn't panic, [suggested on zulip](https://rust-lang.zulipchat.com/#narrow/stream/259402-t-libs.2Fmeetings/topic/Meeting.202023-09-19/near/391942927)

In that situation - on the buggy kernel versions - a zero-mask means no affinities have been set so `_SC_NPROCESSORS_ONLN` provides the right value.
2023-09-22 12:15:27 +02:00
Matthias Krüger
9887dfab2c
Rollup merge of #114379 - RalfJung:command-removed-env-vars, r=m-ou-se
Command: also print removed env vars

There is no real shell syntax for unsetting an env var so easily, so we have to make one up. But we already do that for showing the 'program' name so I hope that's okay here, too. No strong opinion on what that should look like, I went with `unset(VAR_NAME)` for now.
2023-09-22 12:15:25 +02:00
bors
5a4e47ebed Auto merge of #114780 - RalfJung:io-safety, r=Amanieu
add more explicit I/O safety documentation

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/434
Cc https://github.com/rust-lang/rust/issues/114167
Cc `@Manishearth` `@sunfishcode` `@joshtriplett`
2023-09-22 08:47:51 +00:00
bors
8759de0a49 Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obk
Enable effects for libcore

~~r? `@oli-obk~~`

forgot you are on vacation, oops
2023-09-22 07:00:52 +00:00
bors
f73d376fb6 Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber
added support for GNU/Hurd

adding support for i686-unknown-hurd-gnu
2023-09-21 19:24:01 +00:00
The 8472
31cfa4a956 Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty mask 2023-09-21 20:05:24 +02:00
Samuel Thibault
dcea7709f2 added support for GNU/Hurd 2023-09-21 17:31:25 +02:00
Guillaume Gomez
0d2c603b12
Rollup merge of #116007 - m-ou-se:const-panic-fmt-panic-display, r=oli-obk
Call panic_display directly in const_panic_fmt.

`panic_str` just directly calls `panic_display`. The only reason `panic_str` exists, is for a lint to detect an expansion of `panic_2015!(expr)` (which expands to `panic_str`).

It is `panic_display` that is hooked by const-eval, which is the reason we call it here.

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

r? ``@oli-obk``
2023-09-21 13:25:40 +02:00
bors
cbce15c617 Auto merge of #116013 - matthiaskrgr:rollup-mv5i4fd, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #114394 (style-guide: Document formatting of `as` casts (mostly like a binary operator))
 - #115990 (Allow anyone to set llvm-fixed-upstream)
 - #116008 (Rename BoxMeUp to PanicPayload.)
 - #116011 (Update browser-ui-test version to 0.16.10)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-21 01:02:00 +00:00
Matthias Krüger
6bcae4c93e
Rollup merge of #116008 - m-ou-se:boxmeup, r=oli-obk
Rename BoxMeUp to PanicPayload.

"BoxMeUp" is not very clear. Let's rename that to a description of what it actually represents: a panic payload.

This PR also renames the structs that implement this trait to have more descriptive names.

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

r? `@oli-obk`
2023-09-21 00:11:37 +02:00