Commit Graph

239420 Commits

Author SHA1 Message Date
Nilstrieb
9b80d85722 Manual find replace updates 2023-11-24 21:04:51 +01:00
Nilstrieb
377da2f06b Bless Miri tests
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:53 +01:00
Nilstrieb
76a0313285 Bless clippy tests
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Nilstrieb
0346765100 Bless run-make tests
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Nilstrieb
87a354b15d Bless rustdoc-ui tests
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
bors
4fd68eb47b Auto merge of #117934 - Young-Flash:dev, r=petrochenkov
feat: make `let_binding_suggestion` more reasonable

This is my first PR for rustc, which trying to fix https://github.com/rust-lang/rust/issues/117894, I am not familiar with some internal api so maybe some modification here isn't the way to go, appreciated for any review suggestion.
2023-11-24 15:26:04 +00:00
bors
beebcdeb6f Auto merge of #117782 - majaha:tidy_fix, r=onur-ozkan
Fix tidy tripping up on  untracked files with special characters in their name

Previously, the tidy tool would fault if an untracked file had a space or other special characters in its name. If there was an untracked file "foo bar", it would include the quoting in it's path and split on the first space, giving output like this:
`skip untracked path "foo during rustfmt invocations`
2023-11-24 13:16:10 +00:00
bors
b06258cde4 Auto merge of #118228 - Mark-Simulacrum:alloc-opt, r=scottmcm
Indicate that multiplication in Layout::array cannot overflow

Since https://github.com/rust-lang/rust/pull/113113, we have added a check that skips calling into the allocator at all if `capacity == 0`. The global, default allocator will not actually try to allocate though; it returns a dangling pointer explicitly. However, these two checks are not merged/deduplicated by LLVM and so we're comparing to zero twice whenever vectors are allocated/grown. Probably cheap, but also potentially expensive in code size and seems like an unfortunate miss.

This removes that extra check by telling LLVM that the multiplication as part of Layout::array can't overflow, turning the original non-zero value into a zero value afterwards. In my checks locally this successfully drops the duplicate comparisons.

See https://rust.godbolt.org/z/b6nPP9dcK for a code example.

```rust
pub fn foo(elements: usize) -> Vec<u32> {
    Vec::with_capacity(elements)
}
```

r? `@scottmcm` since you touched this in a32305a80f - curious if you have thoughts on doing this / can confirm my model of this being correct.
2023-11-24 11:19:34 +00:00
bors
f74f700952 Auto merge of #118232 - matthiaskrgr:rollup-x8crvm0, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #116807 (Improve rewind documentation)
 - #117656 (Update windows-bindgen and define `INVALID_HANDLE_VALUE` ourselves)
 - #117940 (chore: remove unnecessary drop)
 - #118028 (Document behavior of `<dyn Any as Any>::type_id()`)
 - #118060 (Use an absolute path to the NUL device)
 - #118224 (Sort unstable items last in rustdoc, instead of first)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-24 09:21:23 +00:00
Matthias Krüger
98bae8195d
Rollup merge of #118224 - dtolnay:rustdocsortunstable, r=fmease
Sort unstable items last in rustdoc, instead of first

As far as I can tell, this is a bug introduced inadvertently by https://github.com/rust-lang/rust/pull/77817 in Rust 1.49. Older toolchains used to sort unstable items last.

Notice how in the code before that PR, `(Unstable, Stable) => return Ordering::Greater` in src/librustdoc/html/render/mod.rs. Whereas after that PR, `(Unstable, Stable) => return Ordering::Less`.

Compare https://doc.rust-lang.org/1.48.0/std/marker/index.html vs https://doc.rust-lang.org/1.49.0/std/marker/index.html.
2023-11-24 08:23:54 +01:00
Matthias Krüger
b2d6480f53
Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomcc
Use an absolute path to the NUL device

While a bare "NUL" *should* be redirected to the NUL device, especially in this simple case, let's be explicit that we aren't opening a file called "NUL" and instead open it directly.

This will also set a good example for people copying std code.

r? libs
2023-11-24 08:23:53 +01:00
Matthias Krüger
c3216e2a3a
Rollup merge of #118028 - Jules-Bertholet:dyn-any-doc, r=thomcc
Document behavior of `<dyn Any as Any>::type_id()`

See also #57893

`@rustbot` label A-docs T-libs
2023-11-24 08:23:53 +01:00
Matthias Krüger
f38de06ce6
Rollup merge of #117940 - zhiqiangxu:remove_redundant_drop, r=thomcc
chore: remove unnecessary drop

 No need to manually drop since it's implicit.
2023-11-24 08:23:52 +01:00
Matthias Krüger
7e3ec1b0e2
Rollup merge of #117656 - ChrisDenton:invalid, r=thomcc
Update windows-bindgen and define `INVALID_HANDLE_VALUE` ourselves

We generate bindings to the Windows API via the `windows-bindgen` crate, which is ultimately what's also used to generate the `windows-sys` and `windows` crates. However, there currently is some custom sauce just for std which makes it a bit different from the vanilla bindings. I would love for us to reduce and eventually remove the differences entirely so that std is using the exact same bindings as everyone else. Maybe in the future we can even just have a normal dependency on `windows-sys`.

This PR removes one of those special things. Our definition of `INVALID_HANDLE_VALUE` relies on an experimental nightly feature for strict provenance, so lets bring that back in house. It also excludes it from the codegen step though that isn't strictly necessary as we override it in any case.

This PR also updates windows-bingen to 0.52.0.
2023-11-24 08:23:52 +01:00
Matthias Krüger
b8657093d6
Rollup merge of #116807 - seanlinsley:patch-2, r=thomcc
Improve rewind documentation

The persistent use of an internal cursor for readers is expected for buffer data types that aren't read all at once, but for files it leads to the confusing situation where calling `read_to_end` on the same file handle multiple times only returns the contents of the file for the first call. This PR adds a note to the documentation clarifying that in that case, `rewind()` must first be called.

I'm unsure if this is the right location for the docs update. Maybe it should also be duplicated on `File`?
2023-11-24 08:23:51 +01:00
bors
8abf920985 Auto merge of #117722 - okaneco:binarysearch, r=thomcc
Refactor `binary_search_by` to use conditional moves

Refactor the if/else checking on `cmp::Ordering` variants to a "branchless" reassignment of left and right.

This change results in fewer branches and instructions.
https://rust.godbolt.org/z/698eYffTx

---

I saw consistent benchmark improvements locally. Performance of worst case seems about the same, maybe slightly faster for the L3 test.

Current
```
slice::binary_search_l1             43.00ns/iter +/- 3.00ns
slice::binary_search_l1_with_dups   25.00ns/iter +/- 0.00ns
slice::binary_search_l1_worst_case  10.00ns/iter +/- 0.00ns
slice::binary_search_l2             64.00ns/iter +/- 1.00ns
slice::binary_search_l2_with_dups   42.00ns/iter +/- 0.00ns
slice::binary_search_l2_worst_case  16.00ns/iter +/- 0.00ns
slice::binary_search_l3            132.00ns/iter +/- 2.00ns
slice::binary_search_l3_with_dups  108.00ns/iter +/- 2.00ns
slice::binary_search_l3_worst_case  33.00ns/iter +/- 3.00ns
```
This PR
```
slice::binary_search_l1            21.00ns/iter +/- 0.00ns
slice::binary_search_l1_with_dups  14.00ns/iter +/- 0.00ns
slice::binary_search_l1_worst_case  9.00ns/iter +/- 0.00ns
slice::binary_search_l2            34.00ns/iter +/- 0.00ns
slice::binary_search_l2_with_dups  23.00ns/iter +/- 0.00ns
slice::binary_search_l2_worst_case 16.00ns/iter +/- 0.00ns
slice::binary_search_l3            92.00ns/iter +/- 3.00ns
slice::binary_search_l3_with_dups  63.00ns/iter +/- 1.00ns
slice::binary_search_l3_worst_case 29.00ns/iter +/- 0.00ns
```
2023-11-24 07:23:04 +00:00
bors
41fe75ec6b Auto merge of #118189 - compiler-errors:cache-flags-for-const, r=nnethercote
Cache flags for `ty::Const`

Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in `rustc_type_ir`, since we can assume that consts have a `flags` method that is no-cost.

r? `@ghost`
2023-11-24 04:54:35 +00:00
Mark Rousskov
b81e788d16 Indicate that multiplication in Layout::array cannot overflow
This allows LLVM to optimize comparisons to zero before & after the
multiplication into one, saving on code size and eliminating an (always
true) branch from most Vec allocations.
2023-11-23 22:05:45 -05:00
bors
eab8c7d5fd Auto merge of #118105 - notriddle:master, r=fmease
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 4)

Follow up

* https://github.com/rust-lang/rust/pull/116214
* https://github.com/rust-lang/rust/pull/116432
* https://github.com/rust-lang/rust/pull/116824
2023-11-24 02:23:31 +00:00
David Tolnay
b77aa74a2d
Sort unstable items last in rustdoc, instead of first 2023-11-23 17:20:13 -08:00
David Tolnay
a994f46421
Add test of rustdoc sort order for stable vs unstable item 2023-11-23 17:20:13 -08:00
bors
1fd418f92e Auto merge of #118219 - bjorn3:fix_generator_fn_abi, r=compiler-errors
Fix fn_sig_for_fn_abi and the coroutine transform for generators

There were three issues previously:
* The self argument was pinned, despite Iterator::next taking an unpinned mutable reference.
* A resume argument was passed, despite Iterator::next not having one.
* The return value was CoroutineState<Item, ()> rather than Option<Item>

While these things just so happened to work with the LLVM backend, cg_clif does much stricter checks when trying to assign a value to a place. In addition it can't handle the mismatch between the amount of arguments specified by the FnAbi and the FnSig.
2023-11-24 00:26:24 +00:00
bors
e68f935117 Auto merge of #98943 - WilliamVenner:feat/bufread_skip_until, r=dtolnay
Add `BufRead::skip_until`

Alternative version of `BufRead::read_until` that simply discards data, rather than copying it into a buffer.

Useful for situations like skipping irrelevant data in a binary file format that is NUL-terminated.

<details>
<summary>Benchmark</summary>

```
running 2 tests
test bench_read_until ... bench:         123 ns/iter (+/- 6)
test bench_skip_until ... bench:          66 ns/iter (+/- 3)
```

```rs
#![feature(test)]
extern crate test;
use test::Bencher;

use std::io::{ErrorKind, BufRead};

fn skip_until<R: BufRead + ?Sized>(r: &mut R, delim: u8) -> Result<usize, std::io::Error> {
    let mut read = 0;
    loop {
        let (done, used) = {
            let available = match r.fill_buf() {
                Ok(n) => n,
                Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                Err(e) => return Err(e),
            };
            match memchr::memchr(delim, available) {
                Some(i) => (true, i + 1),
                None => (false, available.len()),
            }
        };
        r.consume(used);
        read += used;
        if done || used == 0 {
            return Ok(read);
        }
    }
}

const STR: &[u8] = b"Ferris\0Hello, world!\0";

#[bench]
fn bench_skip_until(b: &mut Bencher) {
    b.iter(|| {
        let mut io = std::io::Cursor::new(test::black_box(STR));
        skip_until(&mut io, b'\0').unwrap();
        let mut hello = Vec::with_capacity(b"Hello, world!\0".len());
        let num_bytes = io.read_until(b'\0', &mut hello).unwrap();
        assert_eq!(num_bytes, b"Hello, world!\0".len());
        assert_eq!(hello, b"Hello, world!\0");
    });
}

#[bench]
fn bench_read_until(b: &mut Bencher) {
    b.iter(|| {
        let mut io = std::io::Cursor::new(test::black_box(STR));
        io.read_until(b'\0', &mut Vec::new()).unwrap();
        let mut hello = Vec::with_capacity(b"Hello, world!\0".len());
        let num_bytes = io.read_until(b'\0', &mut hello).unwrap();
        assert_eq!(num_bytes, b"Hello, world!\0".len());
        assert_eq!(hello, b"Hello, world!\0");
    });
}
```
</details>
2023-11-23 22:28:14 +00:00
Michael Howell
4f64ff171b rustdoc: move doctest tests to folder 2023-11-23 14:56:03 -07:00
Matt Harding
cbf6bfc452 Fix tidy on untracked files with special character
Previously, the tidy tool would fault if an untracked file had a space
or other special characters in its name. If there was an untracked file
"foo bar", it would include the quoting in it's path and split on the
first space, giving output like this:
`skip untracked path "foo during rustfmt invocations`
2023-11-23 21:55:37 +00:00
Michael Howell
fdde5c77a8 rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
bjorn3
543e559c53 Fix assertion 2023-11-23 21:32:33 +00:00
bjorn3
988fccb45d Exhaustively match CoroutineKind in fn_sig_for_fn_abi 2023-11-23 21:32:33 +00:00
bors
a1a37735cb Auto merge of #118218 - dtolnay:exitcodeext, r=compiler-errors
Fix tracking issue of Windows ExitCodeExt

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

This was left out of the initial ExitCodeExt implementation in https://github.com/rust-lang/rust/pull/97917.
2023-11-23 20:30:59 +00:00
bjorn3
b7bc8d5cb7 Fix fn_sig_for_fn_abi and the coroutine transform for generators
There were three issues previously:
* The self argument was pinned, despite Iterator::next taking an
  unpinned mutable reference.
* A resume argument was passed, despite Iterator::next not having one.
* The return value was CoroutineState<Item, ()> rather than Option<Item>

While these things just so happened to work with the LLVM backend,
cg_clif does much stricter checks when trying to assign a value to a
place. In addition it can't handle the mismatch between the amount of
arguments specified by the FnAbi and the FnSig.
2023-11-23 20:17:19 +00:00
David Tolnay
52c07b9564
Fix tracking issue of Windows ExitCodeExt 2023-11-23 11:16:10 -08:00
bors
a4a5c976fe Auto merge of #118192 - Kyuuhachi:issue-118180, r=fmease
Don't print "private fields" on empty tuple structs

Closes #118180.

While working on this I also noticed that empty struct variants are also rendered rather awkwardly. I'll make another issue for that, since I don't know what the correct rendering would be.
2023-11-23 17:41:46 +00:00
bors
237339fda1 Auto merge of #117978 - petrochenkov:deleggate, r=TaKO8Ki,joshtriplett
Add an experimental feature gate for function delegation

In accordance with the [process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md).

Detailed description of the feature can be found in the RFC repo - https://github.com/rust-lang/rfcs/pull/3530.

TODO: find a lang team liaison - https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/fn.20delegation.20liaison/near/402506959.
2023-11-23 15:05:55 +00:00
Kyuuhachi
a21d7713db Don't print "private fields" on empty tuple structs
Test for presence rather than absence

Remove redundant tests

Issues in those parts will likely be caught by other parts of the test suite.
2023-11-23 16:04:10 +01:00
Vadim Petrochenkov
edf6c9c223 Add an experimental feature gate for function delegation
In accordance with the [process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md).

Detailed description of the feature can be found in the RFC repo - https://github.com/rust-lang/rfcs/pull/3530.
2023-11-23 17:27:31 +03:00
bors
91f7f266ce Auto merge of #117815 - onur-ozkan:update-change-tracking-impl, r=albertlarsan68
improve bootstrap change-tracking system

This PR aims to improve how change-tracking system works for bootstrap changes by doing the followings:

- Enforce embedding directive informations about the changes on `bootstrap/src/lib.rs`.
- Give more informative change inputs on the terminal (https://github.com/rust-lang/rust/pull/117815#discussion_r1390239657).
- Avoid spamming the change informations(by reading and creating `.last-warned-change-id` under build output dir).

see the zulip conversation for more details: https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/config.2Etoml.20change.20tracking

cc `@RalfJung`
2023-11-23 12:54:46 +00:00
Young-Flash
c710db8ea7 feat: make let_binding_suggestion more reasonable 2023-11-23 20:22:17 +08:00
bors
e7b22851a2 Auto merge of #116449 - Kobzol:bootstrap-rustdoc-shim, r=petrochenkov
Pass flags to `rustdoc` shim without env. vars

Discussed here: https://github.com/rust-lang/rust/pull/116448#issuecomment-1748785961. Since it was not really documented why these flags were passed through the shim, I guess that the only way to find out if it's really needed... is to remove it :)

r? `@petrochenkov`
2023-11-23 10:36:54 +00:00
Jakub Beránek
2e7d684820
Add LLD flags to rustdoc cargo invocations 2023-11-23 10:37:36 +01:00
bors
38eecca62c Auto merge of #118073 - saethlin:gc-dead-allocs, r=RalfJung
Miri: GC the dead_alloc_map too

dead_alloc_map is the last piece of state in the interpreter I can find that leaks. With this PR, all of the long-term memory growth I can find in Miri with programs that do things like run a big `loop {` or run property tests is attributable to some data structure properties in borrow tracking, and is _extremely_ slow.

My only gripe with the commit in this PR is that I don't have a new test for it. I'd like to have a regression test for this, but it would have to be statistical I think because the peak memory of a process that Linux reports is not exactly the same run-to-run. Which means it would have to not be very sensitive to slow leaks (some guesswork suggests for acceptable CI time we would be checking for like 10% memory growth over a minute or two, which is still pretty fast IMO).

Unless someone has a better idea for how to detect a regression, I think on balance I'm fine with manually keeping an eye on the memory use situation.

r? RalfJung
2023-11-23 08:20:21 +00:00
bors
fc13ca6d70 Auto merge of #118200 - matthiaskrgr:rollup-neka6xo, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #118131 (improve tool-only help for multiple `#[default]` variants)
 - #118146 (Rework supertrait lint once again)
 - #118167 (make the 'abi_unadjusted' feature internal)
 - #118169 (print query map for deadlock when using parallel front end)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-23 06:22:30 +00:00
Matthias Krüger
0223a811f5
Rollup merge of #118169 - SparrowLii:deadlock_issue, r=compiler-errors
print query map for deadlock when using parallel front end

print query map for deadlock when using parallel front end, so that we can analyze where and why deadlock occurs
2023-11-23 07:06:31 +01:00
Matthias Krüger
9e944c8c1a
Rollup merge of #118167 - RalfJung:unadjusted-abi-is-internal, r=petrochenkov
make the 'abi_unadjusted' feature internal

As [suggested](https://github.com/rust-lang/rust/pull/118127#issuecomment-1820736389) by `@bjorn3.`
2023-11-23 07:06:31 +01:00
Matthias Krüger
add423bcf7
Rollup merge of #118146 - compiler-errors:deref-into-dyn-regions, r=lcnr
Rework supertrait lint once again

I accidentally pushed the wrong commits because I totally didn't check I was on the right computer when updating #118026.
Sorry, this should address all the nits in #118026.

r? lcnr
2023-11-23 07:06:30 +01:00
Matthias Krüger
82538b72c0
Rollup merge of #118131 - lukas-code:multi-default, r=wesleywiser
improve tool-only help for multiple `#[default]` variants

When defining an enum with multiple `#[default]` variants, we emit a tool-only suggestion for every `#[default]`ed variant to remove all other `#[default]`s. This PR improves the suggestion to correctly handle the cases where one variant has multiple `#[default]`s and where different `#[default]`s have the same span due to macro expansions.

fixes https://github.com/rust-lang/rust/issues/118119
2023-11-23 07:06:30 +01:00
bors
193466525d Auto merge of #115159 - solid-rs:patch/kmc-solid/io-safety, r=workingjubilee
kmc-solid: I/O safety

Adds the I/O safety API (#87329) for socket file descriptors in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. All new public items are gated by the `solid_ext` library feature.

This PR adds the following public types and traits:

    std::os::solid::io::AsFd
    std::os::solid::io::BorrowedFd
    std::os::solid::io::OwnedFd

    std::os::solid::prelude::AsFd (re-export)
    std::os::solid::prelude::BorrowedFd (re-export)
    std::os::solid::prelude::OwnedFd (re-export)

And trait implementations:

    From<std::net::TcpListener> for std::os::solid::io::OwnedFd
    From<std::net::TcpStream> for std::os::solid::io::OwnedFd
    From<std::net::UdpSocket> for std::os::solid::io::OwnedFd
    From<std::os::solid::io::OwnedFd> for std::net::TcpListener
    From<std::os::solid::io::OwnedFd> for std::net::TcpStream
    From<std::os::solid::io::OwnedFd> for std::net::UdpSocket
    std::fmt::Debug for std::os::solid::io::BorrowedFd<'_>
    std::fmt::Debug for std::os::solid::io::OwnedFd
    std::io::IsTerminal for std::os::solid::io::BorrowedFd<'_>
    std::io::IsTerminal for std::os::solid::io::OwnedFd
    std::os::fd::AsRawFd for std::os::solid::io::BorrowedFd<'_>
    std::os::fd::AsRawFd for std::os::solid::io::OwnedFd
    std::os::fd::FromRawFd for std::os::solid::io::OwnedFd
    std::os::fd::IntoRawFd for std::os::solid::io::OwnedFd
    std::os::solid::io::AsFd for &impl std::os::solid::io::AsFd
    std::os::solid::io::AsFd for &mut impl std::os::solid::io::AsFd
    std::os::solid::io::AsFd for Arc<impl std::os::solid::io::AsFd>
    std::os::solid::io::AsFd for Box<impl std::os::solid::io::AsFd>
    std::os::solid::io::AsFd for Rc<impl std::os::solid::io::AsFd>
    std::os::solid::io::AsFd for std::net::TcpListener
    std::os::solid::io::AsFd for std::net::TcpStream
    std::os::solid::io::AsFd for std::net::UdpSocket
    std::os::solid::io::AsFd for std::os::solid::io::BorrowedFd<'_>
    std::os::solid::io::AsFd for std::os::solid::io::OwnedFd

Taking advantage of the above change, this PR also refactors the internal details of `std::sys::solid::net` to match the design of other targets, e.g., by redefining `Socket` as a newtype of `OwnedFd`.
2023-11-23 04:24:09 +00:00
Ben Kimock
f5dae8e73c Miri: GC the dead_alloc_map too 2023-11-22 22:40:55 -05:00
SparrowLii
c238e87573 Nit of deadlock detected 2023-11-23 10:35:33 +08:00
bors
360bafad68 Auto merge of #118065 - estebank:core-not-found-404, r=TaKO8Ki
When failing to import `core`, suggest `std`
2023-11-23 02:26:52 +00:00