2020-06-13 13:37:25 -05:00
|
|
|
error[E0277]: the trait bound `(): Foo` is not satisfied
|
Support HIR wf checking for function signatures
During function type-checking, we normalize any associated types in
the function signature (argument types + return type), and then
create WF obligations for each of the normalized types. The HIR wf code
does not currently support this case, so any errors that we get have
imprecise spans.
This commit extends `ObligationCauseCode::WellFormed` to support
recording a function parameter, allowing us to get the corresponding
HIR type if an error occurs. Function typechecking is modified to
pass this information during signature normalization and WF checking.
The resulting code is fairly verbose, due to the fact that we can
no longer normalize the entire signature with a single function call.
As part of the refactoring, we now perform HIR-based WF checking
for several other 'typed items' (statics, consts, and inherent impls).
As a result, WF and projection errors in a function signature now
have a precise span, which points directly at the responsible type.
If a function signature is constructed via a macro, this will allow
the error message to point at the code 'most responsible' for the error
(e.g. a user-supplied macro argument).
2021-07-18 11:33:49 -05:00
|
|
|
--> $DIR/wf-foreign-fn-decl-ret.rs:11:25
|
2020-06-13 13:37:25 -05:00
|
|
|
|
|
Support HIR wf checking for function signatures
During function type-checking, we normalize any associated types in
the function signature (argument types + return type), and then
create WF obligations for each of the normalized types. The HIR wf code
does not currently support this case, so any errors that we get have
imprecise spans.
This commit extends `ObligationCauseCode::WellFormed` to support
recording a function parameter, allowing us to get the corresponding
HIR type if an error occurs. Function typechecking is modified to
pass this information during signature normalization and WF checking.
The resulting code is fairly verbose, due to the fact that we can
no longer normalize the entire signature with a single function call.
As part of the refactoring, we now perform HIR-based WF checking
for several other 'typed items' (statics, consts, and inherent impls).
As a result, WF and projection errors in a function signature now
have a precise span, which points directly at the responsible type.
If a function signature is constructed via a macro, this will allow
the error message to point at the code 'most responsible' for the error
(e.g. a user-supplied macro argument).
2021-07-18 11:33:49 -05:00
|
|
|
LL | pub trait Foo {
|
|
|
|
| ------------- required by this bound in `Foo`
|
|
|
|
...
|
2020-06-13 13:37:25 -05:00
|
|
|
LL | pub fn lint_me() -> <() as Foo>::Assoc;
|
Support HIR wf checking for function signatures
During function type-checking, we normalize any associated types in
the function signature (argument types + return type), and then
create WF obligations for each of the normalized types. The HIR wf code
does not currently support this case, so any errors that we get have
imprecise spans.
This commit extends `ObligationCauseCode::WellFormed` to support
recording a function parameter, allowing us to get the corresponding
HIR type if an error occurs. Function typechecking is modified to
pass this information during signature normalization and WF checking.
The resulting code is fairly verbose, due to the fact that we can
no longer normalize the entire signature with a single function call.
As part of the refactoring, we now perform HIR-based WF checking
for several other 'typed items' (statics, consts, and inherent impls).
As a result, WF and projection errors in a function signature now
have a precise span, which points directly at the responsible type.
If a function signature is constructed via a macro, this will allow
the error message to point at the code 'most responsible' for the error
(e.g. a user-supplied macro argument).
2021-07-18 11:33:49 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()`
|
2020-06-13 13:37:25 -05:00
|
|
|
|
|
|
|
error[E0277]: the trait bound `u32: Unsatisfied` is not satisfied
|
|
|
|
--> $DIR/wf-foreign-fn-decl-ret.rs:14:32
|
|
|
|
|
|
|
|
|
LL | pub struct Bar<T: Unsatisfied>(T);
|
|
|
|
| ----------- required by this bound in `Bar`
|
|
|
|
...
|
|
|
|
LL | pub fn lint_me_aswell() -> Bar<u32>;
|
|
|
|
| ^^^^^^^^ the trait `Unsatisfied` is not implemented for `u32`
|
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0277`.
|