Commit Graph

19 Commits

Author SHA1 Message Date
Matthias Krüger
d7fcd01f67
Rollup merge of #106072 - eopb:dyn-derive, r=estebank
fix: misleading "add dyn keyword before derive macro" suggestion

Fixes #106071
2023-01-15 01:01:36 +01:00
Ethan Brierley
1caec6fa1d fix: misleading add dyn to derive macro suggestion 2023-01-14 12:14:06 +00:00
Matthias Krüger
8c538f7d83
Rollup merge of #106788 - estebank:elaborate_pred_E0599, r=compiler-errors
Tweak E0599 and elaborate_predicates

CC https://github.com/rust-lang/rust/issues/86377.
2023-01-14 13:04:26 +01:00
Matthias Krüger
108b5f462b
Rollup merge of #106752 - sulami:master, r=estebank
Emit a hint for bad call return types due to generic arguments

When the return type of a function call depends on the type of an argument, e.g.

```
fn foo<T>(x: T) -> T {
    x
}
```

and the expected type is set due to either an explicitly typed binding, or because the call to the function is in a tail position without semicolon, the current error implies that the argument in the call has the wrong type.

This new hint highlights that the expected type doesn't match the returned type, which matches the argument type, and that that's why we're flagging the argument type.

Fixes #43608.
2023-01-14 13:04:26 +01:00
kadmin
2de9d679ad Add note when FnPtr vs. FnDef impl trait
I encountered an instance where an `FnPtr` implemented a trait, but I was passing an `FnDef`. To
the end user, there is really no way to differentiate each of them, but it is necessary to cast
to the generic function in order to compile. It is thus useful to suggest `as` in the help note,
(even if the Fn output implements the trait).
2023-01-14 10:37:56 +00:00
Esteban Küber
81ba427a7b Add tests 2023-01-13 18:20:24 +00:00
Esteban Küber
3d6b09e53e Keep obligation chain when elaborating obligations 2023-01-13 18:20:23 +00:00
Matthias Krüger
c6e3a47843
Rollup merge of #106585 - estebank:issue-46585, r=compiler-errors
When suggesting writing a fully qualified path probe for appropriate types

Address the more common part of #46585.
2023-01-13 19:16:42 +01:00
Yuki Okushi
5adc7a5e37
Rollup merge of #106785 - compiler-errors:better-impl-wf-spans, r=estebank
Make blame spans better for impl wfcheck

r? types
2023-01-13 16:54:24 +09:00
Robin Schroer
a3cf3822d2
Emit a hint for bad call return types due to generic arguments
When the return type of a function call depends on the type of an
argument, e.g.

```
fn foo<T>(x: T) -> T {
    x
}
```

and the expected type is set due to either an explicitly typed
binding, or because the call to the function is in a tail position
without semicolon, the current error implies that the argument in the
call has the wrong type.

This new hint highlights that the expected type doesn't match the
returned type, which matches the argument type, and that that's why
we're flagging the argument type.

Fixes #43608.
2023-01-13 13:34:55 +09:00
Michael Goulet
5924c2511e Only point at impl self ty in WF if trait predicate shares self ty 2023-01-12 22:25:30 +00:00
Michael Goulet
950b47fb96 Render missing generics suggestion verbosely 2023-01-12 22:04:30 +00:00
Michael Goulet
2aabb0fd5d Point at impl self type for impl wf obligations 2023-01-12 20:44:47 +00:00
Michael Goulet
d76e168f01 Point at HIR types when impl trait ref doesn't normalize 2023-01-12 20:44:47 +00:00
Matthias Krüger
9b538e8e62
Rollup merge of #106309 - compiler-errors:prefer-non-err-candidates, r=oli-obk
Prefer non-`[type error]` candidates during selection

Fixes #102130
Fixes #106351

r? types

note: Alternatively we could filter out error where-clauses during param-env construction? But we still need to filter out impls with errors during `match_impl`, I think.
2023-01-12 06:52:34 +01:00
Esteban Küber
12ddf77811 When suggesting writing a fully qualified path probe for appropriate types
Fix #46585.
2023-01-11 21:30:10 +00:00
Michael Goulet
83fbc71d02 Filter impl and where-clause candidates that reference errors 2023-01-11 20:03:29 +00:00
Michael Goulet
9a39d7e441 Note predicate span on ImplDerivedObligation 2023-01-11 19:46:45 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00