Commit Graph

258101 Commits

Author SHA1 Message Date
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
sayantn
1e1b3fcada Fix stderr cases 2024-06-19 11:19:25 +05:30
Sayantan Chakraborty
b6d20d1a1f Add the target-features 2024-06-19 11:19:23 +05:30
Oli Scherer
1cb75dc4a9 Remove a hack that isn't needed anymore 2024-06-19 04:41:57 +00:00
Oli Scherer
3594a19f2a Taint infcx when reporting errors 2024-06-19 04:41:56 +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
许杰友 Jieyou Xu (Joe)
87ca0731c3
Rollup merge of #126586 - madsmtm:mac-catalyst-maintainers, r=Nilstrieb
Add @badboy and @BlackHoleFox as Mac Catalyst maintainers

Assented in https://github.com/rust-lang/compiler-team/issues/761#issuecomment-2173071316 and https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Promote.20Mac.20Catalyst.20targets.20to.20Tier.202.20compiler-team.23761/near/444590303.
2024-06-19 01:51:41 +01:00
许杰友 Jieyou Xu (Joe)
bf841c4773
Rollup merge of #126558 - jieyouxu:caller-chooses-ty, r=fmease
hir_typeck: be more conservative in making "note caller chooses ty param" note

In https://github.com/rust-lang/rust/pull/122195 I added a "caller chooses ty for type param" note for when the return expression type a.k.a. found type does not match the expected return type.

#126547 found that this note was confusing when the found return type *contains* the expected type, e.g.

```rs
fn f<T>(t: &T) -> T {
    t
}
```

because the found return type `&T` will *always* be different from the expected return type `T`, so the note was needlessly redundant and confusing.

This PR addresses that by not making the note if the found return type contains the expected return type.

r? ``@fmease`` (since you reviewed the original PR)

Fixes https://github.com/rust-lang/rust/issues/126547
2024-06-19 01:51:41 +01:00
许杰友 Jieyou Xu (Joe)
3c61378c5a
Rollup merge of #126504 - erickt:bump-fuchsia, r=tmandry
Sync fuchsia test runner with clang test runner

This synchronizes the fuchsia test running code with the clang test runner. This brings with it:

* Improved logging
* Uses the fuchsia image from the SDK version
* Caches the product bundle across test runs
* Strips the binaries to reduce the data sent to the emulator

r? ``@tmandry``
2024-06-19 01:51:40 +01:00
许杰友 Jieyou Xu (Joe)
0e46111660
Rollup merge of #126493 - jswrenn:fix-126460, r=compiler-errors
safe transmute: support non-ZST, variantful, uninhabited enums

Previously, `Tree::from_enum`'s implementation branched into three disjoint cases:

 1. enums that uninhabited
 2. enums for which all but one variant is uninhabited
 3. enums with multiple variants

This branching (incorrectly) did not differentiate between variantful and variantless uninhabited enums. In both cases, we assumed (and asserted) that uninhabited enums are zero-sized types. This assumption is false for enums like:

    enum Uninhabited { A(!, u128) }

...which, currently, has the same size as `u128`. This faulty assumption manifested as the ICE reported in #126460.

In this PR, we revise the first case of `Tree::from_enum` to consider only the narrow category of "enums that are uninhabited ZSTs". These enums, whose layouts are described with `Variants::Single { index }`, are special in their layouts otherwise resemble the `!` type and cannot be descended into like typical enums. This first case captures uninhabited enums like:

    enum Uninhabited { A(!, !), B(!) }

The second case is revised to consider the broader category of "enums that defer their layout to one of their variants"; i.e., enums whose layouts are described with `Variants::Single { index }` and that do have a variant at `index`. This second case captures uninhabited enums that are not ZSTs, like:

    enum Uninhabited { A(!, u128) }

...which represent their variants with `Variants::Single`.

Finally, the third case is revised to cover the broader category of "enums with multiple variants", which captures uninhabited enums like:

    enum Uninhabited { A(u8, !), B(!, u32) }

...which represent their variants with `Variants::Multiple`.

This PR also adds a comment requested by ````@RalfJung```` in his review of #126358 to `compiler/rustc_const_eval/src/interpret/discriminant.rs`.

Fixes #126460

r? ````@compiler-errors````
2024-06-19 01:51:39 +01:00
许杰友 Jieyou Xu (Joe)
081cc5cc2d
Rollup merge of #126422 - Urgau:doctest-impl-non-local-def, r=fmease
Suggest using a standalone doctest for non-local impl defs

This PR tweaks the lint output of the `non_local_definitions` lint to suggest using a standalone doctest instead of a moving the `impl` def to an impossible place as was already done with `macro_rules!` case in https://github.com/rust-lang/rust/pull/124568.

Fixes #126339
r? ```@fmease```
2024-06-19 01:51:39 +01:00
许杰友 Jieyou Xu (Joe)
8eb2e5f4c8
Rollup merge of #125293 - dingxiangfei2009:tail-expr-temp-lifetime, r=estebank,davidtwco
Place tail expression behind terminating scope

This PR implements #123739 so that we can do further experiments in nightly.

A little rewrite has been applied to `for await` lowering. It was previously `unsafe { Pin::unchecked_new(into_async_iter(..)) }`. Under the edition 2024 rule, however, `into_async_iter` gets dropped at the end of the `unsafe` block. This presumably the first Edition 2024 migration rule goes by hoisting `into_async_iter(..)` into `match` one level above, so it now looks like the following.
```rust
match into_async_iter($iter_expr) {
  ref mut iter => match unsafe { Pin::unchecked_new(iter) } {
    ...
  }
}
```
2024-06-19 01:51:38 +01:00
许杰友 Jieyou Xu (Joe)
c9a9d5cee7
Rollup merge of #125078 - linyihai:issue-124496, r=compiler-errors
fix: break inside async closure has incorrect span for enclosing closure

Fixes #124496
2024-06-19 01:51:38 +01:00
许杰友 Jieyou Xu (Joe)
f8ce1cfbf5
Rollup merge of #124135 - petrochenkov:deleglob, r=fmease
delegation: Implement glob delegation

Support delegating to all trait methods in one go.
Overriding globs with explicit definitions is also supported.

The implementation is generally based on the design from https://github.com/rust-lang/rfcs/pull/3530#issuecomment-2020869823, but unlike with list delegation in https://github.com/rust-lang/rust/pull/123413 we cannot expand glob delegation eagerly.
We have to enqueue it into the queue of unexpanded macros (most other macros are processed this way too), and then a glob delegation waits in that queue until its trait path is resolved, and enough code expands to generate the identifier list produced from the glob.

Glob delegation is only allowed in impls, and can only point to traits.
Supporting it in other places gives very little practical benefit, but significantly raises the implementation complexity.

Part of https://github.com/rust-lang/rust/issues/118212.
2024-06-19 01:51:36 +01:00
Trevor Gross
1299aef921 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-18 19:40:37 -05:00
bors
4e63822fc4 Auto merge of #126607 - Oneirical:the-testern-world, r=jieyouxu
Rewrite `separate-link`, `separate-link-fail` and `allocator-shim-circular-deps` `run-make` tests to `ui` or `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).
2024-06-18 23:38:09 +00:00
Michael Goulet
9b0f9ef42e Make rustc_next_trait_solver nightly again 2024-06-18 18:52:48 -04:00
Michael Goulet
c20d909701 Make rustc_type_ir nightly again 2024-06-18 18:51:26 -04:00
ardi
9f6371236f make this comment correct 2024-06-19 00:27:41 +02:00
ardi
d51b4462ec Improve conflict marker recovery 2024-06-19 00:27:41 +02:00
Guillaume Gomez
1ba5c9808c Migrate run-make/rustdoc-io-error to rmake.rs 2024-06-18 23:28:55 +02:00
许杰友 Jieyou Xu (Joe)
939026c8fb tests: update tests for more conservative return ty mismatch note 2024-06-18 21:06:53 +00:00
许杰友 Jieyou Xu (Joe)
bfe6a26af6 hir_typeck: be more conservative in making "note caller chooses ty param" note
- Avoid "caller chooses ty for type param" note if the found type a.k.a.
  the return expression type *contains* the type parameter, because e.g.
  `&T` will always be different from `T` (i.e. "well duh").
- Rename `note_caller_chooses_ty_for_ty_param` to
  `try_note_caller_chooses_ty_for_ty_param` because the note is not
  always made.

Issue: https://github.com/rust-lang/rust/issues/126547
2024-06-18 21:05:59 +00:00
Oneirical
d1e8c6bc7e rewrite extern-overrides-distribution to rmake 2024-06-18 16:30:26 -04:00
Oneirical
dff354e57f rewrite metadata-flag-frobs-symbols to rmake 2024-06-18 16:20:32 -04:00
Oneirical
9e2ace85f9 rewrite debugger-visualizer-dep-info to rmake 2024-06-18 16:05:56 -04:00
Oneirical
060a13e9fd rewrite extern-flag-rename-transitive to rmake 2024-06-18 15:59:33 -04:00
bors
8fcd4dd08e Auto merge of #126614 - compiler-errors:uplift-next-trait-solver, r=lcnr
Uplift next trait solver to `rustc_next_trait_solver`

🎉

There's so many FIXMEs! Sorry! Ideally this merges with the FIXMEs and we track and squash them over the near future.

Also, this still doesn't build on anything other than rustc. I still need to fix `feature = "nightly"` in `rustc_type_ir`, and remove and fix all the nightly feature usage in the new trait solver (notably: let-chains).

Also, sorry `@lcnr` I know you asked for me to separate the commit where we `mv rustc_trait_selection/solve/... rustc_next_trait_solver/solve/...`, but I had already done all the work by that point. Luckily, `git` understands the file moves so it should still be relatively reviewable.

If this is still very difficult to review, then I can do some rebasing magic to try to separate this out. Please let me know!

r? lcnr
2024-06-18 19:41:33 +00:00
Guillaume Gomez
62431b73e0 Migrate run-make/compressed-debuginfo to rmake.rs 2024-06-18 21:32:24 +02:00
Oneirical
977d3f6f96 use llvm_readobj in run-make test instead of nm 2024-06-18 14:57:00 -04:00
Oneirical
c1597f9039 try implementing suggestions 2024-06-18 14:43:35 -04:00
Oneirical
83cb760e2c run_make_support nm implementation + bin-emit-no-symbols rmake rewrite 2024-06-18 14:38:33 -04:00
Oneirical
78998f3fea rewrite allocator-shim-circular-deps to ui test 2024-06-18 14:25:59 -04:00
Oneirical
03a4259c8b Rewrite lto-readonly-lib to rmake 2024-06-18 12:55:44 -04:00
Oneirical
594135ea37 Rewrite ls-metadata to rmake 2024-06-18 12:54:55 -04:00
Oneirical
fa2b612213 Rewrite link-args-order to rmake 2024-06-18 12:54:53 -04:00
bors
dd104ef163 Auto merge of #126623 - oli-obk:do_not_count_errors, r=davidtwco
Replace all `&DiagCtxt` with a `DiagCtxtHandle<'_>` wrapper type

r? `@davidtwco`

This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle

Basically I will add a field to the `DiagCtxtHandle` that refers back to the `InferCtxt`'s (and others) `Option<ErrorHandled>`, allowing us to immediately taint these contexts when emitting an error and not needing manual tainting anymore (which is easy to forget and we don't do in general anyway)
2024-06-18 16:49:19 +00:00