Commit Graph

2332 Commits

Author SHA1 Message Date
bors
59a4f02f83 Auto merge of #127438 - compiler-errors:compute-outlives-visitor, r=lcnr
Make `push_outlives_components` into a `TypeVisitor`

This involves removing the `visited: &mut SsoHashSet<GenericArg<'tcx>>` that is being passed around the `VerifyBoundCx`. The fact that we were using it when decomposing different type tests seems sketchy, so I don't think, though it may technically result in us registering more redundant outlives components 🤷

I did end up deleting some of the comments that referred back to RFC 1214 during this refactor. I can add them back if you think they were useful.

r? lcnr
2024-07-08 10:56:15 +00:00
许杰友 Jieyou Xu (Joe)
ffb93361b4
Rollup merge of #127439 - compiler-errors:uplift-elaborate, r=lcnr
Uplift elaboration into `rustc_type_ir`

Allows us to deduplicate and consolidate elaboration (including these stupid elaboration duplicate fns i added for pretty printing like 3 years ago) so I'm pretty hyped about this change :3

r? lcnr
2024-07-08 13:04:33 +08:00
许杰友 Jieyou Xu (Joe)
928d71f17b
Rollup merge of #127437 - compiler-errors:uplift-trait-ref-is-knowable, r=lcnr
Uplift trait ref is knowable into `rustc_next_trait_solver`

Self-explanatory. Eliminates one more delegate method.

r? lcnr cc ``@fmease``
2024-07-08 13:04:32 +08:00
bors
89aefb9c53 Auto merge of #127172 - compiler-errors:full-can_eq-everywhere, r=lcnr
Make `can_eq` process obligations (almost) everywhere

Move `can_eq` to an extension trait on `InferCtxt` in `rustc_trait_selection`, and change it so that it processes obligations. This should strengthen it to be more accurate in some cases, but is most important for the new trait solver which delays relating aliases to `AliasRelate` goals. Without this, we always basically just return true when passing aliases to `can_eq`, which can lead to weird errors, for example #127149.

I'm not actually certain if we should *have* `can_eq` be called on the good path. In cases where we need `can_eq`, we probably should just be using a regular probe.

Fixes #127149

r? lcnr
2024-07-07 23:03:48 +00:00
Michael Goulet
90423a7abb Uplift elaboration 2024-07-07 11:28:01 -04:00
Michael Goulet
c895985e75 Make push_outlives_components into a visitor 2024-07-07 11:22:52 -04:00
Michael Goulet
a982471e07 Uplift trait_ref_is_knowable and friends 2024-07-07 11:10:32 -04:00
Michael Goulet
87d61f2540 Don't track visited outlives bounds when decomposing verify for alias 2024-07-06 18:49:20 -04:00
Michael Goulet
413345c61d
Rollup merge of #127417 - chenyukang:yukang-method-output-diff, r=oli-obk
Show fnsig's unit output  explicitly when there is output diff in diagnostics

Fixes #127263
2024-07-06 14:55:25 -04:00
Michael Goulet
f664171cb5
Rollup merge of #127405 - compiler-errors:uplift-predicate-emitting-relation, r=lcnr
uplift `PredicateEmittingRelation`

Small follow-up to #127333

r? lcnr
2024-07-06 14:55:24 -04:00
Michael Goulet
dfc02d28c7
Rollup merge of #127386 - compiler-errors:uplift-outlives-components, r=lcnr
Uplift outlives components to `rustc_type_ir`

We need this to uplift `push_outlives_components`, since the elaborator uses `push_outlives_components` to elaborate type outlives obligations and I want to uplift elaboration.

This ends up reworking and inlining a fair portion of the `GenericArg::walk_shallow` function, whose only callsite was this one. I believe I got the logic correct, but may be worthwhile to look at it closely just in case. Unfortunately github was too dumb to understand that this is a rename + change -- I could also rework the git history to split the "copy the file over" part from the actual logical changes if that makes this easier to review.

r? lcnr
2024-07-06 14:55:23 -04:00
bors
8a8ad3433e Auto merge of #127388 - compiler-errors:elaboration-tweaks, r=lcnr
Elaboration tweaks

Removes `Filter::OnlySelfThatDefines` and reimplements `transitive_bounds_that_define_assoc_item` as a separate function, since I don't want to have to uplift that mode since it's both an implementation detail (only exists to avoid cycles in astconv) and requires exposing `Ident` as an associated type on `Interner`.

r? lcnr
2024-07-06 15:56:16 +00:00
yukang
81c86ddf8e show fnsig's output when there is difference 2024-07-06 23:29:58 +08:00
Michael Goulet
cc6c5de39d Import via rustc_type_ir::outlives
We could use rustc_middle::ty::outlives I guess?
2024-07-06 10:47:46 -04:00
Michael Goulet
23c6f23b21 Uplift push_outlives_components 2024-07-06 10:47:46 -04:00
Michael Goulet
e5d6a416e8 Uplift PredicateEmittingRelation first 2024-07-06 10:05:49 -04:00
yukang
f46c4129e0 show unit output when there is only output diff in diagnostics 2024-07-06 21:00:30 +08:00
Michael Goulet
99429a6a18 Split out transitive_bounds_that_define_assoc_item 2024-07-05 20:21:16 -04:00
Michael Goulet
27588d1de3 Split SolverDelegate back out from InferCtxtLike 2024-07-05 16:39:39 -04:00
Michael Goulet
e5412da723 Supertrait elaboration doesn't need to use Predicates 2024-07-05 15:51:53 -04:00
Michael Goulet
fb8d5f1e13 Actually just make can_eq process obligations (almost) everywhere 2024-07-05 11:59:54 -04:00
Michael Goulet
fdde66acee Process alias-relate obligations when proving receiver_is_valid 2024-07-05 11:59:52 -04:00
Esteban Küber
2699d8108c Use shorter span for float literal suggestion 2024-07-04 05:19:35 +00:00
Michael Goulet
b1059ccda2 Instance::resolve -> Instance::try_resolve, and other nits 2024-07-02 17:28:03 -04:00
bors
7b21c18fe4 Auto merge of #126996 - oli-obk:do_not_count_errors, r=nnethercote
Automatically taint InferCtxt when errors are emitted

r? `@nnethercote`

Basically `InferCtxt::dcx` now returns a `DiagCtxt` that refers back to the `Cell<Option<ErrorGuaranteed>>` of the `InferCtxt` and thus when invoking `Diag::emit`, and the diagnostic is an error, we taint the `InferCtxt` directly.

That change on its own has no effect at all, because `InferCtxt` already tracks whether errors have been emitted by recording the global error count when it gets opened, and checking at the end whether the count changed. So I removed that error count check, which had a bit of fallout that I immediately fixed by invoking `InferCtxt::dcx` instead of `TyCtxt::dcx` in a bunch of places.

The remaining new errors are because an error was reported in another query, and never bubbled up. I think they are minor enough for this to be ok, and sometimes it actually improves diagnostics, by not silencing useful diagnostics anymore.

fixes #126485 (cc `@olafes)`

There are more improvements we can do (like tainting in hir ty lowering), but I would rather do that in follow up PRs, because it requires some refactorings.
2024-07-01 06:35:58 +00:00
Michael Goulet
81c2c57519 Make queries more explicit 2024-06-27 12:03:57 -04:00
Oli Scherer
86c8eae774 Automatically taint InferCtxt when errors are emitted 2024-06-26 16:01:45 +00:00
Oli Scherer
5988078aa2 Restrict diagnostic context lifetime of InferCtxt to itself instead of TyCtxt 2024-06-26 16:01:44 +00:00
Oli Scherer
79ac8982ca Restrict diagnostic context lifetime of TypeErrCtxt to InferCtxt instead of TyCtxt 2024-06-26 16:01:44 +00:00
Oli Scherer
f3d9523a2e Restrict diagnostic context lifetime of FnCtxt to InferCtxt instead of TyCtxt 2024-06-26 16:01:44 +00:00
Matthias Krüger
dad39e8840
Rollup merge of #126915 - SparkyPotato:fix-126903, r=compiler-errors
Don't suggest awaiting in closure patterns

Fixes #126903.

For
```rust
async fn do_async() {}

fn main() {
    Some(do_async()).map(|()| {});
}
```
the error is now
```rust
error[E0308]: mismatched types
 --> src/main.rs:4:27
  |
4 |     Some(do_async()).map(|()| {});
  |                           ^^
  |                           |
  |                           expected future, found `()`
  |                           expected due to this
  |
  = note: expected opaque type `impl Future<Output = ()>`
               found unit type `()`
```

Ideally, if `main` were to be `async`, it should be
```rs
error[E0308]: mismatched types
 --> src/main.rs:4:27
  |
4 |     Some(do_async()).map(|()| {});
  |                           ^^
  |                           |
  |                           expected future, found `()`
  |                           expected due to this
  |
  = note: expected opaque type `impl Future<Output = ()>`
               found unit type `()`
help: consider `await`ing on the `Future`
  |
4 |     Some(do_async().await).map(|()| {});
  |                    ++++++
```
However, this would mean `FnCtx::check_pat_top` would have to be called with an `origin_expr` in `rustc_hir_typeck::check::check_fn`, and that expr would have to be somehow plumbed through `FnCtxt::check_expr_closure` and closure signature deduction. I'm willing to work on the plumbing but unsure how to start.
2024-06-25 18:03:01 +02:00
SparkyPotato
26677eb06e don't suggest awaiting type expr patterns 2024-06-24 16:20:22 -05:00
Michael Goulet
f26cc349d9 Split out IntoIterator and non-Iterator constructors for AliasTy/AliasTerm/TraitRef/projection 2024-06-24 11:28:21 -04:00
Michael Goulet
db638ab968 Rename a bunch of things 2024-06-21 12:32:05 -04:00
Nicholas Nethercote
665821cb60 Add blank lines after module-level //! comments.
Most modules have such a blank line, but some don't. Inserting the blank
line makes it clearer that the `//!` comments are describing the entire
module, rather than the `use` declaration(s) that immediately follows.
2024-06-20 09:23:20 +10:00
Oli Scherer
ba4510ece8 Allow constraining opaque types during subtyping in the trait system 2024-06-19 08:29:17 +00:00
bors
8fcd4dd08e Auto merge of #126614 - compiler-errors:uplift-next-trait-solver, r=lcnr
Uplift next trait solver to `rustc_next_trait_solver`

🎉

There's so many FIXMEs! Sorry! Ideally this merges with the FIXMEs and we track and squash them over the near future.

Also, this still doesn't build on anything other than rustc. I still need to fix `feature = "nightly"` in `rustc_type_ir`, and remove and fix all the nightly feature usage in the new trait solver (notably: let-chains).

Also, sorry `@lcnr` I know you asked for me to separate the commit where we `mv rustc_trait_selection/solve/... rustc_next_trait_solver/solve/...`, but I had already done all the work by that point. Luckily, `git` understands the file moves so it should still be relatively reviewable.

If this is still very difficult to review, then I can do some rebasing magic to try to separate this out. Please let me know!

r? lcnr
2024-06-18 19:41:33 +00:00
Oli Scherer
3f34196839 Remove redundant argument from subdiagnostic method 2024-06-18 15:42:11 +00:00
Oli Scherer
7ba82d61eb Use a dedicated type instead of a reference for the diagnostic context
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18 15:42:11 +00:00
Michael Goulet
baf94bddf0 SolverDelegate 2024-06-18 10:40:30 -04:00
Oli Scherer
c91edc3888 Prefer dcx methods over fields or fields' methods 2024-06-18 13:45:08 +00:00
Vadim Petrochenkov
14da80c372 rustc_span: Minor improvements
Introduce `{IndexNewtype,SyntaxContext}::from_u16` for convenience because small indices are sometimes encoded as `u16`.
Use `SpanData::span` instead of `Span::new` where appropriate.
Add a clarifying comment about decoding span parents.
2024-06-16 14:08:25 +03:00
Guillaume Gomez
aa6fb1cfcb
Rollup merge of #126496 - compiler-errors:more-generics, r=lcnr
Make proof tree probing and `Candidate`/`CandidateSource` generic over interner

`<TyCtxt<'tcx>>` is ugly, but will become `<I>` when things actually become generic.

r? lcnr
2024-06-15 19:51:36 +02:00
Matthias Krüger
335e320baa
Rollup merge of #126354 - compiler-errors:variance, r=lcnr
Use `Variance` glob imported variants everywhere

Fully commit to using the globbed variance. Could be convinced the other way, and change this PR to not use the globbed variants anywhere, but I'd rather we do one or the other.

r? lcnr
2024-06-15 10:56:40 +02:00
Michael Goulet
c2e416c471 Make proof tree probing generic 2024-06-14 16:04:45 -04:00
Matthias Krüger
9f2fc640f3
Rollup merge of #126368 - nnethercote:rm-more-unused-crate-deps, r=jackh726
Remove some unnecessary crate dependencies.

A follow-up to #126063.

r? ``@jackh726``
2024-06-14 08:35:50 +02:00
Matthias Krüger
74e82328ce
Rollup merge of #124884 - bvanjoi:fix-124785, r=estebank
place explicit lifetime bound after generic param

Fixes #124785

An easy fix.
2024-06-14 08:35:48 +02:00
Michael Goulet
c8e42065f0 Address nits
- Remove the ValuePairs glob import
- Make DummyPairs -> ValuePairs::Dummy and make it bug more
- Fix WC
- Make interner return `impl IntoIterator`s
2024-06-13 09:47:45 -04:00
Michael Goulet
a2fb2ebc17 Fix some TODOs 2024-06-13 09:34:29 -04:00
Michael Goulet
e82db89b4d Finish uplifting all of structural_traits 2024-06-13 09:34:29 -04:00