summary refs log tree commit diff
path: root/src/test/ui/parser
AgeCommit message (Collapse)AuthorLines
2022-06-21Improve suggestion for calling closure on type mismatchMichael Goulet-0/+10
2022-06-17Auto merge of #97892 - klensy:fix-spaces, r=oli-obkbors-75/+75
diagnostics: remove trailing spaces Remove few occurrences of trailing spaces and drive by fix of needless alloc of const string.
2022-06-16--bless uiMaybe Waffle-4/+3
2022-06-16 fix one more case of trailing spaceklensy-13/+13
2022-06-16diagnostics: fix trailing spaceklensy-62/+62
2022-06-13Improve parsing errors and suggestions for bad if statementsMichael Goulet-66/+177
2022-06-14Rollup merge of #95211 - terrarier2111:improve-parser, r=compiler-errorsYuki Okushi-24/+47
Improve parser diagnostics This pr fixes https://github.com/rust-lang/rust/issues/93867 and contains a couple of diagnostics related changes to the parser. Here is a short list with some of the changes: - don't suggest the same thing that is the current token - suggest removing the current token if the following token is one of the suggestions (maybe incorrect) - tell the user to put a type or lifetime after where if there is none (as a warning) - reduce the amount of tokens suggested (via the new eat_noexpect and check_noexpect methods) If any of these changes are undesirable, i can remove them, thanks!
2022-06-12Improves parser diagnostics, fixes #93867threadexception-24/+47
2022-06-08Rollup merge of #97857 - ChayimFriedman2:box-identifier-help, r=compiler-errorsMichael Goulet-4/+69
Suggest escaping `box` as identifier Fixes #97810.
2022-06-08Suggest escaping `box` as identifierChayim Refael Friedman-4/+69
2022-06-08Rollup merge of #97823 - compiler-errors:missing-comma-match-arm, r=estebankDylan DPC-10/+6
Recover missing comma after match arm If we're missing a comma after a match arm expression, try parsing another pattern and a following `=>`. If we find both of those, then recover by suggesting to insert a `,`. Fixes #80112
2022-06-07Recover missing comma after match armMichael Goulet-10/+6
2022-06-07Auto merge of #97512 - scottmcm:add-coldcc, r=nagisa,lcnrbors-1/+1
Add support for emitting functions with `coldcc` to LLVM The eventual goal is to try using this for things like the internal panicking stuff, to see whether it helps.
2022-06-07Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakisbors-3/+2
Remove migrate borrowck mode Closes #58781 Closes #43234 # Stabilization proposal This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile. Tracking issue: #43234 RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable). ## Motivation Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors. The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition. In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker. In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver. While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff. ## What is stabilized As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise. There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl. As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions. ## What isn't stabilized This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck. ## Tests Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll` ## History * On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234) * On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271) * On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094) * On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825) * On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862) * On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083) * On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681) * On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114) * On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221) * On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-06Add spaces before and after expr in add {} suggestionWaffle Maybe-12/+12
Co-authored-by: Michael Goulet <michael@errs.io>
2022-06-05Suggest removing label in `'label: non_block_expr`Maybe Waffle-10/+53
2022-06-05Do not suggest adding labeled block if there are no labeled breaksMaybe Waffle-24/+10
2022-06-05Suggest adding `{}` for `'label: non_block_expr`Maybe Waffle-10/+94
2022-06-03Fully stabilize NLLJack Huey-3/+2
2022-06-03Auto merge of #89862 - lcnr:path-generics-diagnostics, r=estebankbors-11/+18
rewrite error handling for unresolved inference vars Pretty much completely rewrites `fn emit_inference_failure_err`. This new setup should hopefully be easier to extend and is already a lot better when looking for generic arguments. Because this is a rewrite there are still some parts which are lacking, these are tracked in #94483 and will be fixed in later PRs. r? `@estebank` `@petrochenkov`
2022-06-03Auto merge of #97497 - c410-f3r:z-errors, r=petrochenkovbors-0/+46
Move some tests to more reasonable places r? `@petrochenkov`
2022-06-02add new `emit_inference_failure_err`lcnr-11/+18
2022-05-30Rollup merge of #97172 - SparrowLii:unsafe_extern, r=compiler-errorsMichael Goulet-6/+37
Optimize the diagnostic generation for `extern unsafe` This PR does the following about diagnostic generation when parsing foreign mod: 1. Fixes the FIXME about avoiding depending on the error message text. 2. Continue parsing when `unsafe` is followed by `{` (just like `unsafe extern {...}`). 3. Add test case.
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.