Commit Graph

265007 Commits

Author SHA1 Message Date
Ralf Jung f6b7727605 enumerate the two parts of the NaN rules 2024-08-30 11:31:36 +02:00
Nicholas Nethercote c5e4ff17a6 Remove `#[macro_use] extern crate tracing` from `rustc_hir_typeck`. 2024-08-30 17:14:59 +10:00
Nicholas Nethercote 4b3fa8e9f0 Remove `#[macro_use] extern crate tracing` from `rustc_trait_selection`. 2024-08-30 17:14:59 +10:00
Nicholas Nethercote cc16c902f1 Remove `#[macro_use] extern crate tracing` from `rustc_hir_analysis`. 2024-08-30 17:14:59 +10:00
Nicholas Nethercote 67556eca99 Remove `#[macro_use] extern crate tracing` from `rustc_borrowck`. 2024-08-30 17:14:53 +10:00
Rémy Rakic dff3d3588d add borrows to NLL MIR dumps
explicitly disable `-Zmir-include-spans` in mir-opt tests

This will override the NLL default of true, and keep the blessed dumps
easier to work with.
2024-08-30 07:14:31 +00:00
Rémy Rakic f3f5b4dcf2 refactor NLL MIR dump entry point 2024-08-30 07:14:31 +00:00
Rémy Rakic 92e1046502 enable extra comments in NLL MIR dumps 2024-08-30 07:14:31 +00:00
Rémy Rakic e0bb1c7291 make `-Z mir-include-spans` a dedicated enum
We want to allow setting this on the CLI, override it only in MIR
passes, and disable it altogether in mir-opt tests.

The default value is "only for NLL MIR dumps", which is considered off
for all intents and purposes, except for `rustc_borrowck` when an NLL
MIR dump is requested.
2024-08-30 07:14:19 +00:00
Rémy Rakic c646b46b52 introduce `PrettyPrintMirOptions` for cosmetic MIR dump options
initially starting with `-Z mir-include-spans` because we want them in
the NLL mir dump pass
2024-08-30 07:07:28 +00:00
Ralf Jung 08fadfd8d8 add hyphen in floating-point 2024-08-30 08:23:12 +02:00
Yuri Astrakhan f41e0bb41d Squashed `aarch64_unknown_nto_qnx700` support 2024-08-30 01:19:55 -04:00
bors f03c7b2170 Auto merge of #3853 - rust-lang:rustup-2024-08-30, r=saethlin
Automatic Rustup
2024-08-30 05:13:13 +00:00
The Miri Cronjob Bot 23f4eae905 Merge from rustc 2024-08-30 05:09:57 +00:00
The Miri Cronjob Bot 0453d9bee8 Preparing for merge from rustc 2024-08-30 05:02:07 +00:00
Nicholas Nethercote ac7a293336 Avoid repeated interning in `SelfArgVisitor`. 2024-08-30 13:35:41 +10:00
Nicholas Nethercote ee5ec5a196 Remove `#[macro_use] extern crate tracing` from rustfmt. 2024-08-30 13:35:05 +10:00
Nicholas Nethercote de02c4af61 Remove `#[macro_use] extern crate tracing` from rustfmt helpers. 2024-08-30 13:31:05 +10:00
Nicholas Nethercote 37d1ce91b5 Remove `#[macro_use] extern crate tracing` from rustdoc. 2024-08-30 13:16:08 +10:00
Nicholas Nethercote 8541b0f1f3 Use `let`/`else` to reduce some indentation. 2024-08-30 10:30:57 +10:00
Nicholas Nethercote 243109e006 Remove an unnecessary `continue`. 2024-08-30 10:30:57 +10:00
Nicholas Nethercote 590a02173b Factor out some repetitive code. 2024-08-30 10:30:57 +10:00
Nicholas Nethercote 408481f4d8 Remove some unnecessary constants.
These are just renamings of `CoroutineArgs` constants.
2024-08-30 10:30:57 +10:00
Nicholas Nethercote d7cb1181dc Merge `DerefArgVisitor` and `PinArgVisitor`.
They are almost identical, differing only in the `ProjectionElem` they
insert. This commit merges them into a new type `SelfArgVisitor`.
2024-08-30 10:30:57 +10:00
Nicholas Nethercote 5331280a2b Merge some `if`s.
For more concise code.
2024-08-30 10:30:57 +10:00
Nicholas Nethercote 3b6af9a451 Use a local variable. 2024-08-30 10:30:57 +10:00
Nicholas Nethercote 66b3585145 Simplify a pattern. 2024-08-30 10:30:57 +10:00
Nicholas Nethercote 2932e097f4 Simplify creation of a set. 2024-08-30 10:30:57 +10:00
Nicholas Nethercote fda52b8f63 Simplify a provider definition. 2024-08-30 10:30:57 +10:00
Nicholas Nethercote 016a709b24 Condense `use rustc_*` declarations.
No reason to have two of them listed separately, after modules.
2024-08-30 10:30:56 +10:00
Nicholas Nethercote 016a2e30a9 Remove unused features. 2024-08-30 10:30:56 +10:00
Nicholas Nethercote 04a07dc314 Remove `#[macro_use] extern crate tracing` from `rustc_infer`. 2024-08-30 10:01:35 +10:00
Nicholas Nethercote ed5161c5ac Remove `#[macro_use] extern crate tracing` from `rustc_mir_transform`. 2024-08-30 10:01:34 +10:00
Nicholas Nethercote fa4f8925f1 Remove `Option<!>` return types.
Several compiler functions have `Option<!>` for their return type.
That's odd. The only valid return value is `None`, so why is this type
used?

Because it lets you write certain patterns slightly more concisely. E.g.
if you have these common patterns:
```
    let Some(a) = f() else { return };
    let Ok(b) = g() else { return };
```
you can shorten them to these:
```
    let a = f()?;
    let b = g().ok()?;
```
Huh.

An `Option` return type typically designates success/failure. How should
I interpret the type signature of a function that always returns (i.e.
doesn't panic), does useful work (modifying `&mut` arguments), and yet
only ever fails? This idiom subverts the type system for a cute
syntactic trick.

Furthermore, returning `Option<!>` from a function F makes things
syntactically more convenient within F, but makes things worse at F's
callsites. The callsites can themselves use `?` with F but should not,
because they will get an unconditional early return, which is almost
certainly not desirable. Instead the return value should be ignored.
(Note that some of callsites of `process_operand`, `process_immedate`,
`process_assign` actually do use `?`, though the early return doesn't
matter in these cases because nothing of significance comes after those
calls. Ugh.)

When I first saw this pattern I had no idea how to interpret it, and it
took me several minutes of close reading to understand everything I've
written above. I even started a Zulip thread about it to make sure I
understood it properly. "Save a few characters by introducing types so
weird that compiler devs have to discuss it on Zulip" feels like a bad
trade-off to me. This commit replaces all the `Option<!>` return values
and uses `else`/`return` (or something similar) to replace the relevant
`?` uses. The result is slightly more verbose but much easier to
understand.
2024-08-30 08:18:41 +10:00
Alex Crichton 99558dc7f4 Update the `wasm-component-ld` binary dependency
This keeps it up-to-date by moving from 0.5.6 to 0.5.7. While here I've
additionally updated some other wasm-related dependencies in the
workspace to keep them up-to-date and try to avoid duplicate versions as
well.
2024-08-29 14:39:12 -07:00
Josh Stone c339541f73 Make the "detect-old-time" UI test more representative
The test code did have an inference failure, but that would have failed
on Rust 1.79 and earlier too. Now it is rewritten to be specifically
affected by 1.80's `impl FromIterator<_> for Box<str>`.
2024-08-29 13:58:43 -07:00
bors 0d634185df Auto merge of #129750 - GuillaumeGomez:rollup-gphsb7y, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #123940 (debug-fmt-detail option)
 - #128166 (Improved `checked_isqrt` and `isqrt` methods)
 - #128970 (Add `-Zlint-llvm-ir`)
 - #129316 (riscv64imac: allow shadow call stack sanitizer)
 - #129690 (Add `needs-unwind` compiletest directive to `libtest-thread-limit` and replace some `Path` with `path` in `run-make`)
 - #129732 (Add `unreachable_pub`, round 3)
 - #129743 (Fix rustdoc clippy lints)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-29 20:45:00 +00:00
Ben Kimock c71ede368c Add a test for trait solver overflow in MIR inliner cycle detection 2024-08-29 16:20:08 -04:00
Jubilee Young 518b41c2bd Try latest backtrace 2024-08-29 12:13:19 -07:00
Alex Crichton c824c1ada7 wasi: Fix sleeping for `Duration::MAX`
This commit fixes an assert in the WASI-specific implementation of
thread sleep to ensure that sleeping for a very large period of time
blocks instead of panicking. This can come up when testing programs that
sleep "forever", for example.
2024-08-29 10:31:17 -07:00
bors 784d444733 Auto merge of #129714 - saethlin:half-a-recursion, r=compiler-errors
Use a reduced recursion limit in the MIR inliner's cycle breaker

This probably papers over https://github.com/rust-lang/rust/issues/128887, but primarily I'm opening this PR because multiple compiler people have thought about making this change which probably means it's a good idea.

r? compiler-errors
2024-08-29 16:15:41 +00:00
Michael Goulet 8c798c89dc Simplify some extern providers 2024-08-29 11:18:03 -04:00
Ralf Jung de34a91350 interpret/visitor: make memory order iteration slightly more efficient 2024-08-29 16:53:14 +02:00
Guillaume Gomez 9c7ae1d4d8
Rollup merge of #129743 - GuillaumeGomez:fix-rustdoc-clippy, r=notriddle
Fix rustdoc clippy lints

Ran clippy on rustdoc and fixed the errors.

r? `@notriddle`
2024-08-29 16:21:50 +02:00
Guillaume Gomez 7e23a44495
Rollup merge of #129732 - nnethercote:unreachable_pub-3, r=Urgau
Add `unreachable_pub`, round 3

A follow-up to #129648.

r? `@Urgau`
2024-08-29 16:21:49 +02:00
Guillaume Gomez 7dc2caba7b
Rollup merge of #129690 - Oneirical:run-make-tidbits, r=jieyouxu
Add `needs-unwind` compiletest directive to `libtest-thread-limit` and replace some `Path` with `path` in `run-make`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

This PR does two things:

1. Add this to `libtest-thread-limit` ([Why?](https://github.com/rust-lang/rust/pull/128507#issuecomment-2315158014))
```
//@ needs-unwind
// Reason: this should be ignored in cg_clif (Cranelift) CI and anywhere
// else that uses panic=abort.
```

2. Use `path` instead of `Path` to simplify multiple run-make tests.
2024-08-29 16:21:48 +02:00
Guillaume Gomez a65404aba4
Rollup merge of #129316 - dingxiangfei2009:riscv64-imac-scs, r=nnethercote
riscv64imac: allow shadow call stack sanitizer

cc `@Darksonn` for shadow call stack sanitizer support on RV64IMAC and RV64GC
2024-08-29 16:21:47 +02:00
Guillaume Gomez d5c40d03dc
Rollup merge of #128970 - DianQK:lint-llvm-ir, r=nikic
Add `-Zlint-llvm-ir`

This flag is similar to `-Zverify-llvm-ir` and allows us to lint the generated IR.

r? compiler
2024-08-29 16:21:47 +02:00
Guillaume Gomez 4b08b2e400
Rollup merge of #128166 - ChaiTRex:isqrt, r=tgross35
Improved `checked_isqrt` and `isqrt` methods

### Improved tests of `isqrt` and `checked_isqrt` implementations

* Inputs chosen more thoroughly and systematically.
* Checks that `isqrt` and `checked_isqrt` have equivalent results for signed types, either equivalent numerically or equivalent as a panic and a `None`.
* Checks that `isqrt` has numerically-equivalent results for unsigned types and their `NonZero` counterparts.

### Added benchmarks for `isqrt` implementations

### Greatly sped up `checked_isqrt` and `isqrt` methods

* Uses a lookup table for 8-bit integers and then the Karatsuba square root algorithm for larger integers.
* Includes optimization hints that give the compiler the exact numeric range of results.

### Feature tracking issue

`isqrt` is an unstable feature tracked at #116226.

<details><summary>Benchmarked improvements</summary>

### Command used to benchmark

    ./x bench library/core -- int_sqrt

### Before

    benchmarks:
        num::int_sqrt::i128::isqrt           439591.65/iter  +/- 6652.70
        num::int_sqrt::i16::isqrt              5302.97/iter   +/- 160.93
        num::int_sqrt::i32::isqrt             62999.11/iter  +/- 2022.05
        num::int_sqrt::i64::isqrt            125248.81/iter  +/- 1674.43
        num::int_sqrt::i8::isqrt                123.56/iter     +/- 1.87
        num::int_sqrt::isize::isqrt          125356.56/iter  +/- 1017.03
        num::int_sqrt::non_zero_u128::isqrt  437443.75/iter  +/- 3535.43
        num::int_sqrt::non_zero_u16::isqrt     8604.58/iter    +/- 94.76
        num::int_sqrt::non_zero_u32::isqrt    62933.33/iter   +/- 517.30
        num::int_sqrt::non_zero_u64::isqrt   125076.38/iter +/- 11340.61
        num::int_sqrt::non_zero_u8::isqrt       221.51/iter     +/- 1.58
        num::int_sqrt::non_zero_usize::isqrt 136005.21/iter  +/- 2020.35
        num::int_sqrt::u128::isqrt           439014.55/iter  +/- 3920.45
        num::int_sqrt::u16::isqrt              8575.08/iter   +/- 148.06
        num::int_sqrt::u32::isqrt             63008.89/iter   +/- 803.67
        num::int_sqrt::u64::isqrt            125088.09/iter   +/- 879.29
        num::int_sqrt::u8::isqrt                230.18/iter     +/- 2.04
        num::int_sqrt::usize::isqrt          125237.51/iter  +/- 4747.83
### After

    benchmarks:
        num::int_sqrt::i128::isqrt           105184.89/iter +/- 1171.38
        num::int_sqrt::i16::isqrt              1910.26/iter   +/- 78.50
        num::int_sqrt::i32::isqrt             34260.34/iter  +/- 960.84
        num::int_sqrt::i64::isqrt             45939.19/iter +/- 2525.65
        num::int_sqrt::i8::isqrt                 22.87/iter    +/- 0.45
        num::int_sqrt::isize::isqrt           45884.17/iter  +/- 595.49
        num::int_sqrt::non_zero_u128::isqrt  106344.27/iter  +/- 780.99
        num::int_sqrt::non_zero_u16::isqrt     2790.19/iter   +/- 53.43
        num::int_sqrt::non_zero_u32::isqrt    33613.99/iter  +/- 362.96
        num::int_sqrt::non_zero_u64::isqrt    46235.42/iter  +/- 429.69
        num::int_sqrt::non_zero_u8::isqrt        31.78/iter    +/- 0.75
        num::int_sqrt::non_zero_usize::isqrt  46208.75/iter  +/- 375.27
        num::int_sqrt::u128::isqrt           106385.94/iter +/- 1649.95
        num::int_sqrt::u16::isqrt              2747.69/iter   +/- 28.72
        num::int_sqrt::u32::isqrt             33627.09/iter  +/- 475.68
        num::int_sqrt::u64::isqrt             46182.29/iter  +/- 311.16
        num::int_sqrt::u8::isqrt                 33.10/iter    +/- 0.30
        num::int_sqrt::usize::isqrt           46165.00/iter  +/- 388.41

</details>

Tracking Issue for {u8,i8,...}::isqrt #116226

try-job: test-various
2024-08-29 16:21:46 +02:00
Guillaume Gomez 015e9371e0
Rollup merge of #123940 - kornelski:remove-derived-debug, r=Urgau
debug-fmt-detail option

I'd like to propose a new option that makes `#[derive(Debug)]` generate no-op implementations that don't print anything, and makes `{:?}` in format strings a no-op.

There are a couple of motivations for this:

1. A more thorough stripping of debug symbols. Binaries stripped of debug symbols still retain some of them through `Debug` implementations. It's hard to avoid that without compiler's help, because debug formatting can be used in many places, including dependencies, and their loggers, asserts, panics, etc.
   * In my testing it gives about 2% binary size reduction on top of all other binary-minimizing best practices (including `panic_immediate_abort`). There are targets like Web WASM or embedded where users pay attention to binary sizes.
   * Users distributing closed-source binaries may not want to "leak" any symbol names as a matter of principle.
2. Adds ability to test whether code depends on specifics of the `Debug` format implementation in unwise ways (e.g. trying to get data unavailable via public interface, or using it as a serialization format). Because current Rust's debug implementation doesn't change, there's a risk of it becoming a fragile de-facto API that [won't be possible to change in the future](https://www.hyrumslaw.com/). An option that "breaks" it can act as a [grease](https://www.rfc-editor.org/rfc/rfc8701.html).

This implementation is a `-Z fmt-debug=opt` flag that takes:

* `full` — the default, current state.
* `none` — makes derived `Debug` and `{:?}` no-ops. Explicit `impl Debug for T` implementations are left unharmed, but `{:?}` format won't use them, so they may get dead-code eliminated if they aren't invoked directly.
* `shallow` — makes derived `Debug` print only the type's name, without recursing into fields. Fieldless enums print their variant names. `{:?}` works.

The `shallow` option is a compromise between minimizing the `Debug` code, and compatibility. There are popular proc-macro crates that use `Debug::fmt` as a way to convert enum values into their Rust source code.

There's a corresponding `cfg` flag: `#[cfg(fmt_debug = "none")]` that can be used in user code to react to this setting to minimize custom `Debug` implementations or remove unnecessary formatting helper functions.
2024-08-29 16:21:46 +02:00