about summary refs log tree commit diff
path: root/src/test/ui/parser
AgeCommit message (Collapse)AuthorLines
2022-05-30Optimize the diagnostic generation for `extern unsafe`SparrowLii-6/+37
2022-05-30Bless tests with the full list of conventions in the outputScott McMurray-1/+1
2022-05-28Move some tests to more reasonable placesCaio-0/+46
2022-05-28Make some tests check-passYuki Okushi-4/+4
2022-05-24Minor improvement on else-no-if diagnosticMichael Goulet-10/+2
2022-05-23Parse expression after `else` as a condition if followed by `{`Michael Goulet-0/+90
2022-05-21Add regression test for #81827Yuki Okushi-0/+46
2022-05-16Add regression test for #81804Yuki Okushi-0/+50
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-0/+1
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-06Resolve vars in note_type_errJack Huey-0/+9
2022-05-05Allow unused rules in the testsuite where the lint triggersest31-0/+1
2022-05-04Auto merge of #96353 - estebank:issue-95413, r=compiler-errorsbors-0/+5
When suggesting to import an item, also suggest changing the path if appropriate When we don't find an item we search all of them for an appropriate import and suggest `use`ing it. This is sometimes done for expressions that have paths with more than one segment. We now also suggest changing that path to work with the `use`. Fix #95413
2022-05-03Tweak wordingEsteban Kuber-2/+2
2022-05-03When suggesting to import an item, also suggest changing the path if appropriateEsteban Küber-1/+6
When we don't find an item we search all of them for an appropriate import and suggest `use`ing it. This is sometimes done for expressions that have paths with more than one segment. We now also suggest changing that path to work with the `use`. Fix #95413
2022-05-02Fix invalid keyword order for function declarationsKen Matsui-9/+9
2022-04-23Better handle too many `#` recovery in raw strEsteban Küber-6/+50
Point at all the unnecessary trailing `#`. Better handle interaction with outer attributes when `;` is missing. Fix #95030.
2022-04-21Move some tests to more reasonable directoriesCaio-0/+13
2022-04-16Implementation for 65853Jack Huey-16/+42
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-09expand: Remove `ParseSess::missing_fragment_specifiers`Vadim Petrochenkov-2/+14
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-06Stop flagging certain inner attrs as outer onesLeón Orell Valerian Liehr-10/+32
2022-04-03Auto merge of #88672 - camelid:inc-parser-sugg, r=davidtwcobors-0/+277
Suggest `i += 1` when we see `i++` or `++i` Closes #83502 (for `i++` and `++i`; `--i` should be covered by #82987, and `i--` is tricky to handle). This is a continuation of #83536. r? `@estebank`
2022-03-28Remove opaque type obligation and just register opaque types as they are ↵Oli Scherer-32/+52
encountered. This also registers obligations for the hidden type immediately.
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-44/+117
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-27Fix from rebaseNoah Lev-19/+27
I changed the test functions to be `pub` rather than called from a `main` function too, for easier future modification of tests.
2022-03-27Auto merge of #94495 - estebank:missing-closing-gt, r=jackh726bors-13/+134
Provide suggestion for missing `>` in a type parameter list When encountering an inproperly terminated type parameter list, provide a suggestion to close it after the last non-constraint type parameter that was successfully parsed. Fix #94058.
2022-03-27Handle `,` to `;` substitution in arg paramsEsteban Kuber-7/+19
2022-03-27Provide suggestion for missing `>` in a type parameter listEsteban Kuber-9/+118
When encountering an inproperly terminated type parameter list, provide a suggestion to close it after the last non-constraint type parameter that was successfully parsed. Fix #94058.
2022-03-27Point (again) to more expressions with their type, even if not fully resolvedEsteban Kuber-12/+27
2022-03-23Fix rustfix panic on testNoah Lev-113/+134
`run-rustfix` applies all suggestions regardless of their Applicability. There's a flag, `rustfix-only-machine-applicable`, that does what it says, but then the produced `.fixed` file would have invalid code from the suggestions that weren't applied. So, I moved the cases of postfix increment, in which case multiple suggestions are given, to the `-notfixed` test, which does not run rustfix. I also changed the Applicability to Unspecified since MaybeIncorrect requires that the code be valid, even if it's incorrect.
2022-03-23Use `multipart_suggestions`Noah Lev-12/+0
This records that the suggestions are mutually-exclusive (i.e., only one should be applied).
2022-03-23Change temporary variable name if it would conflictNoah Lev-6/+6
2022-03-23Add heuristic to avoid treating `x + +2` as incrementNoah Lev-9/+5
2022-03-23Bless testsNoah Lev-5/+9
2022-03-23Improve handling of `tmp` variable name conflictsNoah Lev-5/+80
2022-03-23Emit both subexp and standalone sugg for postfixNoah Lev-0/+15
This solves the TODO.
2022-03-23Emit structured suggestions for field accesses tooNoah Lev-2/+9
2022-03-23Refactor, handle fields better, add field testsNoah Lev-4/+48
2022-03-23Move increment checks to improve errorsNoah Lev-36/+76
2022-03-23Suggest `i += 1` when we see `i++` or `++i`Camelid-0/+79
2022-03-22diagnostics: do not suggest `fn foo({ <body> }`Michael Howell-3/+1
Instead of suggesting that the body always replace the last character on the line, presuming it must be a semicolon, the parser should instead check what the last character is, and append the body if it is anything else. Fixes #83104
2022-03-21Auto merge of #95104 - compiler-errors:remove-ascription, r=davidtwcobors-0/+80
suggest removing type ascription in bad parsing position Not sure how to test this with the non-nightly suggestion. Didn't add a new UI test because it already manifests in an existing UI test. Fixes #95014
2022-03-20fix a not emitted unmatched angle bracket errorTakayuki Maeda-0/+17
2022-03-18suggest removing type ascription in bad positionMichael Goulet-0/+80
2022-03-17Rollup merge of #91133 - terrarier2111:unsafe-diagnostic, r=jackh726Dylan DPC-1/+6
Improve `unsafe` diagnostic This fixes: https://github.com/rust-lang/rust/issues/90880 I didn't use the exact proposed messages though.
2022-03-11Format core and std macro rules, removing needless surrounding blocksDavid Tolnay-1/+1
2022-03-06Auto merge of #90076 - jackh726:wherethewhere, r=nikomatsakisbors-61/+117
Change location of where clause on GATs Closes #89122 ~Blocked on lang FCP~ r? `@nikomatsakis`
2022-03-05Review changesJack Huey-44/+106
2022-03-05Change to lintJack Huey-7/+9
2022-03-05Change syntax for TyAlias where clausesJack Huey-33/+25
2022-03-05Rollup merge of #94633 - ↵Ralf Jung-0/+18
TaKO8Ki:suggest-removing-semicolon-after-derive-attribute, r=cjgillot Suggest removing a semicolon after derive attributes closes #93942