Commit Graph

258783 Commits

Author SHA1 Message Date
bors 036b38ced3 Auto merge of #126993 - petrochenkov:atvisord3, r=BoxyUwU
ast: Standardize visiting order

Order: ID, attributes, inner nodes in source order if possible, tokens, span.

Also always use exhaustive matching in visiting infra, and visit some discovered missing nodes.

Unlike https://github.com/rust-lang/rust/pull/125741 this shouldn't affect anything serious like `macro_rules` scopes.
2024-06-27 12:25:46 +00:00
bors a4ce33c0b2 Auto merge of #126728 - onur-ozkan:stage1-rustdoc, r=Kobzol
rustdoc: use current stage if download-rustc enabled

When using download-rustc, using stage 1 rustdoc results in the wrong librustc_driver being used.

```sh
$ ./build/host/stage1/bin/rustdoc --version
./build/host/stage1/bin/rustdoc: error while loading shared libraries: librustc_driver-7ff02ed05016d515.so: cannot open shared object file: No such file or directory
```

This change fixes that by not cutting the stage if download-rustc is enabled.
2024-06-27 10:09:10 +00:00
bors 127fa2261b Auto merge of #127014 - jhpratt:rollup-45ic8f5, r=jhpratt
Rollup of 6 pull requests

Successful merges:

 - #126571 (Less `maybe_whole_expr`, take 2)
 - #126721 (coverage: Make `#[coverage(..)]` apply recursively to nested functions)
 - #126928 (Some `Nonterminal` removal precursors)
 - #126929 (Remove `__rust_force_expr`.)
 - #126980 (set self.is_known_utf8 to false in extend_from_slice)
 - #126983 (Remove `f16` and `f128` ICE paths from smir)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-27 07:54:44 +00:00
Jacob Pratt 73016dc8a4
Rollup merge of #126983 - tgross35:f16-f128-smir, r=celinval
Remove `f16` and `f128` ICE paths from smir

Just chasing down some possible ICE paths. ```@compiler-errors``` mentioned in https://github.com/rust-lang/rust/pull/121728#discussion_r1506133496 that it is okay not to support these in smir, but this change seems pretty trivial?

r? ```@celinval``` since you reviewed https://github.com/rust-lang/rust/pull/114607#pullrequestreview-1771673591
2024-06-27 02:06:20 -04:00
Jacob Pratt 8905be5ef3
Rollup merge of #126980 - Borgerr:fix-extendfromslice-check, r=workingjubilee
set self.is_known_utf8 to false in extend_from_slice

try-job: x86_64-msvc

closes #126977
Related to #126885, #126333, and [this conversation](<aa46a3368e (r143539097)>)
2024-06-27 02:06:20 -04:00
Jacob Pratt d3debc0037
Rollup merge of #126929 - nnethercote:rm-__rust_force_expr, r=oli-obk
Remove `__rust_force_expr`.

This was added (with a different name) to improve an error message. It is no longer needed -- removing it changes the error message, but overall I think the new message is no worse:
- the mention of `#` in the first line is a little worse,
- but the extra context makes it very clear what the problem is, perhaps even clearer than the old message,
- and the removal of the note about the `expr` fragment (an internal detail of `__rust_force_expr`) is an improvement.

Overall I think the error is quite clear and still far better than the old message that prompted #61933, which didn't even mention patterns.

The motivation for this is #124141, which will cause pasted metavariables to be tokenized and reparsed instead of the AST node being cached. This change in behaviour occasionally has a non-zero perf cost, and `__rust_force_expr` causes the tokenize/reparse step to occur twice. Removing `__rust_force_expr` greatly reduces the extra overhead for the `deep-vector` benchmark.

r? ```@oli-obk```
2024-06-27 02:06:19 -04:00
Jacob Pratt b1f43974c4
Rollup merge of #126928 - nnethercote:124141-pre, r=oli-obk
Some `Nonterminal` removal precursors

Small things to prepare for #124141, more or less.

r? ```@oli-obk```
2024-06-27 02:06:19 -04:00
Jacob Pratt 70b69a2384
Rollup merge of #126721 - Zalathar:nested-cov-attr, r=oli-obk
coverage: Make `#[coverage(..)]` apply recursively to nested functions

This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to.

Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value.

---

Fixes #126625.
2024-06-27 02:06:18 -04:00
Jacob Pratt 5ec93b8e36
Rollup merge of #126571 - nnethercote:less-maybe_whole-expr-2, r=petrochenkov
Less `maybe_whole_expr`, take 2

I first tried this in #107550. I now think it's worth doing again, as a precursor to #124141.

r? ```@petrochenkov```
2024-06-27 02:06:18 -04:00
bors 536235f07e Auto merge of #126907 - glaubitz:sparc-fixes, r=nagisa
Fixes for 32-bit SPARC on Linux

This PR fixes a number of issues which previously prevented `rustc` from being built
successfully for 32-bit SPARC using the `sparc-unknown-linux-gnu` triplet.

In particular, it adds linking against `libatomic` where necessary, uses portable `AtomicU64`
for `rustc_data_structures` and rewrites the spec for `sparc_unknown_linux_gnu` to use
`TargetOptions` and replaces the previously used `-mv8plus` with the more portable
`-mcpu=v9 -m32`.

To make `rustc` build successfully, support for 32-bit SPARC needs to be added to the `object`
crate as well as the `nix` crate which I will be sending out later as well.

r? nagisa
2024-06-27 05:44:47 +00:00
bors 1def498e3b Auto merge of #126692 - DianQK:nixos-patchelf, r=Nilstrieb
patch `rust-lld` and `ld.lld` on NixOS

When `rustc` uses its self-contained lld, we also need to patch `rust-lld` and `ld.lld`.
The `rpath` for `rust-lld` is `$ORIGIN/../../../:$ORIGIN/../lib`, so I use `--add-rpath` instead of `--set-rpath`, which should be easier to maintain.

I also changed `src/bootstrap/src/core/download.rs`, even this doesn't fix any known issues.

For the `lld-wrapper.sh` of lld, refer to: https://github.com/rust-lang/rustc-dev-guide/pull/1999.
2024-06-27 03:31:41 +00:00
bors 7033f9b14a Auto merge of #123918 - DianQK:clang-format, r=Kobzol
Use `clang-format` in `tidy` to check the C++ code style under `llvm-wrapper`

Fixes #123510.

Based on the discussion at https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Enable.20.60clang-format.60.20for.20.60rustc.60.20compiler-team.23756/near/443562800, we can use clang-format from pip to achieve the code formatting.

r? `@Kobzol`
2024-06-27 01:18:56 +00:00
bors 4bc39f028d Auto merge of #120924 - xFrednet:rfc-2383-stabilization-party, r=Urgau,blyxyas
Let's `#[expect]` some lints: Stabilize `lint_reasons` (RFC 2383)

Let's give this another try! The [previous stabilization attempt](https://github.com/rust-lang/rust/pull/99063) was stalled by some unresolved questions. These have been discussed in a [lang team](https://github.com/rust-lang/lang-team/issues/191) meeting. The last open question, regarding the semantics of the `#[expect]` attribute was decided on in https://github.com/rust-lang/rust/issues/115980

I've just updated the [stabilization report](https://github.com/rust-lang/rust/issues/54503#issuecomment-1179563964) with the discussed questions and decisions. Luckily, the decision is inline with the current implementation.

This hopefully covers everything. Let's hope that the CI will be green like the spring.

fixes #115980
fixes #54503

---

r? `@wesleywiser`

Tacking Issue: https://github.com/rust-lang/rust/issues/54503
Stabilization Report: https://github.com/rust-lang/rust/issues/54503#issuecomment-1179563964
Documentation Update: https://github.com/rust-lang/reference/pull/1237

<!--
For Clippy:

changelog: [`allow_attributes`]: Is now available on stable, since the `lint_reasons` feature was stabilized
changelog: [`allow_attributes_without_reason`]: Is now available on stable, since the `lint_reasons` feature was stabilized
-->

---

Roses are red,
Violets are blue,
Let's expect lints,
With reason clues
2024-06-26 16:38:30 +00:00
Urgau 7666534381
Clarify comment on changing to warn future breakage items
https://github.com/rust-lang/rust/pull/120924/files#r1653512240
2024-06-26 17:00:46 +02:00
Vadim Petrochenkov ba3f6812c1 ast: Standardize visiting order
Id, attributes, inner nodes in source order if possible, tokens, span.

Also always use exhaustive matching in visiting infra, and visit some missing nodes.
2024-06-26 17:41:24 +03:00
bors d7c59370ce Auto merge of #126844 - scottmcm:more-ptr-cast-gvn, r=saethlin
Remove more `PtrToPtr` casts in GVN

This addresses two things I noticed in MIR:

1. `NonNull::<T>::eq` does `(a as *mut T) == (b as *mut T)`, but it could just compare the `*const T`s, so this removes `PtrToPtr` casts that are on both sides of a pointer comparison, so long as they're not fat-to-thin casts.

2. `NonNull::<T>::addr` does `transmute::<_, usize>(p as *const ())`, but so long as `T: Thin` that cast doesn't do anything, and thus we can directly transmute the `*const T` instead.

r? mir-opt
2024-06-26 14:22:31 +00:00
DianQK c163d5c99d
Add `cpp:fmt` to mingw-check-tidy 2024-06-26 20:18:49 +08:00
DianQK e17c16d55b
Format C++ files in `llvm-wrapper` 2024-06-26 20:18:49 +08:00
DianQK de0ece2f29
Add clang-format to the external tool check 2024-06-26 20:16:52 +08:00
bors 4bdf8d2d58 Auto merge of #126608 - tgross35:f16-f128-library, r=Mark-Simulacrum
Add more constants, functions, and tests for `f16` and `f128`

This adds everything that was in some way blocked on const eval, since https://github.com/rust-lang/rust/pull/126429 landed. There is a lot of `cfg(bootstrap)` since that is a fairly recent change.

`f128` tests are disabled on everything except x86_64 and Linux aarch64, which are two platforms I know have "good" support for these types - meaning basic math symbols are available and LLVM doesn't hit selection crashes. `f16` tests are enabled on almost everything except for known LLVM crashes. Doctests are only enabled on x86_64.

Tracking issue: https://github.com/rust-lang/rust/issues/116909
2024-06-26 12:06:05 +00:00
bors bae813a265 Auto merge of #126934 - onur-ozkan:broken-build-cache, r=Kobzol
fix broken build cache caused by rustdoc builds

Currently rustdoc breaks the build cache (due to having different rustflags) when building rustdoc before building another tool (e.g., `x test miri && x test rustdoc && x test miri`).

This change fixes that by moving `on-broken-pipe` into `prepare_cargo_tool` so it is set for all tools.

cc `@RalfJung`

Fixes #123177
2024-06-26 09:42:33 +00:00
bors 7731802570 Auto merge of #126979 - matthiaskrgr:rollup-fdqledz, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #126724 (Fix a span in `parse_ty_bare_fn`.)
 - #126812 (Rename `tcx` to `cx` in new solver generic code)
 - #126879 (fix Drop items getting leaked in Filter::next_chunk)
 - #126925 (Change E0369 to give note informations for foreign items.)
 - #126938 (miri: make sure we can find link_section statics even for the local crate)
 - #126954 (resolve: Tweak some naming around import ambiguities)
 - #126964 (Migrate `lto-empty`, `invalid-so` and `issue-20626` `run-make` tests to rmake.rs)
 - #126968 (Don't ICE during RPITIT refinement checking for resolution errors after normalization)
 - #126971 (Bump black, ruff and platformdirs)
 - #126973 (Fix bad replacement for unsafe extern block suggestion)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-26 07:22:41 +00:00
Trevor Gross 518b74ec5d Remove `f16` and `f128` ICE paths from smir 2024-06-26 02:56:48 -04:00
Jubilee Young 5aac24909c std: test a variety of ways to extend a Wtf8Buf 2024-06-25 23:44:49 -07:00
ash e5167fe7bd set self.is_known_utf8 to false in extend_from_slice 2024-06-25 23:58:43 -06:00
Matthias Krüger b2720867f1
Rollup merge of #126973 - chenyukang:yukang-fix-126756-unsafe-suggestion-error, r=spastorino
Fix bad replacement for unsafe extern block suggestion

Fixes #126756

r? ``@spastorino``

link #123743
2024-06-26 07:50:21 +02:00
Matthias Krüger ee07d90aae
Rollup merge of #126971 - DianQK:bump, r=Kobzol
Bump black, ruff and platformdirs

Mainly because I encountered the following error, and we have no reason to prevent our upgrade.

```
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed.
This behaviour is the source of the following dependency conflicts.
virtualenv 20.25.3 requires platformdirs<5,>=3.9.1, but you have platformdirs 3.6.0 which is incompatible.
```

r? `@Kobzol`
2024-06-26 07:50:21 +02:00
Matthias Krüger 8c6c6a7591
Rollup merge of #126968 - lqd:issue-126670, r=compiler-errors
Don't ICE during RPITIT refinement checking for resolution errors after normalization

#126670 shows a case where resolution errors after normalization can happen during RPITIT refinement checking. Our tests didn't reach this path before, and we explicitly ICEd until we had a test. We can now delay a bug since we're sure it is reachable and have the test from the isue.

The comment I added likely still needs more expert wordsmithing.

r? ``@compiler-errors`` who's making me work during vacation (j/k).
Fixes #126670
2024-06-26 07:50:20 +02:00
Matthias Krüger bf8da39aa9
Rollup merge of #126964 - Oneirical:total-catestrophe, r=Kobzol
Migrate `lto-empty`, `invalid-so` and `issue-20626` `run-make` tests to rmake.rs

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-06-26 07:50:20 +02:00
Matthias Krüger 8b3bbee26b
Rollup merge of #126954 - petrochenkov:globamb, r=compiler-errors
resolve: Tweak some naming around import ambiguities
2024-06-26 07:50:19 +02:00
Matthias Krüger 5c4ede88c6
Rollup merge of #126938 - RalfJung:link_section, r=compiler-errors
miri: make sure we can find link_section statics even for the local crate

Miri needs some way to iterate all the exported functions and "used" statics of all crates. For dependency crates, this already works fine since we can overwrite the query resonsible for computing `exported_symbols`, but it turns out for local binary crates this does not work: for binaries, `reachable_set` skips a lot of its logic and only checks `contains_extern_indicator()` and `RUSTC_STD_INTERNAL_SYMBOL`. Other flags like `CodegenFnAttrFlags::USED` are entirely ignored.

This PR proposes to use the same check, `has_custom_linkage`, in binaries that we already use to drive the main workqueue of the reachability recursive traversal. I have no idea why binaries used a slightly different check that ignores `USED` -- was that deliberate or does it just not matter most of the time?
2024-06-26 07:50:19 +02:00
Matthias Krüger 95332b8918
Rollup merge of #126925 - surechen:fix_125631, r=compiler-errors
Change E0369 to give note informations for foreign items.

Change E0369 to give note informations for foreign items.
Make it easy for developers to understand why the binop cannot be applied.

fixes #125631
2024-06-26 07:50:18 +02:00
Matthias Krüger cf22be186c
Rollup merge of #126879 - the8472:next-chunk-filter-drop, r=cuviper
fix Drop items getting leaked in Filter::next_chunk

The optimization only makes sense for non-drop elements anyway. Use the default implementation for items that are Drop instead.

It also simplifies the implementation.

fixes #126872
tracking issue #98326
2024-06-26 07:50:18 +02:00
Matthias Krüger dc22ffc725
Rollup merge of #126812 - compiler-errors:tcx-cx, r=lcnr
Rename `tcx` to `cx` in new solver generic code

self-explanatory, should be last major churn-y rename

r? lcnr
2024-06-26 07:50:17 +02:00
Matthias Krüger dd6b04663e
Rollup merge of #126724 - nnethercote:fix-parse_ty_bare_fn-span, r=compiler-errors
Fix a span in `parse_ty_bare_fn`.

It currently goes one token too far.

Example: line 259 of `tests/ui/abi/compatibility.rs`:
```
test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32);
```
This commit changes the span for the second element from `fn(),` to `fn()`, i.e. removes the extraneous comma.

This doesn't affect any tests. I found it while debugging some other code. Not a big deal but an easy fix so I figure it worth doing.

r? ``@spastorino``
2024-06-26 07:50:16 +02:00
onur-ozkan b3fb67e050 set `on-broken-pipe` in `prepare_cargo_tool`
Currently rustdoc breaks the build cache (due to having different rustflags) when building
rustdoc before building another tool (e.g., `x test miri && x test rustdoc && x test miri`).

This change fixes that by moving `on-broken-pipe` into `prepare_cargo_tool` so it is
set for all tools.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-26 08:03:55 +03:00
bors a299aa5df7 Auto merge of #126955 - weihanglo:update-cargo, r=weihanglo
Update cargo

10 commits in bc89bffa5987d4af8f71011c7557119b39e44a65..4ed7bee47f7dd4416b36fada1909e9a62c546246
2024-06-22 00:36:36 +0000 to 2024-06-25 16:28:22 +0000
- test: omit target-dir name (rust-lang/cargo#14142)
- test: migrate offline, open_namespaces and owner to snapbox (rust-lang/cargo#14138)
- docs: remove stray comment (rust-lang/cargo#14133)
- Change tests to support `rustc` wording changes (rust-lang/cargo#14135)
- deps: dont use tracing-attributes for workspace, use for cargo only (rust-lang/cargo#14122)
- Include vcs_info even if workspace is dirty (rust-lang/cargo#13960)
- test: migrate profile* to snapbox (rust-lang/cargo#14128)
- test: migrate path and paths to snapbox (rust-lang/cargo#14109)
- test: migrate rustflags, rustup and script to snapbox (rust-lang/cargo#14126)
- test: migrate rename_deps, replace, required_features and run to snapbox (rust-lang/cargo#14127)
2024-06-26 01:43:41 +00:00
yukang 0addda6578 Fix bad replacement for unsafe extern block suggestion 2024-06-26 08:50:50 +08:00
Zalathar 7f37f8af5f coverage: Allow `#[coverage(..)]` on `impl` and `mod`
These attributes apply to all enclosed functions/methods/closures, unless
explicitly overridden by another coverage attribute.
2024-06-26 10:08:05 +10:00
Zalathar 3262611cc5 coverage: Apply `#[coverage(..)]` recursively to nested functions 2024-06-26 10:08:05 +10:00
Zalathar 457fda1701 coverage: Detach `#[coverage(..)]` from codegen attribute handling 2024-06-26 10:08:05 +10:00
bors 31f8b70d2e Auto merge of #126951 - matthiaskrgr:rollup-xg0o4mc, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #126618 (Mark assoc tys live only if the corresponding trait is live)
 - #126746 (Deny `use<>` for RPITITs)
 - #126868 (not use offset when there is not ends with brace)
 - #126884 (Do not ICE when suggesting dereferencing closure arg)
 - #126893 (Eliminate the distinction between PREC_POSTFIX and PREC_PAREN precedence level)
 - #126915 (Don't suggest awaiting in closure patterns)
 - #126943 (De-duplicate all consecutive native libs regardless of their options)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-25 23:29:58 +00:00
Nicholas Nethercote cf0251d92c Fix a span in `parse_ty_bare_fn`.
It currently goes one token too far.

Example: line 259 of `tests/ui/abi/compatibility.rs`:
```
test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32);
```
This commit changes the span for the second element from `fn(),` to
`fn()`, i.e. removes the extraneous comma.
2024-06-26 08:23:57 +10:00
DianQK 9f1f6a3387
Add clang-format to requirements.txt in tidy 2024-06-26 05:59:20 +08:00
DianQK 57c8f6f252
Add `.clang-format` 2024-06-26 05:56:00 +08:00
DianQK efa48bfaf3
Bump black, ruff and platformdirs
Mainly because I encountered the following error, and we have no reason to prevent our upgrade.

```
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed.
This behaviour is the source of the following dependency conflicts.
virtualenv 20.25.3 requires platformdirs<5,>=3.9.1, but you have platformdirs 3.6.0 which is incompatible.
```
2024-06-26 05:55:54 +08:00
Michael Goulet 275d922dab Rename tcx to cx 2024-06-25 17:36:52 -04:00
The 8472 0d7aef9738 regression test for leaks in the the Filter::next_chunk implementation
previously next_chunk would forget items rejected by the filter
2024-06-25 23:22:27 +02:00
The 8472 2be2d77c50 add comments explaining optimizations for Filter::next_chunk 2024-06-25 23:20:00 +02:00
The 8472 133e7b10a4 fix Drop items getting leaked in Filter::next_chunk
The optimization only makes sense for non-drop elements anyway.
Use the default implementation for items that are Drop instead.

It also simplifies the implementation.
2024-06-25 23:19:58 +02:00