Commit Graph

5405 Commits

Author SHA1 Message Date
bors
274455a9d1 Auto merge of #116965 - estebank:issue-65329, r=cjgillot
Move where doc comment meant as comment check

The new place makes more sense and covers more cases beyond individual statements.

```
error: expected one of `.`, `;`, `?`, `else`, or an operator, found doc comment `//!foo
  --> $DIR/doc-comment-in-stmt.rs:25:22
   |
LL |     let y = x.max(1) //!foo
   |                      ^^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator
   |
help: add a space before `!` to write a regular comment
   |
LL |     let y = x.max(1) // !foo
   |                        +
```

Fix #65329.
2023-10-20 13:02:11 +00:00
bors
7849162ace Auto merge of #116899 - compiler-errors:closure-sig-infer, r=lcnr
Add a test showing failing closure signature inference in new solver

Been thinking a bit about how to make this test pass... but we don't actually have any good tests exercising this behavior in the suite.

r? lcnr
2023-10-20 05:55:25 +00:00
Esteban Küber
20de5c762d Move where doc comment meant as comment check
The new place makes more sense and covers more cases beyond individual
statements.

```
error: expected one of `.`, `;`, `?`, `else`, or an operator, found doc comment `//!foo
  --> $DIR/doc-comment-in-stmt.rs:25:22
   |
LL |     let y = x.max(1) //!foo
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator
   |
help: add a space before `!` to write a regular comment
   |
LL |     let y = x.max(1) // !foo
   |                        +
```

Fix #65329.
2023-10-20 02:54:45 +00:00
bors
ae466d2d0a Auto merge of #116838 - gurry:116836-dup-macro-invoc-diag, r=petrochenkov
Fix duplicate labels emitted in `render_multispan_macro_backtrace()`

This PR replaces the `Vec` used to store labels with an `FxIndexSet` in order to eliminate duplicates

Fixes #116836
2023-10-20 02:07:05 +00:00
bors
94c4e5c411 Auto merge of #115214 - Urgau:rfc-3127-trim-paths, r=compiler-errors
Implement rustc part of RFC 3127 trim-paths

This PR implements (or at least tries to) [RFC 3127 trim-paths](https://github.com/rust-lang/rust/issues/111540), the rustc part. That is `-Zremap-path-scope` with all of it's components/scopes.

`@rustbot` label: +F-trim-paths
2023-10-19 19:09:29 +00:00
Camille GILLOT
328192bff4 FileCheck transmute. 2023-10-19 15:51:54 +00:00
Camille GILLOT
69d9369f0c FileCheck inline_shims. 2023-10-19 15:51:54 +00:00
Camille GILLOT
13683554ed FileCheck issue_106141. 2023-10-19 15:51:54 +00:00
Camille GILLOT
c679b208d2 Mention skip in README. 2023-10-19 15:51:54 +00:00
Camille GILLOT
d24e44a07e FileCheck lower_slice_len. 2023-10-19 15:51:54 +00:00
Camille GILLOT
ad057d4397 FileCheck lower_array_len. 2023-10-19 15:51:54 +00:00
Camille GILLOT
4bae847969 FileCheck lower_intrinsics. 2023-10-19 15:51:54 +00:00
Camille GILLOT
d8cffda66a FileCheck casts. 2023-10-19 15:51:54 +00:00
Camille GILLOT
68c409f8f6 FileCheck combine_transmutes. 2023-10-19 15:51:54 +00:00
Camille GILLOT
386fff34f7 FileCheck duplicate_switch_targets. 2023-10-19 15:51:54 +00:00
Camille GILLOT
f856247cc9 FileCheck intrinsic_asserts. 2023-10-19 15:51:54 +00:00
Camille GILLOT
ddc328c2f1 FileCheck combine_clone_of_primitives. 2023-10-19 15:51:54 +00:00
Camille GILLOT
5453a4f056 FileCheck bool_compare. 2023-10-19 15:51:53 +00:00
Camille GILLOT
f0690d5232 FileCheck combine_array_len. 2023-10-19 15:51:53 +00:00
Camille GILLOT
d6f4bd5a8d Add README. 2023-10-19 15:51:53 +00:00
Camille GILLOT
38bf660771 FileCheck box_expr.rs
This check is made `needs-unwind`, as the panic=abort case is a strictly
simpler version.
2023-10-19 15:51:53 +00:00
Camille GILLOT
f65eb1f752 FileCheck basic_assignment.rs. 2023-10-19 15:51:53 +00:00
Camille GILLOT
00a7958e79 FileCheck asm_unwind_panic_abort.rs 2023-10-19 15:51:53 +00:00
Camille GILLOT
47fa01d2b8 FileCheck array_index_is_temporary.rs 2023-10-19 15:51:53 +00:00
Camille GILLOT
8daf14f046 Run filecheck on reference_prop.rs 2023-10-19 15:51:53 +00:00
Camille GILLOT
4ff03cd1a4 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
Matthias Krüger
096943a534
Rollup merge of #116896 - cjgillot:single-inline, r=oli-obk
Only check in a single place if a pass is enabled.

Fixes https://github.com/rust-lang/rust/issues/116294
2023-10-19 14:38:26 +02:00
bors
a01382dbea Auto merge of #116037 - wesleywiser:stack_protector_test_windows, r=cuviper
Add `-Zstack-protector` test for Windows targets

Add variants of the `stack-protector-heuristics-effect.rs` test for 32-bit and 64-bit MSVC Windows and update the original test to run on GNU Windows targets.

I added two tests instead of trying to modify the original because:
  - MSVC uses a different function name (`__security_check_cookie` to perform the test rather than doing the test inline and calling `__stack_chk_fail`).
  - LLVM's stack protection pass doesn't currently support generating checks for [frames with funclet based EH personality](37fd3c96b9/llvm/lib/CodeGen/StackProtector.cpp (L103C1-L109C4)).
  - 32-bit Windows uses classic EH while 64-bit Windows uses table-based EH which results in slightly different codegen.

[CI run with test passing on {i686,x86_64}-{msvc,mingw}](https://github.com/rust-lang/rust/actions/runs/6275450644/job/17042958375?pr=116037)
2023-10-19 07:50:09 +00:00
León Orell Valerian Liehr
64ed233fc1
Rollup merge of #116908 - estebank:issue-78206, r=compiler-errors
Tweak wording of type errors involving type params

Fix #78206.
2023-10-19 04:34:47 +02:00
León Orell Valerian Liehr
2eb6e5f740
Rollup merge of #116829 - fmease:rust-aint-c, r=compiler-errors
Make `#[repr(Rust)]` incompatible with other (non-modifier) representation hints like `C` and `simd`

Read more about this change here: https://github.com/rust-lang/rust/pull/116829#issuecomment-1768618240.

Fixes [after backport] #116825.
2023-10-19 04:34:46 +02:00
León Orell Valerian Liehr
2dd1c8f693
Rollup merge of #116663 - compiler-errors:resolve-regions, r=lcnr
Don't ICE when encountering unresolved regions in `fully_resolve`

We can encounter unresolved regions due to unconstrained impl lifetime arguments because `collect_return_position_impl_trait_in_trait_tys` runs before WF actually checks that the impl is well-formed.

Fixes #116525
2023-10-19 04:34:45 +02:00
Gurinder Singh
0091166b57 Fix duplicate labels emitted in render_multispan_macro_backtrace()
Using hash set instead of vec to weed out duplicates
2023-10-19 08:03:40 +05:30
Esteban Küber
bd8b46800d Tweak wording of type errors involving type params
Fix #78206.
2023-10-18 23:53:18 +00:00
bors
0039d739d4 Auto merge of #116493 - compiler-errors:coinductive-cycle-lint, r=lcnr
Bump `COINDUCTIVE_OVERLAP_IN_COHERENCE` to deny + warn in deps

1.73 is the first place this shows up in stable (recall that there was only 1 regression), so let's bump this to deny on nightly.

r? lcnr
2023-10-18 21:41:50 +00:00
Michael Goulet
ea73f10867 Don't ICE when encountering unresolved regions in fully_resolve 2023-10-18 20:39:29 +00:00
Michael Goulet
611766dcee Add a test showing failing closure signature inference in new solver 2023-10-18 18:59:02 +00:00
Michael Goulet
973d589582 Bump COINDUCTIVE_OVERLAP_IN_COHERENCE 2023-10-18 18:54:11 +00:00
bors
cc705b8012 Auto merge of #116046 - Zalathar:fn-cov-info, r=cjgillot
coverage: Move most per-function coverage info into `mir::Body`

Currently, all of the coverage information collected by the `InstrumentCoverage` pass is smuggled through MIR in the form of individual `StatementKind::Coverage` statements, which must then be reassembled by coverage codegen.

That's awkward for a number of reasons:
- While some of the coverage statements do care about their specific position in the MIR control-flow graph, many of them don't, and are just tacked onto the function's first BB as metadata carriers.
- MIR inlining can result in coverage statements being duplicated, so coverage codegen has to jump through hoops to avoid emitting duplicate mappings.
- MIR optimizations that would delete coverage statements need to carefully copy them into the function's first BB so as not to omit them from coverage reports.
- The order in which coverage codegen sees coverage statements is dependent on MIR optimizations/inlining, which can cause unnecessary churn in the emitted coverage mappings.
- We don't have a good way to annotate MIR-level functions with extra coverage info that doesn't belong in a statement.

---

This PR therefore takes most of the per-function coverage info and stores it in a field in `mir::Body` as `Option<Box<FunctionCoverageInfo>>`.

(This adds one pointer to the size of `mir::Body`, even when coverage is not enabled.)

Coverage statements still need to be injected into MIR in some cases, but only when they actually affect codegen (counters) or are needed to detect code that has been optimized away as unreachable (counters/expressions).

---

By the end of this PR, the information stored in `FunctionCoverageInfo` is:

- A hash of the function's source code (needed by LLVM's coverage map format)
- The number of coverage counters added by coverage instrumentation
- A table of coverage expressions, associating each expression ID with its operator (add or subtract) and its two operands
- The list of mappings, associating each covered code region with a counter/expression/zero value

---

~~This is built on top of #115301, so I'll rebase and roll a reviewer once that lands.~~
r? `@ghost`
`@rustbot` label +A-code-coverage
2023-10-18 18:48:34 +00:00
Camille GILLOT
c1c5a1d69a Only check in a single place if a pass is enabled. 2023-10-18 16:59:23 +00:00
León Orell Valerian Liehr
d0b99e3efe
Make #[repr(Rust)] and #[repr(C)] incompatible with one another 2023-10-18 17:25:23 +02:00
Zalathar
13b2d604ec coverage: Store expression data in function coverage info
Even though expression details are now stored in the info structure, we still
need to inject `ExpressionUsed` statements into MIR, because if one is missing
during codegen then we know that it was optimized out and we can remap all of
its associated code regions to zero.
2023-10-18 23:44:34 +11:00
Zalathar
6da319f635 coverage: Store all of a function's mappings in function coverage info
Previously, mappings were attached to individual coverage statements in MIR.
That necessitated special handling in MIR optimizations to avoid deleting those
statements, since otherwise codegen would be unable to reassemble the original
list of mappings.

With this change, a function's list of mappings is now attached to its MIR
body, and survives intact even if individual statements are deleted by
optimizations.
2023-10-18 23:42:39 +11:00
Ali MJ Al-Nasrawy
8489bce7f5
Rollup merge of #116879 - aliemjay:revert-opaque-bubble, r=oli-obk
revert #114586

Reverts #114586.

cc #116877 (not closing until this gets a beta backport)
fixes #116684
fixes https://github.com/rust-lang/rust/pull/114586#issuecomment-1751967321

r? `@oli-obk` or `@lcnr`
2023-10-18 14:24:52 +03:00
Ali MJ Al-Nasrawy
d69cdb2ceb
Rollup merge of #116865 - estebank:issue-46969, r=compiler-errors
Suggest constraining assoc types in more cases

Fix #46969.

```
error[E0308]: mismatched types
  --> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:12:21
   |
LL |     const N: C::M = 4u8;
   |                     ^^^ expected associated type, found `u8`
   |
   = note: expected associated type `<C as O>::M`
                         found type `u8`
help: consider constraining the associated type `<C as O>::M` to `u8`
   |
LL | impl<C: O<M = u8>> U<C> for u16 {
   |          ++++++++

```
2023-10-18 14:24:51 +03:00
Ali MJ Al-Nasrawy
a536d58607
Rollup merge of #116856 - oli-obk:no_effects, r=compiler-errors
Disable effects in libcore again

r? `@fee1-dead`

This was accidentally allowed by https://github.com/rust-lang/rust/pull/114776 without feature gates
2023-10-18 14:24:51 +03:00
Ali MJ Al-Nasrawy
0653d7eebf
Rollup merge of #116812 - rmehri01:missing_copy_implementations_non_exhaustive, r=petrochenkov
Disable missing_copy_implementations lint on non_exhaustive types

Fixes #116766
2023-10-18 14:24:50 +03:00
bors
6d7160ce97 Auto merge of #116814 - estebank:windows-ice-path, r=petrochenkov
Use `YYYY-MM-DDTHH_MM_SS` as datetime format for ICE dump files

Windows paths do not support `:`, so use a datetime format in ICE dump paths that Windows will accept.

CC #116809, fix #115180.
2023-10-18 07:45:56 +00:00
Ali MJ Al-Nasrawy
a1e274f172 revert rust-lang/rust#114586 2023-10-18 06:19:04 +00:00
bors
b9832e72c9 Auto merge of #116713 - estebank:issue-116703, r=compiler-errors
Properly account for self ty in method disambiguation suggestion

Fix #116703.
2023-10-18 05:51:40 +00:00
Ben Kimock
a76cae0234 Bless coverage-map tests 2023-10-17 19:53:51 -04:00