about summary refs log tree commit diff
path: root/src/test/ui/suggestions
AgeCommit message (Collapse)AuthorLines
2018-06-21Account for bindings with types and in crate macrosEsteban Küber-4/+58
2018-06-20Don't suggest incorrect syntaxEsteban Küber-1/+13
2018-06-19Update message for `!Sized` typesEsteban Küber-3/+3
2018-06-19Add link to book for `Sized` errorsEsteban Küber-0/+1
2018-06-19Add message to `rustc_on_unimplemented` attributes in coreEsteban Küber-2/+2
2018-06-19NLL: Updates to diagnostic output in `test/ui`.Felix S. Klock II-3/+3
2018-06-06Use consistent span for repr attr suggestionEsteban Küber-2/+2
2018-06-06Change repr documentation linkEsteban Küber-2/+2
2018-06-06Add `transparent` as valid `repr` hintEsteban Küber-2/+2
2018-06-06Turn warning into lintEsteban Küber-0/+1
2018-06-06Expand output and suggestions, fix testsEsteban Küber-0/+52
2018-06-01rework to report errors from crates in a consistent orderNiko Matsakis-6/+6
We first collect unused crates into a map and then walk all extern crates in crate order.
2018-06-01merge UNNECESSARY_EXTERN_CRATE and UNUSED_EXTERN_CRATESNiko Matsakis-15/+15
2018-05-30Suggest using `as_ref` on some borrow errors [hack]Esteban Küber-0/+72
When encountering the following code: ```rust struct Foo; fn takes_ref(_: &Foo) {} let ref opt = Some(Foo); opt.map(|arg| takes_ref(arg)); ``` Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead. This is a stop gap solution until we expand typeck to deal with these cases in a more graceful way.
2018-05-28Auto merge of #50724 - zackmdavis:applicability_rush, r=Manishearthbors-8/+58
add suggestion applicabilities to librustc and libsyntax A down payment on #50723. Interested in feedback on whether my `MaybeIncorrect` vs. `MachineApplicable` judgement calls are well-calibrated (and that we have a consensus on what this means). r? @Manishearth cc @killercup @estebank
2018-05-25Fix naming conventions for new lintsVadim Petrochenkov-1/+1
2018-05-22Remove the unstable Float traitSimon Sapin-11/+11
Following up to #49896 and #50629. Fixes #32110. E0689 is weird.
2018-05-20suggestion applicabilities for libsyntax and librustc, run-rustfix testsZack M. Davis-8/+58
Consider this a down payment on #50723. To recap, an `Applicability` enum was recently (#50204) added, to convey to Rustfix and other tools whether we think it's OK for them to blindly apply the suggestion, or whether to prompt a human for guidance (because the suggestion might contain placeholders that we can't infer, or because we think it has a sufficiently high probability of being wrong even though it's— presumably—right often enough to be worth emitting in the first place). When a suggestion is marked as `MaybeIncorrect`, we try to use comments to indicate precisely why (although there are a few places where we just say `// speculative` because the present author's subjective judgement balked at the idea that the suggestion has no false positives). The `run-rustfix` directive is opporunistically set on some relevant UI tests (and a couple tests that were in the `test/ui/suggestions` directory, even if the suggestions didn't originate in librustc or libsyntax). This is less trivial than it sounds, because a surprising number of test files aren't equipped to be tested as fixed even when they contain successfully fixable errors, because, e.g., there are more, not-directly-related errors after fixing. Some test files need an attribute or underscore to avoid unused warnings tripping up the "fixed code is still producing diagnostics" check despite the fixes being correct; this is an interesting contrast-to/inconsistency-with the behavior of UI tests (which secretly pass `-A unused`), a behavior which we probably ought to resolve one way or the other (filed issue #50926). A few suggestion labels are reworded (e.g., to avoid phrasing it as a question, which which is discouraged by the style guidelines listed in `.span_suggestion`'s doc-comment).
2018-05-18Reimplement unused_labels lint as a compiler builtin in the resolverKyle Stachowicz-1/+1
2018-05-11rustc: Include semicolon when removing `extern crate`Alex Crichton-0/+96
Currently the lint for removing `extern crate` suggests removing `extern crate` most of the time, but the rest of the time it suggest replacing it with `use crate_name`. Unfortunately though when spliced into the original code you're replacing extern crate foo; with use foo which is syntactically invalid! This commit ensure that the trailing semicolon is included in rustc's suggestion to ensure that the code continues to compile afterwards.
2018-05-04Fold rustfix tests back into the UI test suiteAlex Crichton-9/+176
2018-05-04First step towards rustfix compiletest modePascal Hertleif-0/+20
This is the first small step towards testing auto-fixable compiler suggestions using compiletest. Currently, it only checks if next to a UI test there also happens to a `*.rs.fixed` file, and then uses rustfix (added as external crate) on the original file, and asserts that it produces the fixed version. To show that this works, I've included one such test. I picked this test case at random (and because it was simple) -- It is not relevant to the 2018 edition. Indeed, in the near future, we want to be able to restrict rustfix to edition-lints, so this test cast might go away soon. In case you still think this is somewhat feature-complete, here's a quick list of things currently missing that I want to add before telling people they can use this: - [ ] Make this an actual compiletest mode, with `test [fix] …` output and everything - [ ] Assert that fixed files still compile - [ ] Assert that fixed files produce no (or a known set of) diagnostics output - [ ] Update `update-references.sh` to support rustfix - [ ] Use a published version of rustfix (i.e.: publish a new version rustfix that exposes a useful API for this)
2018-04-21Move intrinsics-based float methods out of libcore into libstdSimon Sapin-11/+11
Affected methods are `abs`, `signum`, and `powi`. CC https://github.com/rust-lang/rust/issues/32110#issuecomment-379503183
2018-04-11Checkpoint the current status of NLL on `ui` tests via compare-mode=nll.Felix S. Klock II-0/+18
2018-03-30Rollup merge of #49446 - frewsxcv:frewsxcv-mention-optiono, r=GuillaumeGomezkennytm-2/+2
Explicitly mention `Option` in `?` error message. Save users the time/effort of having to lookup what types implement the `Try` trait.
2018-03-28Explicitly mention `Option` in `?` error message.Corey Farwell-2/+2
Save users the time/effort of having to lookup what types implement the `Try` trait.
2018-03-28Stabilize match_default_bindingsTaylor Cramer-30/+0
This includes a submodule update to rustfmt in order to allow a stable feature declaration.
2018-03-19Do not suggest `.into()` in `const`sEsteban Küber-0/+36
2018-03-14update testsGuillaume Gomez-28/+28
2018-02-28fix rebaseEsteban Küber-2/+2
2018-02-27Diagnostic tweaks (review)Esteban Küber-4/+1
2018-02-27Provide missing comma in match arm suggestionEsteban Küber-0/+32
When finding: ```rust match &Some(3) { &None => 1 &Some(2) => { 3 } _ => 2 } ``` provide the following diagnostic: ``` error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` --> $DIR/missing-comma-in-match.rs:15:18 | X | &None => 1 | -- - help: missing comma | | | while parsing the match arm starting here X | &Some(2) => { 3 } | ^^ expected one of `,`, `.`, `?`, `}`, or an operator here ```
2018-02-26Update UI testsVadim Petrochenkov-35/+35
2018-02-26Update UI testsVadim Petrochenkov-595/+595
2018-02-25Update ui testsGuillaume Gomez-0/+28
2018-02-01Fix test after rebaseEsteban Küber-33/+1
2018-02-01Add filter to detect local crates for rustc_on_unimplementedEsteban Küber-0/+32
2018-02-01Change rustc_on_unimplemented for Iterator and binopsEsteban Küber-1/+5
2018-02-01Add filtering options to `rustc_on_unimplemented`Esteban Küber-5/+1
- filter error on the evaluated value of `Self` - filter error on the evaluated value of the type arguments - add argument to include custom note in diagnostic - allow the parser to parse `Self` when processing attributes - add custom message to binops
2018-01-28use correct casing for rename suggestionsAndy Russell-1/+1
If the original name is uppercase, use camel case. Otherwise, use snake case.
2018-01-28Auto merge of #47767 - estebank:as-suggestion, r=petrochenkovbors-0/+27
Correctly format `extern crate` conflict resolution help Closes #45799. Follow up to @Cldfire's #45820. If the `extern` statement that will have a suggestion ends on a `;`, synthesize a new span that doesn't include it.
2018-01-27Auto merge of #47690 - estebank:for-block-277, r=nikomatsakisbors-16/+36
For E0277 on `for` loops, point at the "head" expression When E0277's span points at a `for` loop, the actual issue is in the element being iterated. Instead of pointing at the entire loop, point only at the first line (when possible) so that the span ends in the element for which E0277 was triggered.
2018-01-26Instead of modifying the item's span synthesize itEsteban Küber-2/+3
2018-01-26Don't add "in this macro invocation" label to desugared spansEsteban Küber-16/+4
2018-01-26Modify spans of expanded expressionEsteban Küber-2/+2
Modify the spans used for `for`-loop expression expansion, instead of creating a new span during error creation.
2018-01-25Correctly format `extern crate` conflict resolution helpCldfire-0/+26
2018-01-25Rollup merge of #47702 - etaoins:fix-into-cast-paren-precedence, r=petrochenkovGuillaume Gomez-1/+26
Fix into() cast paren check precedence As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are: ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(foo as i8); | ^^^^^^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(foo as i8.into()); | ``` ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(*foo); | ^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(*foo.into()); | ``` As suggested by @petrochenkov switch the precedence check to `PREC_POSTFIX`. This catches both `as` and unary operators. Fixes #47699. r? @petrochenkov
2018-01-24Fix into() cast paren check precedenceRyan Cumming-1/+26
As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are: ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(foo as i8); | ^^^^^^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(foo as i8.into()); | ``` ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(*foo); | ^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(*foo.into()); | ``` As suggested by @petrochenkov switch the precedence check to PREC_POSTFIX. This catches both `as` and unary operators. Fixes #47699.
2018-01-23For E0277 on `for` loops, point at first lineEsteban Küber-0/+32
When E0277's span points at a `for` loop, the actual issue is in the element being iterated. Instead of pointing at the entire loop, point only at the first line (when possible) so that the span ends in the element for which E0277 was triggered.
2018-01-22Do not suggest private traits that have missing methodEsteban Küber-0/+27
When encountering a method call for an ADT that doesn't have any implementation of it, we search for traits that could be implemented that do have that method. Filter out private non-local traits that would not be able to be implemented. This doesn't account for public traits that are in a private scope, but works as a first approximation and is a more correct behavior than the current one.