Commit graph

257894 commits

Author SHA1 Message Date
bors 5c8459f1ec Auto merge of #126691 - fee1-dead-contrib:rollup-v4vtowh, r=fee1-dead
Rollup of 5 pull requests

Successful merges:

 - #126668 (Remove now NOP attrs `#[rustc_dump{,_env}_program_clauses]`)
 - #126674 (Allow tracing through item_bounds query invocations on opaques)
 - #126675 (Change a `DefineOpaqueTypes::No` to `Yes` in diagnostics code)
 - #126681 (Rework doc-test attribute documentation example)
 - #126684 (Migrate `run-make/glibc-staticlib-args` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-19 16:10:30 +00:00
fee1-dead 9e8a7a87e4
Rollup merge of #126684 - GuillaumeGomez:migrate-run-make-glibc-staticlib-args, r=Kobzol
Migrate `run-make/glibc-staticlib-args` to `rmake.rs`

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

r? ``@jieyouxu``
2024-06-19 22:51:06 +08:00
fee1-dead 69e26df5c4
Rollup merge of #126681 - Urgau:rustdoc-deny-doc, r=GuillaumeGomez
Rework doc-test attribute documentation example

This PR change the doc-test attribute documentation example to prefer a more neutral example `deny(dead_code)`, instead of `deny(warnings)`, which is less susceptible to breakage across Rust version.

r? ```@GuillaumeGomez```
2024-06-19 22:51:05 +08:00
fee1-dead e649eca1d2
Rollup merge of #126675 - oli-obk:diagnostics_opaque, r=jackh726
Change a `DefineOpaqueTypes::No` to `Yes` in diagnostics code

Explanation in comments of the function.

r? ```@compiler-errors```

cc https://github.com/rust-lang/rust/issues/116652
2024-06-19 22:51:05 +08:00
fee1-dead cc4ace33cf
Rollup merge of #126674 - oli-obk:tracing_item_bounds, r=lqd
Allow tracing through item_bounds query invocations on opaques

Previously these caused cycles when printing the result of the query.
2024-06-19 22:51:04 +08:00
fee1-dead be3b5663ae
Rollup merge of #126668 - fmease:rm-rustc_dump_program_clauses-attrs, r=fee1-dead
Remove now NOP attrs `#[rustc_dump{,_env}_program_clauses]`

Likely NOP since #113303.

r? `@fee1-dead`
2024-06-19 22:51:03 +08:00
bors 894f7a4ba6 Auto merge of #126678 - nnethercote:fix-duplicated-attrs-on-nt-expr, r=petrochenkov
Fix duplicated attributes on nonterminal expressions

This PR fixes a long-standing bug (#86055) whereby expression attributes can be duplicated when expanded through declarative macros.

First, consider how items are parsed in declarative macros:
```
Items:
- parse_nonterminal
  - parse_item(ForceCollect::Yes)
    - parse_item_
      - attrs = parse_outer_attributes
      - parse_item_common(attrs)
        - maybe_whole!
        - collect_tokens_trailing_token
```
The important thing is that the parsing of outer attributes is outside token collection, so the item's tokens don't include the attributes. This is how it's supposed to be.

Now consider how expression are parsed in declarative macros:
```
Exprs:
- parse_nonterminal
  - parse_expr_force_collect
    - collect_tokens_no_attrs
      - collect_tokens_trailing_token
        - parse_expr
          - parse_expr_res(None)
            - parse_expr_assoc_with
              - parse_expr_prefix
                - parse_or_use_outer_attributes
                - parse_expr_dot_or_call
```
The important thing is that the parsing of outer attributes is inside token collection, so the the expr's tokens do include the attributes, i.e. in `AttributesData::tokens`.

This PR fixes the bug by rearranging expression parsing to that outer attribute parsing happens outside of token collection. This requires a number of small refactorings because expression parsing is somewhat complicated. While doing so the PR makes the code a bit cleaner and simpler, by eliminating `parse_or_use_outer_attributes` and `Option<AttrWrapper>` arguments (in favour of the simpler `parse_outer_attributes` and `AttrWrapper` arguments), and simplifying `LhsExpr`.

r? `@petrochenkov`
2024-06-19 13:58:21 +00:00
Guillaume Gomez 0c2bfd913e Migrate run-make/glibc-staticlib-args to rmake.rs 2024-06-19 13:57:55 +02:00
bors 3186d17d56 Auto merge of #126679 - fmease:rollup-njrv2py, r=fmease
Rollup of 6 pull requests

Successful merges:

 - #125447 (Allow constraining opaque types during subtyping in the trait system)
 - #125766 (MCDC Coverage: instrument last boolean RHS operands from condition coverage)
 - #125880 (Remove `src/tools/rust-demangler`)
 - #126154 (StorageLive: refresh storage (instead of UB) when local is already live)
 - #126572 (override user defined channel when using precompiled rustc)
 - #126662 (Unconditionally warn on usage of `wasm32-wasi`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-19 11:09:31 +00:00
Urgau d70d76b9e7 Rework doc-test attribute documentation example 2024-06-19 13:08:26 +02:00
León Orell Valerian Liehr ca61d7470a
Rollup merge of #126662 - alexcrichton:warn-on-wasm32-wasi, r=michaelwoerister
Unconditionally warn on usage of `wasm32-wasi`

This commit is a continuation of the work originally proposed in rust-lang/compiler-team#607 and later amended in
rust-lang/compiler-team#695. The end goal is to rename `wasm32-wasi` to `wasm32-wasip1` to reflect WASI's development and distinguish the preexisting target from the `wasm32-wasip2` target that WASI is now developing. Work for this transition began in #120468 which landed in Rust 1.78 which became stable on 2024-05-02.

This implements the next phase of the transition plan to warn on usage of `wasm32-wasi`. This is intended to help alert users that a removal is pending and all release channels have the replacement available as well. This will reach stable on 2024-09-05. The next stage of the plan is to remove the `wasm32-wasi` target some time in October 2024 which means that the removal will reach stable on 2025-01-09. For reference a full schedule of this transition is listed [here].

Currently this implementation is a simple unconditional warning whenever `rustc --target wasm32-wasi` is invoked. As-implemented there's no way to turn off the warning other than to switch to the `wasm32-wasip1` target.

[here]: https://github.com/rust-lang/rust/pull/120468#issuecomment-1977878747
2024-06-19 13:04:59 +02:00
León Orell Valerian Liehr cbf9d57e89
Rollup merge of #126572 - onur-ozkan:channel-problem, r=clubby789
override user defined channel when using precompiled rustc

We need to override `rust.channel` if it's manually specified when using the CI rustc. This is because if the compiler uses a different channel than the one specified in config.toml, tests may fail due to using a different channel than the one used by the compiler during tests.

For more context, see https://github.com/rust-lang/rust/pull/122709#issuecomment-2165246281.
2024-06-19 13:04:59 +02:00
León Orell Valerian Liehr 035285b464
Rollup merge of #126154 - RalfJung:storage-live, r=compiler-errors
StorageLive: refresh storage (instead of UB) when local is already live

Blocked on [this FCP](https://github.com/rust-lang/rust/issues/99160#issuecomment-2155924538), which also contains the motivation.

Fixes https://github.com/rust-lang/rust/issues/99160
Fixes https://github.com/rust-lang/rust/issues/98896 (by declaring it not-a-bug)
Fixes https://github.com/rust-lang/rust/issues/119366
Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/129
2024-06-19 13:04:58 +02:00
León Orell Valerian Liehr 1e460368fd
Rollup merge of #125880 - Zalathar:demangler, r=oli-obk
Remove `src/tools/rust-demangler`

`rust-demangler` is a small binary that reads a list of mangled symbols from stdin, demangles them (using the `rustc-demangle` library crate), and prints the demangled symbols to stdout.

It was added as part of the initial implementation of coverage instrumentation in 2020/2021, so that coverage tests could pass it to `llvm-cov --Xdemangler` when generating coverage reports. It has been largely untouched since then.

As of #125816 it is no longer used by coverage tests, and has no remaining in-tree uses.

There is code in bootstrap to build and package the demangler, but it's unclear where the resulting binaries actually end up, or whether there's any reasonable way for `rustup` users to obtain them.

---

For users needing a command-line demangler, `rustfilt` exists and is more actively maintained. It's also quite easy to use the `rustc-demangle` library to build a custom command-line demangler if necessary, with only a few lines of code.

The tool's name (`rust-demangler`) is easily confused with the name of the library crate `rustc-demangle`, so removing the tool will eliminate that confusion. There also doesn't appear to be much reason to use `rust-demangler` over `rustfilt`.

---

This PR therefore removes the tool, and removes all of its associated code from bootstrap.

MCP filed: https://github.com/rust-lang/compiler-team/issues/754
2024-06-19 13:04:58 +02:00
León Orell Valerian Liehr a7cf6ece62
Rollup merge of #125766 - RenjiSann:fresh-mcdc-branch-on-bool, r=nnethercote
MCDC Coverage: instrument last boolean RHS operands from condition coverage

Fresh PR from #124652

--

This PR ensures that the top-level boolean expressions that are not part of the control flow are correctly instrumented thanks to condition coverage.

See discussion on https://github.com/rust-lang/rust/issues/124120.
Depends on `@Zalathar` 's condition coverage implementation #125756.
2024-06-19 13:04:57 +02:00
León Orell Valerian Liehr 25d47fe388
Rollup merge of #125447 - oli-obk:eq_opaque_pred, r=compiler-errors
Allow constraining opaque types during subtyping in the trait system

Previous attempt: https://github.com/rust-lang/rust/pull/123979

Sometimes we don't immediately perform subtyping, but instead register a subtyping obligation and solve that obligation when its inference variables become resolved. Unlike immediate subtyping, we currently do not allow registering hidden types for opaque types. This PR also allows that.
2024-06-19 13:04:56 +02:00
Zalathar fd4fe7d129 Remove src/tools/rust-demangler 2024-06-19 20:41:34 +10:00
Nicholas Nethercote 64c2e9ed3b Change how parse_expr_force_collect works.
It now parses outer attributes before collecting tokens. This avoids the
problem where the outer attribute tokens were being stored twice -- for
the attribute tokesn, and also for the expression tokens.

Fixes #86055.
2024-06-19 19:15:06 +10:00
Nicholas Nethercote 8170acb197 Refactor parse_expr_res.
This removes the final `Option<AttrWrapper>` argument.
2024-06-19 19:12:02 +10:00
Nicholas Nethercote 43eae4cef4 Simplify LhsExpr::Unparsed.
By making the `AttrWrapper` non-optional.
2024-06-19 19:12:02 +10:00
Nicholas Nethercote aaa220e875 Move parse_or_use_outer_attributes out of parse_expr_prefix_range.
This eliminates another `Option<AttrWrapper>` argument and changes one
obscure error message.
2024-06-19 19:12:00 +10:00
bors 5978f35330 Auto merge of #126671 - fmease:rollup-dmet4fi, r=fmease
Rollup of 7 pull requests

Successful merges:

 - #123782 (Test that opaque types can't have themselves as a hidden type with incompatible lifetimes)
 - #124580 (Suggest removing unused tuple fields if they are the last fields)
 - #125787 (Migrate `bin-emit-no-symbols` `run-make` test to `rmake`)
 - #126553 (match lowering: expand or-candidates mixed with candidates above)
 - #126594 (Make async drop code more consistent with regular drop code)
 - #126654 (Make pretty printing for `f16` and `f128` consistent)
 - #126656 (rustc_type_ir: Omit some struct fields from Debug output)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-19 08:56:43 +00:00
Nicholas Nethercote 802779f77d Move parse_or_use_outer_attributes out of parse_expr_prefix.
This eliminates one `Option<AttrWrapper>` argument.
2024-06-19 18:53:25 +10:00
Nicholas Nethercote ead0a45202 Inline and remove parse_expr_assoc.
It has a single call site.
2024-06-19 18:53:25 +10:00
Nicholas Nethercote 25523ba382 Refactor LhsExpr.
Combine `NotYetParsed` and `AttributesParsed` into a single variant,
because (a) that reflects the structure of the code that consumes
`LhsExpr`, and (b) because that variant will have the `Option` removed
in a later commit.
2024-06-19 18:53:25 +10:00
Nicholas Nethercote 42e47dfe82 Remove From impls for LhsExpr.
The `Option<AttrWrapper>` one maps to the first two variants, and the
`P<Expr>` one maps to the third. Weird. The code is shorter and clearer
without them.
2024-06-19 18:53:25 +10:00
Nicholas Nethercote 1c28229ada Simplify Parser::parse_expr_dot_or_call.
The call in `parse_expr_prefix` for the `++` case passes an empty
`attrs`, but it doesn' need to. This commit changes it to pass the
parsed `attrs`, which doesn't change any behaviour. As a result,
`parse_expr_dot_or_call` no longer needs an `Option` argument, and no
longer needs to call `parse_or_use_outer_attributes`.
2024-06-19 18:53:25 +10:00
Nicholas Nethercote 1fbb3eca67 Expand another comment. 2024-06-19 18:53:24 +10:00
Nicholas Nethercote 219389360c Add a comment.
Something that was non-obvious to me.
2024-06-19 18:53:24 +10:00
Oli Scherer 56cd30104a Change a DefineOpaqueTypes::No to Yes in diagnostics code 2024-06-19 08:49:16 +00:00
Oli Scherer 393dea8bc3 Allow tracing through item_bounds query invocations on opaques
Previously these caused cycles when printing the result
2024-06-19 08:47:55 +00:00
Oli Scherer ba4510ece8 Allow constraining opaque types during subtyping in the trait system 2024-06-19 08:29:17 +00:00
León Orell Valerian Liehr b980f6d7b1
Rollup merge of #126656 - fmease:skip-debug-for-_, r=compiler-errors
rustc_type_ir: Omit some struct fields from Debug output

r? compiler-errors or compiler
2024-06-19 09:52:02 +02:00
León Orell Valerian Liehr 2bc0cf2da5
Rollup merge of #126654 - tgross35:f16-f128-pretty-print, r=jackh726
Make pretty printing for `f16` and `f128` consistent

Currently the docs show e.g.

    {transmute(0xfffeffffffffffffffffffffffffffff): f128}

for f128 constants. This should fix that to instead use apfloat for printing, as is done for `f32` and `f64`.
2024-06-19 09:52:02 +02:00
León Orell Valerian Liehr ef062ea80d
Rollup merge of #126594 - zetanumbers:fix-cross-crate-async-drop-glue, r=oli-obk
Make async drop code more consistent with regular drop code

Fixes #126573

Relates to #126482

r? ````@petrochenkov````
2024-06-19 09:52:01 +02:00
León Orell Valerian Liehr e111e99253
Rollup merge of #126553 - Nadrieril:expand-or-pat-into-above, r=matthewjasper
match lowering: expand or-candidates mixed with candidates above

This PR tweaks match lowering of or-patterns. Consider this:
```rust
match (x, y) {
    (1, true) => 1,
    (2, false) => 2,
    (1 | 2, true | false) => 3,
    (3 | 4, true | false) => 4,
    _ => 5,
}
```
One might hope that this can be compiled to a single `SwitchInt` on `x` followed by some boolean checks. Before this PR, we compile this to 3 `SwitchInt`s on `x`, because an arm that contains more than one or-pattern was compiled on its own. This PR groups branch `3` with the two branches above, getting us down to 2 `SwitchInt`s on `x`.

We can't in general expand or-patterns freely, because this interacts poorly with another optimization we do: or-pattern simplification. When an or-pattern doesn't involve bindings, we branch the success paths of all its alternatives to the same block. The drawback is that in a case like:
```rust
match (1, true) {
    (1 | 2, false) => unreachable!(),
    (2, _) => unreachable!(),
    _ => {}
}
```
if we used a single `SwitchInt`, by the time we test `false` we don't know whether we came from the `1` case or the `2` case, so we don't know where to go if `false` doesn't match.

Hence the limitation: we can process or-pattern alternatives alongside candidates that precede it, but not candidates that follow it. (Unless the or-pattern is the only remaining match pair of its candidate, in which case we can process it alongside whatever).

This PR allows the processing of or-pattern alternatives alongside candidates that precede it. One benefit is that we now process or-patterns in a single place in `mod.rs`.

r? ``@matthewjasper``
2024-06-19 09:52:00 +02:00
León Orell Valerian Liehr 11391115cc
Rollup merge of #125787 - Oneirical:infinite-test-a-novel, r=jieyouxu
Migrate `bin-emit-no-symbols` `run-make` test to `rmake`

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
try-job: armhf-gnu
2024-06-19 09:52:00 +02:00
León Orell Valerian Liehr 96144c94af
Rollup merge of #124580 - gurry:124556-suggest-remove-tuple-field, r=jackh726
Suggest removing unused tuple fields if they are the last fields

Fixes #124556

We now check if dead/unused fields are the last fields of the tuple and suggest their removal instead of suggesting them to be changed to `()`.
2024-06-19 09:51:59 +02:00
León Orell Valerian Liehr f03bd96d66
Rollup merge of #123782 - oli-obk:equal_tait_args, r=compiler-errors
Test that opaque types can't have themselves as a hidden type with incompatible lifetimes

fixes #122876

This PR used to add extra logic to prevent those cases, but after https://github.com/rust-lang/rust/pull/113169 this is implicitly rejected, because such usages are not defining.
2024-06-19 09:51:59 +02:00
Dorian Péron e15adef457 tests(coverage): Bless mcdc_non_control_flow tests 2024-06-19 07:41:51 +00:00
Dorian Péron 6c7c824767 coverage: Make MCDC take in account last RHS of condition-coverage
Condition coverage extends branch coverage to treat the specific case
of last operands of boolean decisions not involved in control flow.
This is ultimately made for MCDC to be exhaustive on all boolean expressions.

This patch adds a call to `visit_branch_coverage_operation` to track the
top-level operand of the said decisions, and changes
`visit_coverage_standalone_condition` so MCDC branch registration is called
when enabled on these _last RHS_ cases.
2024-06-19 07:41:51 +00:00
León Orell Valerian Liehr c894ece8fe
Remove now NOP attrs #[rustc_dump{,_env}_program_clauses] 2024-06-19 09:19:09 +02:00
bors 3c0f019b3c Auto merge of #125852 - bvanjoi:improve-tip-for-invisible-trait, r=compiler-errors
improve tip for inaccessible traits

Improve the tips when the candidate method is from an inaccessible trait.

For example:

```rs
mod m {
  trait Trait {
    fn f() {}
  }
  impl<T> Trait for T {}
}

fn main() {
  struct S;
  S::f();
}
```

The difference between before and now is:

```diff
error[E0599]: no function or associated item named `f` found for struct `S` in the current scope
  --> ./src/main.rs:88:6
   |
LL |   struct S;
   |   -------- function or associated item `f` not found for this struct
LL |   S::f();
   |      ^ function or associated item not found in `S`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
- help: trait `Trait` which provides `f` is implemented but not in scope; perhaps you want to import it
+ help: trait `crate:Ⓜ️:Trait` which provides `f` is implemented but not reachable
   |
- LL + use crate:Ⓜ️:Trait;
   |
```
2024-06-19 06:19:22 +00:00
Alex Crichton e003a12ad5 Unconditionally warn on usage of wasm32-wasi
This commit is a continuation of the work originally proposed in
rust-lang/compiler-team#607 and later amended in
rust-lang/compiler-team#695. The end goal is to rename `wasm32-wasi` to
`wasm32-wasip1` to reflect WASI's development and distinguish the
preexisting target from the `wasm32-wasip2` target that WASI is now
developing. Work for this transition began in #120468 which landed in
Rust 1.78 which became stable on 2024-05-02.

This implements the next phase of the transition plan to warn on usage
of `wasm32-wasi`. This is intended to help alert users that a removal is
pending and all release channels have the replacement available as well.
This will reach stable on 2024-09-05. The next stage of the plan is to
remove the `wasm32-wasi` target some time in October 2024 which means
that the removal will reach stable on 2025-01-09. For reference a full
schedule of this transition is listed [here].

Currently this implementation is a simple unconditional warning whenever
`rustc --target wasm32-wasi` is invoked. As-implemented there's no way
to turn off the warning other than to switch to the `wasm32-wasip1`
target.

[here]: https://github.com/rust-lang/rust/pull/120468#issuecomment-1977878747
2024-06-18 21:05:56 -07:00
bors 9889a6f5d3 Auto merge of #126657 - weihanglo:update-cargo, r=weihanglo
Update cargo

13 commits in a1f47ec3f7cd076986f1bfcd7061f2e8cb1a726e..3ed207e416fb2f678a40cc79c02dcf4f936a21ce
2024-06-15 01:10:07 +0000 to 2024-06-18 19:18:22 +0000
- test: prefer raw string for regex reduction (rust-lang/cargo#14099)
- test: migrate tree and tree_graph_features to snapbox (rust-lang/cargo#14094)
- test: Migrate some files to snapbox (rust-lang/cargo#14069)
- remove some legacy public dependency code from the resolver (rust-lang/cargo#14090)
- fix(fix): Address problems with implicit -&gt; explicit feature migration (rust-lang/cargo#14018)
- refactor: 1.79 cleanup (rust-lang/cargo#14088)
- test: migrate `git_(gc|shallow)` to snapbox (rust-lang/cargo#14087)
- test: migrate timings_works to snapbox (rust-lang/cargo#14082)
- test: migrate minimal_versions to snapbox (rust-lang/cargo#14080)
- Remove `run_expect_error` to avoid tests incorrectly passing (rust-lang/cargo#14078)
- test: migrate help to snapbox (rust-lang/cargo#14060)
- test: Migrate tests/testsuite/co*.rs to snapbox (rust-lang/cargo#14079)
- Use `std::fs::absolute` instead of reimplementing it (rust-lang/cargo#14075)

<!--
r? ghost
-->
2024-06-19 04:03:14 +00:00
Weihang Lo 087add3cb2
Update cargo 2024-06-18 22:04:58 -04:00
bors a1ca449981 Auto merge of #126655 - jieyouxu:rollup-z7k1k6l, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - #124135 (delegation: Implement glob delegation)
 - #125078 (fix: break inside async closure has incorrect span for enclosing closure)
 - #125293 (Place tail expression behind terminating scope)
 - #126422 (Suggest using a standalone doctest for non-local impl defs)
 - #126493 (safe transmute: support non-ZST, variantful, uninhabited enums)
 - #126504 (Sync fuchsia test runner with clang test runner)
 - #126558 (hir_typeck: be more conservative in making "note caller chooses ty param" note)
 - #126586 (Add `@badboy` and `@BlackHoleFox` as Mac Catalyst maintainers)
 - #126615 (Add `rustc-ice*` to `.gitignore`)
 - #126632 (Replace `move||` with `move ||`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-19 01:49:20 +00:00
León Orell Valerian Liehr 2126c1d446
rustc_type_ir: Omit some struct fields from Debug output 2024-06-19 03:08:34 +02:00
许杰友 Jieyou Xu (Joe) 7450ab7acb
Rollup merge of #126632 - Vonr:fix/moving-closure-formatting-v2, r=Nilstrieb
Replace `move||` with `move ||`

Edit from #126631 to revert changes in `tests/ui`.

There are 18 instances of `move||` across 6 files in the repo:
- `compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs`
- `library/core/src/sync/atomic.rs`
- `library/std/src/sync/condvar.rs`
- `library/std/src/sync/mpsc/mod.rs`
- `library/std/src/sync/barrier.rs`
- `library/std/src/thread/local.rs`

I have replaced all such instances with `move ||` instead as it better adheres to modern formatting standards.

Ideally, we would have this automated by rustfmt or some other tool, but I do not have the time to implement such a feature or tool.
Nonetheless, I would encourage any effort invested into such a tool or feature.
2024-06-19 01:51:42 +01:00
许杰友 Jieyou Xu (Joe) a2436a83d3
Rollup merge of #126615 - tgross35:gitignore-ice, r=compiler-errors
Add `rustc-ice*` to `.gitignore`

I am a bit surprised this wasn't already here but there doesn't seem to be any reason not to add it. This will be nice to cut down on `git {add, diff, etc}` noise when debugging crashes.
2024-06-19 01:51:42 +01:00