about summary refs log tree commit diff
path: root/src/test/ui/if
AgeCommit message (Collapse)AuthorLines
2020-11-24Move src/test/ui/if to src/test/ui/expr/ifHavvy (Ryan Scheel)-1025/+0
2020-09-02pretty: trim paths of unique symbolsDan Aloni-4/+4
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-06-27Improve messaging from PR feedbackDavid Hewitt-10/+5
2020-06-24Add `format_args_capture` featureDavid Hewitt-0/+15
2020-05-08Skip tests on emscriptenYuki Okushi-0/+4
2020-05-06Move tests from `test/run-fail` to UIYuki Okushi-0/+67
2020-04-30Rollup merge of #71433 - antoyo:error/missing-right-operand, r=Dylan-DPCDylan DPC-0/+2
Add help message for missing right operand in condition closes #30035
2020-04-23Moving more build-pass tests to check-passVal Markovic-1/+1
One or two tests became build-pass without the FIXME because they really needed build-pass (were failing without it). Helps with #62277
2020-04-22Add help message for missing right operand in conditionAntoni Boucher-0/+2
2020-04-11rustc: Add a warning count upon completionRoccoDev-0/+2
2020-02-06rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros.Eduard-Mihai Burtescu-0/+8
2020-01-05Add backticks to various diagnosticsvarkor-20/+20
2019-12-23refactor parse_if_exprMazdak Farrokhzad-2/+2
2019-12-23more recovery in if-parsingMazdak Farrokhzad-2/+2
2019-11-25Tweak duplicate fmt arg errorEsteban Küber-7/+3
2019-11-18Surround types with backticks in type errorsEsteban Küber-23/+23
2019-11-18Remove E0308 note when primary label has all infoEsteban Küber-47/+0
2019-11-18review comments: tweak prefix stringsEsteban Küber-15/+15
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-21/+21
2019-11-09Rollup merge of #66134 - estebank:unknown-formatting-trait, r=nikomatsakisMazdak Farrokhzad-4/+4
Point at formatting descriptor string when it is invalid When a formatting string contains an invalid descriptor, point at it instead of the argument: ``` error: unknown format trait `foo` --> $DIR/ifmt-bad-arg.rs:86:17 | LL | println!("{:foo}", 1); | ^^^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait ```
2019-11-06Rollup merge of #66093 - estebank:fmt-ice, r=CentrilMazdak Farrokhzad-1/+17
Do not ICE with a precision flag in formatting str and no format arguments Fix #66065.
2019-11-05Point at formatting descriptor string when it is invalidEsteban Küber-4/+4
When a formatting string contains an invalid descriptor, point at it instead of the argument: ``` error: unknown format trait `foo` --> $DIR/ifmt-bad-arg.rs:86:17 | LL | println!("{:foo}", 1); | ^^^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait ```
2019-11-05Do not ICE whith a precision flag in formatting str and no format argumentsEsteban Küber-1/+17
2019-11-03Update error annotations positionsTomasz Miąsko-6/+8
Since 8ec9d7242c3352fbc617d907bec3632215811356, in the case of a local macro expansion, the errors are now matched to macro definition location. Update test cases accordingly.
2019-10-26Rollup merge of #65773 - estebank:sugg-whitespace, r=CentrilMazdak Farrokhzad-0/+1
Increase spacing for suggestions in diagnostics Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages. r? @Centril
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+1
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-23Tweak format string error to point at arguments alwaysEsteban Küber-4/+6
Add secondary span labels with no text to make it clear when there's a mismatch bewteen the positional arguments in a format string and the arguments to the macro. This shouldn't affect experienced users, but it should make it easier for newcomers to more clearly understand how `format!()` and `println!()` are supposed to be used. ``` error: 2 positional arguments in format string, but there is 1 argument --> file8.rs:2:14 | 2 | format!("{} {}", 1); | ^^ ^^ - ``` instead of ``` error: 2 positional arguments in format string, but there is 1 argument --> file8.rs:2:14 | 2 | format!("{} {}", 1); | ^^ ^^ ```
2019-10-08Call `Expr::peel_drop_temps()` from more places for more accurate suggestionsEsteban Küber-4/+16
2019-10-08Ignore `ExprKind::DropTemps` for some ref suggestionsEsteban Küber-20/+8
2019-10-06Suggest dereferencing boolean reference when used in 'if' or 'while'wangxiangqing-2/+2
Change-Id: I0c5c4d767be2647e6f017ae7bf83558c56dbca97
2019-10-06Suggest dereferencing boolean reference when used in 'if' or 'while'wangxiangqing-10/+34
Change-Id: I0c5c4d767be2647e6f017ae7bf83558c56dbca97
2019-08-31Emit a single error on if expr with expectation and no else clauseEsteban Küber-82/+7
2019-07-29review commentsEsteban Küber-7/+7
2019-07-29Improve handling of invalid references in `format!()`Esteban Küber-5/+48
2019-07-29On `format!()` arg count mismatch provide extra infoEsteban Küber-1/+62
When positional width and precision formatting flags are present in a formatting string that has an argument count mismatch, provide extra information pointing at them making it easiser to understand where the problem may lay: ``` error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:78:15 | LL | println!("{} {:.*} {}", 1, 3.2, 4); | ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:81:15 | LL | println!("{} {:07$.*} {}", 1, 3.2, 4); | ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag | | | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: 3 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:84:15 | LL | println!("{} {:07$} {}", 1, 3.2, 4); | ^^ ^^---^ ^^ | | | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html ```
2019-07-20Auto merge of #62710 - estebank:bad-named-args, r=petrochenkovbors-5/+7
Specific error for positional args after named args in `format!()` When writing positional arguments after named arguments in the `format!()` and `println!()` macros, provide a targeted diagnostic. Follow up to https://github.com/rust-lang/rust/pull/57522/files#r247278885
2019-07-17normalize use of backticks in compiler messages for librustc/lintSamy Kacimi-1/+1
https://github.com/rust-lang/rust/issues/60532
2019-07-15Specific error for positional args after named args in `format!()`Esteban Küber-5/+7
When writing positional arguments after named arguments in the `format!()` and `println!()` macros, provide a targeted diagnostic.
2019-07-06Make sure while-exprs require 'cond: bool' exactly.Mazdak Farrokhzad-1/+43
2019-07-03Migrate compile-pass annotations to build-passYuki Okushi-1/+1
2019-06-16compiletest: Remove `skip-codegen`Vadim Petrochenkov-4/+2
2019-05-10add test checking that 'if cond { .. }' where 'cond: &mut? bool' isn't accepted.Mazdak Farrokhzad-0/+61
2019-05-10Various test changesMazdak Farrokhzad-9/+157
2019-03-21Auto merge of #58981 - estebank:elseless-if, r=davidtwcobors-1/+80
Point at coercion reason for `if` expressions without else clause if caused by return type ``` error[E0317]: if may be missing an else clause --> $DIR/if-without-else-as-fn-expr.rs:2:5 | LL | fn foo(bar: usize) -> usize { | ----- found `usize` because of this return type LL | / if bar % 5 == 0 { LL | | return 3; LL | | } | |_____^ expected (), found usize | = note: expected type `()` found type `usize` = note: `if` expressions without `else` must evaluate to `()` ``` Fix #25228.
2019-03-11Update testsVadim Petrochenkov-25/+25
2019-03-07Add more details to elseless if errorEsteban Küber-2/+51
2019-03-07address review commentsEsteban Küber-6/+8
2019-03-07Point at coercion reason for if exprs without else clauseEsteban Küber-0/+28
``` error[E0317]: if may be missing an else clause --> $DIR/if-without-else-as-fn-expr.rs:2:5 | LL | fn foo(bar: usize) -> usize { | ----- found `usize` because of this return type LL | / if bar % 5 == 0 { LL | | return 3; LL | | } | |_____^ expected (), found usize | = note: expected type `()` found type `usize` = note: `if` expressions without `else` must evaluate to `()` ```
2019-02-07Reweork incompatible match arms errorEsteban Küber-19/+12
- Point at the body expression of the match arm with the type error. - Point at the prior match arms explicitely stating the evaluated type. - Point at the entire match expr in a secondary span, instead of primary. - For type errors in the first match arm, the cause is outside of the match, treat as implicit block error to give a more appropriate error.
2019-01-13Tweak output of type mismatch between "then" and `else` `if` armsEsteban Küber-2/+4