You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #118668 - fmease:resolve-assoc-item-bindings-by-namespace, r=compiler-errors
Resolve associated item bindings by namespace
This is the 3rd commit split off from #118360 with tests reblessed (they no longer contain duplicated diags which were caused by 4c0addc) & slightly adapted (removed supertraits from a UI test, cc #118040).
> * Resolve all assoc item bindings (type, const, fn (feature `return_type_notation`)) by namespace instead of trying to resolve a type first (in the non-RTN case) and falling back to consts afterwards. This is consistent with RTN. E.g., for `Tr<K = {…}>` we now always try to look up assoc consts (this extends to supertrait bounds). This gets rid of assoc tys shadowing assoc consts in assoc item bindings which is undesirable & inconsistent (types and consts live in different namespaces after all)
> * Consolidate the resolution of assoc {ty, const} bindings and RTN (dedup, better diags for RTN)
> * Fix assoc consts being labeled as assoc *types* in several diagnostics
> * Make a bunch of diagnostics translatable
Fixes#112560 (error → pass).
As discussed
r? `@compiler-errors`
---
**Addendum**: What I call “associated item bindings” are commonly referred to as “type bindings” for historical reasons. Nowadays, “type bindings” include assoc type bindings, assoc const bindings and RTN (return type notation) which is why I prefer not to use this outdated term.
hir_analysis_assoc_bound_on_const = expected associated type, found {$descr}
5
-
.note = trait bounds not allowed on {$descr}
7
+
hir_analysis_assoc_item_not_found = associated {$assoc_kind} `{$assoc_name}` not found for `{$ty_param_name}`
8
+
9
+
hir_analysis_assoc_item_not_found_found_in_other_trait_label = there is {$identically_named->
10
+
[true] an
11
+
*[false] a similarly named
12
+
} associated {$assoc_kind} `{$suggested_name}` in the trait `{$trait_name}`
13
+
hir_analysis_assoc_item_not_found_label = associated {$assoc_kind} `{$assoc_name}` not found
14
+
hir_analysis_assoc_item_not_found_other_sugg = `{$ty_param_name}` has the following associated {$assoc_kind}
15
+
hir_analysis_assoc_item_not_found_similar_in_other_trait_sugg = change the associated {$assoc_kind} name to use `{$suggested_name}` from `{$trait_name}`
16
+
hir_analysis_assoc_item_not_found_similar_in_other_trait_with_bound_sugg = and also change the associated {$assoc_kind} name
17
+
hir_analysis_assoc_item_not_found_similar_sugg = there is an associated {$assoc_kind} with a similar name
18
+
19
+
hir_analysis_assoc_kind_mismatch = expected {$expected}, found {$got}
20
+
.label = unexpected {$got}
21
+
.expected_because_label = expected a {$expected} because of this associated {$expected}
22
+
.note = the associated {$assoc_kind} is defined here
23
+
.bound_on_assoc_const_label = bounds are not allowed on associated constants
24
+
25
+
hir_analysis_assoc_kind_mismatch_wrap_in_braces_sugg = consider adding braces here
6
26
7
27
hir_analysis_assoc_type_binding_not_allowed =
8
28
associated type bindings are not allowed here
@@ -280,10 +300,6 @@ hir_analysis_placeholder_not_allowed_item_signatures = the placeholder `_` is no
280
300
281
301
hir_analysis_requires_note = the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`
0 commit comments