Commit Graph

246960 Commits

Author SHA1 Message Date
bors
d8b00690ec Auto merge of #121415 - matthiaskrgr:rollup-o9zzet4, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #121206 (Top level error handling)
 - #121261 (coverage: Remove `pending_dups` from the span refiner)
 - #121336 (triagebot: add queue notifications)
 - #121373 (Consistently refer to a test's `revision` instead of `cfg`)
 - #121391 (never patterns: Fix liveness analysis in the presence of never patterns)
 - #121392 (Unify dylib loading between proc macros and codegen backends)
 - #121399 (Solaris linker does not support --strip-debug)
 - #121406 (Add a couple tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-22 00:04:07 +00:00
Matthias Krüger
35650a42a2
Rollup merge of #121406 - compiler-errors:tests, r=Nilstrieb
Add a couple tests

Fixes #119857
Fixes #115497
2024-02-21 22:49:00 +01:00
Matthias Krüger
8ab24c9fc0
Rollup merge of #121399 - psumbera:solaris-strip-debug, r=petrochenkov
Solaris linker does not support --strip-debug

Fixes #121381
2024-02-21 22:49:00 +01:00
Matthias Krüger
64dbc3f38f
Rollup merge of #121392 - bjorn3:unify_dylib_loading, r=petrochenkov
Unify dylib loading between proc macros and codegen backends

As bonus this makes the errors when failing to load a proc macro more informative to match the backend loading errors. In addition it makes it slightly easier to patch rustc to work on platforms that don't support dynamic linking like wasm.
2024-02-21 22:48:59 +01:00
Matthias Krüger
60cb794181
Rollup merge of #121391 - Nadrieril:fix-liveness, r=compiler-errors
never patterns: Fix liveness analysis in the presence of never patterns

There's a bunch of code that only looks at the first alternative of an or-pattern, under the assumption that all alternatives have the same set of bindings. This is true except for never pattern alternatives  (e.g. `Ok(x) | Err(!)`), so we skip these. I expect there's other code with this problem, I'll have to check that later.

I don't have tests for this yet because mir lowering causes other issues; I'll have some in the next PR.

r? ``@compiler-errors``
2024-02-21 22:48:58 +01:00
Matthias Krüger
084e2322f3
Rollup merge of #121373 - Zalathar:test-revision, r=oli-obk
Consistently refer to a test's `revision` instead of `cfg`

Compiletest allows a test file to specify multiple “revisions” (`//@ revisions: foo bar`), with each revision running as a separate test, and having the ability to define revision-specific headers (`//`@[foo]` ignore-blah`) and revision-specific code (`#[cfg(foo)]`).

The code that implements this feature sometimes uses the term “cfg” instead of “revision”. This results in two confusingly-different names for the same concept, one of which is ambiguous with other kinds of configuration (such as compiletest's own config).

This PR replaces those occurrences of `cfg` with `revision`, so that one name is used consistently.
2024-02-21 22:48:58 +01:00
Matthias Krüger
718998591e
Rollup merge of #121336 - davidtwco:triagebot-notifications, r=wesleywiser
triagebot: add queue notifications

This seems like it could be useful.

r? ``@wesleywiser``
2024-02-21 22:48:57 +01:00
Matthias Krüger
9949bbc19c
Rollup merge of #121261 - Zalathar:pending-dups, r=oli-obk
coverage: Remove `pending_dups` from the span refiner

When extracting coverage spans from a function's MIR, we need to decide how to handle spans that are associated with more than one node (BCB) in the coverage control flow graph.

The existing code for managing those duplicate spans is very subtle and difficult to modify. But by eagerly deduplicating those extracted spans in a much simpler way, we can remove a massive chunk of complexity from the span refiner.

There is a tradeoff here, in that we no longer try to retain *all* nondominating BCBs that have the same span, only the last one in the (semi-arbitrary) dominance ordering. But in practice, this produces very little difference in our coverage tests, and the simplification is so significant that I think it's worthwhile.

``@rustbot`` label +A-code-coverage
2024-02-21 22:48:56 +01:00
Matthias Krüger
5c89029585
Rollup merge of #121206 - nnethercote:top-level-error-handling, r=oli-obk
Top level error handling

The interactions between the following things are surprisingly complicated:
- `emit_stashed_diagnostics`,
- `flush_delayed`,
- normal return vs `abort_if_errors`/`FatalError.raise()` unwinding in the call to the closure in `interface::run_compiler`.

This PR disentangles it all.

r? `@oli-obk`
2024-02-21 22:48:56 +01:00
bors
3406ada96f Auto merge of #117658 - RalfJung:ptr-dangling, r=m-ou-se
rename ptr::invalid -> ptr::without_provenance

It has long bothered me that `ptr::invalid` returns a pointer that is actually valid for zero-sized memory accesses. In general, it doesn't even make sense to ask "is this pointer valid", you have to ask "is this pointer valid for a given memory access". We could say that a pointer is invalid if it is not valid for *any* memory access, but [the way this FCP is going](https://github.com/rust-lang/unsafe-code-guidelines/issues/472), it looks like *all* pointers will be valid for zero-sized memory accesses.

Two possible alternative names emerged as people's favorites:
1. Something involving `dangling`, in analogy to `NonNull::dangling`. To avoid inconsistency with the `NonNull` method, the address-taking method could be called `dangling_at(addr: usize) -> *const T`.
2. `without_provenance`, to be symmetric with the inverse operation `ptr.addr_without_provenance()` (currently still called `ptr.addr()` but probably going to be renamed)

I have no idea which one of these is better. I read [this comment](https://github.com/rust-lang/rust/pull/117658#issuecomment-1830934701) as expressing a slight preference for something like the second option, so I went for that. I'm happy to go with `dangling_at` as well.

Cc `@rust-lang/opsem`
2024-02-21 21:48:38 +00:00
Nicholas Nethercote
f16c226af3 Inline and remove abort_on_err.
It's clumsy and doesn't improve readability.
2024-02-22 08:03:47 +11:00
Nicholas Nethercote
4da67fff61 Replace unnecessary abort_if_errors.
Replace `abort_if_errors` calls that are certain to abort -- because
we emit an error immediately beforehand -- with `FatalErro.raise()`.
2024-02-22 08:03:47 +11:00
Nicholas Nethercote
44006444c8 Refactor run_global_ctxt.
It currently is infallible and uses `abort_if_errors` and
`FatalError.raise()` to signal errors. It's easy to instead return a
`Result<_, ErrorGuaranteed>`, which is the more usual way of doing
things.
2024-02-22 08:03:47 +11:00
Nicholas Nethercote
c2512a130f Inline and remove Session::compile_status.
Because it's now simple enough that it doesn't provide much benefit.
2024-02-22 08:03:47 +11:00
Nicholas Nethercote
72b172bdf6 Overhaul the handling of errors at the top-level.
Currently `emit_stashed_diagnostic` is called from four(!) different
places: `print_error_count`, `DiagCtxtInner::drop`, `abort_if_errors`,
and `compile_status`.

And `flush_delayed` is called from two different places:
`DiagCtxtInner::drop` and `Queries`.

This is pretty gross! Each one should really be called from a single
place, but there's a bunch of entanglements. This commit cleans up this
mess.

Specifically, it:
- Removes all the existing calls to `emit_stashed_diagnostic`, and adds
  a single new call in `finish_diagnostics`.
- Removes the early `flush_delayed` call in `codegen_and_build_linker`,
  replacing it with a simple early return if delayed bugs are present.
- Changes `DiagCtxtInner::drop` and `DiagCtxtInner::flush_delayed` so
  they both assert that the stashed diagnostics are empty (i.e.
  processed beforehand).
- Changes `interface::run_compiler` so that any errors emitted during
  `finish_diagnostics` (i.e. late-emitted stashed diagnostics) are
  counted and cannot be overlooked. This requires adding
  `ErrorGuaranteed` return values to several functions.
- Removes the `stashed_err_count` call in `analysis`. This is possible
  now that we don't have to worry about calling `flush_delayed` early
  from `codegen_and_build_linker` when stashed diagnostics are pending.
- Changes the `span_bug` case in `handle_tuple_field_pattern_match` to a
  `delayed_span_bug`, because it now can be reached due to the removal
  of the `stashed_err_count` call in `analysis`.
- Slightly changes the expected output of three tests. If no errors are
  emitted but there are delayed bugs, the error count is no longer
  printed. This is because delayed bugs are now always printed after the
  error count is printed (or not printed, if the error count is zero).

There is a lot going on in this commit. It's hard to break into smaller
pieces because the existing code is very tangled. It took me a long time
and a lot of effort to understand how the different pieces interact, and
I think the new code is a lot simpler and easier to understand.
2024-02-22 08:03:47 +11:00
Nicholas Nethercote
46f4983356 Adjust the has_errors* methods.
Currently `has_errors` excludes lint errors. This commit changes it to
include lint errors.

The motivation for this is that for most places it doesn't matter
whether lint errors are included or not. But there are multiple places
where they must be includes, and only one place where they must not be
included. So it makes sense for `has_errors` to do the thing that fits
the most situations, and the new `has_errors_excluding_lint_errors`
method in the one exceptional place.

The same change is made for `err_count`. Annoyingly, this requires the
introduction of `err_count_excluding_lint_errs` for one place, to
preserve existing error printing behaviour. But I still think the change
is worthwhile overall.
2024-02-22 08:03:47 +11:00
Nicholas Nethercote
9919c3dab3 Remove EarlyDiagCtxt::abort_if_errors.
Its one use isn't necessary, because it's not possible for errors to
have been emitted at that point.
2024-02-22 08:03:47 +11:00
Nicholas Nethercote
203b4332bb Remove dead expect_error_or_delayed_bug method. 2024-02-22 08:03:47 +11:00
Nicholas Nethercote
1e16927ef3 Remove an out-of-date comment. 2024-02-22 08:03:39 +11:00
Pavel Grigorenko
c42057f89e
bootstrap: improvements for stage0 checks
+ Do not resolve symlinks (as this may break rustup)
+ Check version not just for rustc, but also for cargo.
+ Check that the program's self-reported name
  matches the expected name (such as "rustc" or "cargo").
2024-02-21 23:33:47 +03:00
Nadrieril
0610f59194 Inline simplify_match_pair 2024-02-21 21:19:00 +01:00
Nadrieril
b1a0607e10 Process bindings and ascriptions in MatchPair::new() 2024-02-21 21:19:00 +01:00
Nadrieril
a181bdc065 Introduce TestCase enum to replace most matching on PatKind 2024-02-21 21:18:59 +01:00
Nadrieril
5c9d580fea Tiny simplification 2024-02-21 21:17:43 +01:00
Ralf Jung
07b6240947 remove simd_reduce_{min,max}_nanless 2024-02-21 20:50:47 +01:00
bors
d7bd9cd469 Auto merge of #121321 - compiler-errors:yeet-querytyperelating, r=lcnr
Yeet `QueryTypeRelatingDelegate`, move `NllTypeRelating` into borrowck crate

We can just use the existing equate relation for query instantiation. I don't expect us to want to move everything into `TypeRelating`.

r? lcnr
2024-02-21 19:28:57 +00:00
clubby789
eee56725f0 Make x test tests work 2024-02-21 19:24:15 +00:00
Ralf Jung
b58f647d54 rename ptr::invalid -> ptr::without_provenance
also introduce ptr::dangling matching NonNull::dangling
2024-02-21 20:15:52 +01:00
Michael Goulet
64d6303ac6 Inline NllTypeRelating into its only usage site 2024-02-21 18:37:53 +00:00
Michael Goulet
6c030332ee Make TypeRelating more NLL-specific 2024-02-21 18:08:01 +00:00
Michael Goulet
da1e6a8c1c Yeet QueryTypeRelatingDelegate 2024-02-21 18:08:01 +00:00
Michael Goulet
f8fbb7060c Add a non-lifetime-binders test 2024-02-21 18:05:58 +00:00
Michael Goulet
a233b1656e Add an ATB test 2024-02-21 17:16:35 +00:00
bors
f8131a48a4 Auto merge of #121400 - fmease:rollup-8m29g7a, r=fmease
Rollup of 8 pull requests

Successful merges:

 - #121044 (Support async trait bounds in macros)
 - #121175 (match lowering: test one or pattern at a time)
 - #121340 (bootstrap: apply most of clippy's suggestions)
 - #121347 (compiletest: support auxiliaries with auxiliaries)
 - #121359 (miscellaneous type system improvements)
 - #121366 (Remove `diagnostic_builder.rs`)
 - #121379 (Remove an `unchecked_error_guaranteed` call.)
 - #121396 (make it possible for outside crates to inspect a mir::ConstValue with the interpreter)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-21 16:05:46 +00:00
Petr Sumbera
a17211b05c Solaris linker does not support --strip-debug
Fixes #121381
2024-02-21 16:49:01 +01:00
Ikko Eltociear Ashimine
00234f0f68
Fix typo in serialized.rs
accomodate -> accommodate
2024-02-22 00:33:23 +09:00
León Orell Valerian Liehr
bd7ba278e5
Rollup merge of #121396 - RalfJung:mir-const-value-inspect, r=oli-obk
make it possible for outside crates to inspect a mir::ConstValue with the interpreter

For MiniRust we need to convert MIR constant values into MiniRust constant values. However, it's not currently possible to get nice high-level access to the inerts of a `ConstValue`: we can access the raw contents (the allocation / `ScalarInt`), but if it is e.g. of enum type and we want to determine which variant is encoded, we are stuck. There's only `try_destructure_mir_constant_for_user_output` which is meant for diagnostics, so it doesn't fit.

The interpreter has all the APIs to traverse such a value, so we just need a way to get such a ConstValue into an interpreter instance. This adds the public functions necessary to make that happen.
2024-02-21 16:33:00 +01:00
León Orell Valerian Liehr
ae01e99831
Rollup merge of #121379 - nnethercote:rm-unchecked_error_guaranteed, r=oli-obk
Remove an `unchecked_error_guaranteed` call.

If we abort immediately after complaining about the obsolete `impl Trait for ..` syntax, then we avoid reaching HIR lowering. This means we can use `TyKind::Dummy` instead of `TyKind::Err`.

r? `@oli-obk`
2024-02-21 16:32:59 +01:00
León Orell Valerian Liehr
ef14c17fe1
Rollup merge of #121366 - nnethercote:rm-diagnostic_builder.rs, r=compiler-errors
Remove `diagnostic_builder.rs`

#120576 moved a big chunk of `DiagnosticBuilder`'s functionality out of `diagnostic_builder.rs` into `diagnostic.rs`, which left `DiagnosticBuilder` spread across the two files.

This PR fixes that messiness by merging what remains of `diagnostic_builder.rs` into `diagnostic.rs`.

This is part of https://github.com/rust-lang/compiler-team/issues/722.

r? `@davidtwco`
2024-02-21 16:32:59 +01:00
León Orell Valerian Liehr
8d27fc86f2
Rollup merge of #121359 - lcnr:typesystem-cleanup, r=compiler-errors
miscellaneous type system improvements

see review comments for rationale

r? `@compiler-errors`
2024-02-21 16:32:58 +01:00
León Orell Valerian Liehr
2d98f05cf1
Rollup merge of #121347 - davidtwco:compiletest-aux-aux, r=oli-obk
compiletest: support auxiliaries with auxiliaries

To test behaviour that depends on the extern options of intermediate crates, compiletest auxiliaries must have their own auxiliaries.

Auxiliary compilation previously did not trigger compilation of any auxiliaries in the auxiliary's headers. In addition, those auxiliaries would need to be in an `auxiliary/auxiliary` directory, which is unnecessary and makes some crate graphs harder to write tests for, such as when A depends on B and C, and B depends on C.

For a test `tests/ui/$path/root.rs`, with the following crate graph:

```
root
|-- grandparent
`-- parent
    `-- grandparent
```

then the intermediate outputs from compiletest will be:

```
build/$target/test/ui/$path/
|-- auxiliary
|   |-- libgrandparent.dylib
|   |-- libparent.dylib
|   |-- grandparent
|   |   |-- grandparent.err
|   |   `-- grandparent.out
|   `-- parent
|       |-- parent.err
|       `-- parent.out
|-- libroot.rmeta
|-- root.err
`-- root.out
```
2024-02-21 16:32:58 +01:00
León Orell Valerian Liehr
216f9a4778
Rollup merge of #121340 - GrigorenkoPV:bootstrap-clippy, r=onur-ozkan
bootstrap: apply most of clippy's suggestions
2024-02-21 16:32:57 +01:00
León Orell Valerian Liehr
4daa43aaff
Rollup merge of #121175 - Nadrieril:simplify-or-selection, r=matthewjasper
match lowering: test one or pattern at a time

This is a bit more opinionated than the previous PRs. On the face of it this is less efficient and more complex than before, but I personally found the loop that digs into `leaf_candidates` on each iteration very confusing. Instead this does "generate code for this or-pattern" then "generate further code for each branch if needed" in two steps.

Incidentally this way we don't _require_ or patterns to be sorted at the end. It's still an important optimization but I find it clearer to not rely on it for correctness.

r? `@matthewjasper`
2024-02-21 16:32:57 +01:00
León Orell Valerian Liehr
082b97ad05
Rollup merge of #121044 - compiler-errors:mbe-async-trait-bounds, r=fmease
Support async trait bounds in macros

r? fmease

This is similar to your work on const trait bounds. This theoretically regresses `impl async $ident:ident` in macros, but I doubt this is occurring in practice.
2024-02-21 16:32:56 +01:00
Ralf Jung
3dc631a61a make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags 2024-02-21 16:28:20 +01:00
Ralf Jung
25fe3cc69d intrinsics::simd: add missing functions 2024-02-21 16:26:32 +01:00
David Wood
a2aa9672f6
compiletest: support auxiliaries with auxiliaries
To test behaviour that depends on the extern options of intermediate
crates, compiletest auxiliaries must have their own auxiliaries.

Auxiliary compilation previously did not trigger compilation of any
auxiliaries in the auxiliary's headers. In addition, those auxiliaries
would need to be in an `auxiliary/auxiliary` directory, which is
unnecessary and makes some crate graphs harder to write tests for,
such as when A depends on B and C, and B depends on C.

For a test `tests/ui/$path/root.rs`, with the following crate graph:

```
root
|-- grandparent
`-- parent
    `-- grandparent
```

then the intermediate outputs from compiletest will be:

```
build/$target/test/ui/$path/
|-- auxiliary
|   |-- libgrandparent.dylib
|   |-- libparent.dylib
|   |-- grandparent
|   |   |-- grandparent.err
|   |   `-- grandparent.out
|   `-- parent
|       |-- parent.err
|       `-- parent.out
|-- libroot.rmeta
|-- root.err
`-- root.out
```

Signed-off-by: David Wood <david@davidtw.co>
2024-02-21 14:37:13 +00:00
Ralf Jung
9eabdc2a4c make it possible for outside crates to inspect a mir::ConstValue with the interpreter 2024-02-21 14:32:52 +01:00
bors
1d447a9946 Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #121208 (Convert `delayed_bug`s to `bug`s.)
 - #121288 (make rustc_expand translatable)
 - #121304 (Add docs for extension proc-macro)
 - #121328 (Make --verbose imply -Z write-long-types-to-disk=no)
 - #121338 (Downgrade ambiguous_wide_pointer_comparisons suggestions to MaybeIncorrect)
 - #121361 (diagnostic items for legacy numeric modules)
 - #121375 (Print proper relative path for descriptive name check)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-21 12:09:22 +00:00
bjorn3
f25c90a83f Unify dylib loading between proc macros and codegen backends
As bonus this makes the errors when failing to load a proc macro more
informative to match the backend loading errors. In addition it makes it
slightly easier to patch rustc to work on platforms that don't support
dynamic linking like wasm.
2024-02-21 11:17:07 +00:00