Commit Graph

236244 Commits

Author SHA1 Message Date
bors
e7bdc5f9f8 Auto merge of #114330 - RalfJung:dagling-ptr-deref, r=oli-obk
don't UB on dangling ptr deref, instead check inbounds on projections

This implements https://github.com/rust-lang/reference/pull/1387 in Miri. See that PR for what the change is about.

Detecting dangling references in `let x = &...;` is now done by validity checking only, so some tests need to have validity checking enabled. There is no longer inherently a "nodangle" check in evaluating the expression `&*ptr` (aside from the aliasing model).

r? `@oli-obk`

Based on:
- https://github.com/rust-lang/reference/pull/1387
- https://github.com/rust-lang/rust/pull/115524
2023-10-16 12:40:16 +00:00
Ralf Jung
1ac153f60b add oversized-ref test back 2023-10-16 13:52:19 +02:00
bors
a00c09e9d8 Auto merge of #116724 - RalfJung:alloc-bytes, r=oli-obk
interpret: clean up AllocBytes

Fixes https://github.com/rust-lang/miri/issues/2836
Nothing has moved here in half a year, so let's just remove these unused stubs -- they need a proper re-design anyway.

r? `@oli-obk`
2023-10-16 10:45:00 +00:00
bors
9ace9da2e0 Auto merge of #116782 - matthiaskrgr:rollup-t3yrgku, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #115196 (Suggest adding `return` if the for semi which can coerce to the fn return type)
 - #115955 (Stabilize `{IpAddr, Ipv6Addr}::to_canonical`)
 - #116776 (Enable `review-requested` feature for rustbot)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-16 06:02:25 +00:00
Matthias Krüger
8feb7c55fe
Rollup merge of #116776 - WaffleLapkin:hell-yeah-review-requested, r=Mark-Simulacrum
Enable `review-requested` feature for rustbot

See https://github.com/rust-lang/triagebot/pull/1733.

r? `@Mark-Simulacrum`
2023-10-16 06:26:21 +02:00
Matthias Krüger
17113f7db6
Rollup merge of #115955 - tgross35:ip-to-canonical, r=dtolnay
Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- https://github.com/rust-lang/rust/issues/27709
- https://github.com/rust-lang/rust/issues/76205

Stabilization of all methods under the `ip` gate was attempted once at https://github.com/rust-lang/rust/pull/66584 then again at https://github.com/rust-lang/rust/pull/76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in https://github.com/rust-lang/rust/pull/87708

cc implementor ``@the8472``

r? libs-api
``@rustbot`` label +T-libs-api +needs-fcp
2023-10-16 06:26:20 +02:00
Matthias Krüger
1de910fc0d
Rollup merge of #115196 - chenyukang:yukang-fix-86094, r=estebank
Suggest adding `return` if the for semi which can coerce to the fn return type

Fixes #86094
r? `@estebank`
2023-10-16 06:26:20 +02:00
bors
99592fdfa1 Auto merge of #116775 - nnethercote:inline-Bytes-next, r=the8472
Inline `Bytes::next` and `Bytes::size_hint`.

This greatly increases its speed. On one small test program using `Bytes::next` to iterate over a large file, execution time dropped from ~330ms to ~220ms.

r? `@the8472`
2023-10-16 04:05:32 +00:00
bors
58352c0649 Auto merge of #114589 - ijackson:exit-code-default, r=dtolnay
impl Default for ExitCode

As suggested here
  https://github.com/rust-lang/rust/pull/106425#issuecomment-1382952598

Needs FCP since this is an insta-stable impl.

Ideally we would have `impl From<ExitCode> for ExitStatus` and implement the default `ExitStatus` using that.   That is sadly not so easy because of the various strange confusions about `ExitCode` (unix: exit status) vs `ExitStatus` (unix: wait status) in the not-really-unix platforms in `library//src/sys/unix/process`.  I'll try to follow that up.
2023-10-16 02:06:01 +00:00
bors
30d310cc1f Auto merge of #113747 - clarfonthey:ip_bitops, r=dtolnay
impl Not, Bit{And,Or}{,Assign} for IP addresses

ACP: rust-lang/libs-team#235

Note: since these are insta-stable, these require an FCP.

Implements, where `N` is either `4` or `6`:

```rust
impl Not for IpvNAddr
impl Not for &IpvNAddr

impl BitAnd<IpvNAddr> for IpvNAddr
impl BitAnd<&IpvNAddr> for IpvNAddr
impl BitAnd<IpvNAddr> for &IpvNAddr
impl BitAnd<&IpvNAddr> for &IpvNAddr

impl BitAndAssign<IpvNAddr> for IpvNAddr
impl BitAndAssign<&IpvNAddr> for IpvNAddr

impl BitOr<IpvNAddr> for IpvNAddr
impl BitOr<&IpvNAddr> for IpvNAddr
impl BitOr<IpvNAddr> for &IpvNAddr
impl BitOr<&IpvNAddr> for &IpvNAddr

impl BitOrAssign<IpvNAddr> for IpvNAddr
impl BitOrAssign<&IpvNAddr> for IpvNAddr
```
2023-10-15 23:05:06 +00:00
Waffle Maybe
61a752a0f9
Enable review-requested feature for rustbot 2023-10-16 00:37:05 +02:00
bors
42b1224e9e Auto merge of #116772 - matthiaskrgr:rollup-mpff3lh, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116172 (Broaden the consequences of recursive TLS initialization)
 - #116341 (Implement sys::args for UEFI)
 - #116522 (use `PatKind::Error` when an ADT const value has violation)
 - #116732 (Make x capable of resolving symlinks)
 - #116755 (Remove me from libcore review rotation)
 - #116760 (Remove trivial cast in `guaranteed_eq`)
 - #116771 (Ignore let-chains formatting)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-15 21:10:50 +00:00
Nicholas Nethercote
4d6810844e Inline Bytes::next and Bytes::size_hint.
This greatly increases its speed.
2023-10-16 08:08:32 +11:00
Matthias Krüger
66417cba73
Rollup merge of #116771 - compiler-errors:blame-ignore-let-chains, r=Mark-Simulacrum
Ignore let-chains formatting

Follow-up to #116688
2023-10-15 21:29:09 +02:00
Matthias Krüger
32da83d338
Rollup merge of #116760 - Nilstrieb:triviality, r=oli-obk
Remove trivial cast in `guaranteed_eq`

I found this while accidentally breaking trivial casts in another branch.

r? oli-obk
2023-10-15 21:29:09 +02:00
Matthias Krüger
7a67562924
Rollup merge of #116755 - scottmcm:review-rotation, r=Mark-Simulacrum
Remove me from libcore review rotation

I'm looking at my commitments right now, and unfortunately this needs to go for at least a while.

If there's something in particular I can probably still take them, but I should drop out of the rotation for now.
2023-10-15 21:29:08 +02:00
Matthias Krüger
dd5023599d
Rollup merge of #116732 - onur-ozkan:resolve-linked-x, r=Mark-Simulacrum
Make x capable of resolving symlinks

When bootstrapping from outside of the rust source, instead of calling 'x' from the absolute path
(like /home/user/rust/x), we should be able to link 'x' from the rust source to binary paths so it can be used easily. Before this change, 'x' was not capable of finding 'x.py' when called from the linked file.
2023-10-15 21:29:08 +02:00
Matthias Krüger
51be0df011
Rollup merge of #116522 - bvanjoi:fix-115599, r=oli-obk
use `PatKind::Error` when an ADT const value has violation

Fixes #115599

Since the [to_pat](https://github.com/rust-lang/rust/pull/111913/files#diff-6d8d99538aca600d633270051580c7a9e40b35824ea2863d9dda2c85a733b5d9R126-R155) behavior has been changed in the #111913 update, the kind of `inlined_const_ast_pat` has transformed from `PatKind::Leaf { pattern: Pat { kind: Wild, ..} } ` to `PatKind::Constant`. This caused a scenario where there are no matched candidates, leading to a testing of the candidates. This process ultimately attempts to test the string const, triggering the `bug!` invocation finally.

r? ``@oli-obk``
2023-10-15 21:29:07 +02:00
Matthias Krüger
835edc1397
Rollup merge of #116341 - Ayush1325:uefi-args, r=Mark-Simulacrum
Implement sys::args for UEFI

- Uses `EFI_LOADED_IMAGE_PROTOCOL`, which is implemented for all loaded images.

Tested on qemu with OVMF

cc ``@nicholasbishop``
cc ``@dvdhrm``
2023-10-15 21:29:07 +02:00
Matthias Krüger
e063d8a591
Rollup merge of #116172 - joboet:recursive_tls_initialization, r=dtolnay
Broaden the consequences of recursive TLS initialization

This PR updates the documentation of `LocalKey` to clearly disallow the behaviour described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525738849). This allows using `OnceCell` for the lazy initialization of TLS variables, which panics on reentrant initialization instead of updating the value like TLS variables currently do.

``@rustbot`` label +T-libs-api
r? ``@m-ou-se``
2023-10-15 21:29:06 +02:00
bors
f70779b0fb Auto merge of #110604 - a1phyr:vecdeque_buf_read, r=dtolnay
Implement `BufRead` for `VecDeque<u8>`

Note: it would become insta-stable
2023-10-15 19:15:01 +00:00
David Tolnay
b149d16d3a
Deduplicate std::process Default impl feature names
error[E0711]: feature `process-exitcode-default` is declared stable since 1.74.0-beta.1, but was previously declared stable since 1.73.0
        --> library/std/src/process.rs:1964:1
         |
    1964 | #[stable(feature = "process-exitcode-default", since = "CURRENT_RUSTC_VERSION")]
         | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-15 11:42:28 -07:00
Michael Goulet
07e8ee5795 Ignore let-chains formatting 2023-10-15 18:30:34 +00:00
bors
64368d0279 Auto merge of #110729 - ColinFinck:decode-utf16-fused-iterator, r=dtolnay
Implement FusedIterator for DecodeUtf16 when the inner iterator does

I have just implemented an iterator that wraps `DecodeUtf16` and wanted to implement `FusedIterator` for my iterator when I noticed that `DecodeUtf16` currently doesn't implement `FusedIterator` at all.
A quick look at the code of `DecodeUtf16` revealed that `DecodeUtf16::next` only returns `None` when its inner iterator returns `None`:
3462f79e94/library/core/src/char/decode.rs (L45)

As a result, we can implement `FusedIterator` for `DecodeUtf16` when the inner iterator does.

I'm following the example of #96397 here and consider this change minor and non-controversial, which is why I haven't added an RFC. I have also added the required feature name (`"decode_utf16_fused_iterator"`), however without adding a chapter to the Rust Unstable book (same as #96397).
2023-10-15 17:09:37 +00:00
Ralf Jung
28b0c87ad6 update MIR place semantics UB comment 2023-10-15 18:13:33 +02:00
Ralf Jung
b131fc10ae separate bounds-check from alignment check 2023-10-15 18:13:33 +02:00
Ralf Jung
e24835c6e0 more precise error for 'based on misaligned pointer' case 2023-10-15 18:13:33 +02:00
Ralf Jung
cbf47a17d2 avoid computing misalignment if we won't act on it 2023-10-15 18:13:33 +02:00
Ralf Jung
f3f9b795bd place evaluation: require the original pointer to be aligned if an access happens 2023-10-15 18:13:31 +02:00
Ralf Jung
ea9a24e32e avoid re-checking the offset while iterating an array/slice 2023-10-15 18:12:46 +02:00
Ralf Jung
b1ebf002c3 don't UB on dangling ptr deref, instead check inbounds on projections 2023-10-15 18:12:46 +02:00
bors
d60d63fbf7 Auto merge of #116527 - sthibaul:libc, r=Mark-Simulacrum
Bump libc dependency

To get GNU/Hurd support, so that CI of external repositories (e.g. getrandom) can build std.
2023-10-15 15:17:17 +00:00
yukang
25d38c48c3 Suggest adding return if the type of unused semi return value can coerce to the fn return type 2023-10-15 22:57:03 +08:00
bors
a48396984a Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstrieb
Format all the let-chains in compiler crates

Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped).

This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else.

I will also add this commit to the ignore list after it has landed.

The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree.
```
~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates
~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif
```

cc `@rust-lang/rustfmt`
r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :>

cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-15 13:23:55 +00:00
Ayush Singh
6713ae9d42
Implement args for UEFI
- Uses `EFI_LOADED_IMAGE_PROTOCOL`
- verify that cli args are valid UTF-16
- Update Docs

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-10-15 18:45:13 +05:30
bors
4331c151b0 Auto merge of #116757 - matthiaskrgr:rollup-3c25ogw, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #116594 (Fix `std::convert::TryFrom` doc)
 - #116741 (Document `string_deref_patterns` feature)
 - #116748 (Fix a spot I wrote the wrong word)
 - #116753 (add 'Onur Özkan' to .mailmap)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-15 11:30:38 +00:00
bohan
223674a824 use PatKind::error when an ADT const value has violation 2023-10-15 19:20:06 +08:00
Nilstrieb
fe9d422e7b Remove trivial cast in guaranteed_eq
I found this while accidentally breaking trivial casts in another
branch.
2023-10-15 12:33:44 +02:00
Matthias Krüger
28739772b0
Rollup merge of #116753 - onur-ozkan:add-myself-to-mailmap, r=cjgillot
add 'Onur Özkan' to .mailmap

self-explanatory
2023-10-15 11:37:25 +02:00
Matthias Krüger
23d8847ae9
Rollup merge of #116748 - scottmcm:oops-typo, r=fee1-dead
Fix a spot I wrote the wrong word

I was reading this comment while I was looking at #116505, and it garden-path-sentence'd me, so fix that for people in the future.
2023-10-15 11:37:24 +02:00
Matthias Krüger
fb1f8dd950
Rollup merge of #116741 - mejrs:string_pat, r=fee1-dead
Document `string_deref_patterns` feature

Rendered:
![image](https://github.com/rust-lang/rust/assets/59372212/aa3ef9e7-080d-4979-a363-3c24fe299c00)
2023-10-15 11:37:24 +02:00
Matthias Krüger
e86e6b45e7
Rollup merge of #116594 - tae-soo-kim:convert-tryfrom-doc, r=scottmcm
Fix `std::convert::TryFrom` doc

Original text:

> truncating the [i64](https://doc.rust-lang.org/std/primitive.i64.html) to an [i32](https://doc.rust-lang.org/std/primitive.i32.html) (essentially giving the [i64](https://doc.rust-lang.org/std/primitive.i64.html)’s value modulo [i32::MAX](https://doc.rust-lang.org/std/primitive.i32.html#associatedconstant.MAX))

This can't be true, because `i32::MAX` is an odd number. The correct value seems `(i32::MAX + 1) * 2`, but this is complicated and distracting, and I suggest removing the parentheses entirely.
2023-10-15 11:37:23 +02:00
bors
ab73de7d7f Auto merge of #116691 - chenx97:rustix-0.38.19, r=Mark-Simulacrum
Update rustix to 0.38.19

addresses [rustix/#856](https://github.com/bytecodealliance/rustix/pull/856).

Commands that do the update:

`cargo +nightly update rustix`

r? `@Mark-Simulacrum`
2023-10-15 09:36:49 +00:00
Scott McMurray
b50aa24a4e Remove me from libcore review rotation 2023-10-15 00:49:44 -07:00
bors
b0fedc07ce Auto merge of #116643 - onur-ozkan:x-zsh-completion, r=Mark-Simulacrum
x.py zsh completion support

self-explanatory

![image](https://github.com/rust-lang/rust/assets/39852038/81278f8b-3679-426b-b1c0-331b60593a1e)
2023-10-15 07:42:45 +00:00
onur-ozkan
97b7b847be add 'Onur Özkan' to .mailmap
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-15 09:24:09 +03:00
onur-ozkan
fa013d50ef add x.py.zsh to tidy check
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-15 09:06:10 +03:00
onur-ozkan
f457c61fc3 optimize GenerateCompletions::run
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-15 09:06:06 +03:00
onur-ozkan
62d88f9775 generate zsh autocompletion for x
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-15 09:05:55 +03:00
onur-ozkan
8c62ed581f bump bootstrap:clap_complete to 4.4.3
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-15 09:05:21 +03:00