Skip to content

Commit 269ce36

Browse files
committed
migrating rustc_resolve to SessionDiagnostic. work in progress. start
implement binding_shadows migrate till self-in-generic-param-default use braces in fluent message as suggested by @compiler-errors. to fix lock file issue reported by CI migrate 'unreachable label' error run formatter name the variables correctly in fluent file SessionDiagnostic -> Diagnostic test "pattern/pat-tuple-field-count-cross.rs" passed test "resolve/bad-env-capture2.rs" passed test "enum/enum-in-scope.rs" and other depended on "resolve_binding_shadows_something_unacceptable" should be passed now. fix crash errors while running test-suite. there might be more. then_some(..) suits better here. all tests passed convert TraitImpl and InvalidAsm. TraitImpl is buggy yet. will fix after receiving help from Zulip migrate "Ralative-2018" migrate "ancestor only" migrate "expected found" migrate "Indeterminate" migrate "module only" revert to the older implementation for now. since this is failing at the moment. follow the convension for fluent variable order the diag attribute as suggested in review comment fix merge error. migrate trait-impl-duplicate make the changes compatible with "Flatten diagnostic slug modules #103345" fix merge remove commented code merge issues fix review comments fix tests
1 parent 928d14b commit 269ce36

File tree

9 files changed

+885
-363
lines changed

9 files changed

+885
-363
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4047,6 +4047,7 @@ dependencies = [
40474047
"rustc_feature",
40484048
"rustc_hir",
40494049
"rustc_index",
4050+
"rustc_macros",
40504051
"rustc_metadata",
40514052
"rustc_middle",
40524053
"rustc_query_system",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
resolve_parent_module_reset_for_binding =
2+
parent module is reset for binding
3+
4+
resolve_ampersand_used_without_explicit_lifetime_name =
5+
`&` without an explicit lifetime name cannot be used here
6+
.note = explicit lifetime name needed here
7+
8+
resolve_underscore_lifetime_name_cannot_be_used_here =
9+
`'_` cannot be used here
10+
.note = `'_` is a reserved lifetime name
11+
12+
resolve_crate_may_not_be_imported =
13+
`$crate` may not be imported
14+
15+
resolve_crate_root_imports_must_be_named_explicitly =
16+
crate root imports need to be explicitly named: `use crate as name;`
17+
18+
resolve_generic_params_from_outer_function =
19+
can't use generic parameters from outer function
20+
.label = use of generic parameter from outer function
21+
.suggestion = try using a local generic parameter instead
22+
23+
resolve_self_type_implicitly_declared_by_impl =
24+
`Self` type implicitly declared here, by this `impl`
25+
26+
resolve_cannot_use_self_type_here =
27+
can't use `Self` here
28+
29+
resolve_use_a_type_here_instead =
30+
use a type here instead
31+
32+
resolve_type_param_from_outer_fn =
33+
type parameter from outer function
34+
35+
resolve_const_param_from_outer_fn =
36+
const parameter from outer function
37+
38+
resolve_try_using_local_generic_parameter =
39+
try using a local generic parameter instead
40+
41+
resolve_try_adding_local_generic_param_on_method =
42+
try adding a local generic parameter in this method instead
43+
44+
resolve_help_try_using_local_generic_param =
45+
try using a local generic paramter instead
46+
47+
resolve_name_is_already_used_as_generic_parameter =
48+
the name `{$name}` is already used for a generic parameter in this item's generic parameters
49+
.label = already used
50+
.first_use_of_name = first use of `{$name}`
51+
52+
resolve_method_not_member_of_trait =
53+
method `{$method}` is not a member of trait `{$trait_}`
54+
.label = not a member of trait `{$trait_}`
55+
56+
resolve_associated_fn_with_similar_name_exists =
57+
there is an associated function with a similar name
58+
59+
resolve_type_not_member_of_trait =
60+
type `{$type_}` is not a member of trait `{$trait_}`
61+
.label = not a member of trait `{$trait_}`
62+
63+
resolve_associated_type_with_similar_name_exists =
64+
there is an associated type with a similar name
65+
66+
resolve_const_not_member_of_trait =
67+
const `{$const_}` is not a member of trait `{$trait_}`
68+
.label = not a member of trait `{$trait_}`
69+
70+
resolve_associated_const_with_similar_name_exists =
71+
there is an associated constant with a similar name
72+
73+
resolve_variable_bound_with_different_mode =
74+
variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`
75+
.label = bound in different ways
76+
.first_binding_span = first binding
77+
78+
resolve_ident_bound_more_than_once_in_parameter_list =
79+
identifier `{$identifier}` is bound more than once in this parameter list
80+
.label = used as parameter more than once
81+
82+
resolve_ident_bound_more_than_once_in_same_pattern =
83+
identifier `{$identifier}` is bound more than once in the same pattern
84+
.label = used in a pattern more than once
85+
86+
resolve_undeclared_label =
87+
use of undeclared label `{$name}`
88+
.label = undeclared label `{$name}`
89+
90+
resolve_label_with_similar_name_reachable =
91+
a label with a similar name is reachable
92+
93+
resolve_try_using_similarly_named_label =
94+
try using similarly named label
95+
96+
resolve_unreachable_label_with_similar_name_exists =
97+
a label with a similar name exists but is unreachable
98+
99+
resolve_self_import_can_only_appear_once_in_the_list =
100+
`self` import can only appear once in an import list
101+
.label = can only appear once in an import list
102+
103+
resolve_self_import_only_in_import_list_with_non_empty_prefix =
104+
`self` import can only appear in an import list with a non-empty prefix
105+
.label = can only appear in an import list with a non-empty prefix
106+
107+
resolve_cannot_capture_dynamic_environment_in_fn_item =
108+
can't capture dynamic environment in a fn item
109+
.help = use the `|| {"{"} ... {"}"}` closure form instead
110+
111+
resolve_attempt_to_use_non_constant_value_in_constant =
112+
attempt to use a non-constant value in a constant
113+
114+
resolve_attempt_to_use_non_constant_value_in_constant_with_suggestion =
115+
consider using `{$suggestion}` instead of `{$current}`
116+
117+
resolve_attempt_to_use_non_constant_value_in_constant_label_with_suggestion =
118+
non-constant value
119+
120+
resolve_attempt_to_use_non_constant_value_in_constant_without_suggestion =
121+
this would need to be a `{$suggestion}`
122+
123+
resolve_self_imports_only_allowed_within =
124+
`self` imports are only allowed within a {"{"} {"}"} list
125+
126+
resolve_self_imports_only_allowed_within_suggestion =
127+
consider importing the module directly
128+
129+
resolve_self_imports_only_allowed_within_multipart_suggestion =
130+
alternatively, use the multi-path `use` syntax to import `self`
131+
132+
resolve_binding_shadows_something_unacceptable =
133+
{$shadowing_binding}s cannot shadow {$shadowed_binding}s
134+
.label = cannot be named the same as {$article} {$shadowed_binding}
135+
.label_shadowed_binding = the {$shadowed_binding} `{$name}` is {$participle} here
136+
137+
resolve_binding_shadows_something_unacceptable_suggestion =
138+
try specify the pattern arguments
139+
140+
resolve_forward_declared_generic_param =
141+
generic parameters with a default cannot use forward declared identifiers
142+
.label = defaulted generic parameters cannot be forward declared
143+
144+
resolve_param_in_ty_of_const_param =
145+
the type of const parameters must not depend on other generic parameters
146+
.label = the type must not depend on the parameter `{$name}`
147+
148+
resolve_self_in_generic_param_default =
149+
generic parameters cannot use `Self` in their defaults
150+
.label = `Self` in generic parameter default
151+
152+
resolve_param_in_non_trivial_anon_const =
153+
generic parameters may not be used in const operations
154+
.label = cannot perform const operation using `{$name}`
155+
156+
resolve_param_in_non_trivial_anon_const_help =
157+
use `#![feature(generic_const_exprs)]` to allow generic const expressions
158+
159+
resolve_param_in_non_trivial_anon_const_sub_type =
160+
type parameters may not be used in const expressions
161+
162+
resolve_param_in_non_trivial_anon_const_sub_non_type =
163+
const parameters may only be used as standalone arguments, i.e. `{$name}`
164+
165+
resolve_unreachable_label =
166+
use of unreachable label `{$name}`
167+
.label = unreachable label `{$name}`
168+
.label_definition_span = unreachable label defined here
169+
.note = labels are unreachable through functions, closures, async blocks and modules
170+
171+
resolve_unreachable_label_suggestion_use_similarly_named =
172+
try using similarly named label
173+
174+
resolve_unreachable_label_similar_name_reachable =
175+
a label with a similar name is reachable
176+
177+
resolve_unreachable_label_similar_name_unreachable =
178+
a label with a similar name exists but is also unreachable
179+
180+
resolve_trait_impl_mismatch =
181+
item `{$name}` is an associated {$kind}, which doesn't match its trait `{$trait_path}`
182+
.label = does not match trait
183+
.label_trait_item = item in trait
184+
185+
resolve_invalid_asm_sym =
186+
invalid `sym` operand
187+
.label = is a local variable
188+
.help = `sym` operands must refer to either a function or a static
189+
190+
resolve_trait_impl_duplicate =
191+
duplicate definitions with name `{$name}`:
192+
.label = duplicate definition
193+
.old_span_label = previous definition here
194+
.trait_item_span = item in trait
195+
196+
resolve_relative_2018 =
197+
relative paths are not supported in visibilities in 2018 edition or later
198+
.suggestion = try
199+
200+
resolve_ancestor_only =
201+
visibilities can only be restricted to ancestor modules
202+
203+
resolve_expected_found =
204+
expected module, found {$res} `{$path_str}`
205+
.label = not a module
206+
207+
resolve_indeterminate =
208+
cannot determine resolution for the visibility
209+
210+
resolve_module_only =
211+
visibility must resolve to a module

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ fluent_messages! {
6363
plugin_impl => "../locales/en-US/plugin_impl.ftl",
6464
privacy => "../locales/en-US/privacy.ftl",
6565
query_system => "../locales/en-US/query_system.ftl",
66+
resolve => "../locales/en-US/resolve.ftl",
6667
save_analysis => "../locales/en-US/save_analysis.ftl",
6768
session => "../locales/en-US/session.ftl",
6869
symbol_mangling => "../locales/en-US/symbol_mangling.ftl",

compiler/rustc_errors/src/diagnostic_impls.rs

+6
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ impl IntoDiagnosticArg for DiagnosticSymbolList {
211211
}
212212
}
213213

214+
impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
215+
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
216+
DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
217+
}
218+
}
219+
214220
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
215221
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
216222
let mut diag;

compiler/rustc_resolve/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rustc_expand = { path = "../rustc_expand" }
1919
rustc_feature = { path = "../rustc_feature" }
2020
rustc_hir = { path = "../rustc_hir" }
2121
rustc_index = { path = "../rustc_index" }
22+
rustc_macros = { path = "../rustc_macros" }
2223
rustc_metadata = { path = "../rustc_metadata" }
2324
rustc_query_system = { path = "../rustc_query_system" }
2425
rustc_session = { path = "../rustc_session" }

0 commit comments

Comments
 (0)