Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #120711

Closed
wants to merge 29 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

oli-obk and others added 29 commits January 29, 2024 08:53
This makes it possible for two nodes/edges in the coverage graph to share the
same counter, without causing the instrumentor to inject unwanted duplicate
counter-increment statements.
And make sure all other imports have non-empty resolution lists.
It doesn't affect behaviour, but makes sense with (a) `FailureNote` having
`()` as its emission guarantee, and (b) in `Level` the `is_error` levels
now are all listed before the non-`is_error` levels.
I.e. `Bug` and `Fatal` level diagnostics are never downgraded.
- Combine two different blocks involving
  `diagnostic.level.get_expectation_id()` into one.
- Combine several `if`s involving `diagnostic.level` into a single
  `match`.

This requires reordering some of the operations, but this has no
functional effect.
The two kinds of delayed bug have quite different semantics so a
stronger conceptual separation is nice. (`is_error` is a good example,
because the two kinds have different behaviour.)

The commit also moves the `DelayedBug` variant after `Error` in `Level`,
to reflect the fact that it's weaker than `Error` -- it might trigger an
error but also might not. (The pre-existing `downgrade_to_delayed_bug`
function also reflects the notion that delayed bugs are lower/after
normal errors.)

Plus it condenses some of the comments on `Level` into a table, for
easier reading, and introduces `can_be_top_or_sub` to indicate which
levels can be used in top-level diagnostics vs. subdiagnostics.

Finally, it renames `DiagCtxtInner::span_delayed_bugs` as
`DiagCtxtInner::delayed_bugs`. The `span_` prefix is unnecessary because
some delayed bugs don't have a span.
All the other `emit`/`emit_diagnostic` methods were recently made
consuming (e.g. rust-lang#119606), but this one wasn't. But it makes sense to.

Much of this is straightforward, and lots of `clone` calls are avoided.
There are a couple of tricky bits.
- `Emitter::primary_span_formatted` no longer takes a `Diagnostic` and
  returns a pair. Instead it takes the two fields from `Diagnostic` that
  it used (`span` and `suggestions`) as `&mut`, and modifies them. This
  is necessary to avoid the cloning of `diag.children` in two emitters.
- `from_errors_diagnostic` is rearranged so various uses of `diag` occur
  before the consuming `emit_diagnostic` call.
Co-authored-by: Ralf Jung <post@ralfj.de>
…alfJung

various const interning cleanups

After rust-lang#119044 I noticed that some things can be simplified and refactored.

This is also a requirement for rust-lang#116564 as there we'll need to treat the base allocation differently from the others

r? ``@RalfJung``
…i-obk

Some cleanups around diagnostic levels.

Plus some refactoring in and around diagnostic levels and emission. Details in the individual commit logs.

r? ```@oli-obk```
…ructors, r=dtolnay,oli-obk

Make `NonZero` constructors generic.

This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax.

Tracking issue: rust-lang#120257

~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~

```rust
101 |         if n == T::ZERO {
    |            ^^^^^^^^^^^^ expected `host`, found `true`
    |
    = note: expected constant `host`
               found constant `true`
```

r? ``@dtolnay``
…ochenkov

Switch OwnedStore handle count to AtomicU32

This is already panics if overflowing a u32, so let's use the smaller int size to save a tiny bit of memory.
coverage: Split out counter increment sites from BCB node/edge counters

This makes it possible for two nodes/edges in the coverage graph to share the same counter, without causing the instrumentor to inject unwanted duplicate counter-increment statements.

---

``@rustbot`` label +A-code-coverage
…handling, r=estebank

Simplify codegen diagnostic handling

Some nice improvements. Details in the individual commit logs.

r? ```@estebank```
…in-pat, r=estebank

Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolved

Fixes rust-lang#120591.
~~Will conflict with rust-lang#120570~~ (rebased).

r? estebank or compiler
…r-errors

hir: Stop keeping prefixes for most of `use` list stems

And make sure all other imports have non-empty resolution lists.

Addresses one of FIXMEs in rust-lang#120206.
…rrors

pattern_analysis: gather up place-relevant info

We track 3 things about each place during exhaustiveness: its type, its (data) validity, and whether it's the scrutinee place. This PR gathers all three into a single struct.

r? ``@compiler-errors``
@rustbot rustbot added the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Feb 6, 2024
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Feb 6, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=9

@bors
Copy link
Contributor

bors commented Feb 6, 2024

📌 Commit 00794ce has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2024
@bors
Copy link
Contributor

bors commented Feb 6, 2024

⌛ Testing commit 00794ce with merge 65b0173...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#120302 (various const interning cleanups)
 - rust-lang#120520 (Some cleanups around diagnostic levels.)
 - rust-lang#120521 (Make `NonZero` constructors generic.)
 - rust-lang#120527 (Switch OwnedStore handle count to AtomicU32)
 - rust-lang#120564 (coverage: Split out counter increment sites from BCB node/edge counters)
 - rust-lang#120575 (Simplify codegen diagnostic handling)
 - rust-lang#120597 (Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolved)
 - rust-lang#120609 (hir: Stop keeping prefixes for most of `use` list stems)
 - rust-lang#120633 (pattern_analysis: gather up place-relevant info)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job dist-i586-gnu-i586-i686-musl failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [ui] tests/ui/print_type_sizes/niche-filling.rs stdout ----
diff of stdout:

- print-type-size type: `core::fmt::rt::Placeholder`: 56 bytes, alignment: 8 bytes
- print-type-size     field `.precision`: 16 bytes
- print-type-size     field `.width`: 16 bytes
- print-type-size     field `.position`: 8 bytes
+ print-type-size type: `core::fmt::rt::Placeholder`: 32 bytes, alignment: 4 bytes
+ print-type-size     field `.precision`: 8 bytes
+ print-type-size     field `.width`: 8 bytes
5 print-type-size     field `.fill`: 4 bytes
+ print-type-size     field `.position`: 4 bytes
6 print-type-size     field `.flags`: 4 bytes
7 print-type-size     field `.align`: 1 bytes
- print-type-size     end padding: 7 bytes
- print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes
- print-type-size     field `.pieces`: 16 bytes
- print-type-size     field `.args`: 16 bytes
- print-type-size     field `.fmt`: 16 bytes
- print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes
- print-type-size     field `.file`: 16 bytes
+ print-type-size     end padding: 3 bytes
+ print-type-size type: `std::fmt::Arguments<'_>`: 24 bytes, alignment: 4 bytes
+ print-type-size     field `.pieces`: 8 bytes
+ print-type-size     field `.args`: 8 bytes
+ print-type-size     field `.fmt`: 8 bytes
+ print-type-size type: `std::panic::Location<'_>`: 16 bytes, alignment: 4 bytes
+ print-type-size     field `.file`: 8 bytes
15 print-type-size     field `.line`: 4 bytes
16 print-type-size     field `.col`: 4 bytes
- print-type-size type: `core::fmt::rt::Count`: 16 bytes, alignment: 8 bytes
- print-type-size     discriminant: 8 bytes
- print-type-size     variant `Is`: 8 bytes
- print-type-size         field `.0`: 8 bytes
- print-type-size     variant `Param`: 8 bytes
- print-type-size         field `.0`: 8 bytes
- print-type-size     variant `Implied`: 0 bytes
- print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes
- print-type-size     variant `Some`: 16 bytes
- print-type-size         field `.0`: 16 bytes
- print-type-size     variant `None`: 0 bytes
28 print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes
29 print-type-size     field `.nested`: 8 bytes
30 print-type-size     field `.post`: 2 bytes

61 print-type-size     field `.post`: 2 bytes
62 print-type-size     field `.pre`: 1 bytes
63 print-type-size     end padding: 1 bytes
+ print-type-size type: `core::fmt::rt::Count`: 8 bytes, alignment: 4 bytes
+ print-type-size     discriminant: 4 bytes
+ print-type-size     variant `Is`: 4 bytes
+ print-type-size         field `.0`: 4 bytes
+ print-type-size     variant `Param`: 4 bytes
+ print-type-size         field `.0`: 4 bytes
+ print-type-size     variant `Implied`: 0 bytes
+ print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 8 bytes, alignment: 4 bytes
+ print-type-size     variant `Some`: 8 bytes
+ print-type-size         field `.0`: 8 bytes
+ print-type-size     variant `None`: 0 bytes
64 print-type-size type: `Enum4<(), char, (), ()>`: 4 bytes, alignment: 4 bytes
65 print-type-size     variant `Two`: 4 bytes
66 print-type-size         field `.0`: 4 bytes

The actual stdout differed from the expected stdout.
Actual stdout saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/print_type_sizes/niche-filling/niche-filling.stdout
To update references, rerun the tests and pass the `--bless` flag
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args print_type_sizes/niche-filling.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/print_type_sizes/niche-filling.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=i586-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/print_type_sizes/niche-filling" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/i586-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=i586-unknown-linux-gnu-gcc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/print_type_sizes/niche-filling/auxiliary" "-Z" "print-type-sizes" "--crate-type=lib"
--- stdout -------------------------------
print-type-size type: `core::fmt::rt::Placeholder`: 32 bytes, alignment: 4 bytes
print-type-size     field `.precision`: 8 bytes
print-type-size     field `.width`: 8 bytes
print-type-size     field `.fill`: 4 bytes
print-type-size     field `.position`: 4 bytes
print-type-size     field `.flags`: 4 bytes
print-type-size     field `.align`: 1 bytes
print-type-size     end padding: 3 bytes
print-type-size type: `std::fmt::Arguments<'_>`: 24 bytes, alignment: 4 bytes
print-type-size     field `.pieces`: 8 bytes
print-type-size     field `.args`: 8 bytes
print-type-size     field `.fmt`: 8 bytes
print-type-size type: `std::panic::Location<'_>`: 16 bytes, alignment: 4 bytes
print-type-size     field `.file`: 8 bytes
print-type-size     field `.line`: 4 bytes
print-type-size     field `.col`: 4 bytes
print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes
print-type-size     field `.nested`: 8 bytes
print-type-size     field `.post`: 2 bytes
print-type-size     field `.pre`: 1 bytes
print-type-size     end padding: 1 bytes
print-type-size type: `MyOption<IndirectNonZero>`: 12 bytes, alignment: 4 bytes
print-type-size     variant `Some`: 12 bytes
print-type-size         field `.0`: 12 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `EmbeddedDiscr`: 8 bytes, alignment: 4 bytes
print-type-size     discriminant: 1 bytes
print-type-size     variant `Record`: 7 bytes
print-type-size         field `.pre`: 1 bytes
print-type-size         field `.post`: 2 bytes
print-type-size         field `.val`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `MyOption<Union1<std::num::NonZero<u32>>>`: 8 bytes, alignment: 4 bytes
print-type-size     discriminant: 4 bytes
print-type-size     variant `Some`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `MyOption<Union2<std::num::NonZero<u32>, std::num::NonZero<u32>>>`: 8 bytes, alignment: 4 bytes
print-type-size     discriminant: 4 bytes
print-type-size     variant `Some`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `MyOption<Union2<std::num::NonZero<u32>, u32>>`: 8 bytes, alignment: 4 bytes
print-type-size     discriminant: 4 bytes
print-type-size     variant `Some`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `NestedNonZero`: 8 bytes, alignment: 4 bytes
print-type-size     field `.val`: 4 bytes
print-type-size     field `.post`: 2 bytes
print-type-size     field `.pre`: 1 bytes
print-type-size     end padding: 1 bytes
print-type-size type: `core::fmt::rt::Count`: 8 bytes, alignment: 4 bytes
print-type-size     discriminant: 4 bytes
print-type-size     variant `Is`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `Param`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `Implied`: 0 bytes
print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 8 bytes, alignment: 4 bytes
print-type-size     variant `Some`: 8 bytes
print-type-size         field `.0`: 8 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `Enum4<(), char, (), ()>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Two`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `One`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size     variant `Three`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size     variant `Four`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size type: `MyNotNegativeOne`: 4 bytes, alignment: 4 bytes
print-type-size     field `._i`: 4 bytes
print-type-size type: `MyOption<MyNotNegativeOne>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Some`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `MyOption<char>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Some`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `MyOption<std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Some`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `Union1<std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Union1`: 4 bytes
print-type-size         field `.a`: 4 bytes
print-type-size type: `Union2<std::num::NonZero<u32>, std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Union2`: 4 bytes
print-type-size         field `.a`: 4 bytes
print-type-size         field `.b`: 4 bytes, offset: 0 bytes, alignment: 4 bytes
print-type-size type: `Union2<std::num::NonZero<u32>, u32>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Union2`: 4 bytes
print-type-size         field `.a`: 4 bytes
print-type-size         field `.b`: 4 bytes, offset: 0 bytes, alignment: 4 bytes
print-type-size type: `std::mem::ManuallyDrop<std::option::Option<std::num::NonZero<u32>>>`: 4 bytes, alignment: 4 bytes
print-type-size     field `.value`: 4 bytes
print-type-size type: `std::mem::MaybeUninit<std::option::Option<std::num::NonZero<u32>>>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `MaybeUninit`: 4 bytes
print-type-size         field `.uninit`: 0 bytes
print-type-size         field `.value`: 4 bytes
print-type-size type: `std::num::NonZero<u32>`: 4 bytes, alignment: 4 bytes
print-type-size     field `.0`: 4 bytes
print-type-size type: `std::option::Option<std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
print-type-size     variant `Some`: 4 bytes
print-type-size         field `.0`: 4 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `Enum4<(), (), (), MyOption<u8>>`: 2 bytes, alignment: 1 bytes
print-type-size     variant `Four`: 2 bytes
print-type-size         field `.0`: 2 bytes
print-type-size     variant `One`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size     variant `Two`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size     variant `Three`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size type: `MyOption<MyOption<u8>>`: 2 bytes, alignment: 1 bytes
print-type-size     variant `Some`: 2 bytes
print-type-size         field `.0`: 2 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `MyOption<u8>`: 2 bytes, alignment: 1 bytes
print-type-size     discriminant: 1 bytes
print-type-size     variant `Some`: 1 bytes
print-type-size         field `.0`: 1 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `Enum4<(), (), bool, ()>`: 1 bytes, alignment: 1 bytes
print-type-size     variant `Three`: 1 bytes
print-type-size         field `.0`: 1 bytes
print-type-size     variant `One`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size     variant `Two`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size     variant `Four`: 0 bytes
print-type-size         field `.0`: 0 bytes
print-type-size type: `MyOption<bool>`: 1 bytes, alignment: 1 bytes
print-type-size     variant `Some`: 1 bytes
print-type-size         field `.0`: 1 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `MyOption<std::cmp::Ordering>`: 1 bytes, alignment: 1 bytes
print-type-size     variant `Some`: 1 bytes
print-type-size         field `.0`: 1 bytes
print-type-size     variant `None`: 0 bytes
print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes
print-type-size     discriminant: 1 bytes
print-type-size     variant `Left`: 0 bytes
print-type-size     variant `Right`: 0 bytes
print-type-size     variant `Center`: 0 bytes
print-type-size     variant `Unknown`: 0 bytes
print-type-size type: `std::cmp::Ordering`: 1 bytes, alignment: 1 bytes
print-type-size     discriminant: 1 bytes
print-type-size     variant `Less`: 0 bytes
print-type-size     variant `Equal`: 0 bytes
print-type-size     variant `Greater`: 0 bytes
stderr: none



@bors
Copy link
Contributor

bors commented Feb 6, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 6, 2024
@matthiaskrgr matthiaskrgr deleted the rollup-g8n27fz branch March 16, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.