1 use rustc_macros
::{Diagnostic, Subdiagnostic}
;
3 symbol
::{Ident, Symbol}
,
7 use crate::{late::PatternSource, Res}
;
10 #[diag(resolve_parent_module_reset_for_binding, code = "E0637")]
11 pub(crate) struct ParentModuleResetForBinding
;
14 #[diag(resolve_ampersand_used_without_explicit_lifetime_name, code = "E0637")]
16 pub(crate) struct AmpersandUsedWithoutExplicitLifetimeName(#[primary_span] pub(crate) Span);
19 #[diag(resolve_underscore_lifetime_name_cannot_be_used_here, code = "E0637")]
21 pub(crate) struct UnderscoreLifetimeNameCannotBeUsedHere(#[primary_span] pub(crate) Span);
24 #[diag(resolve_crate_may_not_be_imported)]
25 pub(crate) struct CrateMayNotBeImprted(#[primary_span] pub(crate) Span);
28 #[diag(resolve_crate_root_imports_must_be_named_explicitly)]
29 pub(crate) struct CrateRootNamesMustBeNamedExplicitly(#[primary_span] pub(crate) Span);
32 #[diag(resolve_crate_root_imports_must_be_named_explicitly)]
33 pub(crate) struct ResolutionError(#[primary_span] pub(crate) Span);
36 #[diag(resolve_name_is_already_used_as_generic_parameter, code = "E0403")]
37 pub(crate) struct NameAlreadyUsedInParameterList
{
40 pub(crate) span
: Span
,
41 #[label(first_use_of_name)]
42 pub(crate) first_use_span
: Span
,
43 pub(crate) name
: Symbol
,
47 #[diag(resolve_method_not_member_of_trait, code = "E0407")]
48 pub(crate) struct MethodNotMemberOfTrait
{
51 pub(crate) span
: Span
,
52 pub(crate) method
: Ident
,
53 pub(crate) trait_
: String
,
55 pub(crate) sub
: Option
<AssociatedFnWithSimilarNameExists
>,
58 #[derive(Subdiagnostic)]
60 resolve_associated_fn_with_similar_name_exists
,
62 applicability
= "maybe-incorrect"
64 pub(crate) struct AssociatedFnWithSimilarNameExists
{
66 pub(crate) span
: Span
,
67 pub(crate) candidate
: Symbol
,
71 #[diag(resolve_type_not_member_of_trait, code = "E0437")]
72 pub(crate) struct TypeNotMemberOfTrait
{
75 pub(crate) span
: Span
,
76 pub(crate) type_
: Ident
,
77 pub(crate) trait_
: String
,
79 pub(crate) sub
: Option
<AssociatedTypeWithSimilarNameExists
>,
82 #[derive(Subdiagnostic)]
84 resolve_associated_type_with_similar_name_exists
,
86 applicability
= "maybe-incorrect"
88 pub(crate) struct AssociatedTypeWithSimilarNameExists
{
90 pub(crate) span
: Span
,
91 pub(crate) candidate
: Symbol
,
95 #[diag(resolve_const_not_member_of_trait, code = "E0438")]
96 pub(crate) struct ConstNotMemberOfTrait
{
99 pub(crate) span
: Span
,
100 pub(crate) const_
: Ident
,
101 pub(crate) trait_
: String
,
103 pub(crate) sub
: Option
<AssociatedConstWithSimilarNameExists
>,
106 #[derive(Subdiagnostic)]
108 resolve_associated_const_with_similar_name_exists
,
109 code
= "{candidate}",
110 applicability
= "maybe-incorrect"
112 pub(crate) struct AssociatedConstWithSimilarNameExists
{
114 pub(crate) span
: Span
,
115 pub(crate) candidate
: Symbol
,
118 #[derive(Diagnostic)]
119 #[diag(resolve_variable_bound_with_different_mode, code = "E0409")]
120 pub(crate) struct VariableBoundWithDifferentMode
{
123 pub(crate) span
: Span
,
124 #[label(first_binding_span)]
125 pub(crate) first_binding_span
: Span
,
126 pub(crate) variable_name
: Symbol
,
129 #[derive(Diagnostic)]
130 #[diag(resolve_ident_bound_more_than_once_in_parameter_list, code = "E0415")]
131 pub(crate) struct IdentifierBoundMoreThanOnceInParameterList
{
134 pub(crate) span
: Span
,
135 pub(crate) identifier
: Symbol
,
138 #[derive(Diagnostic)]
139 #[diag(resolve_ident_bound_more_than_once_in_same_pattern, code = "E0416")]
140 pub(crate) struct IdentifierBoundMoreThanOnceInSamePattern
{
143 pub(crate) span
: Span
,
144 pub(crate) identifier
: Symbol
,
147 #[derive(Diagnostic)]
148 #[diag(resolve_undeclared_label, code = "E0426")]
149 pub(crate) struct UndeclaredLabel
{
152 pub(crate) span
: Span
,
153 pub(crate) name
: Symbol
,
155 pub(crate) sub_reachable
: Option
<LabelWithSimilarNameReachable
>,
157 pub(crate) sub_reachable_suggestion
: Option
<TryUsingSimilarlyNamedLabel
>,
159 pub(crate) sub_unreachable
: Option
<UnreachableLabelWithSimilarNameExists
>,
162 #[derive(Subdiagnostic)]
163 #[label(resolve_label_with_similar_name_reachable)]
164 pub(crate) struct LabelWithSimilarNameReachable(#[primary_span] pub(crate) Span);
166 #[derive(Subdiagnostic)]
168 resolve_try_using_similarly_named_label
,
169 code
= "{ident_name}",
170 applicability
= "maybe-incorrect"
172 pub(crate) struct TryUsingSimilarlyNamedLabel
{
174 pub(crate) span
: Span
,
175 pub(crate) ident_name
: Symbol
,
178 #[derive(Subdiagnostic)]
179 #[label(resolve_unreachable_label_with_similar_name_exists)]
180 pub(crate) struct UnreachableLabelWithSimilarNameExists
{
182 pub(crate) ident_span
: Span
,
185 #[derive(Diagnostic)]
186 #[diag(resolve_self_import_can_only_appear_once_in_the_list, code = "E0430")]
187 pub(crate) struct SelfImportCanOnlyAppearOnceInTheList
{
190 pub(crate) span
: Span
,
193 #[derive(Diagnostic)]
194 #[diag(resolve_self_import_only_in_import_list_with_non_empty_prefix, code = "E0431")]
195 pub(crate) struct SelfImportOnlyInImportListWithNonEmptyPrefix
{
198 pub(crate) span
: Span
,
201 #[derive(Diagnostic)]
202 #[diag(resolve_cannot_capture_dynamic_environment_in_fn_item, code = "E0434")]
204 pub(crate) struct CannotCaptureDynamicEnvironmentInFnItem
{
206 pub(crate) span
: Span
,
209 #[derive(Diagnostic)]
210 #[diag(resolve_attempt_to_use_non_constant_value_in_constant, code = "E0435")]
211 pub(crate) struct AttemptToUseNonConstantValueInConstant
<'a
> {
213 pub(crate) span
: Span
,
215 pub(crate) with
: Option
<AttemptToUseNonConstantValueInConstantWithSuggestion
<'a
>>,
217 pub(crate) with_label
: Option
<AttemptToUseNonConstantValueInConstantLabelWithSuggestion
>,
219 pub(crate) without
: Option
<AttemptToUseNonConstantValueInConstantWithoutSuggestion
<'a
>>,
222 #[derive(Subdiagnostic)]
224 resolve_attempt_to_use_non_constant_value_in_constant_with_suggestion
,
225 code
= "{suggestion} {ident}",
226 applicability
= "maybe-incorrect"
228 pub(crate) struct AttemptToUseNonConstantValueInConstantWithSuggestion
<'a
> {
230 pub(crate) span
: Span
,
231 pub(crate) ident
: Ident
,
232 pub(crate) suggestion
: &'a
str,
233 pub(crate) current
: &'a
str,
236 #[derive(Subdiagnostic)]
237 #[label(resolve_attempt_to_use_non_constant_value_in_constant_label_with_suggestion)]
238 pub(crate) struct AttemptToUseNonConstantValueInConstantLabelWithSuggestion
{
240 pub(crate) span
: Span
,
243 #[derive(Subdiagnostic)]
244 #[label(resolve_attempt_to_use_non_constant_value_in_constant_without_suggestion)]
245 pub(crate) struct AttemptToUseNonConstantValueInConstantWithoutSuggestion
<'a
> {
247 pub(crate) ident_span
: Span
,
248 pub(crate) suggestion
: &'a
str,
251 #[derive(Diagnostic)]
252 #[diag(resolve_self_imports_only_allowed_within, code = "E0429")]
253 pub(crate) struct SelfImportsOnlyAllowedWithin
{
255 pub(crate) span
: Span
,
257 pub(crate) suggestion
: Option
<SelfImportsOnlyAllowedWithinSuggestion
>,
259 pub(crate) mpart_suggestion
: Option
<SelfImportsOnlyAllowedWithinMultipartSuggestion
>,
262 #[derive(Subdiagnostic)]
264 resolve_self_imports_only_allowed_within_suggestion
,
266 applicability
= "machine-applicable"
268 pub(crate) struct SelfImportsOnlyAllowedWithinSuggestion
{
270 pub(crate) span
: Span
,
273 #[derive(Subdiagnostic)]
274 #[multipart_suggestion(
275 resolve_self_imports_only_allowed_within_multipart_suggestion
,
276 applicability
= "machine-applicable"
278 pub(crate) struct SelfImportsOnlyAllowedWithinMultipartSuggestion
{
279 #[suggestion_part(code = "{{")]
280 pub(crate) multipart_start
: Span
,
281 #[suggestion_part(code = "}}")]
282 pub(crate) multipart_end
: Span
,
285 #[derive(Diagnostic)]
286 #[diag(resolve_binding_shadows_something_unacceptable, code = "E0530")]
287 pub(crate) struct BindingShadowsSomethingUnacceptable
<'a
> {
290 pub(crate) span
: Span
,
291 pub(crate) shadowing_binding
: PatternSource
,
292 pub(crate) shadowed_binding
: Res
,
293 pub(crate) article
: &'a
str,
295 pub(crate) sub_suggestion
: Option
<BindingShadowsSomethingUnacceptableSuggestion
>,
296 #[label(label_shadowed_binding)]
297 pub(crate) shadowed_binding_span
: Span
,
298 pub(crate) participle
: &'a
str,
299 pub(crate) name
: Symbol
,
302 #[derive(Subdiagnostic)]
304 resolve_binding_shadows_something_unacceptable_suggestion
,
306 applicability
= "unspecified"
308 pub(crate) struct BindingShadowsSomethingUnacceptableSuggestion
{
310 pub(crate) span
: Span
,
311 pub(crate) name
: Symbol
,
314 #[derive(Diagnostic)]
315 #[diag(resolve_forward_declared_generic_param, code = "E0128")]
316 pub(crate) struct ForwardDeclaredGenericParam
{
319 pub(crate) span
: Span
,
322 #[derive(Diagnostic)]
323 #[diag(resolve_param_in_ty_of_const_param, code = "E0770")]
324 pub(crate) struct ParamInTyOfConstParam
{
327 pub(crate) span
: Span
,
328 pub(crate) name
: Symbol
,
331 #[derive(Diagnostic)]
332 #[diag(resolve_self_in_generic_param_default, code = "E0735")]
333 pub(crate) struct SelfInGenericParamDefault
{
336 pub(crate) span
: Span
,
339 #[derive(Diagnostic)]
340 #[diag(resolve_param_in_non_trivial_anon_const)]
341 pub(crate) struct ParamInNonTrivialAnonConst
{
344 pub(crate) span
: Span
,
345 pub(crate) name
: Symbol
,
347 pub(crate) sub_is_type
: ParamInNonTrivialAnonConstIsType
,
349 pub(crate) help
: Option
<ParamInNonTrivialAnonConstHelp
>,
352 #[derive(Subdiagnostic)]
353 #[help(resolve_param_in_non_trivial_anon_const_help)]
354 pub(crate) struct ParamInNonTrivialAnonConstHelp
;
356 #[derive(Subdiagnostic)]
357 pub(crate) enum ParamInNonTrivialAnonConstIsType
{
358 #[note(resolve_param_in_non_trivial_anon_const_sub_type)]
360 #[help(resolve_param_in_non_trivial_anon_const_sub_non_type)]
361 NotAType { name: Symbol }
,
364 #[derive(Diagnostic)]
365 #[diag(resolve_unreachable_label, code = "E0767")]
367 pub(crate) struct UnreachableLabel
{
370 pub(crate) span
: Span
,
371 pub(crate) name
: Symbol
,
372 #[label(label_definition_span)]
373 pub(crate) definition_span
: Span
,
375 pub(crate) sub_suggestion
: Option
<UnreachableLabelSubSuggestion
>,
377 pub(crate) sub_suggestion_label
: Option
<UnreachableLabelSubLabel
>,
379 pub(crate) sub_unreachable_label
: Option
<UnreachableLabelSubLabelUnreachable
>,
382 #[derive(Subdiagnostic)]
384 resolve_unreachable_label_suggestion_use_similarly_named
,
385 code
= "{ident_name}",
386 applicability
= "maybe-incorrect"
388 pub(crate) struct UnreachableLabelSubSuggestion
{
390 pub(crate) span
: Span
,
391 pub(crate) ident_name
: Symbol
,
394 #[derive(Subdiagnostic)]
395 #[label(resolve_unreachable_label_similar_name_reachable)]
396 pub(crate) struct UnreachableLabelSubLabel
{
398 pub(crate) ident_span
: Span
,
401 #[derive(Subdiagnostic)]
402 #[label(resolve_unreachable_label_similar_name_unreachable)]
403 pub(crate) struct UnreachableLabelSubLabelUnreachable
{
405 pub(crate) ident_span
: Span
,
408 #[derive(Diagnostic)]
409 #[diag(resolve_trait_impl_mismatch, code = "{code}")]
410 pub(crate) struct TraitImplMismatch
{
413 pub(crate) span
: Span
,
414 pub(crate) name
: Symbol
,
415 pub(crate) kind
: String
,
416 #[label(label_trait_item)]
417 pub(crate) trait_item_span
: Span
,
418 pub(crate) trait_path
: String
,
419 pub(crate) code
: String
,
422 #[derive(Diagnostic)]
423 #[diag(resolve_invalid_asm_sym)]
425 pub(crate) struct InvalidAsmSym
{
428 pub(crate) span
: Span
,
431 #[derive(Diagnostic)]
432 #[diag(resolve_trait_impl_duplicate, code = "E0201")]
433 pub(crate) struct TraitImplDuplicate
{
436 pub(crate) span
: Span
,
437 #[label(old_span_label)]
438 pub(crate) old_span
: Span
,
439 #[label(trait_item_span)]
440 pub(crate) trait_item_span
: Span
,
441 pub(crate) name
: Symbol
,
444 #[derive(Diagnostic)]
445 #[diag(resolve_relative_2018)]
446 pub(crate) struct Relative2018
{
448 pub(crate) span
: Span
,
449 #[suggestion(code = "crate::{path_str}", applicability = "maybe-incorrect")]
450 pub(crate) path_span
: Span
,
451 pub(crate) path_str
: String
,
454 #[derive(Diagnostic)]
455 #[diag(resolve_ancestor_only, code = "E0742")]
456 pub(crate) struct AncestorOnly(#[primary_span] pub(crate) Span);
458 #[derive(Diagnostic)]
459 #[diag(resolve_expected_found, code = "E0577")]
460 pub(crate) struct ExpectedFound
{
463 pub(crate) span
: Span
,
465 pub(crate) path_str
: String
,
468 #[derive(Diagnostic)]
469 #[diag(resolve_indeterminate, code = "E0578")]
470 pub(crate) struct Indeterminate(#[primary_span] pub(crate) Span);
472 #[derive(Diagnostic)]
473 #[diag(resolve_module_only)]
474 pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span);