Commit Graph

256403 Commits

Author SHA1 Message Date
dalance
9d1ec7ea06 Add translation support by mdbook-i18n-helpers to bootstrap 2024-06-03 16:48:27 +09: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
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
Rua
d23d340858 Implement feature integer_sign_cast 2024-06-02 12:01:07 +02:00
Guillaume Gomez
2416f460f8 Add dynamic_lib_extension and read_dir functions to run-make-support library 2024-06-02 11:59:52 +02:00
bors
13e2d7295e Auto merge of #125827 - jieyouxu:rmake-separate-tmp-dir, r=onur-ozkan
compiletest: split rmake.rs executable from scratch directory

When implementing support for rmake.rs, I copied over the `$TMPDIR` directory logic from the legacy Makefile setup. In doing so, I also compiled recipe `rmake.rs` into executables which unfortunately are placed into `$TMPDIR` as well.

This causes a problem on Windows (as observed in PRs like https://github.com/rust-lang/rust/pull/125752#issuecomment-2142577084) where:

- The `rmake.exe` executable is placed in `$TMPDIR`.
- We run the `rmake.exe` as a process.
- The process uses `rmake.exe` inside `$TMPDIR`.
- Windows prevents the .exe file from being deleted when the process is still alive.
- The recipe test code tries to `remove_dir_all($TMPDIR)`, which fails with access denied because `rmake.exe` is still being used.

We fix this by separating the recipe executable and the output artifacts directory:

```
base_dir/
    rmake.exe
    rmake_out/
```

We construct a base directory, unique to each run-make test, under which we place rmake.exe alongside a `rmake_out/` directory. This `rmake_out/` directory is what is passed to rmake.rs tests as `$TMPDIR`, so now `remove_dir_all($TMPDIR)` has a chance to succeed because it no longer contains `rmake.exe`.

This wasn't a problem for Makefile tests because there's no exe file under `$TMPDIR` whose process is still running when `rm -rf $TMPDIR` is called.

try-job: x86_64-msvc
2024-06-02 08:05:50 +00:00
bors
4717bdfc13 Auto merge of #17328 - Veykril:derive-helper-completions, r=Veykril
feat: Enable completions within derive helper attributes

![Code_zG5qInoQ6B](https://github.com/rust-lang/rust-analyzer/assets/3757771/db30b98d-4981-45e3-83a5-7ff23fbd3f66)
2024-06-02 07:47:13 +00:00
Lukas Wirth
f122a6f2f1 feat: Enable completions within derive helper attributes 2024-06-02 09:45:57 +02:00
Vincenzo Palazzo
36d5fc9a64
Avoid checking the edition as much as possible
Inside #123865, we are adding support for the new semantics
for expr2024, but we have noted a performance issue.

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.

Link: https://github.com/rust-lang/rust/pull/123865
Co-Developed-by: @eholk
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-06-02 09:42:21 +02:00
许杰友 Jieyou Xu (Joe)
45622450f8 compiletest: split rmake executable from scratch dir
When implementing support for rmake.rs, I copied over the `$TMPDIR`
directory logic from the legacy Makefile setup. In doing so, I also
compiled recipe `rmake.rs` into executables which unfortunately are
placed into `$TMPDIR` as well.

This causes a problem on Windows where:

- The `rmake.exe` executable is placed in `$TMPDIR`.
- We run the `rmake.exe` as a process.
- The process uses `rmake.exe` inside `$TMPDIR`.
- Windows prevents the .exe file from being deleted when the process
  is still alive.
- The recipe test code tries to `remove_dir_all($TMPDIR)`, which fails
  with access denied because `rmake.exe` is still being used.

We fix this by separating the recipe executable and the sratch
directory:

```
base_dir/
    rmake.exe
    scratch/
```

We construct a base directory, unique to each run-make test, under
which we place rmake.exe alongside a `scratch/` directory. This
`scratch/` directory is what is passed to rmake.rs tests as `$TMPDIR`,
so now `remove_dir_all($TMPDIR)` has a chance to succeed because
it no longer contains `rmake.exe`.

Oops. This was a fun one to try figure out.
2024-06-02 06:32:15 +00:00
bors
a83cf567b5 Auto merge of #125822 - Urgau:print-check-cfg-refactor-test, r=jieyouxu
Refactor `--print=check-cfg` test

*as asked in https://github.com/rust-lang/rust/pull/125818#discussion_r1622463592*

r? `@jieyouxu`
2024-06-02 05:58:46 +00:00
bors
06d99cd694 Auto merge of #125773 - GuillaumeGomez:migrate-run-make-cdylib, r=jieyouxu
Migrate run make cdylib

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

r? `@jieyouxu`
2024-06-02 02:11:35 +00:00
RustyYato
849c5254af 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.

The new implementation is gated on targets that have a fast 64-bit
floating point implementation in hardware, and on WASM.
2024-06-01 17:29:31 -07:00
bors
12b5d3c29c Auto merge of #124294 - tspiteri:ilog-first-iter, r=the8472
Unroll first iteration of checked_ilog loop

This follows the optimization of #115913. As shown in https://github.com/rust-lang/rust/pull/115913#issuecomment-2066788006, the performance was improved in all important cases, but some regressions were introduced for the benchmarks `u32_log_random_small`, `u8_log_random` and `u8_log_random_small`.

Basically, #115913 changed the implementation from one division per iteration to one multiplication per iteration plus one division. When there are zero iterations, this is a regression from zero divisions to one division.

This PR avoids this by avoiding the division if we need zero iterations by returning `Some(0)` early. It also reduces the number of multiplications by one in all other cases.
2024-06-02 00:05:32 +00:00
Scott McMurray
11d6f18bf6 Add some more specific checks to the MIR validator
None of the `PointerCoercion`s had any, so while there's probably more that could be done here, hopefully these are better than the previous nothing.
2024-06-01 15:36:23 -07:00
bors
f67a1acc04 Auto merge of #125863 - fmease:rej-CVarArgs-in-parse_ty_for_where_clause, r=compiler-errors
Reject `CVarArgs` in `parse_ty_for_where_clause`

Fixes #125847. This regressed in #77035 where the `parse_ty` inside `parse_ty_where_predicate` was replaced with the at the time new `parse_ty_for_where_clause` which incorrectly stated it would permit CVarArgs (maybe a copy/paste error).

r? parser
2024-06-01 21:13:52 +00:00
bors
0038c02103 Auto merge of #125775 - compiler-errors:uplift-closure-args, r=lcnr
Uplift `{Closure,Coroutine,CoroutineClosure}Args` and friends to `rustc_type_ir`

Part of converting the new solver's `structural_traits.rs` to be interner-agnostic.

I decided against aliasing `ClosureArgs<TyCtxt<'tcx>>` to `ClosureArgs<'tcx>` because it seemed so rare. I could do so if desired, though.

r? lcnr
2024-06-01 19:07:03 +00:00
bors
60d2f73fd1 Auto merge of #17326 - Veykril:fix-attr-derive-container, r=Veykril
fix: Fix container search failing for tokens originating within derive attributes
2024-06-01 18:58:59 +00:00
Lukas Wirth
8ab8bb0603 fix: Fix container search failing for tokens originating within derive attributes 2024-06-01 20:57:29 +02:00
León Orell Valerian Liehr
89386092f1
Reject CVarArgs in parse_ty_for_where_clause 2024-06-01 20:57:15 +02:00
Caleb Zulawski
9bdc5b2455 Improve documentation 2024-06-01 14:17:16 -04:00
Michael Goulet
333458c2cb Uplift TypeRelation and Relate 2024-06-01 12:50:58 -04:00
bors
a94483a5f2 Auto merge of #125856 - onur-ozkan:bootstrap-submodule-hotfix, r=onur-ozkan
include missing submodule on bootstrap

As of https://github.com/rust-lang/rust/pull/125408 PR, rustbook now relies on dependencies from the "src/doc/book" submodule.

However, bootstrap does not automatically sync this submodule before reading metadata informations. And if the submodule is not present, reading metadata will fail because rustbook's dependencies will be missing.

This change makes "src/doc/book" to be fetched/synced automatically before trying to read metadata.

cc `@Zalathar`
2024-06-01 16:48:46 +00:00
Michael Goulet
ee47480f4c Yeet PolyFnSig from Interner 2024-06-01 10:34:34 -04:00
bors
f2208b3297 Auto merge of #123572 - Mark-Simulacrum:vtable-methods, r=oli-obk
Increase vtable layout size

This improves LLVM's codegen by allowing vtable loads to be hoisted out of loops (as just one example). The calculation here is an under-approximation but works for simple trait hierarchies (e.g., FnMut will be improved). We have a runtime assert that the approximation is accurate, so there's no risk of UB as a result of getting this wrong.

```rust
#[no_mangle]
pub fn foo(elements: &[u32], callback: &mut dyn Callback) {
    for element in elements.iter() {
        if *element != 0 {
            callback.call(*element);
        }
    }
}

pub trait Callback {
    fn call(&mut self, _: u32);
}
```

Simplifying a bit (e.g., numbering ends up different):

```diff
 ; Function Attrs: nonlazybind uwtable
-define void `@foo(ptr` noalias noundef nonnull readonly align 4 %elements.0, i64 noundef %elements.1, ptr noundef nonnull align 1 %callback.0, ptr noalias nocapture noundef readonly align 8 dereferenceable(24) %callback.1) unnamed_addr #0 {
+define void `@foo(ptr` noalias noundef nonnull readonly align 4 %elements.0, i64 noundef %elements.1, ptr noundef nonnull align 1 %callback.0, ptr noalias nocapture noundef readonly align 8 dereferenceable(32) %callback.1) unnamed_addr #0 {
 start:
   %_15 = getelementptr inbounds i32, ptr %elements.0, i64 %elements.1
`@@` -13,4 +13,5 `@@`
 bb4.lr.ph:                                        ; preds = %start
   %1 = getelementptr inbounds i8, ptr %callback.1, i64 24
+  %2 = load ptr, ptr %1, align 8, !nonnull !3
   br label %bb4

 bb6:                                              ; preds = %bb4
-  %4 = load ptr, ptr %1, align 8, !invariant.load !3, !nonnull !3
-  tail call void %4(ptr noundef nonnull align 1 %callback.0, i32 noundef %_9)
+  tail call void %2(ptr noundef nonnull align 1 %callback.0, i32 noundef %_9)
   br label %bb7
 }
```
2024-06-01 14:31:07 +00:00
onur-ozkan
5cdec6582a include missing submodule on bootstrap
As of https://github.com/rust-lang/rust/pull/125408 PR,
rustbook now relies on dependencies from the "src/doc/book" submodule.

However, bootstrap does not automatically sync this submodule before reading
metadata informations. And if the submodule is not present, reading
metadata will fail because rustbook's dependencies will be missing.

This change makes "src/doc/book" to be fetched/synced automatically
before trying to read metadata.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-01 17:27:35 +03:00
bors
c1ea2b562e Auto merge of #17302 - mladedav:dm/fix-clear, r=Veykril
fix diagnostics clearing when flychecks run per-workspace

This might be causing #17300 or it's a different bug with the same functionality.

I wonder if the decision to clear diagnostics should stay in the main loop or maybe the flycheck itself should track it and tell the mainloop?

I have used a hash map but we could just as well use a vector since the IDs are `usizes` in some given range starting at 0. It would be probably faster but this just felt a bit cleaner and it allows us to change the ID to newtype later and we can just use a hasher that returns the underlying integer.
2024-06-01 14:14:14 +00:00