rust/tests/ui/impl-trait
Trevor Gross b5771e7e0d
Rollup merge of #127664 - compiler-errors:precise-capturing-better-sugg-apit, r=oli-obk
Fix precise capturing suggestion for hidden regions when we have APITs

Suggests to turn APITs into type parameters so they can be named in precise capturing syntax for hidden type lifetime errors. We also note that it may change the API.

This is currently done via a note *and* a suggestion, which feels a bit redundant, but I wasn't totally sure of a better alternative for the presentation.

Code is kind of a mess but there's a lot of cases to consider. Happy to iterate on this if you think the approach is too messy.

Based on #127619, only the last commit is relevant.
r? oli-obk

Tracking:

- https://github.com/rust-lang/rust/issues/123432
2024-07-17 19:53:26 -05:00
..
alias-liveness Add another test for hidden types capturing lifetimes that outlive but arent mentioned in substs 2024-06-04 21:06:29 -04:00
auxiliary
diagnostics
explicit-generic-args-with-impl-trait
in-ctfe
in-trait Remove invalid further restricting for type bound 2024-07-17 19:08:37 +08:00
issues Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
multiple-lifetimes
precise-capturing Fix precise capturing suggestion for hidden type when APITs are involved 2024-07-17 10:52:13 -04:00
rpit
transmute Automatically taint InferCtxt when errors are emitted 2024-06-26 16:01:45 +00:00
arg-position-impl-trait-too-long.rs
arg-position-impl-trait-too-long.stderr
associated-impl-trait-type-generic-trait.rs
associated-impl-trait-type-issue-114325.rs
associated-impl-trait-type-trivial.rs
associated-impl-trait-type.rs
associated-type-cycle.rs
associated-type-cycle.stderr
associated-type-undefine.rs Add test for walking order dependent opaque type behaviour 2024-06-12 15:32:25 +00:00
associated-type-undefine.stderr Add test for walking order dependent opaque type behaviour 2024-06-12 15:32:25 +00:00
async_scope_creep.rs
auto-trait-coherence.next.stderr
auto-trait-coherence.old.stderr
auto-trait-coherence.rs
auto-trait-leak2.rs
auto-trait-leak2.stderr
auto-trait-leak-rpass.rs
auto-trait-leak.rs
auto-trait-leak.stderr
autoderef.rs
bivariant-lifetime-liveness.rs
bound-normalization-fail.rs
bound-normalization-fail.stderr
bound-normalization-pass.rs
bounds_regression.rs
call_method_ambiguous.next.stderr Delay a bug and mark precise_capturing as not incomplete 2024-06-17 22:35:25 -04:00
call_method_ambiguous.rs Delay a bug and mark precise_capturing as not incomplete 2024-06-17 22:35:25 -04:00
call_method_on_inherent_impl_on_rigid_type.current.stderr Add some tests 2024-06-13 10:41:52 +00:00
call_method_on_inherent_impl_on_rigid_type.next.stderr Add some tests 2024-06-13 10:41:52 +00:00
call_method_on_inherent_impl_on_rigid_type.rs Add some tests 2024-06-13 10:41:52 +00:00
call_method_on_inherent_impl_ref.current.stderr Add some tests 2024-06-13 10:41:52 +00:00
call_method_on_inherent_impl_ref.next.stderr Add some tests 2024-06-13 10:41:52 +00:00
call_method_on_inherent_impl_ref.rs Add some tests 2024-06-13 10:41:52 +00:00
call_method_on_inherent_impl.next.stderr Add some tests 2024-06-13 10:41:52 +00:00
call_method_on_inherent_impl.rs Add some tests 2024-06-13 10:41:52 +00:00
call_method_without_import.no_import.stderr Add some tests 2024-06-13 10:41:52 +00:00
call_method_without_import.rs Add some tests 2024-06-13 10:41:52 +00:00
can-return-unconstrained-closure.rs
capture-lifetime-not-in-hir.rs
capture-lifetime-not-in-hir.stderr
closure-calling-parent-fn.rs
closure-in-impl-trait-arg.rs
closure-in-impl-trait.rs
coherence-treats-tait-ambig.current.stderr
coherence-treats-tait-ambig.rs
coherence-treats-tait-ambig.stderr
cross-return-site-inference.rs
cross-return-site-inference.stderr
deduce-signature-from-supertrait.rs
defined-by-trait-resolution.rs
defining-use-captured-non-universal-region.infer.stderr
defining-use-captured-non-universal-region.rs
defining-use-captured-non-universal-region.statik.stderr
defining-use-uncaptured-non-universal-region-2.rs
defining-use-uncaptured-non-universal-region-3.rs
defining-use-uncaptured-non-universal-region.rs
deprecated_annotation.rs
different_where_bounds.rs
divergence.rs
does-not-live-long-enough.rs
does-not-live-long-enough.stderr
dont-suggest-box-on-empty-else-arm.rs
dont-suggest-box-on-empty-else-arm.stderr
dyn-impl-type-mismatch.rs
dyn-impl-type-mismatch.stderr
dyn-trait-elided-two-inputs-assoc.rs
dyn-trait-elided-two-inputs-param.rs
dyn-trait-elided-two-inputs-ref-assoc.rs borrowck: more eagerly prepopulate opaques 2024-05-06 16:04:57 +00:00
dyn-trait-elided-two-inputs-ref-param.rs
dyn-trait-return-should-be-impl-trait.rs
dyn-trait-return-should-be-impl-trait.stderr
eagerly-reveal-in-local-body.rs
equal-hidden-lifetimes.rs
equality2.rs
equality2.stderr
equality-in-canonical-query.rs
equality-rpass.rs
equality-rpass.stderr
equality.rs Revert "When checking whether an impl applies, constrain hidden types of opaque types." 2024-06-11 08:08:25 +00:00
equality.stderr Spell out other trait diagnostic 2024-06-12 12:34:47 +00:00
erased-regions-in-hidden-ty.current.stderr
erased-regions-in-hidden-ty.next.stderr
erased-regions-in-hidden-ty.rs Always use a colon in //@ normalize-*: headers 2024-07-11 12:23:44 +10:00
example-calendar.rs
example-st.rs
example-st.stderr
extra-impl-in-trait-impl.fixed Improve dead code analysis 2024-07-04 22:05:00 +08:00
extra-impl-in-trait-impl.rs Improve dead code analysis 2024-07-04 22:05:00 +08:00
extra-impl-in-trait-impl.stderr Make impl and ! removal suggestion short 2024-07-12 03:02:57 +00:00
extra-item.rs
extra-item.stderr
failed-to-resolve-instance-ice-105488.rs
failed-to-resolve-instance-ice-105488.stderr
failed-to-resolve-instance-ice-123145.rs
failed-to-resolve-instance-ice-123145.stderr
fallback_inference.rs
fallback_inference.stderr
fallback.rs
feature-self-return-type.rs
feature-self-return-type.stderr
fresh-lifetime-from-bare-trait-obj-114664.rs
fresh-lifetime-from-bare-trait-obj-114664.stderr
future-no-bound-vars-ice-112347.rs Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
generic-with-implicit-hrtb-without-dyn.edition2015.stderr
generic-with-implicit-hrtb-without-dyn.edition2021.stderr
generic-with-implicit-hrtb-without-dyn.rs
hidden-lifetimes.rs
hidden-lifetimes.stderr
hidden-type-is-opaque-2.default.stderr
hidden-type-is-opaque-2.next.stderr
hidden-type-is-opaque-2.rs
hidden-type-is-opaque.rs
ice-unexpected-param-type-whensubstituting-in-region-112823.rs
ice-unexpected-param-type-whensubstituting-in-region-112823.stderr
impl_fn_associativity.rs
impl_trait_projections.rs
impl_trait_projections.stderr
impl-fn-hrtb-bounds-2.rs
impl-fn-hrtb-bounds-2.stderr
impl-fn-hrtb-bounds.rs
impl-fn-hrtb-bounds.stderr
impl-fn-parsing-ambiguities.rs
impl-fn-parsing-ambiguities.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
impl-fn-predefined-lifetimes.rs Automatically taint InferCtxt when errors are emitted 2024-06-26 16:01:45 +00:00
impl-fn-predefined-lifetimes.stderr Automatically taint InferCtxt when errors are emitted 2024-06-26 16:01:45 +00:00
impl-generic-mismatch-ab.rs
impl-generic-mismatch-ab.stderr Use verbose suggestion for changing arg type 2024-07-05 20:58:33 +00:00
impl-generic-mismatch.rs
impl-generic-mismatch.stderr
impl-subtyper2.rs
impl-subtyper.rs
impl-trait-in-macro.rs
impl-trait-in-macro.stderr
impl-trait-plus-priority.rs
impl-trait-plus-priority.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
implicit-capture-late.rs
implicit-capture-late.stderr
in-assoc-type-unconstrained.rs
in-assoc-type-unconstrained.stderr show unit output when there is only output diff in diagnostics 2024-07-06 21:00:30 +08:00
in-assoc-type.rs
in-assoc-type.stderr
issue-35668.rs
issue-35668.stderr
issue-36792.rs
issue-46959.rs
issue-49556.rs
issue-49579.rs
issue-49685.rs
issue-51185.rs
issue-54966.rs
issue-54966.stderr
issue-55872-1.rs
issue-55872-1.stderr
issue-55872-2.rs
issue-55872-2.stderr
issue-55872-3.rs
issue-55872-3.stderr Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
issue-55872.rs
issue-55872.stderr
issue-56445.rs
issue-68532.rs
issue-72911.rs Avoid follow-up errors and ICEs after missing lifetime errors on data structures 2024-07-11 11:00:15 +00:00
issue-72911.stderr Avoid follow-up errors and ICEs after missing lifetime errors on data structures 2024-07-11 11:00:15 +00:00
issue-87450.rs
issue-87450.stderr
issue-99073-2.rs
issue-99073-2.stderr
issue-99073.rs
issue-99073.stderr
issue-99642-2.rs
issue-99642.rs
issue-99914.rs
issue-99914.stderr Inline get_node_fn_decl into get_fn_decl, simplify/explain logic in report_return_mismatched_types 2024-05-20 20:16:29 -04:00
issue-100075-2.rs
issue-100075-2.stderr
issue-100075.rs
issue-100075.stderr
issue-100187.rs
issue-102605.rs
issue-102605.stderr
issue-103181-1.current.stderr
issue-103181-1.next.stderr
issue-103181-1.rs
issue-103181-2.rs
issue-103181-2.stderr
issue-103599.rs
issue-103599.stderr
issue-108591.rs
issue-108592.rs Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
lazy_subtyping_of_opaques.rs Allow constraining opaque types during subtyping in the trait system 2024-06-19 08:29:17 +00:00
lifetime-ambiguity-regression.rs
lifetimes2.rs
lifetimes.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
mapping-duplicated-lifetimes-issue-114597.rs
method-resolution2.next.stderr Add some tests 2024-06-13 10:41:52 +00:00
method-resolution2.rs Method resolution constrains hidden types instead of rejecting method candidates 2024-06-13 10:41:53 +00:00
method-resolution3.current.stderr Method resolution constrains hidden types instead of rejecting method candidates 2024-06-13 10:41:53 +00:00
method-resolution3.next.stderr Method resolution constrains hidden types instead of rejecting method candidates 2024-06-13 10:41:53 +00:00
method-resolution3.rs Method resolution constrains hidden types instead of rejecting method candidates 2024-06-13 10:41:53 +00:00
method-resolution4.next.stderr Add some tests 2024-06-13 10:41:52 +00:00
method-resolution4.rs Method resolution constrains hidden types instead of rejecting method candidates 2024-06-13 10:41:53 +00:00
method-resolution.rs Method resolution constrains hidden types instead of rejecting method candidates 2024-06-13 10:41:53 +00:00
method-suggestion-no-duplication.rs
method-suggestion-no-duplication.stderr
multiple-defining-usages-in-body.rs
multiple-defining-usages-in-body.stderr
must_outlive_least_region_or_bound.rs
must_outlive_least_region_or_bound.stderr
needs_least_region_or_bound.rs
negative-reasoning.rs
negative-reasoning.stderr
nested_impl_trait.rs Actually just make can_eq process obligations (almost) everywhere 2024-07-05 11:59:54 -04:00
nested_impl_trait.stderr Actually just make can_eq process obligations (almost) everywhere 2024-07-05 11:59:54 -04:00
nested-hkl-lifetime.rs
nested-return-type2-tait2.rs
nested-return-type2-tait2.stderr
nested-return-type2-tait3.rs
nested-return-type2-tait3.stderr
nested-return-type2-tait.rs
nested-return-type2-tait.stderr
nested-return-type2.rs
nested-return-type3-tait2.rs
nested-return-type3-tait2.stderr
nested-return-type3-tait3.rs
nested-return-type3-tait3.stderr
nested-return-type3-tait.rs
nested-return-type3-tait.stderr
nested-return-type3.rs
nested-return-type4.rs
nested-return-type4.stderr Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
nested-return-type.rs
nested-rpit-hrtb-2.rs
nested-rpit-hrtb-2.stderr
nested-rpit-hrtb.rs Stop proving outlives constraints on regions we already reported errors on 2024-05-29 09:27:07 +00:00
nested-rpit-hrtb.stderr Stop proving outlives constraints on regions we already reported errors on 2024-05-29 09:27:07 +00:00
nested-rpit-with-anonymous-lifetimes.rs
nesting.rs
no-method-suggested-traits.rs
no-method-suggested-traits.stderr
no-trait.rs
no-trait.stderr
normalize-opaque-with-bound-vars.rs
normalize-tait-in-const.rs Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
normalize-tait-in-const.stderr bless tests 2024-06-21 11:57:24 +00:00
not_general_enough_regression_106630.rs
object-unsafe-trait-in-return-position-dyn-trait.rs
object-unsafe-trait-in-return-position-dyn-trait.stderr
object-unsafe-trait-in-return-position-impl-trait.rs
object-unsafe-trait-in-return-position-impl-trait.stderr
opaque-cast-field-access-in-future.rs
opaque-cast-field-access-in-future.stderr
opaque-used-in-extraneous-argument.rs
opaque-used-in-extraneous-argument.stderr Use verbose style for argument removal suggestion 2024-07-05 19:40:09 +00:00
point-to-type-err-cause-on-impl-trait-return.rs
point-to-type-err-cause-on-impl-trait-return.stderr
printing-binder.rs
printing-binder.stderr
private_unused.rs
projection-mismatch-in-impl-where-clause.rs
projection-mismatch-in-impl-where-clause.stderr
projection.rs
question_mark.rs
recursive-auto-trait.rs
recursive-bound-eval.next.stderr Also test under next solver 2024-06-11 08:19:19 +00:00
recursive-bound-eval.rs Also test under next solver 2024-06-11 08:19:19 +00:00
recursive-coroutine-boxed.next.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
recursive-coroutine-boxed.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
recursive-coroutine-indirect.current.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
recursive-coroutine-indirect.next.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
recursive-coroutine-indirect.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
recursive-ice-101862.rs
recursive-ice-101862.stderr
recursive-impl-trait-type-direct.rs
recursive-impl-trait-type-indirect.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
recursive-impl-trait-type-indirect.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
recursive-impl-trait-type-through-non-recursive.rs
recursive-impl-trait-type-through-non-recursive.stderr
recursive-parent-trait-method-call.rs Add some tests 2024-06-13 10:41:52 +00:00
recursive-type-alias-impl-trait-declaration-too-subtle-2.rs Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
recursive-type-alias-impl-trait-declaration-too-subtle.rs Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
recursive-type-alias-impl-trait-declaration-too-subtle.stderr Use verbose suggestion for changing arg type 2024-07-05 20:58:33 +00:00
recursive-type-alias-impl-trait-declaration.rs Revert "When checking whether an impl applies, constrain hidden types of opaque types." 2024-06-11 08:08:25 +00:00
recursive-type-alias-impl-trait-declaration.stderr Revert "When checking whether an impl applies, constrain hidden types of opaque types." 2024-06-11 08:08:25 +00:00
region-escape-via-bound-contravariant-closure.rs
region-escape-via-bound-contravariant.rs
region-escape-via-bound.rs
region-escape-via-bound.stderr
return-position-impl-trait-minimal.rs
reveal-during-codegen.rs
rpit-assoc-pair-with-lifetime.rs
rpit-not-sized.rs
rpit-not-sized.stderr
stashed-diag-issue-121504.rs
stashed-diag-issue-121504.stderr
static-lifetime-return-position-impl-trait.rs
static-return-lifetime-infered.rs
static-return-lifetime-infered.stderr
stranded-opaque.rs
stranded-opaque.stderr
suggest-calling-rpit-closure.rs
suggest-calling-rpit-closure.stderr
trait_resolution.rs
trait_type.rs
trait_type.stderr show fnsig's output when there is difference 2024-07-06 23:29:58 +08:00
trait_upcasting_reference_mismatch.rs Allow constraining opaque types during auto trait casting 2024-06-19 08:28:31 +00:00
trait_upcasting_reference_mismatch.stderr Allow constraining opaque types during auto trait casting 2024-06-19 08:28:31 +00:00
trait_upcasting.rs Allow constraining opaque types during auto trait casting 2024-06-19 08:28:31 +00:00
two_tait_defining_each_other2.current.stderr Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
two_tait_defining_each_other2.next.stderr
two_tait_defining_each_other2.rs Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
two_tait_defining_each_other3.current.stderr
two_tait_defining_each_other3.rs
two_tait_defining_each_other.current.stderr
two_tait_defining_each_other.rs
type_parameters_captured.rs
type_parameters_captured.stderr
type-alias-generic-param.rs
type-alias-generic-param.stderr
type-alias-impl-trait-in-fn-body.rs Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
type-alias-impl-trait-in-fn-body.stderr Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
type-arg-mismatch-due-to-impl-trait.rs
type-arg-mismatch-due-to-impl-trait.stderr
unactionable_diagnostic.fixed
unactionable_diagnostic.rs
unactionable_diagnostic.stderr
universal_hrtb_anon.rs
universal_hrtb_named.rs
universal_in_adt_in_parameters.rs
universal_in_impl_trait_in_parameters.rs
universal_in_trait_defn_parameters.rs
universal_multiple_bounds.rs
universal_wrong_bounds.rs
universal_wrong_bounds.stderr
universal_wrong_hrtb.rs
universal_wrong_hrtb.stderr
universal-mismatched-type.rs
universal-mismatched-type.stderr
universal-two-impl-traits.rs
universal-two-impl-traits.stderr
unsafety-checking-cycle.rs
unsize_adt.rs Allow constraining opaque types during unsizing 2024-06-19 08:28:31 +00:00
unsize_slice.rs Allow constraining opaque types during unsizing 2024-06-19 08:28:31 +00:00
unsize_tuple.rs Allow constraining opaque types during unsizing 2024-06-19 08:28:31 +00:00
unsized_coercion2.old.stderr Add more tests 2024-06-19 08:28:31 +00:00
unsized_coercion2.rs Add more tests 2024-06-19 08:28:31 +00:00
unsized_coercion3.next.stderr More tests 2024-06-19 08:40:29 +00:00
unsized_coercion3.old.stderr More tests 2024-06-19 08:40:29 +00:00
unsized_coercion3.rs More tests 2024-06-19 08:40:29 +00:00
unsized_coercion4.rs More tests 2024-06-19 08:40:29 +00:00
unsized_coercion5.next.stderr More tests 2024-06-19 08:40:29 +00:00
unsized_coercion5.old.stderr More tests 2024-06-19 08:40:29 +00:00
unsized_coercion5.rs More tests 2024-06-19 08:40:29 +00:00
unsized_coercion.next.stderr Add more tests 2024-06-19 08:28:31 +00:00
unsized_coercion.rs Add more tests 2024-06-19 08:28:31 +00:00
upvar_captures.rs Taint infcx when reporting errors 2024-06-19 04:41:56 +00:00
upvar_captures.stderr Taint infcx when reporting errors 2024-06-19 04:41:56 +00:00
variance.e2024.stderr
variance.new.stderr
variance.old.stderr
variance.rs
wf-check-hidden-type.rs
wf-check-hidden-type.stderr
wf-eval-order.rs
where-allowed-2.rs
where-allowed-2.stderr
where-allowed.rs
where-allowed.stderr Use verbose suggestion for changing arg type 2024-07-05 20:58:33 +00:00
xcrate_simple.rs
xcrate.rs