Commit Graph

334 Commits

Author SHA1 Message Date
Michael Goulet
59315b8a63 Stabilize AFIT and RPITIT 2023-10-13 21:01:36 +00:00
Matthias Krüger
3712ea82f3
Rollup merge of #116436 - compiler-errors:structurally-normalize-for-closure, r=lcnr
Structurally normalize for closure

Fixes some signature deduction problems in the new trait solver (and in the case of async, an ICE).

r? lcnr
2023-10-11 20:08:21 +02:00
Michael Goulet
592163fb71 Extend impl's def_span to include where clauses 2023-10-09 11:47:02 +00:00
bors
94bc9c737e Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser
Show more information when multiple `impl`s apply

- When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s).
```
error[E0283]: type annotations needed
  --> $DIR/multiple-impl-apply.rs:34:9
   |
LL |     let y = x.into();
   |         ^     ---- type must be known at this point
   |
note: multiple `impl`s satisfying `_: From<Baz>` found
  --> $DIR/multiple-impl-apply.rs:14:1
   |
LL | impl From<Baz> for Bar {
   | ^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl From<Baz> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^
   = note: required for `Baz` to implement `Into<_>`
help: consider giving `y` an explicit type
   |
LL |     let y: /* Type */ = x.into();
   |          ++++++++++++
```

- Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user.

- Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases.
```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/cross-return-site-inference.rs:38:16
   |
LL |     return Err(From::from("foo"));
   |                ^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     return Err(</* self type */ as From>::from("foo"));
   |                +++++++++++++++++++     +
```

Fix #88284.
2023-10-06 18:44:32 +00:00
Esteban Küber
4483ac2206 Fix windows test that has different stderr output 2023-10-06 15:51:04 +00:00
bors
cae0791da4 Auto merge of #116417 - ouz-a:trait_type_detective, r=compiler-errors
Remove is global hack

In attempt to fix https://github.com/rust-lang/rust/issues/114057 we found several issues with how compiler computes layouts, this change removes `is_global` from `and` to stop impl from being shadowed.

In depth conversation can be read here https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Getting.20different.20types.20from.20almost.20same.20inputs

This is a fix candidate opened for performance run.

r? `@lcnr`
2023-10-05 19:42:05 +00:00
Oğuz Ağcayazı
e30d27be00 remove is global hack 2023-10-05 21:38:12 +03:00
Alex Macleod
5453a9f34d Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
Michael Goulet
dfbb1bfc89 Also closures 2023-10-05 00:05:45 +00:00
Michael Goulet
966f27977a Structurally normalize async fn return type in deduce_future_output_from_obligations 2023-10-05 00:05:20 +00:00
Esteban Küber
8d92c996ca Fix test on WASM target by making ambiguity pruning more agressive 2023-10-04 18:58:06 +00:00
Esteban Küber
91b9ffeab0 Reorder fullfillment errors to keep more interesting ones first
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed`
and coercion errors to the end of the list. The pre-existing
deduplication logic eliminates redundant errors better that way, keeping
the resulting output with fewer errors than before, while also having
more detail.
2023-10-04 02:04:14 +00:00
Matthias Krüger
9143370868
Rollup merge of #116379 - fmease:opaq-hid-inf-bnds-non-lt-bndrs, r=compiler-errors
non_lifetime_binders: fix ICE in lint opaque-hidden-inferred-bound

Opaque types like `impl for<T> Trait<T>` would previously lead to an ICE.

r? `@compiler-errors`
2023-10-03 16:24:17 +02:00
León Orell Valerian Liehr
3f0a327fbb
non_lifetime_binders: fix ICE in lint opaque-hidden-inferred-bound 2023-10-03 13:59:59 +02:00
Michael Goulet
07851679cd Point out the actual mismatch error 2023-10-02 23:14:29 +00:00
bors
60bb5192d1 Auto merge of #115843 - lcnr:bb-provisional-cache, r=compiler-errors
new solver: remove provisional cache

The provisional cache is a performance optimization if there are large, interleaving cycles. Such cycles generally do not exist. It is incredibly complex and unsound in all trait solvers which have one: the old solver, chalk, and the new solver ([link](https://github.com/rust-lang/rust/blob/master/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs)).

Given the assumption that it is not perf-critical and also incredibly complex, remove it from the new solver, only checking whether a goal is on the stack. While writing this, I uncovered two additional soundness bugs, see the inline comments for them.

r? `@compiler-errors`
2023-09-29 02:09:40 +00:00
Camille GILLOT
211d2ed07b Bless tests. 2023-09-23 13:47:30 +00:00
Ralf Jung
c4ec12f4b7 adjust how closure/generator types and rvalues are printed 2023-09-21 22:20:58 +02:00
lcnr
8eade3aa71 update tests 2023-09-21 08:17:58 +02:00
bors
4b91288484 Auto merge of #115486 - compiler-errors:dont-capture-late-pls, r=cjgillot
Correctly deny late-bound lifetimes from parent in anon consts and TAITs

Reuse the `AnonConstBoundary` scope (introduced in #108553, renamed in this PR to `LateBoundary`) to deny late-bound vars of *all* kinds (ty/const/lifetime) in anon consts and TAITs.

Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657):
c4f25777a0/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs (L733-L754) but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched.

Fixes #115474
2023-09-20 03:34:51 +00:00
lcnr
e8b8ddd17e remove provisional cache 2023-09-18 17:01:29 +02:00
Michael Goulet
280f058560 Canonicalize effect vars in new solver 2023-09-15 05:11:16 +00:00
Michael Goulet
30e6cea0ae Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
Michael Goulet
3bf3dadbc0 Ensure that dyn trait bounds stay sorted 2023-09-07 06:57:08 +00:00
Michael Goulet
67e7d85ad2 Rename folder typo 2023-09-07 04:52:26 +00:00
Michael Goulet
ee9727e263 Don't suggest dereferencing to unsized type 2023-09-07 04:52:00 +00:00
Michael Goulet
52aff53812 Correctly deny late-bound lifetimes from parent in anon consts and TAITs 2023-09-05 20:20:55 +00:00
Michael Goulet
8c667febbd Don't ICE on associated type projection without feature gate 2023-09-03 19:43:58 +00:00
Michael Goulet
4647aea7aa Don't record spans for predicates in coherence 2023-08-30 18:24:18 +00:00
Rémy Rakic
325b585259 add non-regression test for issue 115351 2023-08-29 19:03:08 +00:00
David Tolnay
823bacb6e3
Revert "Suggest using Arc on !Send/!Sync types"
This reverts commit 9de1a472b6.
2023-08-28 03:16:48 -07:00
Esteban Küber
b6494a7bb4 More accurately point at arguments 2023-08-26 19:25:46 +00:00
Esteban Küber
120c24dab5 Point at appropriate type parameter in more trait bound errors 2023-08-26 01:07:05 +00:00
Michael Goulet
055452864e Walk through full path in point_at_path_if_possible 2023-08-25 19:05:38 +00:00
Olanti
8216f17d7d Move issue 29181, 2804, 17431, 66768 2023-08-24 20:44:08 +03:00
Matthias Krüger
33771dfaf0
Rollup merge of #114834 - compiler-errors:try_coerce-side-effects, r=lcnr
Avoid side-effects from `try_coerce` when suggesting borrowing LHS of cast

The name `try_coerce` is a bit misleading -- it has side-effects, so when it's used in diagnostics code, it sometimes causes spurious obligations to be registered which cause other errors to occur that really make no sense in context.

Addendum: let's just rename `try_coerce` to `coerce` -- the `try_` part doesn't really add much, imo.
2023-08-20 08:34:03 +02:00
Michael Goulet
822caa8b80 Avoid side-effects from try_coerce when suggesting borrowing LHS of cast 2023-08-19 22:12:51 +00:00
lcnr
ee04744e64 change to known bug 2023-08-18 23:59:49 +02:00
lcnr
11716830ac instantiate response: no unnecessary new universe
this previously was a off-by-one error.
2023-08-18 23:55:28 +02:00
Michael Goulet
c31aedf47f Don't ICE in is_trivially_sized when encountering late-bound self ty 2023-08-16 01:57:33 +00:00
Guillaume Gomez
47bdda2b45
Rollup merge of #114828 - compiler-errors:next-solver-probe-upcasting, r=lcnr
Probe when assembling upcast candidates so they don't step on eachother's toes in new solver

Lack of a probe causes one candidate to disqualify the other due to inference side-effects.

r? lcnr
2023-08-15 14:29:49 +02:00
Michael Goulet
2ae4bedd85 more span info 2023-08-15 03:40:19 +00:00
Michael Goulet
ab126c2a4e Probe when assembling upcast candidates so they don't step on eachother's toes 2023-08-15 01:02:13 +00:00
lcnr
9eeaf1fd13 normalize in trait_ref_is_knowable in new solver 2023-08-12 20:37:53 +02:00
lcnr
02529d2cbe add and move trait solver cycle tests 2023-08-10 14:18:31 +02:00
lcnr
d558353f28 make the provisional cache slightly less broken 2023-08-10 12:35:34 +02:00
Esteban Kuber
9de1a472b6 Suggest using Arc on !Send/!Sync types 2023-08-09 14:04:10 +00:00
lcnr
95d1f6bab5 add test from chalk#788 for new solver 2023-08-08 18:07:38 +02:00
Matthias Krüger
418b91a3d7
Rollup merge of #114594 - compiler-errors:new-solver-resolve-aliases, r=lcnr
Structurally normalize weak and inherent in new solver

It seems pretty obvious to me that we should be normalizing weak and inherent aliases too, since they can always be normalized. This PR still leaves open the question of what to do with opaques, though 💀

**Also**, we need to structurally resolve the target of a coercion, for the UI test to work.

r? `@lcnr`
2023-08-08 03:30:56 +02:00
Michael Goulet
ba4a2f7cb7 Resolve target type of coercion 2023-08-07 19:06:18 +00:00