Commit Graph

256431 Commits

Author SHA1 Message Date
Nicholas Nethercote
1be65925d7 Explain why tests/rustdoc-ui/ is unformatted. 2024-06-04 14:15:44 +10:00
Nicholas Nethercote
50185807d7 rustfmt tests/rustdoc-js-std/.
This is trivial, because the directory contains no `.rs` files.
2024-06-04 14:15:29 +10:00
Nicholas Nethercote
9f16362ab4 rustfmt tests/rustdoc-json/. 2024-06-04 14:15:19 +10:00
Nicholas Nethercote
c6fb703c05 rustfmt tests/rustdoc-js/. 2024-06-04 14:15:06 +10:00
Nicholas Nethercote
98d65d62c5 Explain why tests/rustdoc-gui/ is unformatted. 2024-06-04 14:14:35 +10:00
Nicholas Nethercote
e372bf8e33 Explain why tests/rustdoc/ is unformatted. 2024-06-04 09:53:02 +10:00
Nicholas Nethercote
a78e1202dd rustfmt tests/run-pass-valgrind/. 2024-06-04 09:53:02 +10:00
Nicholas Nethercote
d161d06241 rustfmt tests/run-make-fulldeps/.
Note: I inserted blank lines between the items in
`pretty-expanded/input.rs` because it looked better that way.
2024-06-04 09:53:02 +10:00
Nicholas Nethercote
5875f3fff3 Explain why tests/pretty/ is unformatted. 2024-06-04 09:53:02 +10:00
bors
7c52d2db63 Auto merge of #125383 - Oneirical:bundle-them-up, r=jieyouxu
Rewrite `emit`, `mixing-formats` and `bare-outfile` `run-make` tests in `rmake.rs` format

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

try-job: x86_64-msvc
2024-06-03 18:35:54 +00:00
bors
eb5e2449c5 Auto merge of #125864 - compiler-errors:opt-in-error-reporting, r=lcnr
Opt-in to `FulfillmentError` generation to avoid doing extra work in the new solver

In the new solver, we do additional trait solving in order to generate fulfillment errors, because all we have is the root obligation. This is problematic because there are many cases where we don't need the full error information, and instead are just calling `ObligationCtxt::select_all_or_error` to probe whether a predicate holds or not. This is also problematic because we use `ObligationCtxt`s within the error reporting machinery itself, and so we can definitely cause stack overflows:

a94483a5f2/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs (L75-L84)

So instead, make `TraitEngine` and `ObligationCtxt` generic over `E: FulfillmentErrorLike<'tcx>`, and introduce a new `ScrubbedTraitError` which only stores whether the failure was due to a "true error" or an ambiguity. Then, introduce `ObligationCtxt::new_with_diagnostics` for the callsites that actually inspect their `FulfillmentError`s.

r? `@lcnr`

Number-wise, there are:
```
     39 ObligationCtxt::new
     32 ObligationCtxt::new_with_diagnostics
      1 ObligationCtxt::new_generic
```
calls to each `ObligationCtxt` constructor, which suggests that there are indeed a lot of callsites that don't care about diagnostics.
2024-06-03 15:43:06 +00:00
Michael Goulet
a41c44f21c Nits and formatting 2024-06-03 10:02:08 -04:00
Michael Goulet
1e72c7f536 Add cycle errors to ScrubbedTraitError to remove a couple more calls to new_with_diagnostics 2024-06-03 09:27:52 -04:00
Michael Goulet
27f5eccd1f Move FulfillmentErrorCode to rustc_trait_selection too 2024-06-03 09:27:52 -04:00
Michael Goulet
94a524ed11 Use ScrubbedTraitError in more places 2024-06-03 09:27:52 -04:00
Michael Goulet
eb0a70a557 Opt-in diagnostics reporting to avoid doing extra work in the new solver 2024-06-03 09:27:52 -04:00
Michael Goulet
54b2b7d460 Make TraitEngines generic over error 2024-06-03 09:27:52 -04:00
Michael Goulet
084ccd2390 Remove unnecessary extension trait 2024-06-03 09:27:52 -04:00
bors
8768db9912 Auto merge of #125912 - nnethercote:rustfmt-tests-mir-opt, r=oli-obk
rustfmt `tests/mir-opt`

Continuing the work started in #125759. Details in individual commit log messages.

r? `@oli-obk`
2024-06-03 10:25:12 +00:00
bors
1d52972dd8 Auto merge of #125778 - estebank:issue-67100, r=compiler-errors
Use parenthetical notation for `Fn` traits

Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`.

Address #67100:

```
error[E0277]: expected a `Fn()` closure, found `F`
 --> file.rs:6:13
  |
6 |     call_fn(f)
  |     ------- ^ expected an `Fn()` closure, found `F`
  |     |
  |     required by a bound introduced by this call
  |
  = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }`
note: required by a bound in `call_fn`
 --> file.rs:1:15
  |
1 | fn call_fn<F: Fn() -> ()>(f: &F) {
  |               ^^^^^^^^^^ required by this bound in `call_fn`
help: consider further restricting this bound
  |
5 | fn call_any<F: std::any::Any + Fn()>(f: &F) {
  |                              ++++++
```
2024-06-03 08:14:03 +00:00
bors
621e957b4d Auto merge of #125904 - workingjubilee:test-packed-simd-more, r=calebzulawski
Test codegen for `repr(packed,simd)` -> `repr(simd)`

This adds the codegen test originally requested in #117116 but exploiting the collection of features in FileCheck and compiletest to make it more resilient to expectations being broken by optimization levels. Mostly by presetting optimization levels for each revision of the tests.

I do not think the dereferenceable attribute's presence or absence is that important.

r? `@calebzulawski`
2024-06-03 06:05:12 +00:00
Nicholas Nethercote
c9c80d2c5f rustfmt tests/mir-opt.
The only non-obvious changes:
- `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]`
  attribute to avoid reformating a table of data.
- Two `.mir` files have slight changes involving line numbers.
- In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to
  outside a function, which is the usual spot, because `tidy` complains
  if such a comment is indented.

The commit also tweaks the comments in `rustfmt.toml`.
2024-06-03 14:17:16 +10:00
Nicholas Nethercote
ac24299636 Reformat mir! macro invocations to use braces.
The `mir!` macro has multiple parts:
- An optional return type annotation.
- A sequence of zero or more local declarations.
- A mandatory starting anonymous basic block, which is brace-delimited.
- A sequence of zero of more additional named basic blocks.

Some `mir!` invocations use braces with a "block" style, like so:
```
mir! {
    let _unit: ();
    {
	let non_copy = S(42);
	let ptr = std::ptr::addr_of_mut!(non_copy);
	// Inside `callee`, the first argument and `*ptr` are basically
	// aliasing places!
	Call(_unit = callee(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue())
    }
    after_call = {
	Return()
    }
}
```
Some invocations use parens with a "block" style, like so:
```
mir!(
    let x: [i32; 2];
    let one: i32;
    {
	x = [42, 43];
	one = 1;
	x = [one, 2];
	RET = Move(x);
	Return()
    }
)
```
And some invocations uses parens with a "tighter" style, like so:
```
mir!({
    SetDiscriminant(*b, 0);
    Return()
})
```
This last style is generally used for cases where just the mandatory
starting basic block is present. Its braces are placed next to the
parens.

This commit changes all `mir!` invocations to use braces with a "block"
style. Why?

- Consistency is good.

- The contents of the invocation is a block of code, so it's odd to use
  parens. They are more normally used for function-like macros.

- Most importantly, the next commit will enable rustfmt for
  `tests/mir-opt/`. rustfmt is more aggressive about formatting macros
  that use parens than macros that use braces. Without this commit's
  changes, rustfmt would break a couple of `mir!` macro invocations that
  use braces within `tests/mir-opt` by inserting an extraneous comma.
  E.g.:
  ```
  mir!(type RET = (i32, bool);, { // extraneous comma after ';'
      RET.0 = 1;
      RET.1 = true;
      Return()
  })
  ```
  Switching those `mir!` invocations to use braces avoids that problem,
  resulting in this, which is nicer to read as well as being valid
  syntax:
  ```
  mir! {
      type RET = (i32, bool);
      {
	  RET.0 = 1;
	  RET.1 = true;
	  Return()
      }
  }
  ```
2024-06-03 13:24:44 +10:00
bors
865eaf96be Auto merge of #125397 - gurry:125303-wrong-builder-suggestion, r=compiler-errors
Do not suggest unresolvable builder methods

Fixes #125303

The issue was that when a builder method cannot be resolved we are suggesting alternatives that themselves cannot be resolved. This PR adds a check that filters them from the list of suggestions.
2024-06-03 03:16:35 +00:00
Jubilee Young
9987363b7e Test codegen for repr(packed,simd) -> repr(simd) 2024-06-02 20:15:15 -07:00
Oneirical
6e120cf464 Remove some allowed-makefiles 2024-06-02 21:59:37 -04:00
bors
9f2d0b3490 Auto merge of #125057 - nnethercote:rustc_lint-cleanups, r=cjgillot
`rustc_lint` cleanups

Minor improvements I found while looking through this code.

r? `@cjgillot`
2024-06-03 00:04:14 +00:00
Nicholas Nethercote
32c8a12854 Tweak CheckLintNameResult::Tool.
It has a clumsy type, with repeated `&'a [LintId]`, and sometimes
requires an empty string that isn't used in the `Err`+`None` case.

This commit splits it into two variants.
2024-06-03 09:02:49 +10:00
Nicholas Nethercote
d070e89230 Reduce some pub exposure. 2024-06-03 08:44:33 +10:00
Nicholas Nethercote
22ca74f2b0 Fix up comments.
Wrap overly long ones, etc.
2024-06-03 08:44:33 +10:00
bors
032af18af5 Auto merge of #125902 - workingjubilee:rollup-f8x6iif, r=workingjubilee
Rollup of 6 pull requests

Successful merges:

 - #121062 (Change f32::midpoint to upcast to f64)
 - #125808 (Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs`)
 - #125884 (Implement feature `integer_sign_cast`)
 - #125890 (Improve compiletest expected/not found formatting)
 - #125896 (compiletest: fix outdated rmake.rs comment)
 - #125898 (typo: depending from -> on)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-02 21:54:30 +00:00
Jubilee
72ea7e9220
Rollup merge of #125898 - RalfJung:typo, r=Nilstrieb
typo: depending from -> on
2024-06-02 12:58:10 -07:00
Jubilee
18a46be6d9
Rollup merge of #125896 - jieyouxu:compiletest-rmake-comment, r=compiler-errors
compiletest: fix outdated rmake.rs comment

Noticed in https://github.com/rust-lang/rust/pull/125827#discussion_r1623420820. I fixed the PR description but forgot to update the comment.
2024-06-02 12:58:10 -07:00
Jubilee
6c92908869
Rollup merge of #125890 - Nilstrieb:gay-compiletest, r=jieyouxu
Improve compiletest expected/not found formatting

compiletest, oh compiletest, you are truly one of the tools in this repository. You're the omnipresent gatekeeper, ensuring that every new change works, doesn't break the world, and is nice. We thank you for your work, for your tests, for your test runs, for your features that help writing tests, for all the stability and and good you have caused. Without you, Rust wouldn't exist as it does, without you, nothing would work, without you, we would all go insane from having changes break and having to test them all by hand. Thank you, compiletest.

but holy shit i fucking hate your stupid debug output so much i simply cannot take this anymore aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

By changing a few magic lines in this file called "runtest.rs", we can cause compiletest to emit nicer messages. This is widely regarded as a good thing. We stop wasting vertical space, allowing more errors to be displayed at once. Additionally, we add colors, which make it so much more pretty *and* gay, both of which are very good and useful.

There's a bit of fuckery needed to get the colors to work. `colored` checks whether stdout is a terminal. We also print to stdout, so that works well.
But.... for some stupid reason that I absolutely refuse to even attempt to debug, stdout is *not* a terminal when executing tests *in a terminal*.
But stderr is >:).
So this just checks whether stderr is a terminal.
If you have a use case where you dump compiletest stdout into a place where colors are not supported while having stderr be a terminal, then I'm sorry for you, but you are gonna get colors and you're gonna like it. Stop it with the usual environment variable, which `colored` also respects by default.

### before (bad, hurts your brain, makes you want to cry)
![image](https://github.com/rust-lang/rust/assets/48135649/cbeecb5d-fc25-460b-b192-9808f8fa2079)

## after (good, gay, makes you want to cry)
![image](https://github.com/rust-lang/rust/assets/48135649/a655b220-8841-443e-a825-72a835d56882)

r? jieyouxu said he wants to review the PR
2024-06-02 12:58:09 -07:00
Jubilee
890770d7bc
Rollup merge of #125884 - Rua:integer_sign_cast, r=Mark-Simulacrum
Implement feature `integer_sign_cast`

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

Since this is my first time making a library addition I wasn't sure where to place the new code relative to existing code. I decided to place it near the top where there are already some other basic bitwise manipulation functions. If there is an official guideline for the ordering of functions, please let me know.
2024-06-02 12:58:08 -07:00
Jubilee
800b2f8b64
Rollup merge of #125808 - GuillaumeGomez:migrate-run-make-c-link-to-rust-dylib, r=jieyouxu
Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs`

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

First commit comes from https://github.com/rust-lang/rust/pull/125773.

r? `@jieyouxu`
2024-06-02 12:58:08 -07:00
Jubilee
713cdcd803
Rollup merge of #121062 - RustyYato:f32-midpoint, r=the8472
Change f32::midpoint to upcast to f64

This has been verified by kani as a correct optimization

see: https://github.com/rust-lang/rust/issues/110840#issuecomment-1942587398

The new implementation is branchless and only differs in which NaN values are produced (if any are produced at all), which is fine to change. Aside from NaN handling, this implementation produces bitwise identical results to the original implementation.

Question: do we need a codegen test for this? I didn't add one, since the original PR #92048 didn't have any codegen tests.
2024-06-02 12:58:07 -07:00
bors
a6416d8907 Auto merge of #125828 - vincenzopalazzo:macros/performance-regression, r=fmease
Avoid checking the edition as much as possible

Inside https://github.com/rust-lang/rust/pull/123865, we are adding support for the new semantics for expr2024, but we have noted a performance issue.

While talking with `@eholk,` we realized there is a redundant check for each token regarding an edition. This commit moves the edition check to the end, avoiding some extra checks that can slow down compilation time.

However, we should keep this issue under observation because we may want to improve the edition check if we are unable to significantly improve compiler performance.

r? ghost
2024-06-02 19:47:06 +00:00
Rua
b181e8106c Wording of the documentation 2024-06-02 21:03:24 +02:00
Ralf Jung
361c6a5c3a typo: depending from -> on 2024-06-02 18:15:50 +02:00
bors
eda9d7f987 Auto merge of #125577 - devnexen:netbsd_stack_min, r=joboet
std::pal::unix::thread fetching min stack size on netbsd.

PTHREAD_STACK_MIN is not defined however sysconf/_SC_THREAD_STACK_MIN returns it as it can vary from arch to another.
2024-06-02 15:42:33 +00:00
许杰友 Jieyou Xu (Joe)
590c373e43 compiletest: fix outdated rmake.rs comment 2024-06-02 14:33:31 +00:00
bors
5e6c2b6092 Auto merge of #125892 - workingjubilee:rollup-gytt1q7, r=workingjubilee
Rollup of 3 pull requests

Successful merges:

 - #125311 (Make repr(packed) vectors work with SIMD intrinsics)
 - #125849 (Migrate `run-make/emit-named-files` to `rmake.rs`)
 - #125851 (Add some more specific checks to the MIR validator)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-02 13:28:04 +00:00
Nilstrieb
3aefc4aeb2 Improve compiletest expected/not found formatting
compiletest, oh compiletest, you are truly one of the tools in this
repository. You're the omnipresent gatekeeper, ensuring that every new
change works, doesn't break the world, and is nice. We thank you for
your work, for your tests, for your test runs, for your features that
help writing tests, for all the stability and and good you have caused.
Without you, Rust wouldn't exist as it does, without you, nothing would
work, without you, we would all go insane from having changes break and
having to test them all by hand. Thank you, compiletest.

but holy shit i fucking hate your stupid debug output so much i simply
cannot take this anymore aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

By changing a few magic lines in this file called "runtest.rs", we can
cause compiletest to emit nicer messages. This is widely regarded as a
good thing. We stop wasting vertical space, allowing more errors to be
displayed at once. Additionally, we add colors, which make it so much
more pretty *and* gay, both of which are very good and useful.

There's a bit of fuckery needed to get the colors to work. `colored`
checks whether stdout is a terminal. We also print to stdout, so that
works well.
But.... for some stupid reason that I absolutely refuse to even attempt
to debug, stdout is *not* a terminal when executing tests *in a
terminal*.
But stderr is >:).
So this just checks whether stderr is a terminal.
If you have a use case where you dump compiletest stdout into a place
where colors are not supported while having stderr be a terminal, then
I'm sorry for you, but you are gonna get colors and you're gonna like
it. Stop it with the usual environment variable, which `colored` also
respects by default.
2024-06-02 14:09:34 +02:00
Jubilee
30dc2bafc8
Rollup merge of #125851 - scottmcm:moar-validate, r=compiler-errors
Add some more specific checks to the MIR validator

None of the `PointerCoercion`s had any checks, so while there's probably more that could be done here, hopefully these are better than the previous nothing.

r? mir
2024-06-02 05:06:48 -07:00
Jubilee
0722c9439e
Rollup merge of #125849 - GuillaumeGomez:migrate-emit-named-files, r=jieyouxu
Migrate `run-make/emit-named-files` to `rmake.rs`

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

r? `@jieyouxu`
2024-06-02 05:06:47 -07:00
Jubilee
ca9dd62c05
Rollup merge of #125311 - calebzulawski:repr-packed-simd-intrinsics, r=workingjubilee
Make repr(packed) vectors work with SIMD intrinsics

In #117116 I fixed `#[repr(packed, simd)]` by doing the expected thing and removing padding from the layout.  This should be the last step in providing a solution to rust-lang/portable-simd#319
2024-06-02 05:06:47 -07:00
bors
8bec878b73 Auto merge of #125887 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-06-02 11:14:39 +00:00
Jubilee Young
5c32f84048 Test codegen for repr(packed,simd) 2024-06-02 04:13:35 -07:00
Guillaume Gomez
32933a6869 Migrate run-make/c-link-to-rust-dylib to rmake.rs 2024-06-02 12:04:39 +02:00