summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/item.rs
AgeCommit message (Collapse)AuthorLines
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-5/+5
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-02fix most compiler/ doctestsElliot Roberts-5/+5
2022-05-02Fix invalid keyword order for function declarationsKen Matsui-2/+2
2022-04-29errors: `span_suggestion` takes `impl ToString`David Wood-5/+5
Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-42/+43
2022-04-12use `to_string` instead of `format!`Takayuki Maeda-1/+1
2022-04-05errors: implement fallback diagnostic translationDavid Wood-1/+1
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05errors: introduce `DiagnosticMessage`David Wood-1/+2
Introduce a `DiagnosticMessage` type that will enable diagnostic messages to be simple strings or Fluent identifiers. `DiagnosticMessage` is now used in the implementation of the standard `DiagnosticBuilder` APIs. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-20fix a not emitted unmatched angle bracket errorTakayuki Maeda-1/+1
2022-03-17Rollup merge of #94960 - codehorseman:master, r=oli-obkDylan DPC-1/+1
Fix many spelling mistakes Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-17Rollup merge of #93222 - mark-i-m:errorreported, r=oli-obkDylan DPC-3/+3
Make ErrorReported impossible to construct outside `rustc_errors` There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name. cc #69426 `@varkor` `@eddyb` `@estebank` I actually didn't see that I was assigned to this issue until now...
2022-03-17Rollup merge of #91133 - terrarier2111:unsafe-diagnostic, r=jackh726Dylan DPC-3/+25
Improve `unsafe` diagnostic This fixes: https://github.com/rust-lang/rust/issues/90880 I didn't use the exact proposed messages though.
2022-03-16rustc_error: make ErrorReported impossible to constructmark-3/+3
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-15use `format_args_capture` in some parts of rustc_parseTakayuki Maeda-27/+26
2022-03-15Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuberbors-4/+7
More robust fallback for `use` suggestion Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion. But this was fragile, as illustrated in issue #87613 This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion. Fix #87613
2022-03-11Rollup merge of #94839 - ↵Dylan DPC-0/+10
TaKO8Ki:suggest-using-double-colon-for-struct-field-type, r=cjgillot Suggest using double colon when a struct field type include single colon #92685
2022-03-11fix a suggestion messageTakayuki Maeda-1/+1
2022-03-11suggest using double colon when using single colon in struct field type pathTakayuki Maeda-0/+10
2022-03-07diagnostics: only talk about `Cargo.toml` if running under CargoMichael Howell-3/+2
Fixes #94646
2022-03-06Auto merge of #90076 - jackh726:wherethewhere, r=nikomatsakisbors-53/+29
Change location of where clause on GATs Closes #89122 ~Blocked on lang FCP~ r? `@nikomatsakis`
2022-03-05Change syntax for TyAlias where clausesJack Huey-53/+29
2022-03-06suggest removing a semicolon after derive attributesTakayuki Maeda-0/+10
use current token span
2022-03-03Adjusted diagnostic output so that if there is no `use` in a item sequence,Felix S. Klock II-1/+4
then we just suggest the first legal position where you could inject a use. To do this, I added `inject_use_span` field to `ModSpans`, and populate it in parser (it is the span of the first token found after inner attributes, if any). Then I rewrote the use-suggestion code to utilize it, and threw out some stuff that is now unnecessary with this in place. (I think the result is easier to understand.) Then I added a test of issue 87613.
2022-03-03Associate multiple with a crate too.Felix S. Klock II-2/+1
2022-03-03refactor: prepare to associate multiple spans with a module.Felix S. Klock II-3/+4
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-2/+2
2022-02-284 - Make more use of `let_chains`Caio-7/+5
Continuation of #94376. cc #53667
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-2/+2
2022-02-23rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.Eduard-Mihai Burtescu-5/+7
2022-02-19Adopt let else in more placesest31-3/+2
2022-02-02better suggestion for duplicated `where`Michael Goulet-7/+22
2022-01-26Introduce a limit to Levenshtein distance computationTomasz Miąsko-1/+1
Incorporate distance limit from `find_best_match_for_name` directly into Levenshtein distance computation. Use the string size difference as a lower bound on the distance and exit early when it exceeds the specified limit. After finding a candidate within a limit, lower the limit further to restrict the search space.
2022-01-05ast: Always keep a `NodeId` in `ast::Crate`Vadim Petrochenkov-1/+1
This makes it more uniform with other expanded nodes
2021-12-28Parse and suggest moving where clauses after equals for type aliasesJack Huey-0/+53
2021-12-13Use Inherited Visibility instead of None when no vis is presentAlexis Bourget-13/+14
2021-12-13Update test to new error messageAlexis Bourget-1/+1
2021-12-13Suggest remove on const async const instead of const const asyncAlexis Bourget-16/+45
2021-12-13Fix broken span and related testsAlexis Bourget-1/+1
2021-12-13Change error for pub in fn decl if already presentAlexis Bourget-13/+37
2021-12-08Rollup merge of #91337 - FabianWolff:issue-91227-misspelled-macro, r=nagisaMatthias Krüger-4/+25
Add a suggestion if `macro_rules` is misspelled Fixes #91227.
2021-12-06Expect extern fn with no body when parsingMichael Howell-1/+1
Also add a test case for inserting a semicolon on extern fns. Without this fix, we got an error like this: error: expected one of `->`, `where`, or `{`, found `}` --> chk.rs:3:1 | 2 | fn foo() | --- - expected one of `->`, `where`, or `{` | | | while parsing this `fn` 3 | } | ^ unexpected token Since this is inside an extern block, you're required to write function prototypes with no body. This fixes a regression, and adds a test case for it.
2021-12-06Add better comments for FnParseModeMichael Howell-2/+49
2021-12-04Do not add `;` to expected tokens list when it's wrongMichael Howell-22/+51
There's a few spots where semicolons are checked for to do error recovery, and should not be suggested (or checked for other stuff). Fixes #87647
2021-11-28Add a suggestion if `macro_rules` is misspelledFabian Wolff-4/+25
2021-11-28expand: Turn `ast::Crate` into a first class expansion targetVadim Petrochenkov-1/+1
And stop creating a fake `mod` item for the crate root when expanding a crate.
2021-11-27Improve `unsafe` diagnosticthreadexception-3/+25
2021-11-24Account for incorrect `impl Foo<const N: ty> {}` syntaxEsteban Küber-1/+1
Fix #84946
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-14/+15
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-10-22Rollup merge of #89257 - aDotInTheVoid:macro-error-2, r=estebankYuki Okushi-10/+40
Give better error for `macro_rules name` follow up to #89221 r? ``@estebank`` ``@rustbot`` modify labels: +A-diagnostics +A-parser