Commit Graph

255337 Commits

Author SHA1 Message Date
Michael Goulet
bd0d306c14 Remove a clippy test that doesn't apply anymore 2024-05-20 19:21:38 -04:00
Michael Goulet
bc6b70f1d1 Adjust the method ambiguity lint too 2024-05-20 19:21:38 -04:00
Michael Goulet
a502e7ac1d Implement BOXED_SLICE_INTO_ITER 2024-05-20 19:21:30 -04:00
Michael Goulet
1a81092531 Add the impls for Box<[T]>: IntoIterator
Co-authored-by: ltdk <usr@ltdk.xyz>
2024-05-20 19:21:30 -04:00
Michael Goulet
c86a4aa5ca Backticks 2024-05-20 19:16:36 -04:00
bors
b92758a9ae Auto merge of #125219 - Urgau:check-cfg-cargo-config, r=fmease
Update `unexpected_cfgs` lint for Cargo new `check-cfg` config

This PR updates the diagnostics output of the `unexpected_cfgs` lint for Cargo new `check-cfg` config.

It's a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction.

```toml
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] }
```

This PR also adds a Cargo specific section regarding check-cfg and Cargo inside rustc's book (motivation is described inside the file, but mainly check-cfg is a rustc feature not a Cargo one, Cargo only enabled the feature, it does not own it; T-cargo even considers the `check-cfg` lint config to be an implementation detail).

This PR also updates the links to refer to that sub-page when using Cargo from rustc.

As well as updating the lint doc to refer to the check-cfg docs.

~**Not to be merged before https://github.com/rust-lang/cargo/pull/13913 reaches master!**~ (EDIT: merged in https://github.com/rust-lang/rust/pull/125237)

`@rustbot` label +F-check-cfg
r? `@fmease` *(feel free to roll)*
Fixes https://github.com/rust-lang/rust/issues/124800
cc `@epage` `@weihanglo`
2024-05-20 20:14:09 +00:00
bors
be71fd4772 Auto merge of #125331 - matthiaskrgr:rollup-4kfrh4n, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124682 (Suggest setting lifetime in borrowck error involving types with elided lifetimes)
 - #124917 (Check whether the next_node is else-less if in get_return_block)
 - #125106 (coverage: Memoize and simplify counter expressions)
 - #125173 (Remove `Rvalue::CheckedBinaryOp`)
 - #125305 (add some codegen tests for issue 120493)
 - #125314 ( Add an experimental feature gate for global registration)
 - #125318 (Migrate `run-make/rustdoc-scrape-examples-whitespace` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-20 18:04:19 +00:00
Matthias Krüger
1640225b9d
Rollup merge of #125318 - GuillaumeGomez:migrate-rustdoc-examples-whitespaces, r=jieyouxu
Migrate `run-make/rustdoc-scrape-examples-whitespace` to `rmake.rs`

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

r? `@jieyouxu`
2024-05-20 18:13:49 +02:00
Matthias Krüger
a79737c3f0
Rollup merge of #125314 - jdonszelmann:global-registration-feature-gate, r=pnkfelix
Add an experimental feature gate for global registration

See #125119 for the tracking issue.
2024-05-20 18:13:49 +02:00
Matthias Krüger
83cceeaf37
Rollup merge of #125305 - jwong101:120493-codegen-test, r=the8472
add some codegen tests for issue 120493

I forgot to add these in https://github.com/rust-lang/rust/pull/123878.
2024-05-20 18:13:48 +02:00
Matthias Krüger
9987e900c0
Rollup merge of #125173 - scottmcm:never-checked, r=davidtwco
Remove `Rvalue::CheckedBinaryOp`

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996>
cc `@RalfJung`

While it's a draft,
r? ghost
2024-05-20 18:13:48 +02:00
Matthias Krüger
e0d922842d
Rollup merge of #125106 - Zalathar:expressions, r=davidtwco
coverage: Memoize and simplify counter expressions

When creating coverage counter expressions as part of coverage instrumentation, we often end up creating obviously-redundant expressions like `c1 + (c0 - c1)`, which is equivalent to just `c0`.

To avoid doing so, this PR checks when we would create an expression matching one of 5 patterns, and uses the simplified form instead:
- `(a - b) + b` → `a`.
- `(a + b) - b` → `a`.
- `(a + b) - a` → `b`.
- `a + (b - a)` → `b`.
- `a - (a - b)` → `b`.

Of all the different ways to combine 3 operands and 2 operators, these are the patterns that allow simplification.

(Some of those patterns currently don't occur in practice, but are included anyway for completeness, to avoid having to add them later as branch coverage and MC/DC coverage support expands.)

---

This PR also adds memoization for newly-created (or newly-simplified) counter expressions, to avoid creating duplicates.

This currently makes no difference to the final mappings, but is expected to be useful for MC/DC coverage of match expressions, as proposed by https://github.com/rust-lang/rust/pull/124278#issuecomment-2106754753.
2024-05-20 18:13:47 +02:00
Matthias Krüger
ba1bb80b6b
Rollup merge of #124917 - cardigan1008:issue-124819, r=pnkfelix
Check whether the next_node is else-less if in get_return_block

Fix #124819
2024-05-20 18:13:47 +02:00
Matthias Krüger
29c603c1fa
Rollup merge of #124682 - estebank:issue-40990, r=pnkfelix
Suggest setting lifetime in borrowck error involving types with elided lifetimes

```
error: lifetime may not live long enough
  --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5
   |
LL | fn foo(mut x: Ref, y: Ref) {
   |        -----       - has type `Ref<'_, '1>`
   |        |
   |        has type `Ref<'_, '2>`
LL |     x.b = y.b;
   |     ^^^^^^^^^ assignment requires that `'1` must outlive `'2`
   |
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: Ref<'a, 'a>) {
   |       ++++           ++++++++        ++++++++
```

As can be seen above, it currently doesn't try to compare the `ty::Ty` lifetimes that diverged vs the `hir::Ty` to correctly suggest the following

```
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'_, 'a>, y: Ref<'_, 'a>) {
   |       ++++           ++++++++        ++++++++
```

but I believe this to still be an improvement over the status quo.

Fix #40990.
2024-05-20 18:13:46 +02:00
Felix S Klock II
a2e0f10639
address nit 2024-05-20 11:55:20 -04:00
bors
474bee7bf5 Auto merge of #118014 - keith:ks/remove-unnecessary-fembed-bitcode-usage-now-that-it-s-deprecated, r=clubby789
Remove unnecessary -fembed-bitcode usage now that it's deprecated

This is a partial revert of 6d819a4b8f because https://github.com/rust-lang/cc-rs/pull/812 removed this flag entirely, meaning we shouldn't have to pass this manually anymore
2024-05-20 15:51:43 +00:00
Joshua Wong
a4efe6fe27 add codegen test for issue 120493 2024-05-20 09:21:09 -05:00
bors
75cb5c51cd Auto merge of #125324 - matthiaskrgr:rollup-5vcgjtq, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #125255 (Make `EvalCtxt` generic over `InferCtxtLike`)
 - #125283 (Use a single static for all default slice Arcs.)
 - #125300 (rustdoc: Don't strip items with inherited visibility in `AliasedNonLocalStripper`)
 - #125309 (Fix `tests/debuginfo/strings-and-strs`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-20 13:37:35 +00:00
Matthias Krüger
e45fd0686f
Rollup merge of #125309 - nnethercote:fix-strings-and-strs, r=Mark-Simulacrum
Fix `tests/debuginfo/strings-and-strs`.

It fails on my machine because it embeds pointer addresses in the expected output.

This commit replaces the addresses with `0x[...]`.

r? ```@Mark-Simulacrum```
2024-05-20 14:26:54 +02:00
Matthias Krüger
3a503157a0
Rollup merge of #125300 - compiler-errors:dont-strip-inherited-viz, r=fmease
rustdoc: Don't strip items with inherited visibility in `AliasedNonLocalStripper`

Enum variants return `None` in `Item::visibility`, which fails the comparison to `Some(Visibility::Public)`. This means that all enums in type aliases are being stripped, leading to this in the `rustc_middle` docs:

<img width="474" alt="image" src="https://github.com/rust-lang/rust/assets/3674314/83704d94-a571-4c28-acbd-ca51c4efd46e">

This regressed in https://github.com/rust-lang/rust/pull/124939#discussion_r1606130566.

This switches the `AliasedNonLocalStripper` to not strip items with `None` as their visibility.
2024-05-20 14:26:53 +02:00
Matthias Krüger
d1da2387a4
Rollup merge of #125283 - zachs18:arc-default-shared, r=dtolnay
Use a single static for all default slice Arcs.

Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated".

As per https://github.com/rust-lang/rust/pull/124640#pullrequestreview-2064962003

r? dtolnay
2024-05-20 14:26:53 +02:00
Matthias Krüger
9911788bbc
Rollup merge of #125255 - compiler-errors:eval-ctxt-generic, r=lcnr
Make `EvalCtxt` generic over `InferCtxtLike`

...but don't change any of the impls, yet! These can get uplifted as we add more methods to `InferCtxtLike`/`Interner` :3

This is built on top of #125230.

r? lcnr
2024-05-20 14:26:52 +02:00
bors
44d679b902 Auto merge of #124985 - dpaoliello:rebalance, r=Mark-Simulacrum
Reduce builder size of jobs that take less than an hour

The current longest build time is ~2hr for the `dist-x86_64-linux-alt` build. This is already on a 16-core builder, so we can't make it any faster (by throwing more hardware at it).

Given that overall build times will be at least 2hrs, we can reduce build costs by reducing the builder size for any job that takes less than 1hr since it will still complete before `dist-x86_64-linux-alt` does.

Note that scaling isn't linear, halving the core count increases end-to-end build times by about 25-50%. In [this sample build](https://github.com/rust-lang/rust/actions/runs/9037235792/usage?pr=124985) `arm-android` went from ~52m to 1h 5m and `dist-arm-linux` went from ~55m to 1h 17m (then failed due to missing metrics).

Current job builder sizes and times and proposed new sizes:

| Job | Size | Proposed | Run 1 | Run 2 | Run 3 | Run 4 |
|-----|------|----------|-------|-------|-------|-------|
| aarch64-gnu | - | | 1h 9m 1s | 1h 8m 47s | 1h 8m 45s | 1h 9m 6s |
| arm-android | 8c | 4c | 52m 32s | 52m 38s | 51m 30s | 53m 13s |
| armhf-gnu | 8c | 4c | 37m 30s | 37m 40s | 38m 41s | 37m 56s |
| dist-aarch64-linux | 8c | 4c | 57m 11s | 56m 48s | 55m 53s | 56m 19s |
| dist-android | 8c | 4c | 24m 37s | 25m 13s | 25m 15s | 24m 17s |
| dist-arm-linux | 16c | 8c | 53m 34s | 55m 11s | 56m 1s | 54m 29s |
| dist-armhf-linux | 8c | 4c | 42m 1s | 43m 32s | 43m 27s | 41m 55s |
| dist-armv7-linux | 8c | 4c | 44m 51s | 44m 35s | 43m 34s | 46m 2s |
| dist-i586-gnu-i586-i686-musl | 8c | 4c | 37m 59s | 37m 56s | 38m 4s | 38m 24s |
| dist-i686-linux | 8c | 4c | 52m 20s | 51m 3s | 52m 53s | 50m 38s |
| dist-loongarch64-linux | 8c | 4c | 40m 39s | 40m 20s | 41m 6s | 40m 44s |
| dist-ohos | 8c | 4c | 25m 5s | 24m 34s | 25m 18s | 23m 40s |
| dist-powerpc-linux | 8c | 4c | 42m 31s | 43m 53s | 42m 35s | 41m 56s |
| dist-powerpc64-linux | 8c | 4c | 42m 52s | 44m 36s | 45m 32s | 43m 51s |
| dist-powerpc64le-linux | 8c | 4c | 43m 41s | 44m 11s | 43m 2s | 44m 21s |
| dist-riscv64-linux | 8c | 4c | 41m 25s | 42m 41s | 41m 52s | 43m 47s |
| dist-s390x-linux | 8c | 4c | 46m 48s | 47m 18s | 47m 27s | 46m 49s |
| dist-various-1 | 8c | 4c | 42m 14s | 43m 20s | 43m 20s | 41m 41s |
| dist-various-2 | 8c | 4c | 36m 18s | 38m 15s | 37m 41s | 39m 28s |
| dist-x86_64-freebsd | 8c | 4c | 39m 21s | 39m 40s | 40m 1s | 40m 2s |
| dist-x86_64-illumos | 8c | 4c | 45m 35s | 46m 43s | 46m 2s | 46m 4s |
| dist-x86_64-linux | 16c | | 1h 53m 10s | 1h 51m 15s | 1h 52m 18s | 1h 52m 26s |
| dist-x86_64-linux-alt | 16c | | 2h 3m 33s | 2h 3m 31s | 2h 4m 12s | 2h 2m 21s |
| dist-x86_64-musl | 8c | | 1h 5m 42s | 1h 6m 13s | 1h 7m 49s | 1h 6m 6s |
| dist-x86_64-netbsd | 8c | 4c | 40m 4s | 39m 48s | 40m 16s | 39m 43s |
| i686-gnu | 8c | | 1h 13m 38s | 1h 13m 39s | 1h 13m 48s | 1h 13m 12s |
| i686-gnu-nopt | 8c | | 1h 17m 44s | 1h 18m 14s | 1h 19m 55s | 1h 18m 44s |
| mingw-check | 4c | | 28m 15s | 27m 39s | 28m 36s | 28m 38s |
| test-various | 8c | 4c | 37m 45s | 37m 17s | 38m 26s | 38m 11s |
| x86_64-gnu | 4c | | 1h 34m 1s | 1h 31m 51s | 1h 30m 35s | 1h 32m 53s |
| x86_64-gnu-stable | 4c | | 1h 28m 26s | 1h 28m 11s | 1h 29m 40s | 1h 46m 28s |
| x86_64-gnu-aux | 4c | | 1h 33m 32s | 1h 31m 57s | 1h 34m 8s | 1h 32m 57s |
| x86_64-gnu-integration | 8c | | 1h 22m 2s | 1h 20m 14s | 1h 19m 46s | 1h 21m 24s |
| x86_64-gnu-debug | 8c | 4c | 52m 41s | 53m 40s | 51m 51s | 56m 9s |
| x86_64-gnu-distcheck | 8c | | 1h 9m 14s | 1h 5m 31s | 1h 6m 29s | 1h 5m 50s |
| x86_64-gnu-llvm-18 | 8c | | 1h 39m 47s | 1h 37m 57s | 1h 38m 40s | 1h 37m 38s |
| x86_64-gnu-llvm-17 | 8c | | 1h 41m 50s | 1h 45m 43s | 1h 45m 4s | 1h 43m 4s |
| x86_64-gnu-nopt | 4c | | 1h 20m 42s | 1h 21m 38s | 1h 20m 4s | 1h 22m 11s |
| x86_64-gnu-tools | 8c | | 1h 5m 0s | 1h 5m 30s | 1h 3m 1s | 1h 3m 20s |
| dist-x86_64-apple | xl | | 1h 35m 1s | 1h 39m 57s | 2h 2m 31s | 1h 47m 37s |
| dist-apple-various | xl | | 1h 18m 54s | 1h 22m 31s | 1h 13m 19s | 1h 38m 18s |
| x86_64-apple-1 | xl | | 1h 32m 8s | 1h 40m 12s | 1h 51m 28s | 1h 40m 26s |
| x86_64-apple-2 | xl | | 1h 0m 32s | 1h 4m 5s | 1h 9m 0s | 1h 7m 17s |
| dist-aarch64-apple | m1 | | 1h 3m 9s | 1h 1m 14s | 1h 2m 6s | 1h 2m 24s |
| aarch64-apple | m1 | | 53m 38s | 1h 1m 5s | 1h 3m 15s | 1h 6m 11s |
| x86_64-msvc | 8c | | 1h 27m 48s | 1h 29m 38s | 1h 29m 55s | 1h 28m 4s |
| i686-msvc | 8c | | 1h 38m 28s | 1h 34m 7s | 1h 39m 19s | 1h 39m 28s |
| x86_64-msvc-ext | 8c | | 1h 44m 5s | 1h 38m 40s | 1h 45m 21s | 1h 44m 19s |
| i686-mingw | 8c | | 1h 49m 57s | 1h 45m 1s | 1h 52m 4s | 1h 51m 4s |
| x86_64-mingw | 8c | | 1h 44m 2s | 1h 37m 36s | 1h 49m 58s | 1h 47m 5s |
| dist-x86_64-msvc | 8c | | 1h 57m 14s | 1h 49m 43s | 1h 52m 53s | 1h 52m 35s |
| dist-i686-msvc | 8c | | 1h 8m 5s | 1h 4m 9s | 1h 9m 26s | 1h 12m 0s |
| dist-aarch64-msvc | 8c | | 1h 18m 40s | 1h 14m 4s | 1h 22m 1s | 1h 19m 6s |
| dist-i686-mingw | 8c | | 1h 15m 36s | 1h 14m 36s | 1h 16m 38s | 1h 16m 2s |
| dist-x86_64-mingw | 8c | | 1h 11m 54s | 1h 16m 12s | 1h 16m 54s | 1h 18m 2s |
| dist-x86_64-msvc-alt | 8c | | 1h 11m 17s | 1h 10m 0s | 1h 11m 8s | 1h 13m 14s |
2024-05-20 11:30:58 +00:00
Guillaume Gomez
7b0fd3b931 Migrate run-make/rustdoc-scrape-examples-whitespace to rmake.rs 2024-05-20 12:09:11 +02:00
Urgau
ccd3e99a1a Fix quote escaping inside check-cfg value 2024-05-20 11:44:09 +02:00
bors
e8ada6ab25 Auto merge of #125313 - matthiaskrgr:rollup-65etxv0, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #125034 (Weekly `cargo update`)
 - #125093 (Add `fn into_raw_with_allocator` to Rc/Arc/Weak.)
 - #125282 (Never type unsafe lint improvements)
 - #125301 (fix suggestion in E0373 for !Unpin coroutines)
 - #125302 (defrost `RUST_MIN_STACK=ice rustc hello.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-20 07:58:40 +00:00
jdonszelmann
1d9757cd84
add todo test for feature gate 2024-05-20 09:18:49 +02:00
Matthias Krüger
ecbd110c7e
Rollup merge of #125302 - workingjubilee:prefer-my-stack-neat, r=compiler-errors
defrost `RUST_MIN_STACK=ice rustc hello.rs`

I didn't think too hard about testing my previous PR rust-lang/rust#122847 which makes our stack overflow handler assist people in discovering the `RUST_MIN_STACK` variable (which apparently is surprisingly useful for Really Big codebases). After it was merged, some useful comments left in a drive-by review led me to discover I had added an ICE. This reworks the code a bit to explain the rationale, remove the ICE that I introduced, and properly test one of the diagnostics.
2024-05-20 08:31:42 +02:00
Matthias Krüger
199d3bf3e4
Rollup merge of #125301 - jwong101:fix-static-coro-suggest, r=compiler-errors
fix suggestion in E0373 for !Unpin coroutines

Coroutines can be prefixed with the `static` keyword to make them
`!Unpin`.
However, given the following function:

```rust

fn check() -> impl Sized {
    let x = 0;
    #[coroutine]
    static || {
        yield;
        x
    }
}
```

We currently suggest prefixing `move` before `static`, which is
syntactically incorrect:

```
error[E0373]: coroutine may outlive the current function, but it borrows
...
 --> src/main.rs:6:5
  |
6 |     static || {
  |     ^^^^^^^^^ may outlive borrowed value `x`
7 |         yield;
8 |         x
  |         - `x` is borrowed here
  |
note: coroutine is returned here
 --> src/main.rs:6:5
  |
6 | /     static || {
7 | |         yield;
8 | |         x
9 | |     }
  | |_____^
help: to force the coroutine to take ownership of `x` (and any other
referenced variables), use the `move` keyword
  |     // this is syntactically incorrect, it should be `static move ||`
6 |     move static || {
  |     ++++

```

This PR suggests adding `move` after `static` for these coroutines.

I also added a UI test for this case.
2024-05-20 08:31:42 +02:00
Matthias Krüger
88552615e8
Rollup merge of #125282 - WaffleLapkin:never-type-unsafe-improvements, r=compiler-errors
Never type unsafe lint improvements

- Move linting code to a separate method
- Remove mentions of `core::convert::absurd` (#124311 was rejected)
- Make the lint into FCW

The last thing is a bit weird though. On one hand it should be `EditionSemanticsChange(2024)`, but on the other hand it shouldn't, because we also plan to break it on all editions some time later. _Also_, it's weird that we don't have `FutureReleaseSemanticsChangeReportInDeps`, IMO "this might cause UB in a future release" is important enough to be reported in deps...

IMO we ought to have three enums instead of [`FutureIncompatibilityReason`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.FutureIncompatibilityReason.html#):

```rust
enum IncompatibilityWhen {
     FutureRelease,
     Edition(Edition),
}

enum IncompatibilyWhat {
    Error,
    SemanticChange,
}

enum IncompatibilityReportInDeps {
    No,
    Yes,
}
```

Tracking:
- https://github.com/rust-lang/rust/issues/123748
2024-05-20 08:31:41 +02:00
Matthias Krüger
7389416284
Rollup merge of #125093 - zachs18:rc-into-raw-with-allocator-only, r=Mark-Simulacrum
Add `fn into_raw_with_allocator` to Rc/Arc/Weak.

Split out from #119761

Add `fn into_raw_with_allocator` for `Rc`/`rc::Weak`[^1]/`Arc`/`sync::Weak`.
* Pairs with `from_raw_in` (which already exists on all 4 types).
* Name matches `Box::into_raw_with_allocator`.
* Associated fns on `Rc`/`Arc`, methods on `Weak`s.

<details> <summary>Future PR/ACP</summary>

As a follow-on to this PR, I plan to make a PR/ACP later to move `into_raw(_parts)` from `Container<_, A: Allocator>` to only `Container<_, Global>` (where `Container` = `Vec`/`Box`/`Rc`/`rc::Weak`/`Arc`/`sync::Weak`) so that users of non-`Global` allocators have to explicitly handle the allocator when using `into_raw`-like APIs.

The current behaviors of stdlib containers are inconsistent with respect to what happens to the allocator when `into_raw` is called (which does not return the allocator)

| Type | `into_raw` currently callable with | behavior of `into_raw`|
| --- | --- | --- |
| `Box` | any allocator | allocator is [dropped](https://doc.rust-lang.org/nightly/src/alloc/boxed.rs.html#1060) |
| `Vec` | any allocator | allocator is [forgotten](https://doc.rust-lang.org/nightly/src/alloc/vec/mod.rs.html#884) |
| `Arc`/`Rc`/`Weak` | any allocator | allocator is [forgotten](https://doc.rust-lang.org/src/alloc/sync.rs.html#1487)(Arc) [(sync::Weak)](https://doc.rust-lang.org/src/alloc/sync.rs.html#2726) [(Rc)](https://doc.rust-lang.org/src/alloc/rc.rs.html#1352) [(rc::Weak)](https://doc.rust-lang.org/src/alloc/rc.rs.html#2993) |

In my opinion, neither implicitly dropping nor implicitly forgetting the allocator is ideal; dropping it could immediately invalidate the returned pointer, and forgetting it could unintentionally leak memory. My (to-be) proposed solution is to just forbid calling `into_raw(_parts)` on containers with non-`Global` allocators, and require calling `into_raw_with_allocator`(/`Vec::into_raw_parts_with_alloc`)

</details>

[^1]:  Technically, `rc::Weak::into_raw_with_allocator` is not newly added, as it was modified and renamed from `rc::Weak::into_raw_and_alloc`.
2024-05-20 08:31:41 +02:00
Matthias Krüger
af6da61ea4
Rollup merge of #125034 - rust-lang:cargo_update, r=Mark-Simulacrum
Weekly `cargo update`

Automation to keep dependencies in `Cargo.lock` current.

The following is the output from `cargo update`:

```txt
     Locking 24 packages to latest compatible versions
    Updating ammonia v3.3.0 -> v4.0.0
    Updating anyhow v1.0.83 -> v1.0.86
    Updating camino v1.1.6 -> v1.1.7
    Updating darling v0.20.8 -> v0.20.9
    Updating darling_core v0.20.8 -> v0.20.9
    Updating darling_macro v0.20.8 -> v0.20.9
      Adding dbus v0.9.7
    Updating either v1.11.0 -> v1.12.0
      Adding html5ever v0.27.0
    Updating instant v0.1.12 -> v0.1.13
      Adding libdbus-sys v0.2.5
    Updating linux-raw-sys v0.4.13 -> v0.4.14 (latest: v0.6.4)
      Adding markup5ever v0.12.1
    Updating mdbook v0.4.37 -> v0.4.40
    Updating miniz_oxide v0.7.2 -> v0.7.3
      Adding opener v0.7.1
    Updating rustversion v1.0.16 -> v1.0.17
    Updating serde v1.0.201 -> v1.0.202
    Updating serde_derive v1.0.201 -> v1.0.202
    Updating serde_spanned v0.6.5 -> v0.6.6
    Removing strsim v0.10.0
    Updating syn v2.0.62 -> v2.0.64
    Updating thiserror v1.0.60 -> v1.0.61
    Updating thiserror-impl v1.0.60 -> v1.0.61
    Updating toml_datetime v0.6.5 -> v0.6.6
note: pass `--verbose` to see 96 unchanged dependencies behind latest
```
2024-05-20 08:31:40 +02:00
bors
f092f73c11 Auto merge of #124560 - madsmtm:update-libc, r=Mark-Simulacrum
Update libc to 0.2.155

Motivation: To fix `-Zbuild-std` / Xargo for visionOS targets.

EDIT: Blocked on ~https://github.com/rust-lang/libc/issues/3608 / https://github.com/rust-lang/libc/pull/3609~ ~https://github.com/rust-lang/libc/pull/3682 and https://github.com/rust-lang/libc/pull/3690~ No longer blocked.
2024-05-20 05:50:24 +00:00
Nicholas Nethercote
4654e87d4c Fix tests/debuginfo/strings-and-strs.
It fails on my machine because it embeds pointer addresses in the
expected output.

This commit replaces the addresses with `0x[...]`.
2024-05-20 15:01:59 +10:00
Jubilee Young
b6d0d6da55 note value of RUST_MIN_STACK and explain unsetting 2024-05-19 20:09:03 -07:00
bors
20483b6826 Auto merge of #125288 - nikic:update-llvm-18.1.6, r=cuviper
Update to LLVM 18.1.6

This rebases our LLVM fork on top of LLVM 18.1.6, which is planned to be the last release of the 18.x series.

Fixes #123695.
Fixes #125053.

r? `@cuviper`
2024-05-20 02:58:19 +00:00
Jubilee Young
9985821b2f defrost RUST_MIN_STACK=ice rustc hello.rs
An earlier commit included the change for a suggestion here.
Unfortunately, it also used unwrap instead of dying properly.
Roll out the ~~rice paper~~ EarlyDiagCtxt before we do anything that
might leave a mess.
2024-05-19 18:28:14 -07:00
Jubilee Young
def6b99b4a move rustc-rust-log test into ui/rustc-env 2024-05-19 18:27:53 -07:00
bors
12075f04e6 Auto merge of #123878 - jwong101:inplacecollect, r=jhpratt
optimize inplace collection of Vec

This PR has the following changes:

1. Using `usize::unchecked_mul` in 79424056b0/library/alloc/src/vec/in_place_collect.rs (L262) as LLVM, does not know that the operation can't wrap, since that's the size of the original allocation.

Given the following:

```rust

pub struct Foo([usize; 3]);

pub fn unwrap_copy(v: Vec<Foo>) -> Vec<[usize; 3]> {
    v.into_iter().map(|f| f.0).collect()
}
```

<details>
<summary>Before this commit:</summary>

```llvm
define void `@unwrap_copy(ptr` noalias nocapture noundef writeonly sret([24 x i8]) align 8 dereferenceable(24) %_0, ptr noalias nocapture noundef readonly align 8 dereferenceable(24) %iter) {
start:
  %me.sroa.0.0.copyload.i = load i64, ptr %iter, align 8
  %me.sroa.4.0.self.sroa_idx.i = getelementptr inbounds i8, ptr %iter, i64 8
  %me.sroa.4.0.copyload.i = load ptr, ptr %me.sroa.4.0.self.sroa_idx.i, align 8
  %me.sroa.5.0.self.sroa_idx.i = getelementptr inbounds i8, ptr %iter, i64 16
  %me.sroa.5.0.copyload.i = load i64, ptr %me.sroa.5.0.self.sroa_idx.i, align 8
  %_19.i.idx = mul nsw i64 %me.sroa.5.0.copyload.i, 24
  %0 = udiv i64 %_19.i.idx, 24

; Unnecessary calculation
  %_16.i.i = mul i64 %me.sroa.0.0.copyload.i, 24
  %dst_cap.i.i = udiv i64 %_16.i.i, 24

  store i64 %dst_cap.i.i, ptr %_0, align 8
  %1 = getelementptr inbounds i8, ptr %_0, i64 8
  store ptr %me.sroa.4.0.copyload.i, ptr %1, align 8
  %2 = getelementptr inbounds i8, ptr %_0, i64 16
  store i64 %0, ptr %2, align 8
  ret void
}
```
</details>

<details>
<summary>After:</summary>

```llvm
define void `@unwrap_copy(ptr` noalias nocapture noundef writeonly sret([24 x i8]) align 8 dereferenceable(24) %_0, ptr noalias nocapture noundef readonly align 8 dereferenceable(24) %iter) {
start:
  %me.sroa.0.0.copyload.i = load i64, ptr %iter, align 8
  %me.sroa.4.0.self.sroa_idx.i = getelementptr inbounds i8, ptr %iter, i64 8
  %me.sroa.4.0.copyload.i = load ptr, ptr %me.sroa.4.0.self.sroa_idx.i, align 8
  %me.sroa.5.0.self.sroa_idx.i = getelementptr inbounds i8, ptr %iter, i64 16
  %me.sroa.5.0.copyload.i = load i64, ptr %me.sroa.5.0.self.sroa_idx.i, align 8
  %_19.i.idx = mul nsw i64 %me.sroa.5.0.copyload.i, 24
  %0 = udiv i64 %_19.i.idx, 24
  store i64 %me.sroa.0.0.copyload.i, ptr %_0, align 8
  %1 = getelementptr inbounds i8, ptr %_0, i64 8
  store ptr %me.sroa.4.0.copyload.i, ptr %1, align 8
  %2 = getelementptr inbounds i8, ptr %_0, i64 16
  store i64 %0, ptr %2, align 8, !alias.scope !9, !noalias !14
  ret void
}
```
</details>

Note that there is still one more `mul,udiv` pair that I couldn't get
rid of. The root cause is the same issue as https://github.com/rust-lang/rust/issues/121239, the `nuw` gets
stripped off of `ptr::sub_ptr`.

2.

`Iterator::try_fold` gets called on the underlying Iterator in
`SpecInPlaceCollect::collect_in_place` whenever it does not implement
`TrustedRandomAccess`. For types that impl `Drop`, LLVM currently can't
tell that the drop can never occur, when using the default
`Iterator::try_fold` implementation.

For example, given the following code from #120493

```rust
#[repr(transparent)]
struct WrappedClone {
    inner: String
}

#[no_mangle]
pub fn unwrap_clone(list: Vec<WrappedClone>) -> Vec<String> {
    list.into_iter().map(|s| s.inner).collect()
}
```

<details>
<summary>The asm for the `unwrap_clone` method is currently:</summary>

```asm
unwrap_clone:
        push    rbp
        push    r15
        push    r14
        push    r13
        push    r12
        push    rbx
        push    rax
        mov     rbx, rdi
        mov     r12, qword ptr [rsi]
        mov     rdi, qword ptr [rsi + 8]
        mov     rax, qword ptr [rsi + 16]
        movabs  rsi, -6148914691236517205
        mov     r14, r12
        test    rax, rax
        je      .LBB0_10
        lea     rcx, [rax + 2*rax]
        lea     r14, [r12 + 8*rcx]
        shl     rax, 3
        lea     rax, [rax + 2*rax]
        xor     ecx, ecx
.LBB0_2:
        cmp     qword ptr [r12 + rcx], 0
        je      .LBB0_4
        add     rcx, 24
        cmp     rax, rcx
        jne     .LBB0_2
        jmp     .LBB0_10
.LBB0_4:
        lea     rdx, [rax - 24]
        lea     r14, [r12 + rcx]
        cmp     rdx, rcx
        je      .LBB0_10
        mov     qword ptr [rsp], rdi
        sub     rax, rcx
        add     rax, -24
        mul     rsi
        mov     r15, rdx
        lea     rbp, [r12 + rcx]
        add     rbp, 32
        shr     r15, 4
        mov     r13, qword ptr [rip + __rust_dealloc@GOTPCREL]
        jmp     .LBB0_6
.LBB0_8:
        add     rbp, 24
        dec     r15
        je      .LBB0_9
.LBB0_6:
        mov     rsi, qword ptr [rbp]
        test    rsi, rsi
        je      .LBB0_8
        mov     rdi, qword ptr [rbp - 8]
        mov     edx, 1
        call    r13
        jmp     .LBB0_8
.LBB0_9:
        mov     rdi, qword ptr [rsp]
        movabs  rsi, -6148914691236517205
.LBB0_10:
        sub     r14, r12
        mov     rax, r14
        mul     rsi
        shr     rdx, 4
        mov     qword ptr [rbx], r12
        mov     qword ptr [rbx + 8], rdi
        mov     qword ptr [rbx + 16], rdx
        mov     rax, rbx
        add     rsp, 8
        pop     rbx
        pop     r12
        pop     r13
        pop     r14
        pop     r15
        pop     rbp
        ret
```
</details>

<details>
<summary>After this PR:</summary>

```asm
unwrap_clone:
	mov	rax, rdi
	movups	xmm0, xmmword ptr [rsi]
	mov	rcx, qword ptr [rsi + 16]
	movups	xmmword ptr [rdi], xmm0
	mov	qword ptr [rdi + 16], rcx
	ret
```
</details>

Fixes https://github.com/rust-lang/rust/issues/120493
2024-05-20 00:51:12 +00:00
Joshua Wong
371de042d9 add ui tests for E0373 suggestion 2024-05-19 19:23:38 -05:00
Joshua Wong
5d7eda224e fix suggestion in E0373 for !Unpin coroutines
Coroutines can be prefixed with the `static` keyword to make them
`!Unpin`.
However, given the following function:

```rust

fn check() -> impl Sized {
    let x = 0;
    #[coroutine]
    static || {
        yield;
        x
    }
}
```

We currently suggest prefixing `move` before `static`, which is
syntactically incorrect:

```
error[E0373]: coroutine may outlive the current function, but it borrows
...
 --> src/main.rs:6:5
  |
6 |     static || {
  |     ^^^^^^^^^ may outlive borrowed value `x`
7 |         yield;
8 |         x
  |         - `x` is borrowed here
  |
note: coroutine is returned here
 --> src/main.rs:6:5
  |
6 | /     static || {
7 | |         yield;
8 | |         x
9 | |     }
  | |_____^
help: to force the coroutine to take ownership of `x` (and any other
referenced variables), use the `move` keyword
  |     // this is syntactically incorrect, it should be `static move ||`
6 |     move static || {
  |     ++++

```

This PR suggests adding `move` after `static` for these coroutines.
2024-05-19 19:13:52 -05:00
Michael Goulet
090dbb12f9 Don't strip items with inherited visibility in AliasedNonLocalStripper 2024-05-19 20:13:18 -04:00
Michael Goulet
dbfed2c43e Add failing test for cross-crate enum in type alias 2024-05-19 20:13:18 -04:00
Michael Goulet
9dc073aa4b Make EvalCtxt generic over interner 2024-05-19 19:38:28 -04:00
Michael Goulet
91685c0ef4 Make search graph generic over interner 2024-05-19 19:38:28 -04:00
bors
d84b903754 Auto merge of #125294 - matthiaskrgr:rollup-w42c829, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #124948 (chore: Remove repeated words (extension of #124924))
 - #124992 (Add example to IsTerminal::is_terminal)
 - #125279 (make `Debug` impl for `Term` simpler)
 - #125286 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-19 21:30:43 +00:00
Matthias Krüger
7a45322300
Rollup merge of #125286 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-05-19 22:50:56 +02:00
Matthias Krüger
131d48f5a1
Rollup merge of #125279 - WaffleLapkin:unpacktermindebug, r=aDotInTheVoid,Nilstrieb,BoxyUwU
make `Debug` impl for `Term` simpler

meow
2024-05-19 22:50:56 +02:00
Matthias Krüger
c5b8c7c3b0
Rollup merge of #124992 - foresterre:example/is-terminal, r=ChrisDenton
Add example to IsTerminal::is_terminal
2024-05-19 22:50:55 +02:00
Matthias Krüger
d5bef41ee5
Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errors
chore: Remove repeated words (extension of #124924)

When I saw #124924 I thought "Hey, I'm sure that there are far more than just two typos of this nature in the codebase". So here's some more typo-fixing.

Some found with regex, some found with a spellchecker. Every single one manually reviewed by me (along with hundreds of false negatives by the tools)
2024-05-19 22:50:55 +02:00