rust/src/test/ui/wf
Aaron Hill a765333738
Add initial implementation of HIR-based WF checking for diagnostics
During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).

This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.

This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.

The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.

Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).
2021-07-16 16:29:02 -05:00
..
issue-48638.rs
wf-array-elem-sized.rs
wf-array-elem-sized.stderr
wf-complex-assoc-type.rs Add initial implementation of HIR-based WF checking for diagnostics 2021-07-16 16:29:02 -05:00
wf-complex-assoc-type.stderr Add initial implementation of HIR-based WF checking for diagnostics 2021-07-16 16:29:02 -05:00
wf-const-type.rs
wf-const-type.stderr
wf-convert-unsafe-trait-obj-box.rs
wf-convert-unsafe-trait-obj-box.stderr review comments 2020-10-20 09:26:15 -07:00
wf-convert-unsafe-trait-obj.rs
wf-convert-unsafe-trait-obj.stderr review comments 2020-10-20 09:26:15 -07:00
wf-enum-bound.rs
wf-enum-bound.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-enum-fields-struct-variant.rs
wf-enum-fields-struct-variant.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-enum-fields.rs
wf-enum-fields.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-fn-where-clause.rs
wf-fn-where-clause.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-foreign-fn-decl-ret.rs
wf-foreign-fn-decl-ret.stderr Replace associated item bound vars with placeholders when projecting. 2021-07-09 00:04:47 -04:00
wf-impl-associated-type-region.rs
wf-impl-associated-type-region.stderr
wf-impl-associated-type-trait.rs
wf-impl-associated-type-trait.stderr Add initial implementation of HIR-based WF checking for diagnostics 2021-07-16 16:29:02 -05:00
wf-impl-self-type.rs
wf-impl-self-type.stderr
wf-in-fn-arg.rs
wf-in-fn-arg.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-in-fn-ret.rs
wf-in-fn-ret.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-in-fn-type-arg.rs
wf-in-fn-type-arg.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-in-fn-type-ret.rs
wf-in-fn-type-ret.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-in-fn-type-static.rs
wf-in-fn-type-static.stderr
wf-in-fn-where-clause.rs
wf-in-fn-where-clause.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-in-foreign-fn-decls-issue-80468.rs FIx ICE on wf check for foreign fns 2020-12-31 11:25:53 +09:00
wf-in-foreign-fn-decls-issue-80468.stderr FIx ICE on wf check for foreign fns 2020-12-31 11:25:53 +09:00
wf-in-obj-type-static.rs
wf-in-obj-type-static.stderr
wf-in-obj-type-trait.rs
wf-in-obj-type-trait.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-inherent-impl-method-where-clause.rs
wf-inherent-impl-method-where-clause.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-inherent-impl-where-clause.rs
wf-inherent-impl-where-clause.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-misc-methods-issue-28609.rs
wf-misc-methods-issue-28609.stderr
wf-object-safe.rs
wf-object-safe.stderr review comments 2020-10-20 09:26:15 -07:00
wf-outlives-ty-in-fn-or-trait.rs
wf-outlives-ty-in-fn-or-trait.stderr
wf-packed-on-proj-of-type-as-unimpl-trait.rs
wf-packed-on-proj-of-type-as-unimpl-trait.stderr
wf-static-method.nll.stderr Adjust self-type to require equality 2021-05-21 10:16:53 -04:00
wf-static-method.rs Adjust self-type to require equality 2021-05-21 10:16:53 -04:00
wf-static-method.stderr Adjust self-type to require equality 2021-05-21 10:16:53 -04:00
wf-static-type.rs
wf-static-type.stderr
wf-struct-bound.rs
wf-struct-bound.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-struct-field.rs
wf-struct-field.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-trait-associated-type-bound.rs
wf-trait-associated-type-bound.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-trait-associated-type-region.rs
wf-trait-associated-type-region.stderr
wf-trait-associated-type-trait.rs
wf-trait-associated-type-trait.stderr
wf-trait-bound.rs
wf-trait-bound.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-trait-default-fn-arg.rs
wf-trait-default-fn-arg.stderr
wf-trait-default-fn-ret.rs
wf-trait-default-fn-ret.stderr
wf-trait-default-fn-where-clause.rs
wf-trait-default-fn-where-clause.stderr
wf-trait-fn-arg.rs
wf-trait-fn-arg.stderr
wf-trait-fn-ret.rs
wf-trait-fn-ret.stderr
wf-trait-fn-where-clause.rs
wf-trait-fn-where-clause.stderr
wf-trait-superbound.rs
wf-trait-superbound.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
wf-unsafe-trait-obj-match.rs
wf-unsafe-trait-obj-match.stderr review comments 2020-10-20 09:26:15 -07:00