Commit Graph

14569 Commits

Author SHA1 Message Date
Matthias Krüger
177139032a
Rollup merge of #124322 - whosehang:master, r=Nilstrieb
chore: fix some typos in comments
2024-04-25 00:19:54 +02:00
bors
ef8b9dcf23 Auto merge of #124330 - fmease:rollup-a98y7jf, r=fmease
Rollup of 6 pull requests

Successful merges:

 - #123316 (Test `#[unix_sigpipe = "inherit"]` with both `SIG_DFL` and `SIG_IGN`)
 - #123794 (More DefineOpaqueTypes::Yes)
 - #123881 (Bump Fuchsia versions)
 - #124281 (fix weak memory bug in TLS on Windows)
 - #124282 (windows fill_utf16_buf: explain the expected return value)
 - #124308 (Add diagnostic item for `std::iter::Enumerate`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-24 19:26:50 +00:00
Gary Guo
f8a1cad07c Add cfg_attr(bootstrap) to doc tests 2024-04-24 13:12:33 +01:00
Gary Guo
94c1920497 Stabilise inline_const 2024-04-24 13:12:25 +01:00
León Orell Valerian Liehr
eaeaeb92a5
Rollup merge of #124308 - CBSpeir:diagnostic-item-enumerate, r=compiler-errors
Add diagnostic item for `std::iter::Enumerate`

This adds a diagnostic item for `std::iter::Enumerate`.  The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items.

see: https://github.com/rust-lang/rust-clippy/issues/5393
2024-04-24 14:00:58 +02:00
León Orell Valerian Liehr
388dc0d0b7
Rollup merge of #124282 - RalfJung:fill_utf16_buf, r=ChrisDenton
windows fill_utf16_buf: explain the expected return value

The comment just says "return what the syscall returns", but that doesn't work for all syscalls as the Windows API is not consistent in how buffer size is negotiated. For instance, GetUserProfileDirectoryW works a bit differently, and so home_dir_crt has to translate this to the usual protocol itself. So it's worth describing that protocol.

r? ``@ChrisDenton``
2024-04-24 14:00:57 +02:00
León Orell Valerian Liehr
4eda87603d
Rollup merge of #124281 - RalfJung:win-tls, r=joboet
fix weak memory bug in TLS on Windows

We need to store the `key` *after* we register the dtor.

Now I hope there isn't also some other reason why we have to actually register the dtor last... `@joboet` is there a reason you picked this particular order in https://github.com/rust-lang/rust/pull/102655?

Fixes https://github.com/rust-lang/rust/issues/123583
2024-04-24 14:00:57 +02:00
Oli Scherer
aef0f4024a Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00
whosehang
65d7c1d2d6 chore: fix some typos in comments
Signed-off-by: whosehang <whosehang@outlook.com>
2024-04-24 13:58:51 +08:00
Christopher B. Speir
bcc4469c2b Add diagnostic item for std::iter::Enumerate 2024-04-23 16:50:10 -05:00
bors
40dcd796d0 Auto merge of #124302 - matthiaskrgr:rollup-2aya8n8, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #124003 (Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics))
 - #124169 (Don't fatal when calling `expect_one_of` when recovering arg in `parse_seq`)
 - #124286 (Subtree sync for rustc_codegen_cranelift)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-23 18:23:46 +00:00
Matthias Krüger
918304b190
Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyo
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics)

This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226.

Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it.

r? ``@scottmcm``
2024-04-23 20:17:51 +02:00
León Orell Valerian Liehr
2d7d480054
Rollup merge of #123048 - RalfJung:layout, r=dtolnay
alloc::Layout: explicitly document size invariant on the type level

https://github.com/rust-lang/rust/pull/95295 added this to the constructor, but it seems worth documenting the type invariant at the type level.
2024-04-23 17:25:16 +02:00
Matthias Krüger
72e8fb4268
Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-se
panic_str only exists for the migration to 2021 panic macros

The only caller is `expect_failed`, which is already a cold inline(never) function, so inlining into that function should be fine. (And indeed `panic_str` was `#[inline]` anyway.)

The existence of panic_str risks someone calling it when they should call `panic` instead, and I can't see a reason why this footgun should exist.

I also extended the comment in `panic` to explain why it needs a `'static` string -- I know I've wondered about this in the past and it took me quite a while to understand.
2024-04-23 12:10:25 +02:00
Ralf Jung
d5d714bb34 fix weak memory bug in TLS on Windows 2024-04-23 10:42:45 +02:00
Ralf Jung
a21c2d8704 windows fill_utf16_buf: explain the expected return value 2024-04-23 09:32:35 +02:00
Matthias Krüger
819b4d5e5b
Rollup merge of #124266 - RalfJung:no-answer, r=joboet
remove an unused type from the reentrant lock tests

At least it seems unused. This was added back in 45aa6c8d1b together with a test related to poisoning; when the test got removed, it seems like it was forgotten to also remove this type.
2024-04-23 06:24:58 +02:00
bors
aca749eefc Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obk
Add simple async drop glue generation

This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work).

This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit).

Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html).

This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work.

Feature completeness:

 - [x] `AsyncDrop` trait
 - [ ] `async_drop_in_place_raw`/async drop glue generation support for
   - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.)
   - [x] Arrays and slices (array pointer is unsized into slice pointer)
   - [x] ADTs (enums, structs, unions)
   - [x] tuple-like types (tuples, closures)
   - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait))
   - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948)
 - [x] Async drop glue includes sync drop glue code
 - [x] Cleanup branch generation for `async_drop_in_place_raw`
 - [ ] Union rejects non-trivially async destructible fields
 - [ ] `AsyncDrop` implementation requires same bounds as type definition
 - [ ] Skip trivially destructible fields (optimization)
 - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators
 - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop)
 - [ ] Automatic async drop at the end of the scope in async context
2024-04-23 02:10:23 +00:00
Guillaume Gomez
6a326d889a
Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnay
Stabilize generic `NonZero`.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? `@dtolnay`
2024-04-22 20:26:00 +02:00
Guillaume Gomez
206e0df78d
Rollup merge of #115913 - FedericoStra:checked_ilog, r=the8472
checked_ilog: improve performance

Addresses #115874.

(This PR replicates the original #115875, which I accidentally closed by deleting my forked repository...)
2024-04-22 20:25:58 +02:00
Ralf Jung
df437a2af4 remove an unused type from the reentrant lock tests 2024-04-22 19:36:21 +02:00
Markus Reiter
33e68aadc9
Stabilize generic NonZero. 2024-04-22 18:48:47 +02:00
Matthias Krüger
c597ccf3f1
Rollup merge of #124246 - gurry:add-comma-in-abs-doc, r=jhpratt
Add comma at one place in `abs()` documentation

As suggested  by ``@RalfJung`` here: https://github.com/rust-lang/rust/pull/124184#discussion_r1573670533
2024-04-22 10:02:56 +02:00
Gurinder Singh
f31e4aef0b Add comma at one place in abs() documentation 2024-04-22 08:16:47 +05:30
Ben Kimock
9989d009c4 Update stdarch submodule 2024-04-21 21:35:17 -04:00
Scott McMurray
1398fe7a5e Address more PR feedback 2024-04-21 11:08:38 -07:00
Scott McMurray
de64ff76f8 Use it in the library, and InstSimplify it away in the easy places 2024-04-21 11:08:37 -07:00
Scott McMurray
4f4442655e Add an intrinsic that lowers to AggregateKind::RawPtr 2024-04-21 11:08:37 -07:00
Guillaume Gomez
24b8c54f6d
Rollup merge of #124184 - gurry:124152-suggest-unsigned-abs-in-abs-doc, r=jhpratt
Suggest using `unsigned_abs` in `abs` documentation

Fixes #124152
2024-04-21 13:30:26 +02:00
Guillaume Gomez
9efd1477ac
Rollup merge of #124089 - simlay:fix-preadv64-and-pwritev64-link-for-watchos-and-visionos, r=workingjubilee
Fix watchOS and visionOS for pread64 and pwrite64 calls

In #122880, links to `preadv64` and `pwritev64` were added for `watchOS` however the underlying [`weak!` macro did not include `target_os = "watchos"`](c45dee5efd/library/std/src/sys/pal/unix/weak.rs (L30-L74)).

This resulted in an `xcodebuild` error when targeting `watchOS`:
```
Undefined symbols for architecture arm64:
  "_preadv64", referenced from:
      __rust_extern_with_linkage_preadv64 in libliveview_native_core.a[274](std-324fdd8d31e8eaa2.std.e18cf7e8d0336778-cgu.08.rcgu.o)
  "_pwritev64", referenced from:
      __rust_extern_with_linkage_pwritev64 in libliveview_native_core.a[274](std-324fdd8d31e8eaa2.std.e18cf7e8d0336778-cgu.08.rcgu.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

So I added them. I also went ahead and added the same for visionOS because it's bound to create the same issue.
2024-04-21 13:30:25 +02:00
Sebastian Imlay
fa53b9f39c Fix watchOS and visionOS for pread64 and pwrite64 calls
* Refactor apple OSs  to use pwritev and preadv rather pwritev64 and preadv64
* Updated the comments for preadv and pwritev
2024-04-21 00:36:07 -04:00
bors
13eb8c736c Auto merge of #123930 - Mark-Simulacrum:vec-length-invariant, r=jhpratt
Tell LLVM Vec::len is invariant across growth

This allows LLVM to avoid re-loading it from memory.
2024-04-21 03:08:50 +00:00
Mark Rousskov
f1ae5314be Avoid reloading Vec::len across grow_one in push
This saves an extra load from memory.
2024-04-20 21:07:00 -04:00
bors
453ceafce3 Auto merge of #124208 - jieyouxu:rollup-gbgpu4u, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - #123379 (Print note with closure signature on type mismatch)
 - #123967 (static_mut_refs: use raw pointers to remove the remaining FIXME)
 - #123976 (Use fake libc in core test)
 - #123986 (lint-docs: Add redirects for renamed lints.)
 - #124053 (coverage: Branch coverage tests for lazy boolean operators)
 - #124071 (Add llvm-bitcode-linker to build manifest)
 - #124103 (Improve std::fs::Metadata Debug representation)
 - #124132 (llvm RustWrapper: explain OpBundlesIndirect argument type)
 - #124191 (Give a name to each distinct manipulation of pretty-printer FixupContext)
 - #124196 (mir-opt tests: rename unit-test -> test-mir-pass)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-20 22:35:56 +00:00
许杰友 Jieyou Xu (Joe)
418a07861a
Rollup merge of #124103 - dtolnay:metadatadebug, r=Mark-Simulacrum
Improve std::fs::Metadata Debug representation

- Remove duplication of `mode` between `file_type` and `permissions`, which both involve operating on the same mode_t integer
- Add `is_symlink`
- Add `len` in bytes
- Remove Ok wrapping around `modified`, `accessed`, `created`, which eliminates 6 useless lines

<table>
<tr><th>Before</th><th>After</th></tr>
<tr><td>

```console
Metadata {
    file_type: FileType(
        FileType {
            mode: 0o100600 (-rw-------),
        },
    ),
    is_dir: false,
    is_file: true,
    permissions: Permissions(
        FilePermissions {
            mode: 0o100600 (-rw-------),
        },
    ),
    modified: Ok(
        SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
    ),
    accessed: Ok(
        SystemTime {
            tv_sec: 1713402983,
            tv_nsec: 206999623,
        },
    ),
    created: Ok(
        SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
    ),
    ..
}
```
</td><td>

```console
Metadata {
    file_type: FileType {
        is_file: true,
        is_dir: false,
        is_symlink: false,
        ..
    },
    permissions: Permissions(
        FilePermissions {
            mode: 0o100600 (-rw-------),
        },
    ),
    len: 2096,
    modified: SystemTime {
        tv_sec: 1713402981,
        tv_nsec: 682983531,
    },
    accessed: SystemTime {
        tv_sec: 1713402983,
        tv_nsec: 206999623,
    },
    created: SystemTime {
        tv_sec: 1713402981,
        tv_nsec: 682983531,
    },
    ..
}

```
</td></tr></table>

Generated by:

```rust
fn main() {
    println!("{:#?}", std::fs::metadata("Cargo.toml").unwrap());
}
```
2024-04-20 21:45:37 +01:00
许杰友 Jieyou Xu (Joe)
a73aabfa92
Rollup merge of #123976 - ChrisDenton:no-libc-in-std-doc-tests, r=Mark-Simulacrum
Use fake libc in core test

The war on libc continues.

Some platforms may not need to link to the libc crate (and it's possible some may not even have a libc), therefore we shouldn't require it for tests. This creates dummy `malloc` and `free` implementations for use in the pointer docs, but, keeps the public documentation looking the same as before.
2024-04-20 21:45:35 +01:00
许杰友 Jieyou Xu (Joe)
ccd9880769
Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb
static_mut_refs: use raw pointers to remove the remaining FIXME

Using `SyncUnsafeCell` would not make a lot of sense IMO.
2024-04-20 21:45:35 +01:00
bors
dbce3b43b6 Auto merge of #122013 - Swatinem:unicode-gen-fastpath, r=scottmcm
Add a lower bound check to `unicode-table-generator` output

This adds a dedicated check for the lower bound
(if it is outside of ASCII range) to the output of the `unicode-table-generator` tool.

This generalized the ASCII-only fast-path, but only for the `Grapheme_Extend` property for now, as that is the only one with a lower bound outside of ASCII.
2024-04-20 20:33:25 +00:00
Arpad Borsos
488598c183
Add a lower bound check to unicode-table-generator output
This adds a dedicated check for the lower bound
(if it is outside of ASCII range) to the output of the `unicode-table-generator` tool.

This generalized the ASCII-only fast-path, but only for the `Grapheme_Extend` property for now,
as that is the only one with a lower bound outside of ASCII.
2024-04-20 10:16:45 +02:00
Gurinder Singh
02ac46c0c2 Suggest using unsigned_abs in abs documentation 2024-04-20 10:18:47 +05:30
bors
9c7b1f4848 Auto merge of #124114 - scottmcm:better-checked, r=workingjubilee
Make `checked` ops emit *unchecked* LLVM operations where feasible

For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write the checked methods in such a way that we stop emitting wrapping versions of them.

For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither
```rust
a.checked_sub(b).unwrap()
```
nor
```rust
a.checked_sub(b).unwrap_unchecked()
```
actually optimizes to `sub nuw`.  After this PR they do.

cc #103299
2024-04-20 04:11:16 +00:00
Jubilee
c8d58faba2
Rollup merge of #124116 - RalfJung:miri-rust-backtrace, r=Nilstrieb
when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation

Fixes https://github.com/rust-lang/miri/issues/2855
2024-04-18 21:38:57 -07:00
Jubilee
55c35dd22e
Rollup merge of #124019 - ChrisDenton:futex-raw-dylib, r=joboet
Use raw-dylib for Windows synchronization functions

Fixes #123999 by using the raw-dylib feature to specify the DLL to load the Windows futex functions from (e.g. [`WaitOnAddress`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress)). This avoids reliance on the import library causing that issue.

With apologies to ``@bjorn3,`` as it's currently necessary to revert this for cranelift.
2024-04-18 21:38:56 -07:00
Jubilee
3831cbb28f
Rollup merge of #123406 - krtab:fix_remainder_iterchunk, r=scottmcm
Force exhaustion in iter::ArrayChunks::into_remainder

Closes: #123333
2024-04-18 21:38:54 -07:00
Scott McMurray
986d9f104b Make checked ops emit *unchecked* LLVM operations where feasible
For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write then checked methods in such a way that we stop emitting wrapping versions of them.

For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither
```rust
a.checked_sub(b).unwrap()
```
nor
```rust
a.checked_sub(b).unwrap_unchecked()
```
actually optimizes to `sub nuw`.  After this PR they do.
2024-04-18 18:11:21 -07:00
bors
c5de414865 Auto merge of #123144 - dpaoliello:arm64eclib, r=GuillaumeGomez,ChrisDenton,wesleywiser
Add support for Arm64EC to the Standard Library

Adds the final pieces so that the standard library can be built for arm64ec-pc-windows-msvc (initially added in #119199)

* Bumps `windows-sys` to 0.56.0, which adds support for Arm64EC.
* Correctly set the `isEC` parameter for LLVM's `writeArchive` function.
* Add `#![feature(asm_experimental_arch)]` to library crates where Arm64EC inline assembly is used, as it is currently unstable.
2024-04-18 12:22:52 +00:00
Ralf Jung
3e633981ef when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation 2024-04-18 12:05:08 +02:00
David Tolnay
fdf93bbde0
Improve std::fs::Metadata Debug representation
Before:

    Metadata {
        file_type: FileType(
            FileType {
                mode: 0o100600 (-rw-------),
            },
        ),
        is_dir: false,
        is_file: true,
        permissions: Permissions(
            FilePermissions {
                mode: 0o100600 (-rw-------),
            },
        ),
        modified: Ok(
            SystemTime {
                tv_sec: 1713402981,
                tv_nsec: 682983531,
            },
        ),
        accessed: Ok(
            SystemTime {
                tv_sec: 1713402983,
                tv_nsec: 206999623,
            },
        ),
        created: Ok(
            SystemTime {
                tv_sec: 1713402981,
                tv_nsec: 682983531,
            },
        ),
        ..
    }

After:

    Metadata {
        file_type: FileType {
            is_dir: false,
            is_file: true,
            is_symlink: false,
            ..
        },
        permissions: Permissions(
            FilePermissions {
                mode: 0o100600 (-rw-------),
            },
        ),
        len: 2096,
        modified: SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
        accessed: SystemTime {
            tv_sec: 1713402983,
            tv_nsec: 206999623,
        },
        created: SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
        ..
    }
2024-04-17 18:43:29 -07:00
ardi
9cc9ba5cae fix: make str::from_raw_parts_mut mut 2024-04-18 01:46:49 +02:00
Matthias Krüger
8f3fd9394f
Rollup merge of #124049 - slanterns:const_io_structs_stabilize, r=jhpratt
Stabilize `const_io_structs`

This PR stabilizes `const_io_structs`.

Tracking issue: https://github.com/rust-lang/rust/issues/78812.
Implementation PR: https://github.com/rust-lang/rust/pull/78811.

FCPs already completed in the tracking issue.

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

```@rustbot``` label: +T-libs-api

r? libs-api
2024-04-17 18:01:39 +02:00