1
Fork 0
rust/compiler/rustc_hir_analysis/src
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
..
astconv Auto merge of #116163 - compiler-errors:lazyness, r=oli-obk 2023-09-27 01:48:53 +00:00
check Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser 2023-10-06 18:44:32 +00:00
coherence Reorder fullfillment errors to keep more interesting ones first 2023-10-04 02:04:14 +00:00
collect Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
impl_wf_check Reorder fullfillment errors to keep more interesting ones first 2023-10-04 02:04:14 +00:00
outlives refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
structured_errors lower impl const to bind to host effect param 2023-08-06 13:34:53 +00:00
variance Optimize some alloc_from_iter call sites. 2023-10-03 18:12:37 +11:00
autoderef.rs Structurally normalize weak and inherent too 2023-08-07 19:05:59 +00:00
bounds.rs Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
check_unused.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
collect.rs don't clone copy types 2023-09-28 00:20:32 +02:00
constrained_generic_params.rs Opaques do not constrain generic params 2023-08-12 17:14:13 +00:00
errors.rs Auto merge of #115821 - obeis:hir-analysis-migrate-diagnostics-5, r=compiler-errors 2023-09-29 00:24:57 +00:00
hir_wf_check.rs Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
impl_wf_check.rs Use {Local}ModDefId in many queries 2023-08-14 07:22:48 +00:00
lib.rs rustc_hir_analysis: add a helper to check function the signature mismatches 2023-09-19 18:15:23 +02:00
structured_errors.rs