Skip to content

Commit e5282a8

Browse files
committed
rustc_parse: migrate more to diagnostic structs
1 parent 5783b8c commit e5282a8

File tree

9 files changed

+990
-481
lines changed

9 files changed

+990
-481
lines changed

compiler/rustc_error_messages/locales/en-US/parse.ftl

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,160 @@ parse_maybe_fn_typo_with_impl = you might have meant to write `impl` instead of
368368
369369
parse_expected_fn_path_found_fn_keyword = expected identifier, found keyword `fn`
370370
.suggestion = use `Fn` to refer to the trait
371+
372+
parse_async_fn_in_2015 = `async fn` is not permitted in Rust 2015
373+
.label = to use `async fn`, switch to Rust 2018 or later
374+
375+
parse_async_block_in_2015 = `async` blocks are only allowed in Rust 2018 or later
376+
377+
parse_self_argument_pointer = cannot pass `self` by raw pointer
378+
.label = cannot pass `self` by raw pointer
379+
380+
parse_visibility_not_followed_by_item = visibility `{$vis}` is not followed by an item
381+
.label = the visibility
382+
.help = you likely meant to define an item, e.g., `{$vis} fn foo() {"{}"}`
383+
384+
parse_default_not_followed_by_item = `default` is not followed by an item
385+
.label = the `default` qualifier
386+
.note = only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
387+
388+
parse_missing_struct_for_struct_definition = missing `struct` for struct definition
389+
.suggestion = add `struct` here to parse `{$ident}` as a public struct
390+
391+
parse_missing_fn_for_function_definition = missing `fn` for function definition
392+
.suggestion = add `fn` here to parse `{$ident}` as a public function
393+
394+
parse_missing_fn_for_method_definition = missing `fn` for method definition
395+
.suggestion = add `fn` here to parse `{$ident}` as a public method
396+
397+
parse_ambiguous_missing_keyword_for_item_definition = missing `fn` or `struct` for function or struct definition
398+
.suggestion = if you meant to call a macro, try
399+
.help = if you meant to call a macro, remove the `pub` and add a trailing `!` after the identifier
400+
401+
parse_missing_trait_in_trait_impl = missing trait in a trait impl
402+
.suggestion_add_trait = add a trait here
403+
.suggestion_remove_for = for an inherent impl, drop this `for`
404+
405+
parse_missing_for_in_trait_impl = missing `for` in a trait impl
406+
.suggestion = add `for` here
407+
408+
parse_expected_trait_in_trait_impl_found_type = expected a trait, found type
409+
410+
parse_non_item_in_item_list = non-item in item list
411+
.suggestion_use_const_not_let = consider using `const` instead of `let` for associated const
412+
.label_list_start = item list starts here
413+
.label_non_item = non-item starts here
414+
.label_list_end = item list ends here
415+
.suggestion_remove_semicolon = consider removing this semicolon
416+
417+
parse_bounds_not_allowed_on_trait_aliases = bounds are not allowed on trait aliases
418+
419+
parse_trait_alias_cannot_be_auto = trait aliases cannot be `auto`
420+
parse_trait_alias_cannot_be_unsafe = trait aliases cannot be `unsafe`
421+
422+
parse_associated_static_item_not_allowed = associated `static` items are not allowed
423+
424+
parse_extern_crate_name_with_dashes = crate name using dashes are not valid in `extern crate` statements
425+
.label = dash-separated idents are not valid
426+
.suggestion = if the original crate name uses dashes you need to use underscores in the code
427+
428+
parse_extern_item_cannot_be_const = extern items cannot be `const`
429+
.suggestion = try using a static value
430+
.note = for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
431+
432+
parse_const_global_cannot_be_mutable = const globals cannot be mutable
433+
.label = cannot be mutable
434+
.suggestion = you might want to declare a static instead
435+
436+
parse_missing_const_type = missing type for `{$kind}` item
437+
.suggestion = provide a type for the item
438+
439+
parse_enum_struct_mutually_exclusive = `enum` and `struct` are mutually exclusive
440+
.suggestion = replace `enum struct` with
441+
442+
parse_unexpected_token_after_struct_name = expected `where`, `{"{"}`, `(`, or `;` after struct name
443+
parse_unexpected_token_after_struct_name_found_reserved_identifier = expected `where`, `{"{"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`
444+
parse_unexpected_token_after_struct_name_found_keyword = expected `where`, `{"{"}`, `(`, or `;` after struct name, found keyword `{$token}`
445+
parse_unexpected_token_after_struct_name_found_reserved_keyword = expected `where`, `{"{"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`
446+
parse_unexpected_token_after_struct_name_found_doc_comment = expected `where`, `{"{"}`, `(`, or `;` after struct name, found doc comment `{$token}`
447+
parse_unexpected_token_after_struct_name_found_other = expected `where`, `{"{"}`, `(`, or `;` after struct name, found `{$token}`
448+
449+
parse_unexpected_self_in_generic_parameters = unexpected keyword `Self` in generic parameters
450+
.note = you cannot use `Self` as a generic parameter because it is reserved for associated items
451+
452+
parse_multiple_where_clauses = cannot define duplicate `where` clauses on an item
453+
.label = previous `where` clause starts here
454+
.suggestion = consider joining the two `where` clauses into one
455+
456+
parse_nonterminal_expected_item_keyword = expected an item keyword
457+
parse_nonterminal_expected_statement = expected a statement
458+
parse_nonterminal_expected_ident = expected ident, found `{$token}`
459+
parse_nonterminal_expected_lifetime = expected a lifetime, found `{$token}`
460+
461+
parse_or_pattern_not_allowed_in_let_binding = top-level or-patterns are not allowed in `let` bindings
462+
parse_or_pattern_not_allowed_in_fn_parameters = top-level or-patterns are not allowed in function parameters
463+
parse_sugg_remove_leading_vert_in_pattern = remove the `|`
464+
parse_sugg_wrap_pattern_in_parens = wrap the pattern in parentheses
465+
466+
parse_note_pattern_alternatives_use_single_vert = alternatives in or-patterns are separated with `|`, not `||`
467+
468+
parse_unexpected_vert_vert_before_function_parameter = unexpected `||` before function parameter
469+
.suggestion = remove the `||`
470+
471+
parse_label_while_parsing_or_pattern_here = while parsing this or-pattern starting here
472+
473+
parse_unexpected_vert_vert_in_pattern = unexpected token `||` in pattern
474+
.suggestion = use a single `|` to separate multiple alternative patterns
475+
476+
parse_trailing_vert_not_allowed = a trailing `|` is not allowed in an or-pattern
477+
.suggestion = remove the `{$token}`
478+
479+
parse_dotdotdot_rest_pattern = unexpected `...`
480+
.label = not a valid pattern
481+
.suggestion = for a rest pattern, use `..` instead of `...`
482+
483+
parse_pattern_on_wrong_side_of_at = pattern on wrong side of `@`
484+
.label_pattern = pattern on the left, should be on the right
485+
.label_binding = binding on the right, should be on the left
486+
.suggestion = switch the order
487+
488+
parse_expected_binding_left_of_at = left-hand side of `@` must be a binding
489+
.label_lhs = interpreted as a pattern, not a binding
490+
.label_rhs = also a pattern
491+
.note = bindings are `x`, `mut x`, `ref x`, and `ref mut x`
492+
493+
parse_ambiguous_range_pattern = the range pattern here has ambiguous interpretation
494+
.suggestion = add parentheses to clarify the precedence
495+
496+
parse_unexpected_lifetime_in_pattern = unexpected lifetime `{$symbol}` in pattern
497+
.suggestion = remove the lifetime
498+
499+
parse_ref_mut_order_incorrect = the order of `mut` and `ref` is incorrect
500+
.suggestion = try switching the order
501+
502+
parse_mut_on_nested_ident_pattern = `mut` must be attached to each individual binding
503+
.suggestion = add `mut` to each binding
504+
parse_mut_on_non_ident_pattern = `mut` must be followed by a named binding
505+
.suggestion = remove the `mut` prefix
506+
parse_note_mut_pattern_usage = `mut` may be followed by `variable` and `variable @ pattern`
507+
508+
parse_repeated_mut_in_pattern = `mut` on a binding may not be repeated
509+
.suggestion = remove the additional `mut`s
510+
511+
parse_extra_eq_in_inclusive_range_pattern = unexpected `=` after inclusive range
512+
.suggestion = use `..=` instead
513+
.note = inclusive ranges end with a single equals sign (`..=`)
514+
515+
parse_inclusive_range_pattern_without_end = inclusive range with no end
516+
.suggestion = use `..` instead
517+
.note = inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
518+
519+
parse_dot_dot_dot_range_to_pattern_not_allowed = range-to patterns with `...` are not allowed
520+
.suggestion = use `..=` instead
521+
522+
parse_enum_pattern_instead_of_identifier = expected identifier, found enum pattern
523+
524+
parse_dot_dot_dot_for_remaining_fields = expected field pattern, found `...`
525+
.suggestion = to omit remaining fields, use one fewer `.`
526+
527+
parse_expected_comma_after_pattern_field = expected `,`

0 commit comments

Comments
 (0)