Commit Graph

10139 Commits

Author SHA1 Message Date
Anders Kaseorg
8c73ce6611 Update coerce_unsized tracking issue from #27732 to #18598
Issue #27732 was closed as a duplicate of #18598.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-12-19 23:09:47 -08:00
Ulrich Weigand
eb22d70aed Implement va_list and va_arg for s390x FFI
Following the s390x ELF ABI and based on the clang implementation,
provide appropriate definitions of va_list in library/core/src/ffi/mod.rs
and va_arg handling in compiler/rustc_codegen_llvm/src/va_arg.rs.

Fixes the following test cases on s390x:
src/test/run-make-fulldeps/c-link-to-rust-va-list-fn
src/test/ui/abi/variadic-ffi.rs

Fixes https://github.com/rust-lang/rust/issues/84628.
2022-12-19 21:07:57 +01:00
Matthias Krüger
575b2a2232
Rollup merge of #105915 - andrewpollack:revert-105250-async-rm-resumety, r=tmandry
Revert "Replace usage of `ResumeTy` in async lowering with `Context`"

Reverts rust-lang/rust#105250
Fixes: #105501

Following instructions from [forge](https://forge.rust-lang.org/compiler/reviews.html#reverts).

This change introduced a breaking change that is not actionable nor relevant, and is blocking updates to our toolchain. Along with other comments on the CL marking issues that are fixed by reverts, reverting is best until these issues can be resolved

cc. `@Swatinem`
2022-12-19 20:55:00 +01:00
Matthias Krüger
a81d0dc3cd
Rollup merge of #105902 - vincenzopalazzo:macros/pin_docs, r=eholk
docs: improve pin docs

Override https://github.com/rust-lang/rust/pull/104195 with a full cleanup of the git history, now it should be ready to be merged.

r? ``@eholk``

``@rustbot`` label +A-async-await
2022-12-19 20:54:59 +01:00
Matthias Krüger
3af45eeb98
Rollup merge of #105801 - zertosh:path_mut_os_str_doc_test, r=dtolnay
Realistic `Path::as_mut_os_str` doctest

With "Implement DerefMut for PathBuf" (#105018) now merged, it's
possible to exercise `Path::as_mut_os_str` (#105002) without going
through `into_boxed_path`.
2022-12-19 20:54:57 +01:00
Andrew Pollack
8441ca5d81
Revert "Replace usage of ResumeTy in async lowering with Context" 2022-12-19 11:24:59 -08:00
bors
7ab803891d Auto merge of #105698 - joboet:unsupported_threads_once, r=thomcc
Use a more efficient `Once` on platforms without threads

The current implementation uses an atomic queue and spins rather than panicking when calling `call_once` recursively. Since concurrency is not supported on platforms like WASM, `Once` can be implemented much more efficiently using just a single non-atomic state variable.
2022-12-19 16:46:57 +00:00
ch-iv
7fc6b0c9f3
docs: improve pin docs
Co-authored-by: <@ch-iv>
2022-12-19 15:46:44 +01:00
Dylan DPC
2a57493fa1
Rollup merge of #105889 - Nilstrieb:fmt-libtest, r=thomcc
Fix `uninlined_format_args` in libtest

Done using clippy with a quick manual review.
2022-12-19 14:41:37 +05:30
Dylan DPC
f74bcfbdb1
Rollup merge of #105682 - thomcc:expose-ptr-fmt, r=RalfJung
Use `expose_addr()` in `fmt::Pointer`

Discussion in https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Should.20.60fmt.3A.3APointer.60.20expose.20the.20argument.3F on whether or not we should do this (still undecided).

CC `@RalfJung`
2022-12-19 14:41:34 +05:30
nils
5fb2d63d07
Fix uninlined_format_args in libtest 2022-12-19 08:58:40 +01:00
Matthias Krüger
63fdc9a857
Rollup merge of #105858 - scottmcm:extra-as-chunks-example, r=the8472
Another `as_chunks` example

I really liked this structure that dtolney brought up in #105316, so wanted to put it in the docs to help others use it.
2022-12-18 18:57:04 +01:00
bors
48b3c46126 Auto merge of #105638 - tavianator:fix-50619-again, r=Mark-Simulacrum
fs: Fix #50619 (again) and add a regression test

Bug #50619 was fixed by adding an end_of_stream flag in #50630.
Unfortunately, that fix only applied to the readdir_r() path.  When I
switched Linux to use readdir() in #92778, I inadvertently reintroduced
the bug on that platform.  Other platforms that had always used
readdir() were presumably never fixed.

This patch enables end_of_stream for all platforms, and adds a
Linux-specific regression test that should hopefully prevent the bug
from being reintroduced again.
2022-12-18 05:04:04 +00:00
Scott McMurray
a37d42133c Another as_chunks example
I really liked this structure that dtolney brought up in #105316, so wanted to put it in the docs to help others use it.
2022-12-17 18:41:14 -08:00
Matthias Krüger
8fc1a72e56
Rollup merge of #105836 - evanj:fmt-doc-use-variables, r=Mark-Simulacrum
std::fmt: Use args directly in example code

The lint "clippy::uninlined_format_args" recommends inline variables in format strings. Fix two places in the docs that do not do this. I noticed this because I copy/pasted one example in to my project, then noticed this lint error. This fixes:

```
error: variables can be used directly in the `format!` string
  --> src/main.rs:30:22
   |
30 |         let string = format!("{:.*}", decimals, magnitude);
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: variables can be used directly in the `format!` string
  --> src/main.rs:39:2
   |
39 |  write!(&mut io::stdout(), "{}", args).unwrap();
```
2022-12-17 23:44:29 +01:00
Matthias Krüger
eaf2f26ecc
Rollup merge of #105814 - JakobDegen:custom-mir-terms, r=oli-obk
Support call and drop terminators in custom mir

The only caveat with this change is that cleanup blocks are not supported. I would like to add them, but it's not quite clear to me what the best way to do that is, so I'll have to think about it some more.

r? ``@oli-obk``
2022-12-17 23:44:28 +01:00
Matthias Krüger
6d1cdcaee5
Rollup merge of #105458 - Ayush1325:blocking_spawn, r=Mark-Simulacrum
Allow blocking `Command::output`

### Problem
Currently, `Command::output` is internally implemented using `Command::spawn`. This is problematic because some targets (like UEFI) do not actually support multitasking and thus block while the program is executing. This coupling does not make much sense as `Command::output` is supposed to block until the execution is complete anyway and thus does not need to rely on a non-blocking `Child` or any other intermediate.

### Solution
This PR moves the implementation of `Command::output` to `std::sys`. This means targets can choose to implement only `Command::output` without having to implement `Command::spawn`.

### Additional Information

This was originally conceived when working on https://github.com/rust-lang/rust/pull/100316. Currently, the only target I know about that will benefit from this change is UEFI.

This PR can also be used to implement more efficient `Command::output` since the intermediate `Process` is not actually needed anymore, but that is outside the scope of this PR.

Since this is not a public API change, I'm not sure if an RFC is needed or not.
2022-12-17 23:44:26 +01:00
Evan Jones
ab2151cbf8 std::fmt: Use args directly in example code
The lint "clippy::uninlined_format_args" recommends inline
variables in format strings. Fix two places in the docs that do
not do this. I noticed this because I copy/pasted one example in
to my project, then noticed this lint error. This fixes:

error: variables can be used directly in the `format!` string
  --> src/main.rs:30:22
   |
30 |         let string = format!("{:.*}", decimals, magnitude);
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: variables can be used directly in the `format!` string
  --> src/main.rs:39:2
   |
39 |  write!(&mut io::stdout(), "{}", args).unwrap();
2022-12-17 13:43:08 -05:00
Stefano Zacchiroli
7f9438910c
str.lines() docstring: clarify that line endings are not returned
Previously, the str.lines() docstring stated that lines are split at line
endings, but not whether those were returned or not.  This new version of the
docstring states this explicitly, avoiding the need of getting to doctests to
get an answer to this FAQ.
2022-12-17 12:20:56 +01:00
bors
fde3000299 Auto merge of #105794 - ChrisDenton:internal-doc, r=jyn514
Add CI test for documentation of hidden items in std

Fixes #87844

r? `@jyn514`
2022-12-17 06:27:30 +00:00
Jakob Degen
3d849ae44c Support call and drop terminators in custom mir 2022-12-16 22:26:33 -08:00
Andres Suarez
c68d2e4b87 Realistic Path::as_mut_os_str doctest 2022-12-16 16:52:36 -05:00
Chris Denton
8534fd3089
Fix intra-doc link 2022-12-16 20:21:44 +00:00
bors
9c07efe84f Auto merge of #105018 - zertosh:path_buf_deref_mut, r=dtolnay
Implement DerefMut for PathBuf

Without this, there's no way to get a `&mut Path` from `PathBuf` without
going through `into_boxed_path`. This is relevant now that #105002 adds
`PathBuf::as_mut_os_string` and `Path::as_mut_os_str`.
2022-12-16 18:06:10 +00:00
Matthias Krüger
1ad070a118
Rollup merge of #105748 - hakoerber:master, r=Dylan-DPC
doc: Fix a few small issues

Hey, while reading through the (awesome) stdlib docs, I found a few minor typos.

* A few typos around generic types (`;` vs `,`)
* Use inline code formatting for code fragments
* One instance of wrong wording
2022-12-16 14:02:19 +01:00
bors
ec56537c43 Auto merge of #105356 - JakobDegen:more-custom-mir, r=oli-obk
Custom MIR: Many more improvements

Commits are each atomic changes, best reviewed one at a time, with the exception that the last commit includes all the documentation.

### First commit

Unsafetyck was not correctly disabled before for `dialect = "built"` custom MIR. This is fixed and a regression test is added.

### Second commit

Implements `Discriminant`, `SetDiscriminant`, and `SwitchInt`.

### Third commit

Implements indexing, field, and variant projections.

### Fourth commit

Documents the previous commits and everything else.

There is some amount of weirdness here due to having to beat Rust syntax into cooperating with MIR concepts, but it hopefully should not be too much. All of it is documented.

r? `@oli-obk`
2022-12-15 19:59:48 +00:00
Hannes Körber
9671dd239d doc: Fix a few small issues
* A few typos around generic types (`;` vs `,`)
* Use inline code formatting for code fragments
* One instance of wrong wording
2022-12-15 14:05:03 +01:00
Jacob Pratt
b134d1108f
Implement From<bool> for f32, f64 2022-12-15 03:55:21 +00:00
Matthias Krüger
6d3a93c823
Rollup merge of #105598 - RalfJung:more-comments, r=the8472
explain mem::forget(env_lock) in fork/exec

I stumbled upon this while doing triage for https://github.com/rust-lang/rust/issues/64718.
2022-12-14 17:17:57 +01:00
Matthias Krüger
35ff2cf295
Rollup merge of #105399 - mikebenfield:lfs, r=thomcc
Use more LFS functions.

On Linux, use mmap64, open64, openat64, and sendfile64 in place of their non-LFS counterparts.

This is relevant to #94173.

With these changes (together with rust-lang/backtrace-rs#501), the simple binaries I produce with rustc seem to have no non-LFS functions, so maybe #94173 is fixed. But I can't be sure if I've missed something and maybe some non-LFS functions could sneak in somehow.
2022-12-14 17:17:56 +01:00
Tavian Barnes
9fb7c5ae5e fs/tests: Fail fast on duplicate errors rather than looping indefinitely 2022-12-14 10:03:46 -05:00
Tavian Barnes
1550a2506d fs/tests: Explicitly kill the zombie rather than sleeping until it dies 2022-12-14 10:03:42 -05:00
joboet
f9b56846ef
std: use a more efficient Once on platforms without threads 2022-12-14 13:55:30 +01:00
bors
ba64ba8b0d Auto merge of #105690 - matthiaskrgr:rollup-khtq97k, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #105642 (Minor grammar nit.)
 - #105658 (Remove ..X from RELEASES.md)
 - #105663 (Adjust log line in `fuchsia-test-runner.py`)
 - #105664 (rustdoc: apply `pre-wrap` CSS to code-wrapped links)
 - #105665 (rustdoc: simplify popover CSS)
 - #105676 (rustdoc: add CSS margin between `impl` docblock and its items)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-14 12:46:08 +00:00
Matthias Krüger
549ba2e198
Rollup merge of #105642 - uberFoo:master, r=Dylan-DPC
Minor grammar nit.

I was browsing the documentation and noticed that this should be an adverb.
2022-12-14 10:58:46 +01:00
Matthias Krüger
e5fde968db
Rollup merge of #105523 - estebank:suggest-collect-vec, r=compiler-errors
Suggest `collect`ing into `Vec<_>`

Fix #105510.
2022-12-14 10:31:07 +01:00
Jakob Degen
b580f29b74 Address documentation suggestions 2022-12-14 01:10:43 -08:00
Jakob Degen
aca1bc5f37 Add documentation for custom mir 2022-12-14 01:10:41 -08:00
Jakob Degen
e59839454d Support more projections in custom mir 2022-12-14 01:10:19 -08:00
Jakob Degen
409f4d2adb Support common enum operations in custom mir 2022-12-14 01:10:16 -08:00
Thom Chiovoloni
f2d0366791
Use expose_addr() in fmt::Pointer 2022-12-13 20:53:14 -08:00
Chris AtLee
e0fd37dcf7 Improve wording for Option and Result 2022-12-13 14:49:10 -05:00
Chris AtLee
b486fd5d83 Add docs for question mark operator for Option 2022-12-13 14:45:12 -05:00
Esteban Küber
9d5e7d3c04 Suggest collecting into Vec<_> 2022-12-13 10:39:44 -08:00
Nilstrieb
8b2a7da3b0 Rename assert_uninit_valid intrinsic
It's not about "uninit" anymore but about "filling with 0x01 bytes" so
the name should at least try to reflect that.
2022-12-13 18:08:35 +01:00
Keith T. Star
c3329ba63a Minor grammar nit. 2022-12-12 16:22:01 -07:00
Tavian Barnes
ba4dd464f5 fs: Fix #50619 (again) and add a regression test
Bug #50619 was fixed by adding an end_of_stream flag in #50630.
Unfortunately, that fix only applied to the readdir_r() path.  When I
switched Linux to use readdir() in #92778, I inadvertently reintroduced
the bug on that platform.  Other platforms that had always used
readdir() were presumably never fixed.

This patch enables end_of_stream for all platforms, and adds a
Linux-specific regression test that should hopefully prevent the bug
from being reintroduced again.
2022-12-12 17:17:26 -05:00
Ralf Jung
3465d5fb16 explain mem::forget(env_lock) in fork/exec 2022-12-12 21:02:49 +01:00
Matthias Krüger
f5852c41a0
Rollup merge of #105616 - est31:add_the, r=Dylan-DPC
Add a "the" to proc_macro documentation
2022-12-12 19:20:37 +01:00
est31
3c809b3c5c Add a "the" to proc_macro documentation 2022-12-12 16:19:18 +01:00
Albert Larsan
736342bb46
Correct typos in core::sync::Exclusive::get_{pin_mut, mut} 2022-12-12 09:19:17 +01:00
raffimolero
46f6e39ac6
add assert messages if chunks/windows are length 0 2022-12-12 12:28:40 +08:00
Matthias Krüger
668976b80a
Rollup merge of #101648 - Timmmm:home_dir_docs, r=joshtriplett
Better documentation for env::home_dir()'s broken behaviour

This improves the documentation to say *why* it was deprecated. The reason was because it reads `HOME` on Windows which is meaningless there. Note that the PR that deprecated it stated that returning an empty string if `HOME` is set to an empty string was a problem, however I can find no evidence that this is the case. `cd` handles it fine whereas if `HOME` is unset it gives an explicit `HOME not set` error.

* Original deprecation reason: https://internals.rust-lang.org/t/deprecate-or-break-fix-std-env-home-dir/7315
* Original deprecation PR: https://github.com/rust-lang/rust/pull/51656

See #71684
2022-12-11 23:36:44 +01:00
bors
4de4d60779 Auto merge of #105508 - eduardosm:ptr-methods-inline-always, r=Mark-Simulacrum
Make pointer `sub` and `wrapping_sub` methods `#[inline(always)]`

Splitted from https://github.com/rust-lang/rust/pull/105262
2022-12-11 11:42:15 +00:00
Ayush Singh
a94793d8d1
Implement blocking output
This allows decoupling `Command::spawn` and `Command::output`. This is
useful for targets which do support launching programs in blocking mode
but do not support multitasking (Eg: UEFI).

This was originally conceived when working on https://github.com/rust-lang/rust/pull/100316

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-12-11 10:21:40 +05:30
Matthias Krüger
e47c96a9cf
Rollup merge of #105460 - mkroening:compiler-builtins-0.1.85, r=Mark-Simulacrum
Bump compiler-builtins to 0.1.85

This makes minimal floating point symbols available on `x86_64-unknown-none`.

See https://github.com/rust-lang/compiler-builtins/issues/509 and https://github.com/rust-lang/compiler-builtins/pull/510.
2022-12-11 00:30:19 +01:00
Matthias Krüger
7f4e7c159b
Rollup merge of #103146 - joboet:cleanup_pthread_condvar, r=Mark-Simulacrum
Cleanup timeouts in pthread condvar
2022-12-11 00:30:18 +01:00
Matthias Krüger
43bee03a67
Rollup merge of #105239 - gh2o:no-heap-alloc-on-thread-start, r=cuviper
Avoid heap allocation when truncating thread names

Ensure that heap allocation does not occur in a thread until `std::thread` is ready. This fixes issues with custom allocators that call `std:🧵:current()`, since doing so prematurely initializes `THREAD_INFO` and causes the following `thread_info::set()` to fail.
2022-12-10 15:01:44 +01:00
Matthias Krüger
f6c2add0ed
Rollup merge of #105522 - est31:remove_or_and_note, r=scottmcm
Remove wrong note for short circuiting operators

They *are* representable by traits, even if the short-circuiting behaviour requires a different approach than the non-short-circuiting operators. For an example proposal, see the postponed [RFC 2722](https://github.com/rust-lang/rfcs/pull/2722). As it is not accurate, remove most of the note.
2022-12-10 09:24:45 +01:00
Matthias Krüger
eb1159cbd8
Rollup merge of #104901 - krtab:filetype_compare, r=the8472
Implement masking in FileType comparison on Unix

Fixes: https://github.com/rust-lang/rust/issues/104900
2022-12-10 09:24:42 +01:00
Matthias Krüger
ae8794ce6a
Rollup merge of #98391 - joboet:sgx_parker, r=m-ou-se
Reimplement std's thread parker on top of events on SGX

Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore, the generic `Parker` needs to be replaced on all platforms where the new lock implementation will be used.

SGX enclaves have a per-thread event state, which allows waiting for and setting specific bits. This is already used by the current mutex implementation. The thread parker can however be much more efficient, as it only needs to store the `TCS` address of one thread. This address is stored in a state variable, which can also be set to indicate the thread was already notified.

`park_timeout` does not guard against spurious wakeups like the current condition variable does. This is allowed by the API of `Parker`, and I think it is better to let users handle these wakeups themselves as the guarding is quite expensive and might not be necessary.

`@jethrogb` as you wrote the initial SGX support for `std`, I assume you are the target maintainer? Could you help me test this, please? Lacking a x86_64 chip, I can't run SGX.
2022-12-10 09:24:40 +01:00
est31
f069e7159f Correct wrong note for short circuiting operators
They *are* representable by traits, even if the short-circuiting
behaviour requires a different approach than the non-short-circuiting
operators. For an example proposal, see the postponed RFC 2722.
As it is not accurate, reword the note.
2022-12-10 08:11:19 +01:00
Matthias Krüger
5156fbdc74
Rollup merge of #105453 - scottmcm:vecdeque_from_iter, r=the8472
Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`

As suggested in https://github.com/rust-lang/rust/pull/105046#issuecomment-1330371695 by
r? ``@the8472``

`Vec` & `VecDeque`'s `IntoIter`s own the allocations, and even if advanced can be turned into `VecDeque`s in O(1).

This is just a specialization, not an API or doc commitment, so I don't think it needs an FCP.
2022-12-09 22:31:56 +01:00
Matthias Krüger
856027a73a
Rollup merge of #105265 - aDotInTheVoid:sum-product-on-unimplemented, r=estebank
Add `rustc_on_unimplemented` to `Sum` and `Product` trait.

Helps with #105184, but I don't think it fully fixes it.
2022-12-09 22:31:55 +01:00
Eduardo Sánchez Muñoz
3ed058bcbb Make <*{const,mut} T>::{,wrapping_}sub methods #[inline(always)] 2022-12-09 20:30:06 +01:00
bors
f058493307 Auto merge of #105262 - eduardosm:more-inline-always, r=thomcc
Make some trivial functions `#[inline(always)]`

This is some kind of follow-up of PRs like https://github.com/rust-lang/rust/pull/85218, https://github.com/rust-lang/rust/pull/84061, https://github.com/rust-lang/rust/pull/87150. Functions that do very basic operations are made `#[inline(always)]` to avoid pessimizing them in debug builds when compared to using built-in operations directly.
2022-12-09 15:42:18 +00:00
Arthur Carcano
24cd863a38 Replace hand-made masking by call to masked() method in FileType 2022-12-09 15:04:36 +01:00
Matthias Krüger
3d727315c5
Rollup merge of #105474 - RalfJung:typo, r=dtolnay
lib docs: fix typo

r? `@thomcc`
2022-12-09 07:25:48 +01:00
Matthias Krüger
0b4d57be53
Rollup merge of #105245 - RalfJung:align_to, r=Amanieu
attempt to clarify align_to docs

This is not intended the change the docs at all, but `@workingjubilee` said the current docs are incomprehensible to some people so this is an attempt to fix that. No idea if it helps, so -- feedback welcome.

(Please let's not use this to discuss *changing* the spec. Whoever wants to change the spec should please make a separate PR for that.)
2022-12-09 07:25:44 +01:00
Scott McMurray
6648134434 Apply review feedback; Fix no_global_oom_handling build 2022-12-08 22:08:55 -08:00
Gary Guo
5e44a65517 Implement allow-by-default multiple_supertrait_upcastable lint 2022-12-09 02:29:51 +00:00
Nixon Enraght-Moony
5626df9c90 Add rustc_on_unimplemented to Sum and Product trait. 2022-12-08 23:07:54 +00:00
Ralf Jung
a25791ee61 lib docs: fix typo 2022-12-08 22:36:57 +01:00
Martin Kröning
6324e5cb6a Bump compiler-builtins to 0.1.85 2022-12-08 15:34:46 +01:00
Ayush Singh
5479fe5f70
Add read_to_end for AnonPipe
Add `read_to_end` method for `sys::{target}::pipe::AnonPipe`. This allows
having a more optimized version of `read_to_end` for ChildStdout.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-12-08 18:12:15 +05:30
Matthias Krüger
433189b742
Rollup merge of #105434 - nbdd0121:lib, r=thomcc
Fix warning when libcore is compiled with no_fp_fmt_parse

Discovered when trying to compile Rust-for-Linux with Rust 1.66 beta.

It'll be helpful if this is backported to beta (should be trivial enough for backporting), so Rust-for-Linux's rust version bump wouldn't need to do `--cap-lints allow` for libcore.
2022-12-08 12:57:33 +01:00
Matthias Krüger
cd936cc812
Rollup merge of #105120 - solid-rs:patch/kmc-solid/maintainance, r=thomcc
kmc-solid: `std::sys` code maintenance

Includes a set of changes to fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets and make some other improvements.

- Address `fuzzy_provenance_casts` by using `expose_addr` and `from_exposed_addr` for pointer-integer casts
- Add a stub implementation of `is_terminal` (#98070)
- Address `unused_imports` and `unused_unsafe`
- Stop doing `Box::from_raw(&*(x: Box<T>) as *const T as *mut T)`
2022-12-08 12:57:29 +01:00
Scott McMurray
58e60ac211 Make VecDeque::from_iter O(1) from vec(_deque)::IntoIter 2022-12-08 01:42:45 -08:00
Gary Guo
a3c4c2ee1d Fix warning when libcore is compiled with no_fp_fmt_parse 2022-12-08 00:16:49 +00:00
Gavin Li
3c55af5b09 Avoid heap allocation when truncating thread names
Ensure that heap allocation does not occur in a thread until std::thread
is ready. This fixes issues with custom allocators that call
std:🧵:current(), since doing so prematurely initializes
THREAD_INFO and causes the following thread_info::set() to fail.
2022-12-07 13:12:29 -08:00
Michael Benfield
27011b4185 Use more LFS functions.
On Linux, use mmap64, open64, openat64, and sendfile64 in place of their
non-LFS counterparts.

This is relevant to #94173.

With these changes (together with rust-lang/backtrace-rs#501), the
simple binaries I produce with rustc seem to have no non-LFS functions,
so maybe #94173 is fixed. But I can't be sure if I've missed something
and maybe some non-LFS functions could sneak in somehow.
2022-12-07 19:58:04 +00:00
Eduardo Sánchez Muñoz
00e7b54d46 Make some trivial functions #[inline(always)] 2022-12-07 17:11:17 +01:00
bors
01fbc5ae78 Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc
Pass on null handle values to child process

Fixes #101645

In Windows, stdio handles are (semantically speaking) `Option<Handle>` where `Handle` is a non-zero value. When spawning a process with `Stdio::Inherit`, Rust currently turns zero values into `-1` values. This has the unfortunate effect of breaking console subprocesses (which typically need stdio) that are spawned from gui applications (that lack stdio by default) because the console process won't be assigned handles from the newly created console (as they usually would in that situation). Worse, `-1` is actually [a valid handle](https://doc.rust-lang.org/std/os/windows/io/struct.OwnedHandle.html) which means "the current process". So if a console process, for example, waits on stdin and it has a `-1` value then the process will end up waiting on itself.

This PR fixes it by propagating the nulls instead of converting them to `-1`.

While I think the current behaviour is a mistake, changing it (however justified) is an API change so I think this PR should at least have some input from t-libs-api. So choosing at random...

r? `@joshtriplett`
2022-12-07 13:52:52 +00:00
bors
91b8f34ac2 Auto merge of #104799 - pcc:linkage-fn, r=tmiasko
Support Option and similar enums as type of static variable with linkage attribute

Compiler MCP:
rust-lang/compiler-team#565
2022-12-07 10:24:59 +00:00
bors
023b5136b5 Auto merge of #105271 - eduardosm:inline-always-int-conv, r=scottmcm
Make integer-to-integer `From` impls `#[inline(always)]`

Splited from https://github.com/rust-lang/rust/pull/105262
2022-12-06 21:41:04 +00:00
Chris Denton
93b774a2a4
Don't set STARTF_USESTDHANDLES if none are set 2022-12-06 17:26:21 +00:00
Matthias Krüger
967085ecdf
Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk
Replace usage of `ResumeTy` in async lowering with `Context`

Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`.

Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air.

fixes https://github.com/rust-lang/rust/issues/104828 and https://github.com/rust-lang/rust/pull/104321#issuecomment-1336363077

r? `@oli-obk`
2022-12-06 16:54:54 +01:00
Matthias Krüger
7d8e329194
Rollup merge of #105243 - RalfJung:no-op-let, r=Mark-Simulacrum
remove no-op 'let _ = '

Also see the discussion at https://github.com/rust-lang/rust/pull/93563#discussion_r1034057555.

I don't know why these `Drop` implementations exist to begin with, given that their body does literally nothing, but did not want to change that. (It might affect dropck.)

Cc `````@ibraheemdev````` `````@Amanieu`````
2022-12-06 13:27:42 +01:00
Arthur Carcano
4198d2975d Implement masking in FileType hashing on Unix
Commit 77005950f0 implemented masking of
FileType to fix an issue[^1] in the semantic of FileType comparison.
This commit introduces masking to Hash to maintain the invariant that
x == y => hash(x) == hash(y).

[^1]: https://github.com/rust-lang/rust/issues/104900
2022-12-06 10:35:34 +01:00
Arpad Borsos
cf031a3355
Replace usage of ResumeTy in async lowering with Context
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`.

Usage of the `'static` lifetime here is technically "cheating", and replaces
the raw pointer in `ResumeTy` and the `get_context` fn that pulls the
correct lifetimes out of thin air.
2022-12-06 10:16:23 +01:00
Yuki Okushi
fa7d3ec630
Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillot
Fix dupe word typos
2022-12-06 12:48:52 +09:00
Peter Collingbourne
b4278b02a7 Reimplement weak! using Option. 2022-12-05 15:05:43 -08:00
Matthias Krüger
e84e8f4165
Rollup merge of #105222 - devnexen:fbsd_update_img, r=petrochenkov
std update libc version and freebsd image build dependencies
2022-12-05 20:43:43 +01:00
Matthias Krüger
8ad447c479
Rollup merge of #104912 - RalfJung:per, r=Mark-Simulacrum
PartialEq: PERs are homogeneous

PartialEq claims that it corresponds to a PER, but that is only a well-defined statement when `Rhs == Self`. There is no standard notion of PER on a relation between two different sets/types. So move this out of the first paragraph and clarify this.
2022-12-05 20:43:40 +01:00
Ralf Jung
ee21454e61 attempt to clarify align_to docs 2022-12-05 11:37:55 +01:00
bors
203c8765ea Auto merge of #105046 - scottmcm:vecdeque-vs-vec, r=Mark-Simulacrum
Send `VecDeque::from_iter` via `Vec::from_iter`

Since it's O(1) to convert between them now, might as well reuse the logic.

Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
2022-12-05 08:45:03 +00:00
Rageking8
58110572fb fix dupe word typos 2022-12-05 16:42:36 +08:00
Eduardo Sánchez Muñoz
2e51122647 Make integer-to-integer From impls #[inline(always)] 2022-12-04 22:55:18 +01:00
Ralf Jung
c823dfa8b2 remove no-op 'let _ = ' 2022-12-04 10:32:00 +01:00
bors
9e772114e6 Auto merge of #101514 - nvzqz:nvzqz/stabilize-nonzero-bits, r=thomcc
Stabilize `nonzero_bits`

Closes #94881, implemented by #93292.

This change stabilizes the associated `BITS` constant for `NonZero{U,I}{8,16,32,64,128,size}` integers, e.g.:

```rs
impl NonZeroUsize {
    pub const BITS: u32 = usize::BITS;
}
```
2022-12-04 08:28:22 +00:00