rust/tests/ui/resolve
Matthias Krüger 14663e09b7
Rollup merge of #116257 - estebank:issue-101351, r=b-naber
Suggest trait bounds for used associated type on type param

Fix #101351.

When an associated type on a type parameter is used, and the type parameter isn't constrained by the correct trait, suggest the appropriate trait bound:

```
error[E0220]: associated type `Associated` not found for `T`
 --> file.rs:6:15
  |
6 |     field: T::Associated,
  |               ^^^^^^^^^^ there is a similarly named associated type `Associated` in the trait `Foo`
  |
help: consider restricting type parameter `T`
  |
5 | struct Generic<T: Foo> {
  |                 +++++
  ```

When an associated type on a type parameter has a typo, suggest fixing
it:

```
error[E0220]: associated type `Baa` not found for `T`
  --> $DIR/issue-55673.rs:9:8
   |
LL |     T::Baa: std::fmt::Debug,
   |        ^^^ there is a similarly named associated type `Bar` in the trait `Foo`
   |
help: change the associated type name to use `Bar` from `Foo`
   |
LL |     T::Bar: std::fmt::Debug,
   |        ~~~
```
2023-10-16 19:10:49 +02:00
..
auxiliary test(resolve): update_resolution for remove single import 2023-06-20 22:54:12 +08:00
112590-2.fixed Add filter with next segment while lookup typo for path 2023-07-07 09:00:50 +08:00
112590-2.rs Add filter with next segment while lookup typo for path 2023-07-07 09:00:50 +08:00
112590-2.stderr Add filter with next segment while lookup typo for path 2023-07-07 09:00:50 +08:00
associated-fn-called-as-fn.rs
associated-fn-called-as-fn.stderr When suggesting self.x for S { x }, use S { x: self.x } 2023-09-25 15:56:36 +00:00
bad-env-capture2.rs
bad-env-capture2.stderr
bad-env-capture3.rs
bad-env-capture3.stderr
bad-env-capture.rs
bad-env-capture.stderr
bad-expr-path2.rs
bad-expr-path2.stderr rustc_hir_analysis: add a helper to check function the signature mismatches 2023-09-19 18:15:23 +02:00
bad-expr-path.rs
bad-expr-path.stderr rustc_hir_analysis: add a helper to check function the signature mismatches 2023-09-19 18:15:23 +02:00
bad-module.rs
bad-module.stderr
bad-type-env-capture.rs
bad-type-env-capture.stderr Generalize E0401 2023-09-10 23:06:14 +02:00
blind-item-local-shadow.rs
blind-item-mixed-crate-use-item.rs
blind-item-mixed-use-item.rs
block-with-trait-parent.rs
crate-called-as-function.rs
crate-called-as-function.stderr
crate-in-paths.rs
crate-in-paths.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
derive-macro-1.rs fix(resolve): update the ambiguity glob binding as warning recursively 2023-07-29 00:19:50 +08:00
derive-macro-2.rs fix(resolve): update the ambiguity glob binding as warning recursively 2023-07-29 00:19:50 +08:00
disambiguate-identical-names.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
disambiguate-identical-names.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
editions-crate-root-2015.rs
editions-crate-root-2015.stderr
editions-crate-root-2018.rs
editions-crate-root-2018.stderr
enums-are-namespaced-xc.rs
enums-are-namespaced-xc.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
enums-pats-not-idents.rs
enums-pats-not-idents.stderr
explicit-self-lowercase-param.rs Improve error for self: Box<self> 2023-05-11 13:21:10 +01:00
explicit-self-lowercase-param.stderr Improve error for self: Box<self> 2023-05-11 13:21:10 +01:00
export-fully-qualified-2018.rs add testcase for 112590 2023-07-02 15:35:18 +08:00
export-fully-qualified-2018.stderr smart_resolve_partial_mod_path_errors should not suggest parent 2023-07-07 10:18:20 +08:00
export-fully-qualified.rs add testcase for 112590 2023-07-02 15:35:18 +08:00
export-fully-qualified.stderr smart_resolve_partial_mod_path_errors should not suggest parent 2023-07-07 10:18:20 +08:00
extern-prelude-fail.rs
extern-prelude-fail.stderr
extern-prelude.rs Adjust UI tests for unit_bindings 2023-06-12 20:24:48 +08:00
field-and-method-in-self-not-available-in-assoc-fn.rs When suggesting self.x for S { x }, use S { x: self.x } 2023-09-25 15:56:36 +00:00
field-and-method-in-self-not-available-in-assoc-fn.stderr Point at field definition when unresolved name exists in Self 2023-09-25 15:56:36 +00:00
filter-intrinsics.rs
filter-intrinsics.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
generic-params-from-outer-item-in-const-item.default.stderr Do not suggest generic const items unless enabled 2023-09-10 23:07:48 +02:00
generic-params-from-outer-item-in-const-item.generic_const_items.stderr Do not suggest generic const items unless enabled 2023-09-10 23:07:48 +02:00
generic-params-from-outer-item-in-const-item.rs Do not suggest generic const items unless enabled 2023-09-10 23:07:48 +02:00
hidden_glob_reexports.rs Adjust span labels for HIDDEN_GLOB_REEXPORTS 2023-06-10 17:11:38 +08:00
hidden_glob_reexports.stderr Adjust span labels for HIDDEN_GLOB_REEXPORTS 2023-06-10 17:11:38 +08:00
impl-items-vis-unresolved.rs
impl-items-vis-unresolved.stderr
issue-2330.rs
issue-2330.stderr
issue-2356.rs
issue-2356.stderr Point at field definition when unresolved name exists in Self 2023-09-25 15:56:36 +00:00
issue-3021-c.rs Generalize E0401 2023-09-10 23:06:14 +02:00
issue-3021-c.stderr Generalize E0401 2023-09-10 23:06:14 +02:00
issue-3021.rs
issue-3021.stderr
issue-3099-a.rs Move tests 2023-05-08 17:58:01 -03:00
issue-3099-a.stderr Move tests 2023-05-08 17:58:01 -03:00
issue-3099-b.rs Move tests 2023-05-08 17:58:01 -03:00
issue-3099-b.stderr Move tests 2023-05-08 17:58:01 -03:00
issue-3907-2.rs
issue-3907-2.stderr
issue-3907.rs
issue-3907.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-5035-2.rs
issue-5035-2.stderr
issue-5035.rs
issue-5035.stderr
issue-5099.rs
issue-5099.stderr
issue-5927.rs
issue-5927.stderr
issue-6642.rs Move tests 2023-08-28 17:47:37 -03:00
issue-6642.stderr Move tests 2023-08-28 17:47:37 -03:00
issue-6702.rs
issue-6702.stderr
issue-10200.rs
issue-10200.stderr
issue-12796.rs Generalize E0401 2023-09-10 23:06:14 +02:00
issue-12796.stderr Generalize E0401 2023-09-10 23:06:14 +02:00
issue-14254.rs
issue-14254.stderr When suggesting self.x for S { x }, use S { x: self.x } 2023-09-25 15:56:36 +00:00
issue-16058.rs
issue-16058.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-17518.rs
issue-17518.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-18252.rs
issue-18252.stderr
issue-19452.rs
issue-19452.stderr
issue-21221-1.rs
issue-21221-1.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-21221-2.rs
issue-21221-2.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-21221-3.rs
issue-21221-3.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-21221-4.rs
issue-21221-4.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-22692.rs
issue-22692.stderr
issue-23305.rs
issue-23305.stderr
issue-23716.rs
issue-23716.stderr
issue-24968.rs
issue-24968.stderr
issue-26545.rs
issue-26545.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-30535.rs
issue-30535.stderr
issue-31845.rs
issue-31845.stderr
issue-33876.rs
issue-33876.stderr
issue-35675.rs
issue-35675.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-39226.rs
issue-39226.stderr
issue-39559-2.rs
issue-39559-2.stderr
issue-39559.rs
issue-39559.stderr
issue-42944.rs
issue-42944.stderr
issue-49074.rs
issue-49074.stderr
issue-50599.rs Suppress "erroneous constant used" for constants tainted by errors 2023-05-15 00:00:00 +00:00
issue-50599.stderr Suppress "erroneous constant used" for constants tainted by errors 2023-05-15 00:00:00 +00:00
issue-54379.rs
issue-54379.stderr
issue-55673.fixed Suggest trait bounds for used associated type on type param 2023-10-13 19:13:56 +00:00
issue-55673.rs Suggest trait bounds for used associated type on type param 2023-10-13 19:13:56 +00:00
issue-55673.stderr Suggest trait bounds for used associated type on type param 2023-10-13 19:13:56 +00:00
issue-57523.rs
issue-60057.rs
issue-60057.stderr Point at field definition when unresolved name exists in Self 2023-09-25 15:56:36 +00:00
issue-65025-extern-static-parent-generics.rs Generalize E0401 2023-09-10 23:06:14 +02:00
issue-65025-extern-static-parent-generics.stderr Generalize E0401 2023-09-10 23:06:14 +02:00
issue-65035-static-with-parent-generics.rs Generalize E0401 2023-09-10 23:06:14 +02:00
issue-65035-static-with-parent-generics.stderr Generalize E0401 2023-09-10 23:06:14 +02:00
issue-69401-trait-fn-no-body-ty-local.rs
issue-69401-trait-fn-no-body-ty-local.stderr
issue-70736-async-fn-no-body-def-collector.rs Stabilize AFIT and RPITIT 2023-10-13 21:01:36 +00:00
issue-70736-async-fn-no-body-def-collector.stderr Stabilize AFIT and RPITIT 2023-10-13 21:01:36 +00:00
issue-73427.rs
issue-73427.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-80079.rs
issue-80079.stderr
issue-81508.rs
issue-81508.stderr
issue-82156.rs
issue-82156.stderr
issue-82865.rs
issue-82865.stderr
issue-85348.rs
issue-85348.stderr
issue-85671.rs
issue-88472.rs
issue-88472.stderr
issue-90113.rs
issue-90113.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-100365.rs
issue-100365.stderr
issue-101749-2.rs
issue-101749-2.stderr
issue-101749.fixed
issue-101749.rs
issue-101749.stderr
issue-102946.rs
issue-102946.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-103202.rs
issue-103202.stderr
issue-103474.rs
issue-103474.stderr Tweak wording and logic 2023-09-23 01:54:05 +00:00
issue-104700-inner_scope.rs
issue-104700-inner_scope.stderr
issue-105069.rs
issue-105069.stderr fix(resolve): update shadowed_glob more precision 2023-06-14 01:38:35 +08:00
issue-107563-ambiguous-glob-reexports.rs Lint ambiguous glob re-exports 2023-03-20 03:22:31 +08:00
issue-107563-ambiguous-glob-reexports.stderr Lint ambiguous glob re-exports 2023-03-20 03:22:31 +08:00
issue-108529.rs diagnostics: avoid querying associated_item in the resolver 2023-02-27 09:22:51 -07:00
issue-108529.stderr diagnostics: avoid querying associated_item in the resolver 2023-02-27 09:22:51 -07:00
issue-109153.rs fix(resolve): update shadowed_glob more precision 2023-06-14 01:38:35 +08:00
issue-109153.stderr fix(resolve): update shadowed_glob more precision 2023-06-14 01:38:35 +08:00
issue-109250.rs refactor(resolve): clean up the early error return caused by non-call 2023-05-10 22:35:01 +08:00
issue-109250.stderr refactor(resolve): clean up the early error return caused by non-call 2023-05-10 22:35:01 +08:00
issue-111312.rs Emits E0599 when meeting MyTrait::missing_method 2023-05-17 16:59:39 +08:00
issue-111312.stderr Emits E0599 when meeting MyTrait::missing_method 2023-05-17 16:59:39 +08:00
issue-111727.rs Keep only the trait when emitting the error for MyTrait + 'a 2023-05-19 22:11:54 +08:00
issue-111727.stderr Keep only the trait when emitting the error for MyTrait + 'a 2023-05-19 22:11:54 +08:00
issue-112472-multi-generics-suggestion.fixed Fix suggestion for E0404 not dealing with multiple generics 2023-06-15 18:19:09 +08:00
issue-112472-multi-generics-suggestion.rs Fix suggestion for E0404 not dealing with multiple generics 2023-06-15 18:19:09 +08:00
issue-112472-multi-generics-suggestion.stderr Fix suggestion for E0404 not dealing with multiple generics 2023-06-15 18:19:09 +08:00
issue-113808-invalid-unused-qualifications-suggestion.fixed Fix removal span calculation of unused_qualifications suggestion 2023-07-18 09:52:08 +08:00
issue-113808-invalid-unused-qualifications-suggestion.rs Fix removal span calculation of unused_qualifications suggestion 2023-07-18 09:52:08 +08:00
issue-113808-invalid-unused-qualifications-suggestion.stderr Fix removal span calculation of unused_qualifications suggestion 2023-07-18 09:52:08 +08:00
issue-114433-invalid-unused-qualifications-suggestion.rs Remove invalid lint when there is a generic argument in prefix path 2023-08-05 15:58:26 +08:00
issue-116164.rs resolve: skip underscore character during candidate lookup 2023-09-28 19:47:58 +08:00
issue-116164.stderr resolve: skip underscore character during candidate lookup 2023-09-28 19:47:58 +08:00
levenshtein.rs
levenshtein.stderr
macro-determinacy-non-module.rs
missing-in-namespace.rs
missing-in-namespace.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
name-clash-nullary.rs
name-clash-nullary.stderr
name-collision-in-trait-fn-sig.rs
no-implicit-prelude-nested.rs
no-implicit-prelude-nested.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
no-implicit-prelude.rs
no-implicit-prelude.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
no-std-1.rs
no-std-2.rs
no-std-3.rs
pathless-extern-ok.rs
point-at-type-parameter-shadowing-another-type.rs
point-at-type-parameter-shadowing-another-type.stderr
privacy-enum-ctor.rs
privacy-enum-ctor.stderr Tweak privacy errors to account for reachable items 2023-06-22 16:50:31 +00:00
privacy-struct-ctor.rs
privacy-struct-ctor.stderr
raw-ident-in-path.rs
raw-ident-in-path.stderr
resolve-assoc-suggestions.rs
resolve-assoc-suggestions.stderr When suggesting self.x for S { x }, use S { x: self.x } 2023-09-25 15:56:36 +00:00
resolve-bad-import-prefix.rs
resolve-bad-import-prefix.stderr
resolve-bad-visibility.rs
resolve-bad-visibility.stderr
resolve-conflict-extern-crate-vs-extern-crate.rs
resolve-conflict-extern-crate-vs-extern-crate.stderr
resolve-conflict-import-vs-extern-crate.rs
resolve-conflict-import-vs-extern-crate.stderr
resolve-conflict-import-vs-import.fixed
resolve-conflict-import-vs-import.rs
resolve-conflict-import-vs-import.stderr
resolve-conflict-item-vs-extern-crate.rs
resolve-conflict-item-vs-extern-crate.stderr
resolve-conflict-item-vs-import.rs
resolve-conflict-item-vs-import.stderr
resolve-conflict-type-vs-import.rs
resolve-conflict-type-vs-import.stderr
resolve-hint-macro.fixed
resolve-hint-macro.rs
resolve-hint-macro.stderr
resolve-inconsistent-binding-mode.rs
resolve-inconsistent-binding-mode.stderr
resolve-inconsistent-names.rs
resolve-inconsistent-names.stderr Replace HashMap with IndexMap in pattern binding resolve 2023-10-02 19:12:42 +02:00
resolve-issue-2428.rs
resolve-label.rs
resolve-label.stderr
resolve-primitive-fallback.rs
resolve-primitive-fallback.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
resolve-pseudo-shadowing.rs Adjust UI tests for unit_bindings 2023-06-12 20:24:48 +08:00
resolve-self-in-impl-2.rs
resolve-self-in-impl-2.stderr
resolve-self-in-impl.rs
resolve-self-in-impl.stderr moved note as unspanned note, moved note to the bottom of the msg 2023-07-18 21:53:34 -04:00
resolve-speculative-adjustment.rs
resolve-speculative-adjustment.stderr When suggesting self.x for S { x }, use S { x: self.x } 2023-09-25 15:56:36 +00:00
resolve-type-param-in-item-in-trait.rs Generalize E0401 2023-09-10 23:06:14 +02:00
resolve-type-param-in-item-in-trait.stderr Generalize E0401 2023-09-10 23:06:14 +02:00
resolve-unknown-trait.rs
resolve-unknown-trait.stderr
resolve-variant-assoc-item.rs
resolve-variant-assoc-item.stderr refactor(resolve): clean up the early error return caused by non-call 2023-05-10 22:35:01 +08:00
shadow-const-param.rs
shadow-const-param.stderr
suggest-import-without-clobbering-attrs.fixed Find lowest span out of use + attrs 2023-09-07 05:19:43 +00:00
suggest-import-without-clobbering-attrs.rs Test showing it doesnt work 2023-09-07 05:18:54 +00:00
suggest-import-without-clobbering-attrs.stderr Test showing it doesnt work 2023-09-07 05:18:54 +00:00
suggest-path-for-tuple-struct.rs
suggest-path-for-tuple-struct.stderr
suggest-path-instead-of-mod-dot-item.rs
suggest-path-instead-of-mod-dot-item.stderr
token-error-correct-2.rs Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
token-error-correct-2.stderr Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
token-error-correct-3.rs Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
token-error-correct-3.stderr Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
token-error-correct-4.rs Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
token-error-correct-4.stderr Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
token-error-correct.rs Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
token-error-correct.stderr Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
tool-import.rs Deny useing tool paths 2023-04-04 14:10:13 +01:00
tool-import.stderr Deny useing tool paths 2023-04-04 14:10:13 +01:00
tuple-struct-alias.rs
tuple-struct-alias.stderr
typo-suggestion-for-variable-with-name-similar-to-struct-field.rs
typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr Point at field definition when unresolved name exists in Self 2023-09-25 15:56:36 +00:00
typo-suggestion-mistyped-in-path.rs
typo-suggestion-mistyped-in-path.stderr
typo-suggestion-named-underscore.rs
typo-suggestion-named-underscore.stderr
unboxed-closure-sugar-nonexistent-trait.rs
unboxed-closure-sugar-nonexistent-trait.stderr
unresolved_static_type_field.rs
unresolved_static_type_field.stderr Point at field definition when unresolved name exists in Self 2023-09-25 15:56:36 +00:00
unresolved-segments-visibility.rs Resolve visibility paths as modules not as types. 2023-08-02 15:30:24 +00:00
unresolved-segments-visibility.stderr Resolve visibility paths as modules not as types. 2023-08-02 15:30:24 +00:00
unused-qualifications-suggestion.fixed Add machine-applicable suggestion for unused_qualifications lint 2023-07-13 08:26:02 +08:00
unused-qualifications-suggestion.rs Add machine-applicable suggestion for unused_qualifications lint 2023-07-13 08:26:02 +08:00
unused-qualifications-suggestion.stderr Fix removal span calculation of unused_qualifications suggestion 2023-07-18 09:52:08 +08:00
use_suggestion_placement.fixed
use_suggestion_placement.rs
use_suggestion_placement.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
use_suggestion.rs
use_suggestion.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
use-self-in-inner-fn.rs Generalize E0401 2023-09-10 23:06:14 +02:00
use-self-in-inner-fn.stderr Generalize E0401 2023-09-10 23:06:14 +02:00
visibility-indeterminate.rs
visibility-indeterminate.stderr