Commit graph

256500 commits

Author SHA1 Message Date
Matthias Krüger
7667a91778
Rollup merge of #125756 - Zalathar:branch-on-bool, r=oli-obk
coverage: Optionally instrument the RHS of lazy logical operators

(This is an updated version of #124644 and #124402. Fixes #124120.)

When `||` or `&&` is used outside of a branching context (such as the condition of an `if`), the rightmost value does not directly influence any branching decision, so branch coverage instrumentation does not treat it as its own true-or-false branch.

That is a correct and useful interpretation of “branch coverage”, but might be undesirable in some contexts, as described at #124120. This PR therefore adds a new coverage level `-Zcoverage-options=condition` that behaves like branch coverage, but also adds additional branch instrumentation to the right-hand-side of lazy boolean operators.

---

As discussed at https://github.com/rust-lang/rust/issues/124120#issuecomment-2092394586, this is mainly intended as an intermediate step towards fully-featured MC/DC instrumentation. It's likely that we'll eventually want to remove this coverage level (rather than stabilize it), either because it has been incorporated into MC/DC instrumentation, or because it's getting in the way of future MC/DC work. The main appeal of landing it now is so that work on tracking conditions can proceed concurrently with other MC/DC-related work.

````@rustbot```` label +A-code-coverage
2024-05-31 17:05:24 +02:00
Matthias Krüger
e9046602c5
Rollup merge of #125730 - mu001999-contrib:clippy-fix, r=oli-obk
Apply `x clippy --fix` and `x fmt` on Rustc

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Just run `x clippy --fix` and `x fmt`, and remove some changes like `impl Default`.
2024-05-31 17:05:24 +02:00
Matthias Krüger
4b41136a47
Rollup merge of #125652 - amandasystems:you-dropped-something, r=oli-obk
Revert propagation of drop-live information from Polonius

#64749 introduced a flow of drop-use data from Polonius to `LivenessResults::add_extra_drop_facts()`, which makes `LivenessResults` agree with Polonius on liveness in the presence of free regions that may be dropped. Later changes accidentally removed this flow. This PR restores it.
2024-05-31 17:05:23 +02:00
Michael Goulet
20699fe6b2 Stop using translate_args in the new solver 2024-05-31 09:42:30 -04:00
bors
2a2c29aafa Auto merge of #125759 - nnethercote:format-some-tests, r=GuillaumeGomez
Format some tests

There are more directories under `tests/` still to do, but this is enough for one PR.

r? `@GuillaumeGomez`
2024-05-31 12:18:57 +00:00
Zalathar
54b6849e06 Remove unused rust-demangler support from compiletest 2024-05-31 21:52:45 +10:00
Zalathar
feb8f3cc5d Use Builder::tool_exe to build the coverage-dump tool
This appears to be the canonical way to build a tool with the stage 0 compiler.
2024-05-31 21:52:45 +10:00
Zalathar
10ffc228a8 Use coverage-dump --demangle as the demangler for coverage-run tests
This avoids the need to build `rust-demangler` when running coverage tests,
since we typically need to build `coverage-dump` anyway.
2024-05-31 21:52:45 +10:00
Zalathar
9abfebdf1e Add an alternate --demangle mode to coverage-dump
The coverage-dump tool already needs `rustc_demangle` for its own purposes, so
the amount of extra code needed for a demangle mode is very small.
2024-05-31 21:52:45 +10:00
Nicholas Nethercote
0ea498aa9f Explain why we don't run rustfmt on tests/incremental/. 2024-05-31 21:30:22 +10:00
Nicholas Nethercote
d71a015d01 Explain why we don't run rustfmt on tests/debuginfo/. 2024-05-31 21:30:22 +10:00
Nicholas Nethercote
3079bd96b9 Run rustfmt on tests/run-make/.
With the exception of `tests/run-make/translation/test.rs`, which has a
syntax error.

The expected output in `rustdoc-error-lines/rmake.rs`'s required slight
tweaking.

The two `reproducible-build.rs` files need `// ignore-tidy-linelength`
because rustfmt produces lines longer than 100 chars, which tidy doesn't
like, yuk.
2024-05-31 21:30:08 +10:00
bors
99cb42c296 Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk
Implement `needs_async_drop` in rustc and optimize async drop glue

This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948.

Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](67980dd6fb/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-31 10:12:24 +00:00
Oli Scherer
befcdec777 Check that we can constrain the hidden tpye of a TAIT used in a const generic type 2024-05-31 08:58:56 +00:00
Oli Scherer
06c4cc44b6 Also resolve the type of constants, even if we already turned it into an error constant 2024-05-31 08:56:38 +00:00
bors
bf8fff783f Auto merge of #125797 - matthiaskrgr:rollup-v2jmg7i, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #125635 (Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup)
 - #125774 (Avoid unwrap diag.code directly in note_and_explain_type_err)
 - #125786 (Fold item bounds before proving them in `check_type_bounds` in new solver)
 - #125790 (Don't recompute `tail` in `lower_stmts`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-31 07:52:58 +00:00
Matthias Krüger
c11e057989
Rollup merge of #125790 - WaffleLapkin:no-tail-recomputation-in-lower-stmts, r=lcnr
Don't recompute `tail` in `lower_stmts`

Does not really matter, but this is slightly nicer.

`@bors` rollup
2024-05-31 08:50:24 +02:00
Matthias Krüger
ab55d42b74
Rollup merge of #125786 - compiler-errors:fold-item-bounds, r=lcnr
Fold item bounds before proving them in `check_type_bounds` in new solver

Vaguely confident that this is sufficient to prevent rust-lang/trait-system-refactor-initiative#46 and rust-lang/trait-system-refactor-initiative#62.

This is not the "correct" solution, but will probably suffice until coinduction, at which point we implement the right solution (`check_type_bounds` must prove `Assoc<...> alias-eq ConcreteType`, normalizing requires proving item bounds).

r? lcnr
2024-05-31 08:50:23 +02:00
Matthias Krüger
4aafc1175e
Rollup merge of #125774 - mu001999-contrib:fix/125757, r=compiler-errors
Avoid unwrap diag.code directly in note_and_explain_type_err

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Fixes #125757
2024-05-31 08:50:23 +02:00
Matthias Krüger
379233242b
Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors
Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup

Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology.

Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense.

---

Old terminology (HIR, rustdoc):

```
`TypeBinding`: (associated) type binding
├── `Constraint`: associated type bound
└── `Equality`: (associated) equality constraint (?)
    ├── `Ty`: (associated) type binding
    └── `Const`: associated const equality (constraint)
```

Old terminology (AST, abbrev.):

```
`AssocConstraint`
├── `Bound`
└── `Equality`
    ├── `Ty`
    └── `Const`
```

New terminology (AST, HIR, rustdoc):

```
`AssocItemConstraint`: associated item constraint
├── `Bound`: associated type bound
└── `Equality`: associated item equality constraint OR associated item binding (for short)
    ├── `Ty`: associated type equality constraint OR associated type binding (for short)
    └── `Const`: associated const equality constraint OR associated const binding (for short)
```

r? compiler-errors
2024-05-31 08:50:22 +02:00
Nicholas Nethercote
70bc0c5b20 Explain why we don't run rustfmt on tests/crashes/. 2024-05-31 15:56:45 +10:00
Nicholas Nethercote
4fd2003026 Run rustfmt on tests/coverage-run-rustdoc/.
There are only two tiny Rust files in this directory, and they are
already formatted correctly.
2024-05-31 15:56:45 +10:00
Nicholas Nethercote
e86709c58a Run rustfmt on tests/coverage/.
There are no changes to `.rs` files because #125693 recently formatted
them all.
2024-05-31 15:56:45 +10:00
Nicholas Nethercote
780a91786e Run rustfmt on tests/codegen-units/. 2024-05-31 15:56:45 +10:00
Nicholas Nethercote
72800d3b89 Run rustfmt on tests/codegen/.
Except for `simd-intrinsic/`, which has a lot of files containing
multiple types like `u8x64` which really are better when hand-formatted.

There is a surprising amount of two-space indenting in this directory.

Non-trivial changes:
- `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the
  test.
- `rustfmt::skip` used in a few places where hand-formatting read more
  nicely: `enum/enum-match.rs`
- Line number adjustments needed for the expected output of
  `debug-column.rs` and `coroutine-debug.rs`.
2024-05-31 15:56:43 +10:00
Scott McMurray
4b96e44ebb Also InstSimplify &raw*
We do this for `&*` and `&mut*` already; might as well do it for raw pointers too.
2024-05-30 22:05:30 -07:00
Henry Chen
772e48cfbb minor: replace command-group with process-wrap
Because command-group no longer receives updates and depends on an
older version of nix.
2024-05-31 12:43:40 +08:00
Lucas Scharenbroch
9af96745d6 Update ui tests for leading-underscore suggestion 2024-05-30 21:39:41 -05:00
Lucas Scharenbroch
08fe940f0a Improve renaming suggestion for names with leading underscores 2024-05-30 21:39:12 -05:00
Lokathor
94d4040925 The modern styling is apparently to use Title Case for the chip/company, "Arm". 2024-05-30 19:34:05 -06:00
bors
366da30d55 Auto merge of #125794 - cjgillot:revert-115105, r=compiler-errors
Revert "Auto merge of #115105 - cjgillot:dest-prop-default, r=oli-obk"

This reverts commit cfb730450f, reversing changes made to 91c0823ee6.

To address https://github.com/rust-lang/rust/pull/115105#issuecomment-2141019310
r? `@oli-obk`

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-05-31 00:39:27 +00:00
r0cky
ed5205fe66 Avoid unwrap diag.code directly 2024-05-31 08:29:42 +08:00
Camille GILLOT
e110567dcd Revert "Auto merge of #115105 - cjgillot:dest-prop-default, r=oli-obk"
This reverts commit cfb730450f, reversing
changes made to 91c0823ee6.
2024-05-31 00:22:40 +00:00
Waffle Maybe
86afea97fd
Don't recompute tail in lower_stmts 2024-05-31 00:46:07 +02:00
bors
434999efe6 Auto merge of #125710 - RalfJung:compiletest-components, r=workingjubilee
compiletest: clarify COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS error

COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS is a confusing name because elsewhere "needs" means "ignore when requirement not met", but here it means "fail when requirement not met".
2024-05-30 21:51:24 +00:00
León Orell Valerian Liehr
34c56c45cf
Rename HIR TypeBinding to AssocItemConstraint and related cleanup 2024-05-30 22:52:33 +02:00
Michael Goulet
5c68eb3fac Add a bunch of tests 2024-05-30 15:52:29 -04:00
Michael Goulet
2f4b7dc047 Fold item bound before checking that they hold 2024-05-30 15:52:29 -04:00
Oneirical
836c08ed21 rewrite mixing-formats test 2024-05-30 15:08:45 -04:00
Oneirical
5db8552b20 rewrite bare-outfile test 2024-05-30 15:08:45 -04:00
Oneirical
1e3e3df81e rewrite emit test 2024-05-30 15:08:45 -04:00
bors
6f3df08aad Auto merge of #125378 - lcnr:tracing-no-lines, r=oli-obk
remove tracing tree indent lines

This allows vscode to collapse nested spans without having to manually remove the indent lines. This is incredibly useful when logging the new solver. I don't mind making them optional depending on some environment flag if you prefer using indent lines

For a gist of the new output, see https://gist.github.com/lcnr/bb4360ddbc5cd4631f2fbc569057e5eb#file-example-output-L181

r? `@oli-obk`
2024-05-30 18:57:48 +00:00
bors
7feb191f18 Auto merge of #125764 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2024-05-30 16:46:31 +00:00
bors
cfb730450f Auto merge of #115105 - cjgillot:dest-prop-default, r=oli-obk
Enable DestinationPropagation by default.

~~Based on https://github.com/rust-lang/rust/pull/115291.~~

This PR proposes to enable the destination propagation pass by default.
This pass is meant to reduce the amount of copies present in MIR.

At the same time, this PR removes the `RenameReturnPlace` pass, as it is currently unsound.
`DestinationPropagation` is not limited to `_0`, but does not handle borrowed locals.
2024-05-30 14:27:46 +00:00
lcnr
8160974ce8 ignore whitespace in ldd tests 2024-05-30 15:28:03 +02:00
lcnr
aa8f995b89 add info to rust-ldd tests failures 2024-05-30 15:26:49 +02:00
lcnr
86cbabbb9d add logging to search graph 2024-05-30 15:26:48 +02:00
lcnr
f7d14b741e update UI tests 2024-05-30 15:26:48 +02:00
lcnr
97d2c3a6a7 remove tracing tree indent lines 2024-05-30 15:26:48 +02:00
bors
91c0823ee6 Auto merge of #124636 - tbu-:pr_env_unsafe, r=petrochenkov
Make `std::env::{set_var, remove_var}` unsafe in edition 2024

Allow calling these functions without `unsafe` blocks in editions up until 2021, but don't trigger the `unused_unsafe` lint for `unsafe` blocks containing these functions.

Fixes #27970.
Fixes #90308.
CC #124866.
2024-05-30 12:17:06 +00:00