rust/tests/ui/associated-types
Matthias Krüger ffdb471872
Rollup merge of #117914 - estebank:issue-85843, r=wesleywiser
On borrow return type, suggest borrowing from arg or owned return type

When we encounter a function with a return type that has an anonymous lifetime with no argument to borrow from, besides suggesting the `'static` lifetime we now also suggest changing the arguments to be borrows or changing the return type to be an owned type.

```
error[E0106]: missing lifetime specifier
  --> $DIR/variadic-ffi-6.rs:7:6
   |
LL | ) -> &usize {
   |      ^ expected named lifetime parameter
   |
   = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
   |
LL | ) -> &'static usize {
   |       +++++++
help: instead, you are more likely to want to change one of the arguments to be borrowed...
   |
LL |     x: &usize,
   |        +
help: ...or alternatively, to want to return an owned value
   |
LL - ) -> &usize {
LL + ) -> usize {
   |
```

Fix #85843.
2023-12-12 17:40:53 +01:00
..
auxiliary
cache Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associate-type-bound-normalization.rs
associated-item-long-paths.rs
associated-type-destructuring-assignment.rs
associated-type-macro.rs
associated-type-macro.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-type-projection-ambig-between-bound-and-where-clause.rs
associated-type-projection-ambig-between-bound-and-where-clause.stderr Unify suggestion wording 2023-10-17 17:33:55 +00:00
associated-type-projection-from-multiple-supertraits.rs
associated-type-projection-from-multiple-supertraits.stderr Sort errors 2023-10-30 22:19:17 +00:00
associated-type-projection-from-supertrait.rs
associated-type-projection-from-supertrait.stderr diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
associated-type-shadowed-from-non-local-supertrait.rs Point out shadowed associated types 2023-12-06 11:05:22 +01:00
associated-type-shadowed-from-non-local-supertrait.stderr Point out shadowed associated types 2023-12-06 11:05:22 +01:00
associated-type-shadowed-from-supertrait.rs Point out shadowed associated types 2023-12-06 11:05:22 +01:00
associated-type-shadowed-from-supertrait.stderr Point out shadowed associated types 2023-12-06 11:05:22 +01:00
associated-type-struct-construction.rs
associated-type-tuple-struct-construction.rs
associated-type-tuple-struct-construction.stderr
associated-types-basic.rs
associated-types-binding-in-trait.rs
associated-types-binding-in-where-clause.rs
associated-types-binding-to-type-defined-in-supertrait.rs
associated-types-binding-to-type-defined-in-supertrait.stderr
associated-types-bound-ambiguity.rs
associated-types-bound-failure.fixed
associated-types-bound-failure.rs
associated-types-bound-failure.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-bound.rs
associated-types-cc.rs
associated-types-coherence-failure.rs
associated-types-coherence-failure.stderr Extend impl's def_span to include where clauses 2023-10-09 11:47:02 +00:00
associated-types-conditional-dispatch.rs
associated-types-constant-type.rs
associated-types-doubleendediterator-object.rs
associated-types-duplicate-binding-in-env-hrtb.rs
associated-types-duplicate-binding-in-env.rs
associated-types-enum-field-named.rs
associated-types-enum-field-numbered.rs
associated-types-eq-1.rs
associated-types-eq-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-eq-2.rs
associated-types-eq-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-eq-3.rs Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
associated-types-eq-3.stderr Note base types of coercion 2023-05-12 00:10:52 +00:00
associated-types-eq-expr-path.rs
associated-types-eq-expr-path.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-eq-hr.rs
associated-types-eq-hr.stderr Specify what 'this' actually is 2023-02-21 05:21:07 +00:00
associated-types-eq-obj.rs
associated-types-for-unimpl-trait.fixed
associated-types-for-unimpl-trait.rs
associated-types-for-unimpl-trait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-from-supertrait.rs
associated-types-ICE-when-projecting-out-of-err.rs
associated-types-ICE-when-projecting-out-of-err.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-impl-redirect.rs
associated-types-in-ambiguous-context.rs rustc_metadata: Filter encoded data more aggressively using DefKind 2023-04-10 16:24:36 +03:00
associated-types-in-ambiguous-context.stderr Unify suggestion wording 2023-10-17 17:33:55 +00:00
associated-types-in-bound-type-arg.rs
associated-types-in-default-method.rs
associated-types-in-fn.rs
associated-types-in-impl-generics.rs
associated-types-in-inherent-method.rs
associated-types-incomplete-object.rs Detect object safety errors when assoc type is missing 2023-10-30 22:12:07 +00:00
associated-types-incomplete-object.stderr Detect object safety errors when assoc type is missing 2023-10-30 22:12:07 +00:00
associated-types-invalid-trait-ref-issue-18865.rs Remove unnecessary select_obligations_where_possible and redundant errors 2023-08-26 19:35:54 +00:00
associated-types-invalid-trait-ref-issue-18865.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-issue-17359.rs
associated-types-issue-17359.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-issue-20220.rs
associated-types-issue-20346.rs
associated-types-issue-20346.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-issue-20371.rs
associated-types-issue-21212.rs
associated-types-iterator-binding.rs
associated-types-method.rs
associated-types-multiple-types-one-trait.rs
associated-types-multiple-types-one-trait.stderr
associated-types-nested-projections.rs
associated-types-no-suitable-bound.rs
associated-types-no-suitable-bound.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-no-suitable-supertrait-2.rs
associated-types-no-suitable-supertrait-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-no-suitable-supertrait.rs Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
associated-types-no-suitable-supertrait.stderr Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
associated-types-normalize-in-bounds-binding.rs
associated-types-normalize-in-bounds-ufcs.rs
associated-types-normalize-in-bounds.rs
associated-types-normalize-unifield-struct.rs
associated-types-outlives.rs
associated-types-outlives.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-overridden-binding-2.rs
associated-types-overridden-binding-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-overridden-binding.rs
associated-types-overridden-binding.stderr
associated-types-overridden-default.rs
associated-types-path-1.rs
associated-types-path-1.stderr Unify suggestion wording 2023-10-17 17:33:55 +00:00
associated-types-path-2.rs
associated-types-path-2.stderr
associated-types-project-from-hrtb-in-fn-body.rs
associated-types-project-from-hrtb-in-fn-body.stderr
associated-types-project-from-hrtb-in-fn.fixed
associated-types-project-from-hrtb-in-fn.rs
associated-types-project-from-hrtb-in-fn.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-project-from-hrtb-in-struct.rs
associated-types-project-from-hrtb-in-struct.stderr
associated-types-project-from-hrtb-in-trait-method.fixed
associated-types-project-from-hrtb-in-trait-method.rs
associated-types-project-from-hrtb-in-trait-method.stderr
associated-types-project-from-type-param-via-bound-in-where.rs
associated-types-projection-bound-ambiguity.rs
associated-types-projection-bound-in-supertraits.rs
associated-types-projection-from-known-type-in-impl.rs
associated-types-projection-in-object-type.rs
associated-types-projection-in-supertrait.rs
associated-types-projection-in-where-clause.rs
associated-types-projection-to-unrelated-trait-in-method-without-default.fixed
associated-types-projection-to-unrelated-trait-in-method-without-default.rs
associated-types-projection-to-unrelated-trait-in-method-without-default.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-projection-to-unrelated-trait.rs
associated-types-qualified-path-with-trait-with-type-parameters.rs
associated-types-ref-from-struct.rs
associated-types-ref-in-struct-literal.rs
associated-types-region-erasure-issue-20582.rs
associated-types-resolve-lifetime.rs
associated-types-return.rs
associated-types-simple.rs
associated-types-stream.rs
associated-types-struct-field-named.rs
associated-types-struct-field-numbered.rs
associated-types-subtyping-1.rs
associated-types-subtyping-1.stderr
associated-types-sugar-path.rs
associated-types-unconstrained.rs
associated-types-unconstrained.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-unsized.fixed
associated-types-unsized.rs
associated-types-unsized.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
associated-types-where-clause-impl-ambiguity.rs
bound-lifetime-constrained.clause.stderr
bound-lifetime-constrained.func.stderr
bound-lifetime-constrained.object.stderr
bound-lifetime-constrained.rs
bound-lifetime-in-binding-only.angle.stderr
bound-lifetime-in-binding-only.elision.stderr Rollup merge of #117914 - estebank:issue-85843, r=wesleywiser 2023-12-12 17:40:53 +01:00
bound-lifetime-in-binding-only.ok.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
bound-lifetime-in-binding-only.paren.stderr
bound-lifetime-in-binding-only.rs
bound-lifetime-in-return-only.elision.stderr Rollup merge of #117914 - estebank:issue-85843, r=wesleywiser 2023-12-12 17:40:53 +01:00
bound-lifetime-in-return-only.local.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
bound-lifetime-in-return-only.ok.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
bound-lifetime-in-return-only.rs
bound-lifetime-in-return-only.sig.stderr
bound-lifetime-in-return-only.structure.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
default-associated-types.rs
defaults-cyclic-fail-1.rs
defaults-cyclic-fail-1.stderr
defaults-cyclic-fail-2.rs
defaults-cyclic-fail-2.stderr
defaults-cyclic-pass-1.rs
defaults-cyclic-pass-2.rs
defaults-in-other-trait-items-pass.rs
defaults-in-other-trait-items.rs Use can_eq to compare types for default assoc type error 2023-01-25 21:25:42 +01:00
defaults-in-other-trait-items.stderr Use can_eq to compare types for default assoc type error 2023-01-25 21:25:42 +01:00
defaults-mixed.rs
defaults-mixed.stderr
defaults-specialization.rs
defaults-specialization.stderr Tweak expected message to explain what it's actually signifying 2023-09-23 00:57:17 +00:00
defaults-suitability.rs
defaults-suitability.stderr Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
defaults-unsound-62211-1.rs
defaults-unsound-62211-1.stderr
defaults-unsound-62211-2.rs
defaults-unsound-62211-2.stderr
defaults-wf.rs
defaults-wf.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
dont-suggest-cyclic-constraint.rs Revert PR #114052 to fix invalid suggestion 2023-08-17 14:33:33 +02:00
dont-suggest-cyclic-constraint.stderr recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05:00
higher-ranked-projection.bad.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
higher-ranked-projection.rs
hr-associated-type-bound-1.rs
hr-associated-type-bound-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hr-associated-type-bound-2.rs
hr-associated-type-bound-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hr-associated-type-bound-object.rs
hr-associated-type-bound-object.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hr-associated-type-bound-param-1.rs
hr-associated-type-bound-param-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hr-associated-type-bound-param-2.rs
hr-associated-type-bound-param-2.stderr Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
hr-associated-type-bound-param-3.rs
hr-associated-type-bound-param-3.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hr-associated-type-bound-param-4.rs
hr-associated-type-bound-param-4.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hr-associated-type-bound-param-5.rs
hr-associated-type-bound-param-5.stderr Specify what 'this' actually is 2023-02-21 05:21:07 +00:00
hr-associated-type-bound-param-6.rs
hr-associated-type-bound-param-6.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hr-associated-type-projection-1.rs
hr-associated-type-projection-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
impl-trait-return-missing-constraint.rs
impl-trait-return-missing-constraint.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
impl-wf-cycle-1.rs
impl-wf-cycle-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
impl-wf-cycle-2.rs
impl-wf-cycle-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-18655.rs
issue-19081.rs
issue-19883.rs
issue-19883.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-20005.rs
issue-20005.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-20825-2.rs
issue-20825.rs
issue-20825.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-21363.rs
issue-21726.rs
issue-22037.rs
issue-22037.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-22066.rs
issue-22560.rs
issue-22560.stderr Sort errors 2023-10-30 22:19:17 +00:00
issue-22828.rs
issue-23208.rs
issue-23595-1.rs
issue-23595-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-23595-2.rs
issue-23595-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-24159.rs
issue-24204.rs
issue-24338.rs
issue-25339.rs
issue-25700-1.rs
issue-25700-2.rs
issue-25700.rs
issue-25700.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-26681.rs
issue-26681.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-27675-unchecked-bounds.rs
issue-27675-unchecked-bounds.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-27901.rs Move test files 2023-04-20 15:06:17 -03:00
issue-28871.rs
issue-31597.rs
issue-32323.rs Move tests 2023-08-28 17:47:37 -03:00
issue-32323.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-32350.rs
issue-36499.rs Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-36499.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-37808.rs
issue-37883.rs
issue-38821.rs Move tests 2023-02-16 11:42:35 -03:00
issue-38821.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-38917.rs
issue-39532.rs
issue-40093.rs
issue-41868.rs
issue-43475.rs
issue-43784-associated-type.rs
issue-43784-associated-type.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-43924.rs
issue-43924.stderr Tweak use of trimmed paths 2023-01-30 20:12:21 +00:00
issue-44153.rs
issue-44153.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-47139-1.rs
issue-47139-2.rs
issue-47385.rs
issue-47814.rs
issue-47814.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-48010.rs
issue-48551.rs
issue-50301.rs
issue-54108.rs
issue-54108.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-54182-1.rs
issue-54182-2.rs
issue-54467.rs
issue-55846.rs
issue-59324.rs
issue-59324.stderr Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
issue-62200.rs
issue-62200.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-63591.rs Split out a separate feature gate for impl trait in associated types 2023-04-12 16:17:31 +00:00
issue-63593.rs
issue-63593.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-64848.rs
issue-64855-2.rs
issue-64855.rs
issue-64855.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-65774-1.rs
issue-65774-1.stderr Note base types of coercion 2023-05-12 00:10:52 +00:00
issue-65774-2.rs
issue-65774-2.stderr Note base types of coercion 2023-05-12 00:10:52 +00:00
issue-65934.rs
issue-67684.rs Do not ICE when failing to normalize in ConstProp. 2023-03-06 09:28:49 +00:00
issue-69398.rs
issue-71113.rs
issue-72806.rs
issue-72806.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-76179.rs
issue-82079.rs
issue-85103-layout-debug.rs better spans for WF errors 2023-09-09 18:00:13 +02:00
issue-85103-layout-debug.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-87261.rs Mention fn coercion rules (needs to be expanded) 2023-01-30 21:51:33 +00:00
issue-87261.stderr Mention fn coercion rules (needs to be expanded) 2023-01-30 21:51:33 +00:00
issue-88856.rs
issue-91069.rs
issue-91231.rs
issue-91234.rs
missing-associated-types.rs
missing-associated-types.stderr Avoid iterating over hashmaps in astconv 2023-11-19 17:45:02 +01:00
normalization-debruijn-1.rs
normalization-debruijn-2.rs
normalization-debruijn-3.rs Adjust UI tests for unit_bindings 2023-06-12 20:24:48 +08:00
normalization-generality-2.rs
normalization-generality.rs
normalization-probe-cycle.rs
normalize-cycle-in-eval-no-region.rs
normalize-cycle-in-eval.rs
object-method-numbering.rs
object-normalization.rs
param-env-normalize-cycle.rs
point-at-type-on-obligation-failure-2.rs
point-at-type-on-obligation-failure-2.stderr Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
point-at-type-on-obligation-failure.rs
point-at-type-on-obligation-failure.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
project-defer-unification.rs
project-recursion-limit-non-fatal.rs
substs-ppaux.normal.stderr Handle Self in paths too 2023-08-25 19:05:38 +00:00
substs-ppaux.rs
substs-ppaux.verbose.stderr Handle Self in paths too 2023-08-25 19:05:38 +00:00
trait-with-supertraits-needing-sized-self.rs
trait-with-supertraits-needing-sized-self.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-cycle-2.rs
wf-cycle.rs