about summary refs log tree commit diff
path: root/src/test/ui/expr
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-1306/+0
2022-12-30Suppress errors due to TypeError not coercing with inference variablesMichael Goulet-24/+3
2022-12-13Avoid rendering empty annotationsOli Scherer-3/+0
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-3/+3
available
2022-12-11Use `with_forced_trimmed_paths`Esteban Küber-1/+1
2022-10-07Rollup merge of #102720 - lyming2007:issue-102397-fix, r=compiler-errorsMatthias Krüger-4/+4
do not reverse the expected type and found type for ObligationCauseCo… …de of IfExpressionWithNoElse this will fix #102397
2022-10-06Rollup merge of #102708 - TaKO8Ki:improve-eqeq-suggestion, r=estebankMatthias Krüger-0/+5
Suggest `==` to wrong assign expr Given the following code: ```rust fn main() { let x = 3; let y = 3; if x == x && y = y { println!("{}", x); } } ``` Current output is: ``` error[E0308]: mismatched types --> src/main.rs:4:18 | 4 | if x == x && y = y { | ^ expected `bool`, found integer error[E0308]: mismatched types --> src/main.rs:4:8 | 4 | if x == x && y = y { | ^^^^^^^^^^^^^^^ expected `bool`, found `()` ``` This adds a suggestion: ```diff error[E0308]: mismatched types --> src/main.rs:6:18 | 6 | if x == x && y = y { | ^ expected `bool`, found integer error[E0308]: mismatched types --> src/main.rs:6:8 | 6 | if x == x && y = y { | ^^^^^^^^^^^^^^^ expected `bool`, found `()` | + help: you might have meant to compare for equality + | + 6 | if x == x && y == y { + | + ``` And this fixes a part of #97469
2022-10-05do not reverse the expected type and found type for ObligationCauseCode of ↵Yiming Lei-4/+4
IfExpressionWithNoElse this will fix #102397
2022-10-05suggest `==` to the rest of assign exprTakayuki Maeda-0/+5
2022-10-01bless ui testsMaybe Waffle-1/+1
2022-09-09Be careful about expr_ty_adjusted when noting block tail typeMichael Goulet-1/+1
2022-08-29Revert let_chains stabilizationNilstrieb-6/+18
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-04Resolve vars before emitting coerce errorMichael Goulet-0/+15
2022-07-19Mention first and last macro in backtraceMichael Goulet-1/+1
2022-07-16Stabilize `let_chains`Caio-18/+6
2022-06-16diagnostics: fix trailing spaceklensy-4/+4
2022-06-13Improve parsing errors and suggestions for bad if statementsMichael Goulet-12/+7
2022-06-07Don't suggest adding let in certain if conditionsMichael Goulet-0/+93
2022-01-18Formally implement let chainsCaio-12/+1
2021-12-17Bless ui testsDeadbeef-2/+2
2021-12-01Improve diagnostic for missing half of binary operator in `if` conditionFabian Wolff-1/+5
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-0/+5
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-14Move some tests to more reasonable directoriesCaio-0/+52
2021-10-15Bless testsCameron Steffen-2/+2
2021-09-16Fix rebaseEsteban Kuber-3/+12
2021-09-09Emit proper errors on missing closure bracesSasha Pourcelot-0/+110
This commit focuses on emitting clean errors for the following syntax error: ``` Some(42).map(|a| dbg!(a); a ); ``` Previous implementation tried to recover after parsing the closure body (the `dbg` expression) by replacing the next `;` with a `,`, which made the next expression belong to the next function argument. As such, the following errors were emitted (among others): - the semicolon token was not expected, - a is not in scope, - Option::map is supposed to take one argument, not two. This commit allows us to gracefully handle this situation by adding giving the parser the ability to remember when it has just parsed a closure body inside a function call. When this happens, we can treat the unexpected `;` specifically and try to parse as much statements as possible in order to eat the whole block. When we can't parse statements anymore, we generate a clean error indicating that the braces are missing, and return an ExprKind::Err.
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-34/+20
2021-08-11Modify structured suggestion outputEsteban Küber-12/+16
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-07-30Use multispan suggestions more oftenEsteban Küber-32/+48
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-2/+2
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-02-18Add explanations and suggestions to `irrefutable_let_patterns` lintCamelid-0/+16
2021-02-18Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkorDylan DPC-16/+16
Replace if-let and while-let with `if let` and `while let` This pull request replaces if-let and while-let with `if let` and `while let`. closes https://github.com/rust-lang/rust/issues/82205
2021-02-17replace if-let and while-let with `if let` and `while let`Takayuki Maeda-16/+16
2021-02-16Move some tests to more reasonable directoriesCaio-0/+45
2020-12-04Move format machinery tests to where they belongAleksey Kladov-486/+0
2020-11-24Move src/test/ui/if-*.rs to src/test/expr/if/if-*.rsHavvy (Ryan Scheel)-0/+195
2020-11-24Move src/test/ui/if-attrs to src/test/ui/expr/if/attrsHavvy (Ryan Scheel)-0/+176
2020-11-24Move src/test/ui/if to src/test/ui/expr/ifHavvy (Ryan Scheel)-0/+1025
2020-11-22Add test for eval order for a+=bHavvy (Ryan Scheel)-0/+76
Yes, the order of evaluation *does* change depending on the types of the operands. Cursed, I know. I've elected to place this test into `expr/compound-assignment` creating both the `expr` directory and the `compound-assignment` directory. I plan in a future PR to also move the `if` directory and the loose `if` tests into `expr/if` and other similar cleanups of the `test/ui` directory. Future work: Test more than just `+=`, but all operators. I don't know if using a macro to generate these tests cases would be okay or not, but it'd be boilerplatey without it. I'm also confident you cannot change the evaluation order of one operator without changing all of them. Future work: Additionally, test more than just `i32 += i32` for the primitive version. I don't actually know the full set of primitive implementations, but I imagine there's enough to cause a combinatorial explosion with the previous future work item. Somewhere on the order of one to two hundred individual functions.