Commit Graph

31343 Commits

Author SHA1 Message Date
Nicholas Nethercote
cf9484e615 Remove -Zreport-delayed-bugs.
It's not used within the repository in any way (e.g. in tests), and
doesn't seem useful.
2024-01-04 17:16:07 +11:00
bors
e51e98dde6 Auto merge of #119251 - Enselic:rustc_lint-query-stability, r=cjgillot
rustc_lint: Enforce `rustc::potential_query_instability` lint

Stop allowing `rustc::potential_query_instability` on all of `rustc_lint` and instead allow it on a case-by-case basis if it is safe to do so. In this particular crate, all lints were safe to allow.

Part of https://github.com/rust-lang/rust/issues/84447 which is E-help-wanted.
2023-12-31 17:31:09 +00:00
Martin Nordholts
295d6003ac rustc_lint: Enforce rustc::potential_query_instability lint
Stop allowing `rustc::potential_query_instability` on all of
`rustc_lint` and instead allow it on a case-by-case basis if it is safe
to do so. In this particular crate, all lints were safe to allow.
2023-12-31 14:50:57 +01:00
Martin Nordholts
231dbbcb6a rustc_lint: Make LintLevelsProvider::current_specs() return &FxIndexMap
So that lint iteration order becomes predicitable. Discovered with
`rustc::potential_query_instability`.
2023-12-31 14:35:28 +01:00
bjorn3
d1d134e464 Merge commit '6d355f6844323db03bfd608899613e363e701951' into sync_cg_clif-2023-12-31 2023-12-31 13:29:53 +00:00
bors
64d5515cc3 Auto merge of #119447 - Nilstrieb:STACKOVERFLOW, r=compiler-errors
Fix `<BoundConstness as Display>`

There was infinite recursion, which is not very good. I'm not sure what the best way to implement this is, I just did something that felt right.

r? `@fmease`
2023-12-31 00:43:25 +00:00
bors
d868bc2842 Auto merge of #119284 - Nadrieril:fix-bodiless-arm-parse, r=cjgillot
Don't drop a hir node after lowering

Fixes https://github.com/rust-lang/rust/issues/119271.

It seems that all hir nodes that get allocated an id must be placed within the hir on pain of ICEs. In https://github.com/rust-lang/rust/pull/118527 I dropped guards on never patterns since they're not useful, which caused the ICE.
2023-12-30 22:44:33 +00:00
bors
2a3e63551f Auto merge of #119443 - Urgau:move-around-builtin-diag-context, r=Nilstrieb
Move around the code responsible for decorating builtin diagnostics

This PR move the code responsible for decorating builtin diagnostics into a separate sub-module for ease of use and readability.

While my original intention was to also move the check-cfg unexpected logic in their own function I changed my mind after moving the match altogether. I can move those if desired.

Fixes https://github.com/rust-lang/rust/pull/119425#discussion_r1438446596

r? `@Nilstrieb`
2023-12-30 20:41:15 +00:00
bors
5a345b325b Auto merge of #119446 - Nilstrieb:bitflags2.0-hell, r=compiler-errors
Update to bitflags 2 in the compiler

This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually.

Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.

r? compiler
2023-12-30 18:39:57 +00:00
Nilstrieb
ffafcd8819 Update to bitflags 2 in the compiler
This involves lots of breaking changes. There are two big changes that
force changes. The first is that the bitflag types now don't
automatically implement normal derive traits, so we need to derive them
manually.

Additionally, bitflags now have a hidden inner type by default, which
breaks our custom derives. The bitflags docs recommend using the impl
form in these cases, which I did.
2023-12-30 18:17:28 +01:00
Nilstrieb
e36a24ec8f Fix <BoundConstness as Display>
There was infinite recursion, which is not very good. I'm not sure what
the best way to implement this is, I just did something that felt right.
2023-12-30 17:22:20 +01:00
Urgau
429287243b Move around the code responsible for decorating builtin diagnostics 2023-12-30 16:17:14 +01:00
bors
e45a937a11 Auto merge of #119438 - Zalathar:prepare-mappings, r=cjgillot
coverage: Prepare mappings separately from injecting statements

These two tasks historically needed to be interleaved, but after various recent changes (including #116046 and #116917) they can now be fully separated.

---

`@rustbot` label +A-code-coverage
2023-12-30 13:39:44 +00:00
bors
d59f06fc64 Auto merge of #119437 - matthiaskrgr:rollup-esf96p6, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #119158 (Clean up alloc::sync::Weak Clone implementation)
 - #119386 (fix typo in `IpAddr::to_canonical`)
 - #119413 (solaris support on bootstrap lock)
 - #119424 (Primitive docs: fix confusing `Send` in `&T`'s list)
 - #119425 (Fix invalid check-cfg Cargo feature diagnostic help)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-30 11:40:42 +00:00
Zalathar
3f67118ae7 coverage: Make coverage_counters a local variable
This avoids the awkwardness of having to create it in the pass's constructor,
and then mutate it later to actually create the counters.
2023-12-30 22:36:11 +11:00
Zalathar
e1a2babc06 coverage: Prepare mappings separately from injecting statements
These two tasks historically needed to be interleaved, but after various recent
changes (including #116046 and #116917) they can now be fully separated.
2023-12-30 22:34:15 +11:00
Matthias Krüger
e930ea274e
Rollup merge of #119425 - Urgau:check-cfg-fix-cargo-diag-bug, r=Nilstrieb
Fix invalid check-cfg Cargo feature diagnostic help

#118213 added specialized diagnostic for Cargo `feature` cfg. However when providing an empty `#[cfg(feature)]` condition the suggestion would suggest adding `feature` as a feature in `Cargo.toml` (wtf!).

This PR removes the invalid logic, which even brings a nice improvement.

```diff
   --> $DIR/cargo-feature.rs:18:7
    |
 LL | #[cfg(feature)]
-   |       ^^^^^^^
+   |       ^^^^^^^- help: specify a config value: `= "bitcode"`
    |
    = note: expected values for `feature` are: `bitcode`
-   = help: consider defining `feature` as feature in `Cargo.toml`
```

The first commit add a test showing the bug and the second commit fixes the bug.

`@rustbot` label +F-check-cfg
2023-12-30 11:42:04 +01:00
bors
c2354aabea Auto merge of #119377 - tmiasko:after, r=cjgillot
Don't validate / lint MIR before each pass

To avoid redundant work and verbose output in case of failures.
2023-12-30 09:42:05 +00:00
bors
ddca5343f2 Auto merge of #118705 - WaffleLapkin:codegen-atomic-exhange-untuple, r=cjgillot
Change `rustc_codegen_ssa`'s `atomic_cmpxchg` interface to return a pair of values

Doesn't change much, but a little nicer that way.
2023-12-30 07:42:19 +00:00
bors
fe2cfd4505 Auto merge of #119367 - Mark-Simulacrum:relative-spans, r=wesleywiser
Shrink span encoding further

Spans are now stored in a more compact form which cuts down on at least 1 byte per span (indirect/direct encoding) and at most 3 bytes per span (indirect/direct encoding, context byte, length byte). As a result, libcore metadata shrinks by 1.5MB.

I'm not a huge fan of the fairly manual encoding/decoding from bits implemented here. Something like Tokio's pack abstraction (https://github.com/tokio-rs/tokio/blob/master/tokio/src/util/bit.rs) might be desirable to cut down on some of the shifting etc. We might also say that this isn't worth doing :)

I took a look at copying the span encoding we use in memory (described [here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/span_encoding.rs)). I think the format there makes a lot more sense for in-memory storage where prioritizing a fixed length (i.e., 4 or 8 bytes) is much more important. In metadata, it's much easier for us to have variable-length values, so there's less of a cliff if we don't quite fit. The bit packing scheme there would need changes to fit the varint scheme since it has a lot of all-1s patterns as the "relative offset" form.
2023-12-30 05:43:39 +00:00
bors
8d76d07666 Auto merge of #116012 - cjgillot:gvn-const, r=oli-obk
Implement constant propagation on top of MIR SSA analysis

This implements the idea I proposed in https://github.com/rust-lang/rust/pull/110719#issuecomment-1718324700

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

The value numbering "GVN" pass formulates each rvalue that appears in MIR with an abstract form (the `Value` enum), and assigns an integer `VnIndex` to each. This abstract form can be used to deduplicate values, reusing an earlier local that holds the same value instead of recomputing. This part is proposed in #109597.

From this abstract representation, we can perform more involved simplifications, for example in https://github.com/rust-lang/rust/pull/111344.

With the abstract representation `Value`, we can also attempt to evaluate each to a constant using the interpreter. This builds a `VnIndex -> OpTy` map. From this map, we can opportunistically replace an operand or a rvalue with a constant if their value has an associated `OpTy`.

The most relevant commit is [Evaluated computed values to constants.](2767c4912e)"

r? `@oli-obk`
2023-12-30 03:45:58 +00:00
Mark Rousskov
09e619d62e Shrink span encoding further
Spans are now stored in a more compact form which cuts down on at least
1 byte per span (indirect/direct encoding) and at most 3 bytes per span
(indirect/direct encoding, context byte, length byte). As a result,
libcore metadata shrinks by 1.5MB.
2023-12-29 21:52:53 -05:00
Urgau
a25e0236df Fix invalid check-cfg Cargo feature diagnostic help 2023-12-30 01:06:03 +01:00
Matthias Krüger
c8d42740c5
Rollup merge of #119388 - Enselic:prevent-lint-triplication, r=cjgillot
rustc_lint: Prevent triplication of various lints

Prevent triplication of various lints. The triplication happens because we run the same lint three times (or less in some cases):
* In `BuiltinCombinedPreExpansionLintPass`
* In `BuiltinCombinedEarlyLintPass`
* In `shallow_lint_levels_on()`

Only run the lints one time by checking the `lint_added_lints` bool.

Set your GitHub diff setting to ignore whitespaces changes when reviewing this PR, since I had to enclose a block inside an if.

Closes #73301

(I found this while exploring the code related to [this](https://github.com/rust-lang/rust/pull/119251#discussion_r1435677330) comment.)
2023-12-29 21:40:23 +01:00
Matthias Krüger
b75ba15062
Rollup merge of #119322 - compiler-errors:async-gen-resume-ty, r=cjgillot
Couple of random coroutine pass simplifications

Just aesthetic changes, except for a random `Ty::new_task_context(tcx)` call that was redundant.
2023-12-29 21:40:22 +01:00
bors
3cdd004e55 Auto merge of #118911 - Young-Flash:fix_issue_118819, r=fmease
fix: correct the args for `disambiguate the associated function` diagnostic

This is somehow silimar to https://github.com/rust-lang/rust/pull/118502, we shouldn't take receiver as first arg all the cases.

close https://github.com/rust-lang/rust/issues/118819
2023-12-29 18:39:23 +00:00
bors
dc450f9dcb Auto merge of #119259 - cjgillot:single-crate-id, r=Mark-Simulacrum
Only store StableCrateId once in DefPathTable.

https://github.com/rust-lang/rust/pull/119238 made me think of this.

cc `@Mark-Simulacrum`
2023-12-29 14:37:40 +00:00
Matthias Krüger
efd9fd66ba
Rollup merge of #119402 - est31:fix_if_guard_unused, r=compiler-errors
Also walk bindings created by if-let guards

This change makes the `unused_variables` lint pick up unused bindings created by if-let guards.

Fixes #119383
2023-12-29 11:19:28 +01:00
Matthias Krüger
4b9a76cddf
Rollup merge of #119401 - Zalathar:query-stability, r=Nilstrieb
coverage: Avoid a possible query stability hazard in `CoverageCounters`

#119252 revealed a possible query stability hazard in `CoverageCounters`: we iterate over the entries of an `FxHashMap` in a way that allows the iteration order to potentially affect the relative creation order of MIR blocks.

I'm not sure whether there's an actual stability problem or not in practice, but it's certainly a hazard, and I don't see any reason not to switch over to `FxIndexMap` to avoid potential issues.

---

This can either be merged on its own, or incorporated into #119252.

cc `@Enselic`
r? `@cjgillot`
2023-12-29 11:19:28 +01:00
Matthias Krüger
12ad777221
Rollup merge of #119393 - DaniPopes:unmap-a-filter, r=Nilstrieb
Use filter instead of filter_map in Parser::expected_one_of_not_found
2023-12-29 11:19:27 +01:00
Matthias Krüger
559c864904
Rollup merge of #119375 - Swatinem:merge-coroutine-lowering, r=compiler-errors
Merge Coroutine lowering functions

Instead of having separate `make_async/etc_expr` functions, this merges them them into one, reducing code duplication a bit.
2023-12-29 11:19:27 +01:00
bors
95613d1b23 Auto merge of #119392 - compiler-errors:args-parts, r=Nilstrieb
make `ClosureArgsParts` and `CoroutineArgsParts` not generic

I hope a few extra calls to `expect_ty` will not affect perf...
2023-12-29 04:21:41 +00:00
est31
ab60a7df64 Also walk bindings created by if-let guards 2023-12-29 03:38:09 +01:00
bors
dfb1f5e37b Auto merge of #119395 - Nilstrieb:walk-pat, r=est31
Use `Pat::walk_always` instead of manual walk

It's also a bit faster, but I doubt that it will have a noticeable perf impact. Mostly doing it because it's shorter and nicer.
2023-12-29 02:03:10 +00:00
Zalathar
8529b63e2b coverage: Avoid a possible query stability hazard in CoverageCounters
The iteration order of this hashmap can potentially affect the relative
creation order of MIR blocks.
2023-12-29 12:33:52 +11:00
Michael Goulet
d71f7be218 Couple of random coroutine pass simplifications 2023-12-29 00:19:33 +00:00
Nilstrieb
8fe4d0d156 Use Pat::walk_always instead of manual walk 2023-12-28 23:21:55 +01:00
bors
fb5ed726f7 Auto merge of #119174 - compiler-errors:movability, r=cjgillot
Remove movability from `TyKind::Coroutine`

There's no reason to store movability in the generator struct directly. It is computed from the HIR, and can be pulled into a query to access when necessary.
2023-12-28 20:41:44 +00:00
Arpad Borsos
2480a0f3f6
Merge Coroutine lowering functions
Instead of having separate `make_async/etc_expr` functions, this merges them them into one, reducing code duplication a bit.
2023-12-28 21:24:24 +01:00
DaniPopes
c7a67747d3
Use filter instead of filter_map in Parser::expected_one_of_not_found 2023-12-28 21:19:41 +01:00
Michael Goulet
2b69399fea make ClosureArgsParts not generic 2023-12-28 20:17:09 +00:00
Martin Nordholts
7ca4e9fcb2 rustc_lint: Prevent triplication of 'unknown lint' lint 2023-12-28 19:46:51 +01:00
Martin Nordholts
741884dab2 rustc_lint: Prevent multiple 'incompatible with previous forbid' lints 2023-12-28 19:46:40 +01:00
Martin Nordholts
e0c626fbbc rustc_lint: Prevent multiple 'lint ignored' lints
Prevent multiple 'ignored unless specified at crate level' lints. The
multiplication happens because we run the same lint three times:
* In BuiltinCombinedEarlyLintPass
* In BuiltinCombinedPreExpansionLintPass
* In shallow_lint_levels_on

Only run the lint one time by checking the `lint_added_lints` bool.
2023-12-28 19:46:40 +01:00
Martin Nordholts
eef02c453f rustc_lint: Rename warn_about_weird_lints to lint_added_lints
So we can apply more kinds of lints to added lints without having to add
another parameter.
2023-12-28 19:46:40 +01:00
Martin Nordholts
a4bcd479cc rustc_error_codes: Update expected error in E0453.md 2023-12-28 19:46:40 +01:00
Matthias Krüger
e8831b6df8
Rollup merge of #119380 - ShE3py:match-never-pat, r=petrochenkov
Don't suggest writing a bodyless arm if the pattern can never be a never pattern

#118527 enabled arms to be bodyless for never patterns ; this PR removes the `,` and `}` suggestions for patterns that could never be never patterns.
2023-12-28 18:48:02 +01:00
Matthias Krüger
0b6e8f5324
Rollup merge of #119379 - ShE3py:parse-seq-doc, r=compiler-errors
Update `parse_seq` doc

Some doc changes I made while working on an issue.
2023-12-28 18:48:01 +01:00
Matthias Krüger
54bcb07ab1
Rollup merge of #119359 - DaniPopes:ident-or-err, r=compiler-errors
Simplify Parser::ident_or_error

Avoid a nested `Result<T, PResult<T>>`.
2023-12-28 18:48:01 +01:00
Michael Goulet
e24da8ea19 Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00