Commit Graph

32771 Commits

Author SHA1 Message Date
bors
bb89df6903 Auto merge of #121018 - oli-obk:impl_unsafety, r=TaKO8Ki
Fully stop using the HIR in trait impl checks

At least I hope I found all happy path usages. I'll need to check if I can figure out a way to make queries declare that they don't access the HIR except in error paths
2024-02-14 07:27:11 +00:00
bors
cc1c0990ab Auto merge of #120454 - clubby789:cargo-update, r=Nilstrieb
`cargo update`

Run `cargo update`, with some pinning and fixes necessitated by that. This *should* unblock #112865

There's a couple of places where I only pinned a dependency in one location - this seems like a bit of a hack, but better than duplicating the FIXME across all `Cargo.toml` where a dependency is introduced.

cc `@Nilstrieb`
2024-02-14 05:27:31 +00:00
bors
7508c3e4c1 Auto merge of #121055 - matthiaskrgr:rollup-bzn5sda, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #118882 (Check normalized call signature for WF in mir typeck)
 - #120999 (rustdoc: replace `clean::InstantiationParam` with `clean::GenericArg`)
 - #121002 (remove unnecessary calls to `commit_if_ok`)
 - #121005 (Remove jsha from the rustdoc review rotation)
 - #121014 (Remove `force_print_diagnostic`)
 - #121043 (add lcnr to the compiler-team assignment group)
 - #121046 (Fix incorrect use of `compile_fail`)
 - #121047 (Do not assemble candidates for default impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-14 03:21:31 +00:00
bors
37b65339c8 Auto merge of #120942 - compiler-errors:deep-assoc-hang, r=lcnr
Ignore own item bounds in parent alias types in `for_each_item_bound`

Fixes #120912

I want to get a vibe check on this approach, which is very obviously a hack, but I believe something that is forwards-compatible with a more thorough solution and "good enough for now".

The problem here is that for a really deep rigid associated type, we are now repeatedly considering unrelated item bounds from the parent alias types, meaning we're doing a *lot* of extra work in the MIR inliner for deeply substituted rigid projections.

This feels intimately related to #107614. In that PR, we split *supertrait* bounds (bound which share the same `Self` type as the predicate which is being elaborated) and *implied* bounds (anything that is implied by elaborating the predicate).

The problem here is related to the fact that we don't maintain the split between these two for `item_bounds`. If we did, then when recursing into a parent alias type, we'd want to consider only the bounds that are given by [`PredicateFilter::All`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/astconv/enum.PredicateFilter.html#variant.SelfOnly) **except** those given by [`PredicateFilter::SelfOnly`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/astconv/enum.PredicateFilter.html#variant.SelfOnly).
2024-02-14 01:23:46 +00:00
Matthias Krüger
ab1fa19d08
Rollup merge of #121047 - compiler-errors:default-impls, r=lcnr
Do not assemble candidates for default impls

There is no reason (as far as I can tell?) that we should assemble an impl candidate for a default impl. This candidate itself does not prove that the impl holds, and any time that it *does* hold, there will be a more specializing non-default impl that also is assembled.

This is because `default impl<T> Foo for T {}` actually expands to `impl<T> Foo for T where T: Foo {}`. The only way to satisfy that where clause (without coinduction) is via *another* implementation that does hold -- precisely an impl that specializes it.

This should fix the specialization related regressions for #116494. That should lead to one root crate regression that doesn't have to do with specialization, which I think we can regress.

r? lcnr cc ``@rust-lang/types``

cc #31844
2024-02-13 22:51:57 +01:00
Matthias Krüger
8c0d54fad6
Rollup merge of #121014 - nnethercote:rm-force_print_diagnostic, r=oli-obk
Remove `force_print_diagnostic`

More diagnostic cleanups, best reviewed one at a time.

r? `@oli-obk`
2024-02-13 22:51:55 +01:00
Matthias Krüger
147fd3f236
Rollup merge of #121002 - lcnr:cleanup-commit_if_ok, r=oli-obk
remove unnecessary calls to `commit_if_ok`

we propagate the error outwards, so anything which wants to discard the error should do so itself.

r? types
2024-02-13 22:51:55 +01:00
Matthias Krüger
db9591cfb6
Rollup merge of #118882 - compiler-errors:normalized-sig-wf, r=lcnr
Check normalized call signature for WF in mir typeck

Unfortunately we don't check that the built-in implementations for `Fn*` traits are actually well-formed in the same way that we do for user-provided impls.

Essentially, when checking a call terminator, we end up with a signature that references an unnormalized `<[closure] as FnOnce<...>>::Output` in its output. That output type, due to the built-in impl, doesn't follow the expected rule that `WF(ty)` implies `WF(normalized(ty))`. We fix this by also checking the normalized signature here.

**See** boxy's detailed and useful explanation comment which explains this in more detail: https://github.com/rust-lang/rust/issues/114936#issuecomment-1710388741

Fixes #114936
Fixes #118876

r? types
cc ``@BoxyUwU`` ``@lcnr``
2024-02-13 22:51:53 +01:00
clubby789
002181f3ce Pin cc version 2024-02-13 21:13:06 +00:00
clubby789
36a16798f7 Pin memchr version 2024-02-13 21:03:34 +00:00
clubby789
4de3a3af4a Bump indexmap
`swap` has been deprecated in favour of `swap_remove` - the behaviour
is the same though.
2024-02-13 21:03:34 +00:00
Nicholas Nethercote
56b451a67a Fix DiagCtxtInner::reset_err_count.
Several fields were not being reset. Using destructuring makes it much
harder to miss a field.
2024-02-14 07:54:05 +11:00
Nicholas Nethercote
c1ffb0b675 Remove force_print_diagnostic.
There are a couple of places where we call
`inner.emitter.emit_diagnostic` directly rather than going through
`inner.emit_diagnostic`, to guarantee the diagnostic is printed. This
feels dubious to me, particularly the bypassing of `TRACK_DIAGNOSTIC`.

This commit removes those.
- In `print_error_count`, it uses `ForceWarning` instead of `Warning`.
- It removes `DiagCtxtInner::failure_note`, because it only has three
  uses and direct use of `emit_diagnostic` is consistent with other
  similar locations.
- It removes `force_print_diagnostic`, and adds `struct_failure_note`,
  and updates `print_query_stack` accordingly, which makes it more
  normal. That location doesn't seem to need forced printing anyway.
2024-02-14 07:51:53 +11:00
Nicholas Nethercote
bdc6d82f9a Make struct_span_note call struct_note.
So it follows the same pattern as all the other `struct_span_*` methods.
2024-02-14 07:50:54 +11:00
Michael Goulet
b4eee2e8b3 Do not assemble candidates for default impls 2024-02-13 19:20:13 +00:00
bors
a84bb95a1f Auto merge of #121036 - matthiaskrgr:rollup-ul05q8e, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #114877 (unstable-book: add quick-edit link)
 - #120548 (rustdoc: Fix handling of doc_auto_cfg feature for cfg attributes on glob reexport)
 - #120549 (modify alias-relate to also normalize ambiguous opaques)
 - #120959 (Remove good path delayed bugs)
 - #120978 (match lowering: simplify block creation)
 - #121019 (coverage: Simplify some parts of the coverage span refiner)
 - #121021 (Extend intra-doc link chapter in the rustdoc book)
 - #121031 (RustWrapper: adapt for coverage mapping API changes)

Failed merges:

 - #121014 (Remove `force_print_diagnostic`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-13 17:27:25 +00:00
Matthias Krüger
8dffa39367
Rollup merge of #121031 - TimNN:lh-fix-20240213, r=durin42
RustWrapper: adapt for coverage mapping API changes

There've been a number of changes to the coverage mapping API today, but the end result is that specifying the MCDC parameters is now optional (they've been moved to the end of the argument list and now default to `std::monostate`).

`@rustbot` label: +llvm-main

r? `@durin42`
2024-02-13 17:38:12 +01:00
Matthias Krüger
e36a7f4c65
Rollup merge of #121019 - Zalathar:covspans, r=oli-obk
coverage: Simplify some parts of the coverage span refiner

This is another incremental step on my quest to dismantle the coverage span refiner into something more understandable and maintainable.

The biggest change here is splitting up `CoverageSpan` into several more specific structs. Doing so reveals that most of the places that were using that struct only need a subset of its fields and methods.

We can also get rid of separate tracking of `curr_original_span` and `prev_original_span`, by observing that `curr.span` never actually needs to be mutated, and that we can store `prev_original_span` directly in the dedicated struct for `prev`.

`@rustbot` label +A-code-coverage
2024-02-13 17:38:11 +01:00
Matthias Krüger
b785fdb80b
Rollup merge of #120978 - Nadrieril:sane-blocks, r=matthewjasper
match lowering: simplify block creation

Match lowering was doing complicated things with block creation. As far as I can tell it was trying to avoid creating unneeded blocks, but of the three places that start out with `otherwise = &mut None`, two of them called `otherwise.unwrap_or_else(|| self.cfg.start_new_block())` anyway. As far as I can tell the only place where this PR makes a difference is in `lower_match_tree`, which did indeed sometimes avoid creating the unreachable final block + FakeRead. Unless this is important I propose we do the naive thing instead.

I have not checked all the graph isomorphisms by hand, but at a glance the test diff looks sensible.

r? `@matthewjasper`
2024-02-13 17:38:11 +01:00
Matthias Krüger
93e9579b5d
Rollup merge of #120959 - nnethercote:rm-good_path, r=oli-obk
Remove good path delayed bugs

Because they're not that useful, and kind of annoying. Details in the individual commits.

r? ```@compiler-errors```
2024-02-13 17:38:10 +01:00
Matthias Krüger
65ab663266
Rollup merge of #120549 - lcnr:errs-showcase, r=compiler-errors
modify alias-relate to also normalize ambiguous opaques

allows a bunch of further cleanups and generally simplifies the type system. To handle https://github.com/rust-lang/trait-system-refactor-initiative/issues/8 we'll have to add a some additional complexity to the `(Alias, Infer)` branches in alias-relate, so removing the opaque type special case here is really valuable.

It does worsen `deduce_closure_signature` and friends even more as they now receive an inference variable which is only constrained via an `AliasRelate` goal. These probably have to look into alias relate goals somehow. Leaving that for a future PR as this is something we'll have to tackle regardless.

r? `@compiler-errors`
2024-02-13 17:38:10 +01:00
Michael Goulet
2b4a2b95dd Check normalized call signature for WF in mir typeck 2024-02-13 16:00:01 +00:00
bors
eaff1af8fd Auto merge of #120055 - nikic:llvm-18, r=cuviper
Update to LLVM 18

LLVM 18 final is planned to be released on Mar 5th. Rust 1.78 is planned to be released on May 2nd.

Tested images: dist-x86_64-linux, dist-s390x-linux, dist-aarch64-linux, dist-riscv64-linux, dist-loongarch64-linux, dist-x86_64-freebsd, dist-x86_64-illumos, dist-x86_64-musl, x86_64-linux-integration, test-various, armhf-gnu, i686-msvc, x86_64-msvc, i686-mingw, x86_64-mingw, x86_64-apple-1, x86_64-apple-2, dist-aarch64-apple

r? `@ghost`
2024-02-13 15:07:28 +00:00
Tim Neumann
14ec3b6c91 RustWrapper: adapt for coverage mapping API changes 2024-02-13 15:15:14 +01:00
Zalathar
e67db4c3b8 coverage: Simplify code for adding prev to pending dups
If we only check for duplicate spans when `prev` is unmodified, we reduce the
number of situations that `update_pending_dups` needs to handle.

This could potentially change the coverage spans we produce in some unknown
corner cases, but none of our current coverage tests indicate any change.
2024-02-13 21:48:03 +11:00
Zalathar
499609d8a4 coverage: Move prev_original_span into PrevCovspan
Now that `prev` has its own dedicated struct, we can store the original span in
that struct, instead of in a separate field in the refiner.
2024-02-13 21:48:03 +11:00
Zalathar
a6183216d8 coverage: Split CoverageSpan into several distinct structs
This requires some extra boilerplate, but in exchange it becomes much easier to
see how each field and method is actually used.
2024-02-13 21:48:03 +11:00
Oli Scherer
7320623f3a Just pass the checker instead of individual fields 2024-02-13 10:23:06 +00:00
Oli Scherer
251c33ce2a Remove an impl_polarity call where the information is already available in the header 2024-02-13 10:18:05 +00:00
Zalathar
5a569b1b80 coverage: Don't track curr_original_span explicitly
Now that we never mutate `curr.span`, we don't need to store its original span
separately.
2024-02-13 21:01:17 +11:00
Zalathar
412c86cf03 coverage: When merging spans, keep prev and merge curr into it
Swapping the direction of this merge produces the same results, but means that
we never need to mutate `curr`.
2024-02-13 21:01:17 +11:00
Oli Scherer
75de6cf9a3 Avoid using the HIR span in the happy path 2024-02-13 09:49:08 +00:00
Oli Scherer
40b3cb0eb1 Don't reinvoke trait_header query twice 2024-02-13 09:38:13 +00:00
Nikita Popov
a911c8ce23 Use MCSubtargetInfo::getAllProcessorFeatures()
This method is now available in upstream LLVM \o/
2024-02-13 10:33:40 +01:00
Oli Scherer
55bbb054c9 Invoke trait_def query only once
This may be a small performance boost as we have to hash less to lookup the value
2024-02-13 09:29:31 +00:00
Oli Scherer
11a73f6d4d Store impl unsafety in impl trait header 2024-02-13 09:21:34 +00:00
Matthias Krüger
70ea26d349
Rollup merge of #120995 - durin42:llvm-19-pgo-coldfuncopt, r=cuviper
PassWrapper: adapt for llvm/llvm-project@93cdd1b5cf

Should be no functional change.

`@rustbot` label: +llvm-main
2024-02-13 06:27:41 +01:00
Matthias Krüger
21d8fb272b
Rollup merge of #120988 - tshepang:fix-comment, r=cjgillot
fix comment
2024-02-13 06:27:41 +01:00
Matthias Krüger
7427460ea9
Rollup merge of #120987 - tshepang:redundant, r=compiler-errors
remove redundant logic

Made redundant in 3f697b85f2
2024-02-13 06:27:40 +01:00
Matthias Krüger
fa3ec02057
Rollup merge of #120974 - zmodem:exportas, r=durin42
llvm-wrapper: adapt for LLVM API change: Add support for EXPORTAS name types

Adapt for llvm/llvm-project@8f23464.
2024-02-13 06:27:39 +01:00
Matthias Krüger
30057f0266
Rollup merge of #120802 - oli-obk:drop_elab_ice, r=compiler-errors
Bail out of drop elaboration when encountering error types

fixes  #120788
2024-02-13 06:27:38 +01:00
Matthias Krüger
1b396913a9
Rollup merge of #120751 - estebank:issue-68982, r=nnethercote
Provide more suggestions on invalid equality where bounds

```
error: equality constraints are not yet supported in `where` clauses
  --> $DIR/equality-bound.rs:50:9
   |
LL |         IntoIterator::Item = A
   |         ^^^^^^^^^^^^^^^^^^^^^^ not supported
   |
   = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information
help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax
   |
LL ~     fn from_iter<T: IntoIterator<Item = A>>(_: T) -> Self
LL ~
   |

error: equality constraints are not yet supported in `where` clauses
  --> $DIR/equality-bound.rs:63:9
   |
LL |         T::Item = A
   |         ^^^^^^^^^^^ not supported
   |
   = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information
help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax
   |
LL ~     fn from_iter<T: IntoIterator<Item = A>>(_: T) -> Self
LL ~
   |
```

Fix #68982.
2024-02-13 06:27:37 +01:00
Matthias Krüger
020e84652d
Rollup merge of #120696 - estebank:issue-115405, r=oli-obk
Properly handle `async` block and `async fn` in `if` exprs without `else`

When encountering a tail expression in the then arm of an `if` expression without an `else` arm, account for `async fn` and `async` blocks to suggest `return`ing the value and pointing at the return type of the `async fn`.

We now also account for AFIT when looking for the return type to point at.

Fix #115405.
2024-02-13 06:27:37 +01:00
lcnr
ae92334c0f remove questionable calls to commit_if_ok 2024-02-13 05:44:46 +01:00
lcnr
3e3e207ad7 use alias-relate to structurally normalize in the solver 2024-02-13 05:08:51 +01:00
lcnr
bbe2f6c0b2 also try to normalize opaque types in alias-relate
with this, alias-relate treats all aliases the same way
and it can be used for structural normalization.
2024-02-13 04:47:32 +01:00
bors
d26b417112 Auto merge of #120919 - oli-obk:impl_polarity, r=compiler-errors
Merge `impl_polarity` and `impl_trait_ref` queries

Hopefully this is perf neutral. I want to finish https://github.com/rust-lang/rust/pull/120835 and stop using the HIR in `coherent_trait`, which should then give us a perf improvement.
2024-02-13 02:48:49 +00:00
bors
0a5b998c57 Auto merge of #120991 - matthiaskrgr:rollup-f8kw2st, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #118983 (Warn on references casting to bigger memory layout)
 - #119451 (Gate PR CI on clippy correctness lints)
 - #120273 (compiletest: few naive improvements)
 - #120950 (Fix async closures in CTFE)
 - #120958 (Dejargonize `subst`)
 - #120965 (Add lahfsahf and prfchw target feature)
 - #120970 (add another test for promoteds-in-static)
 - #120979 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-13 00:31:53 +00:00
Augie Fackler
9d1bd2e067 PassWrapper: adapt for llvm/llvm-project@93cdd1b5cf
Should be no functional change.

@rustbot label: +llvm-main
2024-02-12 19:13:09 -05:00
Nicholas Nethercote
9f2aa09765 Remove good_path_delayed_bug.
It's only has a single remaining purpose: to ensure that a diagnostic is
printed when `trimmed_def_paths` is used. It's an annoying mechanism:
weak, with odd semantics, badly named, and gets in the way of other
changes.

This commit replaces it with a simpler `must_produce_diag` mechanism,
getting rid of a diagnostic `Level` along the way.
2024-02-13 09:33:35 +11:00