Commit Graph

225228 Commits

Author SHA1 Message Date
Michael Goulet
71982341b4
Rollup merge of #112174 - cuishuang:master, r=jyn514
Fix broken link

The previous link is no longer accessible.

Use the latest link.
2023-06-01 23:07:39 -07:00
Michael Goulet
fc557576a4
Rollup merge of #112150 - taiki-e:apple-atomic-128, r=Amanieu
Support 128-bit atomics on all x86_64 Apple targets

On x86_64, we currently set `max_atomic_width` to 128 only on macOS.

ad8304a0d5/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs (L8)

However, other x86_64 Apple targets (iOS, tvOS, and watchOS) are also core2+ and support cmpxchg16b.

ad8304a0d5/compiler/rustc_target/src/spec/apple_base.rs (L71-L76)

```console
# Script to get targets that support cmpxchg16b by default:
$ (for target in $(rustc --print target-list); do [[ $target == "x86_64"* ]] && rustc --print cfg --target "$target" | grep -q cmpxchg16b && echo "$target"; done)
x86_64-apple-darwin
x86_64-apple-ios
x86_64-apple-ios-macabi
x86_64-apple-tvos
x86_64-apple-watchos-sim
x86_64h-apple-darwin
```

r? `@Amanieu`
2023-06-01 23:07:38 -07:00
Michael Goulet
8ceb283c92
Rollup merge of #112030 - sladyn98:item-trait-alias, r=GuillaumeGomez
Migrate `item_trait_alias` to Askama

This PR migrates `item_trait_alias` to Askama

Refers https://github.com/rust-lang/rust/issues/108868
2023-06-01 23:07:37 -07:00
Michael Goulet
ceec2250a3
Rollup merge of #111914 - rcvalle:rust-cfi-fix-111184, r=compiler-errors
CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…

Fixes https://github.com/rust-lang/rust/issues/111184 by encoding ty::Generator parent substs only.
2023-06-01 23:07:37 -07:00
Michael Goulet
24404e6409
Rollup merge of #111670 - compiler-errors:const-param-ty, r=BoxyUwU
Require that const param tys implement `ConstParamTy`

1. Require that const param tys implement `ConstParamTy` instead of using `search_for_adt_const_param_violation`
2. Add `StructuralPartialEq` as a supertrait for `ConstParamTy`, since we need to make sure that we derive *both* `PartialEq` and `Eq`
3. Implement `ConstParamTy` for tuples up to 12 (or whatever the default for tuples is)
4. Add some custom diagnostics to `ConstParamTy` errors, to avoid regressions from (1.). It's still not as great as it could be -- will point out inline in comments.

r? `@BoxyUwU`
2023-06-01 23:07:36 -07:00
bors
774a3d1523 Auto merge of #111553 - cjgillot:mir-e2e, r=scottmcm
Add a few MIR pre-codegen tests

r? `@scottmcm`
2023-06-02 02:36:07 +00:00
cui fliter
bbfadf067c Fix broken link
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-02 09:36:01 +08:00
bors
f85ab544df Auto merge of #112184 - matthiaskrgr:rollup-tlh72el, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #111496 (Extra context for unreachable_pub lint)
 - #111802 (Make `x test --dry-run` less verbose)
 - #112133 (Migrate GUI colors test to original CSS color format)
 - #112146 (Fix `src/etc/pre-push.sh` when `build.locked-deps` is already set)
 - #112147 (add inline-const test for elided lifetimes being infer vars)
 - #112154 (Fix bug in utf16_to_utf8 for zero length strings)
 - #112155 (Improve CGU debug printing.)
 - #112173 (Mention GuillaumeGomez in case GUI tests are updated)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-01 23:39:56 +00:00
Ramon de C Valle
76ff5ec886 CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Binde
Fixes #111184 by encoding ty::Generator parent substs only.
2023-06-01 23:22:54 +00:00
Camille GILLOT
d796c600ad Rebase fallout. 2023-06-01 21:43:52 +00:00
Camille GILLOT
1ad37804a6 Remove brittle test. 2023-06-01 21:41:58 +00:00
Camille GILLOT
b90e165744 Restrict test to x64. 2023-06-01 21:41:58 +00:00
Camille GILLOT
36cae3a3a2 Annotate needs-unwind. 2023-06-01 21:41:58 +00:00
Camille GILLOT
051dd6714c Remove duplication. 2023-06-01 21:41:58 +00:00
Camille GILLOT
3483e77263 Remove spurious comments. 2023-06-01 21:41:58 +00:00
Camille GILLOT
b0121799b3 Add chained comparison e2e test. 2023-06-01 21:41:58 +00:00
Camille GILLOT
434fa8c26d Add e2e mir test for checked arithmetic. 2023-06-01 21:41:58 +00:00
Camille GILLOT
2c6f137d9a Add loop tests. 2023-06-01 21:41:58 +00:00
Camille GILLOT
ae6f97c43d Make slice_filter a pre-codegen test. 2023-06-01 21:41:58 +00:00
Matthias Krüger
d505702a7e
Rollup merge of #112173 - GuillaumeGomez:mention-on-gui-test-change, r=compiler-errors
Mention GuillaumeGomez in case GUI tests are updated
2023-06-01 22:47:33 +02:00
Matthias Krüger
c6aec9459e
Rollup merge of #112155 - nnethercote:debug_dump, r=wesleywiser
Improve CGU debug printing.

- Add more total and per-CGU measurements.
- Ensure CGUs are sorted by name before the first `debug_dump` calls, for deterministic output.
- Print items within CGUs in sorted-by-name order, for deterministic output.
- Add some assertions and comments clarifying sortedness of CGUs at various points.

An example, before:
```
INITIAL PARTITIONING (5 CodegenUnits, max=29, min=1, max/min=29.0):
CodegenUnit scev95ysd7g4b0z estimated size 2:
 - fn <() as std::process::Termination>::report [(External, Hidden)] [h082b15a6d07338dcE] estimated size 2

CodegenUnit 1j0frgtl72rsz24q estimated size 29:
 - fn std::rt::lang_start::<()>::{closure#0} [(External, Hidden)] [h695c7b5d6a212565E] estimated size 17
 - fn std::rt::lang_start::<()> [(External, Hidden)] [h4ca942948e9cb931E] estimated size 12

CodegenUnit 5dbzi1e5qm0d7kj2 estimated size 4:
 - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim [(External, Hidden)] [h24eaa44f03b2b233E] estimated size 1
 - fn <fn() as std::ops::FnOnce<()>>::call_once - shim(fn()) [(External, Hidden)] [hf338f5339c3711acE] estimated size 1
 - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim(vtable) [(External, Hidden)] [h595d414cbb7651d5E] estimated size 1
 - fn std::ptr::drop_in_place::<[closure@std::rt::lang_start<()>::{closure#0}]> - shim(None) [(External, Hidden)] [h17a19dcdb40600daE] estimated size 1

CodegenUnit 220m1mqa2mlbg7r3 estimated size 1:
 - fn main [(External, Hidden)] [hb29587cdb6db5f42E] estimated size 1

CodegenUnit 4ulbh241f7tvyn7x estimated size 6:
 - fn std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> [(External, Hidden)] [h41dada2c21a1259dE] estimated size 6
```
and after:
```
INITIAL PARTITIONING (9 items, total_size=42; 5 CGUs, max_size=29, min_size=1, max_size/min_size=29.0):
- CGU[0] 1j0frgtl72rsz24q (2 items, size=29):
  - fn std::rt::lang_start::<()> [(External, Hidden)] [h4ca942948e9cb931E] (size=12)
  - fn std::rt::lang_start::<()>::{closure#0} [(External, Hidden)] [h695c7b5d6a212565E] (size=17)

- CGU[1] 220m1mqa2mlbg7r3 (1 items, size=1):
  - fn main [(External, Hidden)] [hb29587cdb6db5f42E] (size=1)

- CGU[2] 4ulbh241f7tvyn7x (1 items, size=6):
  - fn std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> [(External, Hidden)] [h41dada2c21a1259dE] (size=6)

- CGU[3] 5dbzi1e5qm0d7kj2 (4 items, size=4):
  - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim(vtable) [(External, Hidden)] [h595d414cbb7651d5E] (size=1)
  - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim [(External, Hidden)] [h24eaa44f03b2b233E] (size=1)
  - fn <fn() as std::ops::FnOnce<()>>::call_once - shim(fn()) [(External, Hidden)] [hf338f5339c3711acE] (size=1)
  - fn std::ptr::drop_in_place::<[closure@std::rt::lang_start<()>::{closure#0}]> - shim(None) [(External, Hidden)] [h17a19dcdb40600daE] (size=1)

- CGU[4] scev95ysd7g4b0z (1 items, size=2):
  - fn <() as std::process::Termination>::report [(External, Hidden)] [h082b15a6d07338dcE] (size=2)
```

r? ``@wesleywiser``
2023-06-01 22:47:33 +02:00
Matthias Krüger
a66ba9b10b
Rollup merge of #112154 - ShaneEverittM:zero-len-utf16, r=thomcc
Fix bug in utf16_to_utf8 for zero length strings

This fixes the behavior of sending EOF by pressing Ctrl+Z => Enter in a windows console.

Previously, that would trip the unpaired surrogate error, whereas now we correctly detect EOF.
2023-06-01 22:47:32 +02:00
Matthias Krüger
20b25d233a
Rollup merge of #112147 - zirconium-n:issue-110934, r=compiler-errors
add inline-const test for elided lifetimes being infer vars

Fixes #110934
2023-06-01 22:47:32 +02:00
Matthias Krüger
8f0e1442b0
Rollup merge of #112146 - jyn514:locked-deps, r=clubby789
Fix `src/etc/pre-push.sh` when `build.locked-deps` is already set

Before, cargo would error:
```
; git push
Running pre-push script /home/jyn/src/rust/x test tidy
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.02s
Build stage0 tool tidy (x86_64-unknown-linux-gnu)
error: the argument '--locked' cannot be used multiple times

Usage: cargo build [OPTIONS]

For more information, try '--help'.
Build completed unsuccessfully in 0:00:00
error: failed to push some refs to 'github.com:jyn514/rust.git'
```
2023-06-01 22:47:31 +02:00
Matthias Krüger
955bba36ea
Rollup merge of #112133 - GuillaumeGomez:migrate-gui-test-color-10, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? ```@notriddle```
2023-06-01 22:47:31 +02:00
Matthias Krüger
6930a944c7
Rollup merge of #111802 - jyn514:less-verbose, r=ozkanonur
Make `x test --dry-run` less verbose

The new output looks like `Testing stage2 book rustc (x86_64-unknown-linux-gnu)`.

Previously, this would print a message for each doctest, which was quite verbose:
```
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/exploit-mitigations.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/instrument-coverage.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/json.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/linker-plugin-lto.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/lints/groups.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/lints/index.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/lints/levels.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/aarch64-apple-ios-sim.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/aarch64-nintendo-switch-freestanding.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/apple-watchos.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/armeb-unknown-linux-gnueabi.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/armv4t-none-eabi.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/armv5te-none-eabi.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/armv6k-nintendo-3ds.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/armv7-sony-vita-newlibeabihf.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/armv7-unknown-linux-uclibceabi.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/armv7-unknown-linux-uclibceabihf.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/esp-idf.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/fuchsia.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/kmc-solid.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/loongarch-linux.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/m68k-unknown-linux-gnu.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/mipsel-sony-psx.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/nto-qnx.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/openbsd.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/openharmony.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/riscv32imac-unknown-xous-elf.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/unknown-uefi.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/wasm64-unknown-unknown.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/x86_64-fortanix-unknown-sgx.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/platform-support/x86_64-unknown-none.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/profile-guided-optimization.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/target-tier-policy.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/targets/custom.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/targets/index.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/tests/index.md
doc tests for: /home/jyn/src/rust/src/doc/rustc/src/what-is-rustc.md
```
2023-06-01 22:47:30 +02:00
Matthias Krüger
e7ec428cad
Rollup merge of #111496 - mpalmer:unreachable-pub-docs, r=pnkfelix
Extra context for unreachable_pub lint

While experienced Rustaceans no doubt know this sort of thing already, as more of a newbie I had trouble understanding why I was triggering the lint. Hopefully this expanded explanation saves someone else some head-scratching.

Fixes #110922
2023-06-01 22:47:30 +02:00
bors
d59363ad0b Auto merge of #111660 - Kobzol:try-build-skip-docs, r=mark-simulacrum
Do not build docs in try builds

This PR adds a new environment variable to the optimized build Python script, which causes it to ignore certain parts of the final `dist` build (mainly docs) in try builds. This reduces the duration of try builds by ~10 minutes.
2023-06-01 20:44:23 +00:00
sladynnunes
780719b2dc Migrate to Askama
Implemented wrap_item_write

Update wrap_item
2023-06-01 12:07:58 -07:00
Michael Goulet
97bacbab57 Remove adt_const_params usage from compiler 2023-06-01 18:21:42 +00:00
Michael Goulet
847d50453c Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
Michael Goulet
a9fcb524ff Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait too 2023-06-01 18:21:42 +00:00
Michael Goulet
8ab10bacdf remove search_for_adt_const_param_violation 2023-06-01 18:03:59 +00:00
Boxy
bbf41279fa Require that const param tys implement ConstParamTy 2023-06-01 18:03:59 +00:00
bors
789dd0b2a2 Auto merge of #112040 - cjgillot:separate-const-switch, r=oli-obk
Enable ConstGoto and SeparateConstSwitch passes by default

These 2 passes implement a limited form of jump-threading.
Filing this PR to see if enabling them would be lighter than https://github.com/rust-lang/rust/pull/107009.
2023-06-01 16:04:40 +00:00
Guillaume Gomez
f8a8ec1cfc Mention GuillaumeGomez in case GUI tests are updated 2023-06-01 12:57:32 +02:00
bors
642c92e630 Auto merge of #112002 - saethlin:enable-sroa, r=oli-obk,scottmcm
Enable ScalarReplacementOfAggregates in optimized builds

Like MatchBranchSimplification, this pass is known to produce significant runtime improvements in Cranelift artifacts, and I believe based on the perf runs here that the primary effect of this pass is to empower MatchBranchSimplification. ScalarReplacementOfAggregates on its own has little effect on anything, but when this was rebased up to include https://github.com/rust-lang/rust/pull/112001 we started seeing significant and majority-positive results.

Based on the fact that we see most of the regressions in debug builds (https://github.com/rust-lang/rust/pull/112002#issuecomment-1566270144) and some rather significant ones in cycles and wall time, I'm only enabling this in optimized builds at the moment.
2023-06-01 10:47:14 +00:00
bors
fabf929863 Auto merge of #112164 - Dylan-DPC:rollup-93zj7jw, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108459 (rustdoc: Fix LinkReplacer link matching)
 - #111318 (Add a distinct `OperandValue::ZeroSized` variant for ZSTs)
 - #111892 (rustdoc: add interaction delays for tooltip popovers)
 - #111980 (Preserve substs in opaques recorded in typeck results)
 - #112024 (Don't suggest break through nested items)
 - #112128 (Don't compute inlining status of mono items in advance.)
 - #112141 (remove reference to Into in ? operator core/std docs, fix #111655)

Failed merges:

 - #112071 (Group rfcs tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-01 08:06:07 +00:00
Jakub Beránek
db113b1c2b
Do not build components unneeded for perf bot in try builds 2023-06-01 08:29:19 +02:00
Dylan DPC
129c559764
Rollup merge of #112141 - anna-singleton:issue-111655-fix, r=thomcc
remove reference to Into in ? operator core/std docs, fix #111655

remove the text stating that `?` uses `Into::into` and add text stating it uses `From::from` instead. This closes #111655.
2023-06-01 11:09:45 +05:30
Dylan DPC
fe123231ad
Rollup merge of #112128 - nnethercote:no-inlining-advance, r=wesleywiser
Don't compute inlining status of mono items in advance.

We record inlining status for mono items in `MonoItems`, and then transfer it to `InliningMap`, for later use in
`InliningMap::with_inlining_candidates`.

But we can just compute inlining status directly in `InliningMap::with_inlining_candidates`, because the mono item is right there. There's no need to compute it in advance.

This commit changes the code to do that, removing the need for `MonoItems` and `InliningMap::inlines`. This does result in more calls to `instantiation_mode` (one per static occurrence) but the performance effect is negligible.

r? ``@wesleywiser``
2023-06-01 11:09:44 +05:30
Dylan DPC
02c4b4b279
Rollup merge of #112024 - compiler-errors:dont-break-thru-item, r=WaffleLapkin
Don't suggest break through nested items

Fixes #112020
2023-06-01 11:09:44 +05:30
Dylan DPC
ccf99bd769
Rollup merge of #111980 - compiler-errors:unmapped-substs, r=lcnr
Preserve substs in opaques recorded in typeck results

This means that we now prepopulate MIR with opaques with the right substs.

The first commit is a hack that I think we discussed, having to do with `DefiningAnchor::Bubble` basically being equivalent to `DefiningAnchor::Error` in the new solver, so having to use `DefiningAnchor::Bind` instead, lol.

r? `@lcnr`
2023-06-01 11:09:43 +05:30
Dylan DPC
453fc03597
Rollup merge of #111892 - notriddle:notriddle/timeout-tooltip, r=me,GuillaumeGomez,Manishearth
rustdoc: add interaction delays for tooltip popovers

Preview:

* [notable traits](http://notriddle.com/rustdoc-demo-html-3/delay-tooltip/testing/struct.Vec.html#method.iter)
* [panicking code block](http://notriddle.com/rustdoc-demo-html-3/delay-tooltip/testing/struct.Vec.html#indexing)

Designing a good hover microinteraction is a matter of guessing user intent from what are, literally, vague gestures. In this case, guessing if hovering in our out of the tooltip base is intentional or not.

To figure this out, a few different techniques are used:

* When the mouse pointer enters a tooltip anchor point, its hitbox is grown on the bottom, where the popover is/will appear. This was already there before this commit: search "hover tunnel" in rustdoc.css for the implementation.

* This commit adds a delay when the mouse pointer enters the base anchor, in case the mouse pointer was just passing through and the user didn't want to open it.

* This commit also adds a delay when the mouse pointer exits the tooltip's base anchor or its popover, before hiding it.

* A fade-out animation is layered onto the pointer exit delay to immediately inform the user that they successfully dismissed the popover, while still providing a way for them to cancel it if it was a mistake and they still wanted to interact with it.

* No animation is used for revealing it, because we don't want people to try to interact with an element while it's in the middle of fading in: either they're allowed to interact with it while it's fading in, meaning it can't serve as mistake- proofing for opening the popover, or they can't, but they might try and be frustrated.

See also:

* https://www.nngroup.com/articles/timing-exposing-content/
* https://www.nngroup.com/articles/tooltip-guidelines/
* https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown
2023-06-01 11:09:43 +05:30
Dylan DPC
03d4299447
Rollup merge of #111318 - scottmcm:operand-value-poison, r=compiler-errors
Add a distinct `OperandValue::ZeroSized` variant for ZSTs

These tend to have special handling in a bunch of places anyway, so the variant helps remember that.  And I think it's easier to grok than `Aggregate`s sometimes being `Immediates` (after all, I previously got that wrong and caused #109992).  As a minor bonus, it means we don't need to generate poison LLVM values for ZSTs to pass around in `OperandValue::Immediate`s.

Inspired by https://github.com/rust-lang/rust/pull/110021#discussion_r1160486991, so
r? `@compiler-errors`
2023-06-01 11:09:42 +05:30
Dylan DPC
0baa30129b
Rollup merge of #108459 - benediktwerner:rustdoc-fix-link-match, r=GuillaumeGomez
rustdoc: Fix LinkReplacer link matching

It currently just uses the first link with the same href which might not necessarily be the matching one.

This fixes replacements when there are several links to the same item but with different text (e.g. `[X] and [struct@X]`). It also fixes replacements in summaries since those use a links list with empty hrefs, so currently all links would always match the first link by href but then not match its text. This could also lead to a panic in the `original_lext[1..len() - 1]` part when the first link only has a single character, which is why the new code uses `.get(..)` instead.
2023-06-01 11:09:42 +05:30
bors
23f93a1266 Auto merge of #103877 - oli-obk:const_eval_step_limit, r=fee1-dead
Replace const eval limit by a lint and add an exponential backoff warning

The lint triggers at the first power of 2 that comes after 1 million function calls or traversed back-edges (takes less than a second on usual programs). After the first emission, an unsilenceable warning is repeated at every following power of 2 terminators, causing it to get reported less and less the longer the evaluation runs.

cc `@rust-lang/wg-const-eval`

fixes #93481
closes #67217
2023-06-01 05:32:00 +00:00
Scott McMurray
bf36193ef6 Add a distinct OperandValue::ZeroSized variant for ZSTs
These tend to have special handling in a bunch of places anyway, so the variant helps remember that.  And I think it's easier to grok than non-Scalar Aggregates sometimes being `Immediates` (like I got wrong and caused 109992).  As a minor bonus, it means we don't need to generate poison LLVM values for them to pass around in `OperandValue::Immediate`s.
2023-05-31 19:10:28 -07:00
Nicholas Nethercote
1191bea6ab Improve CGU debug printing.
- Add more total and per-CGU measurements.
- Ensure CGUs are sorted by name before the first `debug_dump` calls,
  for deterministic output.
- Print items within CGUs in sorted-by-name order, for deterministic
  output.
- Add some assertions and comments clarifying sortedness of CGUs at
  various points.

An example, before:
```
INITIAL PARTITIONING (5 CodegenUnits, max=29, min=1, max/min=29.0):
CodegenUnit scev95ysd7g4b0z estimated size 2:
 - fn <() as std::process::Termination>::report [(External, Hidden)] [h082b15a6d07338dcE] estimated size 2

CodegenUnit 1j0frgtl72rsz24q estimated size 29:
 - fn std::rt::lang_start::<()>::{closure#0} [(External, Hidden)] [h695c7b5d6a212565E] estimated size 17
 - fn std::rt::lang_start::<()> [(External, Hidden)] [h4ca942948e9cb931E] estimated size 12

CodegenUnit 5dbzi1e5qm0d7kj2 estimated size 4:
 - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim [(External, Hidden)] [h24eaa44f03b2b233E] estimated size 1
 - fn <fn() as std::ops::FnOnce<()>>::call_once - shim(fn()) [(External, Hidden)] [hf338f5339c3711acE] estimated size 1
 - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim(vtable) [(External, Hidden)] [h595d414cbb7651d5E] estimated size 1
 - fn std::ptr::drop_in_place::<[closure@std::rt::lang_start<()>::{closure#0}]> - shim(None) [(External, Hidden)] [h17a19dcdb40600daE] estimated size 1

CodegenUnit 220m1mqa2mlbg7r3 estimated size 1:
 - fn main [(External, Hidden)] [hb29587cdb6db5f42E] estimated size 1

CodegenUnit 4ulbh241f7tvyn7x estimated size 6:
 - fn std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> [(External, Hidden)] [h41dada2c21a1259dE] estimated size 6
```
and after:
```
INITIAL PARTITIONING (9 items, total_size=42; 5 CGUs, max_size=29, min_size=1, max_size/min_size=29.0):
- CGU[0] 1j0frgtl72rsz24q (2 items, size=29):
  - fn std::rt::lang_start::<()> [(External, Hidden)] [h4ca942948e9cb931E] (size=12)
  - fn std::rt::lang_start::<()>::{closure#0} [(External, Hidden)] [h695c7b5d6a212565E] (size=17)

- CGU[1] 220m1mqa2mlbg7r3 (1 items, size=1):
  - fn main [(External, Hidden)] [hb29587cdb6db5f42E] (size=1)

- CGU[2] 4ulbh241f7tvyn7x (1 items, size=6):
  - fn std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> [(External, Hidden)] [h41dada2c21a1259dE] (size=6)

- CGU[3] 5dbzi1e5qm0d7kj2 (4 items, size=4):
  - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim(vtable) [(External, Hidden)] [h595d414cbb7651d5E] (size=1)
  - fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim [(External, Hidden)] [h24eaa44f03b2b233E] (size=1)
  - fn <fn() as std::ops::FnOnce<()>>::call_once - shim(fn()) [(External, Hidden)] [hf338f5339c3711acE] (size=1)
  - fn std::ptr::drop_in_place::<[closure@std::rt::lang_start<()>::{closure#0}]> - shim(None) [(External, Hidden)] [h17a19dcdb40600daE] (size=1)

- CGU[4] scev95ysd7g4b0z (1 items, size=2):
  - fn <() as std::process::Termination>::report [(External, Hidden)] [h082b15a6d07338dcE] (size=2)
```
2023-06-01 11:31:22 +10:00
bors
ba1690bedd Auto merge of #111567 - Urgau:uplift_cast_ref_to_mut, r=b-naber
Uplift `clippy::cast_ref_to_mut` lint

This PR aims at uplifting the `clippy::cast_ref_to_mut` lint into rustc.

## `cast_ref_to_mut`

(deny-by-default)

The `cast_ref_to_mut` lint checks for casts of `&T` to `&mut T` without using interior mutability.

### Example

```rust,compile_fail
fn x(r: &i32) {
    unsafe {
        *(r as *const i32 as *mut i32) += 1;
    }
}
```

### Explanation

Casting `&T` to `&mut T` without interior mutability is undefined behavior, as it's a violation of Rust reference aliasing requirements.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler

-----

For Clippy:

changelog: Moves: Uplifted `clippy::cast_ref_to_mut` into rustc
2023-06-01 01:27:32 +00:00