about summary refs log tree commit diff
path: root/tests/ui/parser/issues
AgeCommit message (Collapse)AuthorLines
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-151/+227
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-01-23Bless and add testsBoxy-14/+11
2025-01-22Rollup merge of #135557 - estebank:wtf8, r=fee1-deadMatthias Krüger-2/+2
Point at invalid utf-8 span on user's source code ``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: byte `193` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-22Auto merge of #134478 - compiler-errors:attr-span, r=oli-obkbors-2/+2
Properly record metavar spans for other expansions other than TT This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result. Fixes #132908 Alternative to #133270 cc `@ehuss` cc `@petrochenkov`
2025-01-22Point at invalid utf-8 span on user's source codeEsteban Küber-2/+2
``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `[193]` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-07Update tests.Mara Bos-1/+2
2025-01-02Remove diagnostic_only_typeck and fix placeholder suggestion for const/staticMichael Goulet-10/+1
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-2/+2
2024-12-21Properly record metavar spans for other expansions other than TTMichael Goulet-2/+2
2024-12-08Rollup merge of #133424 - Nadrieril:guard-patterns-parsing, r=fee1-deadMatthias Krüger-3/+3
Parse guard patterns This implements the parsing of [RFC3637 Guard Patterns](https://rust-lang.github.io/rfcs/3637-guard-patterns.html) (see also [tracking issue](https://github.com/rust-lang/rust/issues/129967)). This PR is extracted from https://github.com/rust-lang/rust/pull/129996 with minor modifications. cc `@max-niederman`
2024-11-29Rollup merge of #133590 - nnethercote:rename-parse-only, r=estebankMatthias Krüger-1/+1
Rename `-Zparse-only` It's a misleading name. r? ````@estebank````
2024-11-29Rename `-Zparse-only`.Nicholas Nethercote-1/+1
I was surprised to find that running with `-Zparse-only` only parses the crate root file. Other files aren't parsed because that happens later during expansion. This commit renames the option and updates the help message to make this clearer.
2024-11-27Update tests to use new proc-macro headerEric Huss-6/+1
2024-11-26tests: remove `//@ pretty-expanded` usages许杰友 Jieyou Xu (Joe)-2/+0
Done with ```bash sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs ``` and ``` sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs ```
2024-11-24parse guard patternsNadrieril-3/+3
Co-authored-by: Max Niederman <max@maxniederman.com>
2024-11-23Update tests for new TRPL chapter orderChris Krycho-2/+2
2024-10-26Deny calls to non-`#[const_trait]` methods in MIR constckDeadbeef-4/+0
2024-10-12Rollup merge of #130870 - surechen:fix_130791, r=compiler-errorsTrevor Gross-0/+28
Add suggestion for removing invalid path sep `::` in fn def Add suggestion for removing invalid path separator `::` in function definition. for example: `fn invalid_path_separator::<T>() {}` fixes #130791
2024-10-06On function and method calls in patterns, link to the bookEsteban Küber-2/+5
``` error: expected a pattern, found an expression --> f889.rs:3:13 | 3 | let (x, y.drop()) = (1, 2); //~ ERROR | ^^^^^^^^ not a pattern | = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> error[E0532]: expected a pattern, found a function call --> f889.rs:2:13 | 2 | let (x, drop(y)) = (1, 2); //~ ERROR | ^^^^ not a tuple struct or tuple variant | = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> ``` Fix #97200.
2024-09-27Add suggestion for removing invalid path separator `::` in function definition.surechen-0/+28
for example: `fn invalid_path_separator::<T>() {}` fixes: #130791
2024-09-22Auto merge of #130246 - dianne:issue-97589-fix, r=petrochenkovbors-0/+20
rustc_expand: remember module `#[path]`s during expansion During invocation collection, if a module item parsed from a `#[path]` attribute needed a second pass after parsing, its path wouldn't get added to the file path stack, so cycle detection broke. This checks the `#[path]` in such cases, so that it gets added appropriately. I think it should work identically to the case for external modules that don't need a second pass, but I'm not 100% sure. Fixes #97589
2024-09-18Add suggestions for expressions in patternsLieselotte-0/+15
2024-09-12Implement a Method to Seal `DiagInner`'s SuggestionsVeera-8/+0
2024-09-11add regression test for #97589dianne-0/+20
2024-09-06Add Suggestions for Misspelled KeywordsVeera-8/+25
This PR detects misspelled keywords using two heuristics: 1. Lowercasing the unexpected identifier. 2. Using edit distance to find a keyword similar to the unexpected identifier. However, it does not detect each and every misspelled keyword to minimize false positives and ambiguities. More details about the implementation can be found in the comments.
2024-08-24Rollup merge of #128524 - ↵Trevor Gross-6/+28
chenyukang:yukang-fix-127930-invalid-outer-style-sugg, r=cjgillot Don't suggest turning crate-level attributes into outer style Fixes #127930
2024-08-04don't suggest turning crate-level attributes into outer styleyukang-6/+28
2024-08-03Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix"Michael Goulet-3/+1
This reverts commit 31fe9628cf830a08e7194a446f66c668aaea86e9, reversing changes made to f20307851ead9fbbb9fa88bbffb3258a069230a6.
2024-07-26Improve error message for `extern "C" unsafe fn()`Tamme Dittrich-11/+24
This was handled correctly already for `extern unsafe fn()`. Co-authored-by: Folkert <folkert@folkertdev.nl>
2024-07-26Add a test case for `extern "C" unsafe` to the ui testsTamme Dittrich-0/+20
2024-07-25Rollup merge of #127528 - estebank:ascii-control-chars, r=oli-obkMatthias Krüger-18/+18
Replace ASCII control chars with Unicode Control Pictures Replace ASCII control chars like `CR` with Unicode Control Pictures like `␍`: ``` error: bare CR not allowed in doc-comment --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32 | LL | /// doc comment with bare CR: '␍' | ^ ``` Centralize the checking of unicode char width for the purposes of CLI display in one place. Account for the new replacements. Remove unneeded tracking of "zero-width" unicode chars, as we calculate these in the `SourceMap` as needed now.
2024-07-19Rollup merge of #127350 - veera-sivarajan:bugfix-126311, r=lcnrMatthias Krüger-0/+92
Parser: Suggest Placing the Return Type After Function Parameters Fixes #126311 This PR suggests placing the return type after the function parameters when it's misplaced after a `where` clause. This also tangentially improves diagnostics for cases like [this](https://github.com/veera-sivarajan/rust/blob/86d6f1312a77997ef994240e716288d61a343a6d/tests/ui/parser/issues/misplaced-return-type-without-where-issue-126311.rs#L1C1-L1C28) and adds doc comments for `parser::AllowPlus`.
2024-07-18Be more accurate about calculating `display_col` from a `BytePos`Esteban Küber-36/+36
No longer track "zero-width" chars in `SourceMap`, read directly from the line when calculating the `display_col` of a `BytePos`. Move `char_width` to `rustc_span` and use it from the emitter. This change allows the following to properly align in terminals (depending on the font, the replaced control codepoints are rendered as 1 or 2 width, on my terminal they are rendered as 1, on VSCode text they are rendered as 2): ``` error: this file contains an unclosed delimiter --> $DIR/issue-68629.rs:5:17 | LL | ␜␟ts␀![{i | -- unclosed delimiter | | | unclosed delimiter LL | ␀␀ fn rݻoa>rݻm | ^ ```
2024-07-18Replace ASCII control chars with Unicode Control PicturesEsteban Küber-0/+0
``` error: bare CR not allowed in doc-comment --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32 | LL | /// doc comment with bare CR: '␍' | ^ ```
2024-07-18Fix ICE in suggestion caused by `⩵` being recovered as `==`Esteban Küber-6/+4
The second suggestion shown here would previously incorrectly assume that the span corresponding to `⩵` was 2 bytes wide composed by 2 1 byte wide chars, so a span pointing at `==` could point only at one of the `=` to remove it. Instead, we now replace the whole thing (as we should have the whole time): ``` error: unknown start of token: \u{2a75} --> $DIR/unicode-double-equals-recovery.rs:1:16 | LL | const A: usize ⩵ 2; | ^ | help: Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not | LL | const A: usize == 2; | ~~ error: unexpected `==` --> $DIR/unicode-double-equals-recovery.rs:1:16 | LL | const A: usize ⩵ 2; | ^ | help: try using `=` instead | LL | const A: usize = 2; | ~ ```
2024-07-12Make `;` suggestions inlineEsteban Küber-47/+9
2024-07-12More accurate incorrect use of `await` suggestionEsteban Küber-2/+3
2024-07-12Tweak tests to avoid confusing suggestion outputEsteban Küber-4/+4
2024-07-12Make parse error suggestions verbose and fix spansEsteban Küber-80/+376
Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-07-04Update TestsVeera-0/+92
2024-07-04Improve dead code analysismu001999-1/+3
2024-06-21Fix remaining casesMichael Goulet-1/+1
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-24/+24
2024-05-28Allow type_of to return partially non-error types if the type was already ↵Oli Scherer-3/+15
tainted
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-1/+1
2024-05-20Fix parsing of erroneously placed semicolonsardi-4/+33
2024-05-02Stabilize exclusive_rangeRoss Smyth-2/+0
2024-04-25Fix substitution parts having a shifted underline in some casesLieselotte-1/+1
2024-04-22Improve handling of expr->field errorsSasha Pourcelot-4/+13
The current message for "`->` used for field access" is the following: ```rust error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `->` --> src/main.rs:2:6 | 2 | a->b; | ^^ expected one of 8 possible tokens ``` (playground link[1]) This PR tries to address this by adding a dedicated error message and recovery. The proposed error message is: ``` error: `->` used for field access or method call --> ./tiny_test.rs:2:6 | 2 | a->b; | ^^ help: try using `.` instead | = help: the `.` operator will dereference the value if needed ``` (feel free to bikeshed it as much as necessary) [1]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7f8b6f4433aa7866124123575456f54e Signed-off-by: Sasha Pourcelot <sasha.pourcelot@protonmail.com>
2024-04-07Remove useless configs in testsUrgau-30/+0
Since they are never set and don't have impact on the test. Or for the cfg-panic tests are already tested with check-cfg.