summary refs log tree commit diff
path: root/src/test/ui/parser
AgeCommit message (Collapse)AuthorLines
2020-11-06Revert "Promote missing_fragment_specifier to hard error"Mark Rousskov-12/+5
This reverts commit 02eae432e7476a0686633a8c2b7cb1d5aab1bd2c.
2020-10-20rustc_parse: More precise spans for `tuple.0.0`Vadim Petrochenkov-5/+5
2020-10-02Rollup merge of #77444 - estebank:pat-field-label, r=davidtwcoJonas Schievink-4/+10
Fix span for incorrect pattern field and add label Address #73750.
2020-10-02Fix span for incorrect pattern field and add labelEsteban Küber-4/+10
2020-09-29`delay_span_bug` if const-checking an `async` functionDylan MacKenzie-47/+20
This errors during AST lowering. Any errors we emit here are just noise.
2020-09-26`char` not charvarkor-24/+24
2020-09-22Bless testsDylan MacKenzie-20/+47
2020-09-15improve diagnostics for lifetime after `&mut`SNCPlay42-0/+74
2020-09-10Syntactically permit unsafety on modsDavid Tolnay-0/+55
2020-09-09Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasperTyler Mandry-6/+6
Improve unresolved use error message "use of undeclared type or module `foo`" doesn't mention that it could be a crate. This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate. I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-03Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkovbors-9/+9
diagnostics: shorten paths of unique symbols This is a step towards implementing a fix for #50310, and continuation of the discussion in [Pre-RFC: Nicer Types In Diagnostics - compiler - Rust Internals](https://internals.rust-lang.org/t/pre-rfc-nicer-types-in-diagnostics/11139). Impressed upon me from previous discussion in #21934 that an RFC for this is not needed, and I should just come up with code. The recent improvements to `use` suggestions that I've contributed have given rise to this implementation. Contrary to previous suggestions, it's rather simple logic, and I believe it only reduces the amount of cognitive load that a developer would need when reading type errors. ----- If a symbol name can only be imported from one place, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path to the last component. 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 from anywhere.
2020-09-02Auto merge of #76160 - scileo:format-recovery, r=petrochenkovbors-2/+2
Improve recovery on malformed format call The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues. r? @petrochenkov
2020-09-02pretty: trim paths of unique symbolsDan Aloni-9/+9
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-09-02Improve recovery on malformed format callSasha-2/+2
If a comma in a format call is replaced with a similar token, then we emit an error and continue parsing, instead of stopping at this point.
2020-09-02lexer: Tiny improvement to shebang detectionVadim Petrochenkov-8/+5
Lexer now discerns between regular comments and doc comments, so use that. The change only affects the choice of reported errors.
2020-09-01Clarify message about unresolved useKornel-6/+6
2020-08-22Auto merge of #74566 - lzutao:guard, r=petrochenkovbors-0/+18
Gate if-let guard feature Enhanced on #74315. That PR is in crater queue so I don't want to push to it. Close #74232 cc #51114
2020-08-18Promote missing_fragment_specifier to hard errorAleksey Kladov-5/+12
It has been deny_by_default since 2017 (and warned for some time before that), so it seems reasonable to promote it. The specific technical motivation to do this now is to remove a field from `ParseSess` -- it is a global state, and global state makes extracting libraries annoying. Closes #40107
2020-08-16Auto merge of #75536 - estebank:e0255-suggestion, r=varkorbors-15/+15
Tweak output of E0225 When encountering multiple non-auto trait bounds suggest creating a new trait and explain what auto-traits are. _Inspired by https://fasterthanli.me/articles/frustrated-its-not-you-its-rust_
2020-08-14Rollup merge of #75513 - estebank:confused-parser, r=davidtwcoTyler Mandry-17/+3
Recover gracefully from `struct` parse errors Currently the parser tries to recover from finding a keyword where a field name was expected, but this causes extra knock down parse errors that are completely irrelevant. Instead, bail out early in the parsing of the field and consume the remaining tokens in the block. This can reduce output significantly. _Improvements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust_
2020-08-14Tweak output of E0225Esteban Küber-15/+15
When encountering multiple non-auto trait bounds suggest creating a new trait and explain what auto-traits are.
2020-08-13Recover gracefully from `struct ` parse errorsEsteban Küber-17/+3
2020-08-13Rollup merge of #74650 - estebank:ambiguous-expr-binop, r=eddybTyler Mandry-22/+45
Correctly parse `{} && false` in tail expression Fix #74233, fix #54186.
2020-08-11Detect tuple variants used as struct pattern and suggest correct patternEsteban Küber-3/+11
2020-08-08Add a regression test for match guardLzu Tao-0/+18
Unlike if condition, match guard accepts struct literal.
2020-08-08Fallback to pase_expr because match guard accepts struct literalsLzu Tao-5/+27
2020-08-08Gate to if-let guard featureLzu Tao-27/+5
2020-07-27mv std libs to library/mark-1/+1
2020-07-22Correctly parse `{} && false` in tail expressionEsteban Küber-22/+45
Fix #74233.
2020-07-14Suggest struct pat on incorrect unit or tuple patEsteban Küber-1/+1
When encountering a unit or tuple pattern for a struct-like item, suggest using the correct pattern. Use `insert_field_names_local` when evaluating variants and store field names even when the list is empty in order to produce accurate structured suggestions.
2020-07-10Rollup merge of #71322 - petrochenkov:tuple00, r=nikomatsakisManish Goregaokar-0/+474
Accept tuple.0.0 as tuple indexing (take 2) If we expect something identifier-like when parsing a field name after `.`, but encounter a float token, we break that float token into parts, similarly to how we break `&&` into `&` `&`, or `<<` into `<` `<`, etc. An alternative to https://github.com/rust-lang/rust/pull/70420.
2020-07-09Rollup merge of #74188 - estebank:tweak-ascription-typo-heuristic, ↵Manish Goregaokar-10/+10
r=petrochenkov Tweak `::` -> `:` typo heuristic and reduce verbosity Do not trigger on correct type ascription expressions with trailing operators and _do_ trigger on likely path typos where a turbofish is used. On likely path typos, remove note explaining type ascription. Clean up indentation. r? @petrochenkov
2020-07-09Tweak `::` -> `:` typo heuristic and reduce verbosityEsteban Küber-10/+10
Do not trigger on correct type ascription expressions with trailing operators and _do_ trigger on likely path typos where a turbofish is used. On likely path typos, remove note explaining type ascription.
2020-07-06Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebankManish Goregaokar-30/+345
Audit hidden/short code suggestions Should fix #73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
2020-07-04Update UI testsGuillaume Gomez-8/+11
2020-07-02Add some requested testsVadim Petrochenkov-0/+63
2020-07-02parser: Break float tokens into parts in tuple field positionsVadim Petrochenkov-0/+411
2020-07-02Audit uses of `tool_only_span_suggestion`Yuki Okushi-12/+28
2020-07-02Audit uses of `span_suggestion_short`Yuki Okushi-18/+317
2020-07-01Rollup merge of #73803 - Aaron1011:feature/angle-field-recovery, r=matthewjasperManish Goregaokar-0/+22
Recover extra trailing angle brackets in struct definition This commit applies the existing 'extra angle bracket recovery' logic when parsing fields in struct definitions. This allows us to continue parsing the struct's fields, avoiding spurious 'missing field' errors in code that tries to use the struct.
2020-07-01Rollup merge of #73828 - nop:fix/parameter-name-help, r=estebankManish Goregaokar-3/+3
Fix wording for anonymous parameter name help ``` --> exercises/functions/functions2.rs:8:15 | 8 | fn call_me(num) { | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name | 8 | fn call_me(self: num) { | ^^^^^^^^^ help: if this was a parameter name, give it a type | 8 | fn call_me(num: TypeName) { | ^^^^^^^^^^^^^ help: if this is a type, explicitly ignore the parameter name | 8 | fn call_me(_: num) { | ``` This commit changes "if this was a parameter name" to "if this is a parameter name" to match the wording of similar errors.
2020-06-27Fix wording for anonymous parameter name helpJames Box-3/+3
2020-06-28Rename the lint to clashing_extern_declarations.jumbatm-1/+1
Also, run RustFmt on the clashing_extern_fn test case and update stderrs.
2020-06-27Recover extra trailing angle brackets in struct definitionAaron Hill-0/+22
This commit applies the existing 'extra angle bracket recovery' logic when parsing fields in struct definitions. This allows us to continue parsing the struct's fields, avoiding spurious 'missing field' errors in code that tries to use the struct.
2020-06-26rustc_lexer: Simplify shebang parsing once moreVadim Petrochenkov-0/+9
2020-06-25Rollup merge of #73581 - GuillaumeGomez:add-0766, r=varkorManish Goregaokar-1/+2
Create 0766 error code
2020-06-25Rollup merge of #72770 - crlf0710:mixed_script_confusable, r=ManishearthManish Goregaokar-3/+5
Implement mixed script confusable lint. This implements the mixed script confusable lint defined in RFC 2457. This is blocked on #72069 and https://github.com/unicode-rs/unicode-security/pull/13, and will need a Cargo.toml version bump after those are resolved. The lint message warning is sub-optimal for now. We'll need a mechanism to properly output `AugmentScriptSet` to screen, this is to be added in `unicode-security` crate. r? @Manishearth
2020-06-25Update UI testGuillaume Gomez-1/+2
2020-06-23Refactor non_ascii_idents lints, exclude ascii pair for confusable_idents lint.Charles Lew-3/+5
2020-06-21Update UI testsGuillaume Gomez-1/+2