summary refs log tree commit diff
path: root/tests/ui/parser/issues
AgeCommit message (Collapse)AuthorLines
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.
2024-03-25Rollup merge of #122910 - compiler-errors:unit-struct-in-path-pat-only, ↵Matthias Krüger-6/+7
r=petrochenkov Validate that we're only matching on unit struct for path pattern Resolution doesn't validate that we only really take `CtorKind::Unit` in path patterns, since all it sees is `Res::SelfCtor(def_id)`. Check this instead during pattern typeck. r? petrochenkov Fixes #122809
2024-03-24Rollup merge of #122217 - estebank:issue-119685, r=fmeaseMatthias Krüger-4/+4
Handle str literals written with `'` lexed as lifetime Given `'hello world'` and `'1 str', provide a structured suggestion for a valid string literal: ``` error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-3.rs:2:26 | LL | println!('hello world'); | ^^^^ | help: if you meant to write a `str` literal, use double quotes | LL | println!("hello world"); | ~ ~ ``` ``` error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-1.rs:2:20 | LL | println!('1 + 1'); | ^^^^ | help: if you meant to write a `str` literal, use double quotes | LL | println!("1 + 1"); | ~ ~ ``` Fix #119685.
2024-03-22Validate that we're only matching on unit struct for path patternMichael Goulet-6/+7
2024-03-18Provide structured suggestion for `#![feature(foo)]`Esteban Küber-1/+4
``` error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | ``` Fix #55941.
2024-03-17review comment: `str` -> string in messagesEsteban Küber-2/+2
2024-03-17Use shorter span for existing `'` -> `"` structured suggestionEsteban Küber-2/+2
2024-03-09Improve diagnostics for parenthesized type argumentsDaniel Sedlak-0/+76
2024-03-01Detect more cases of `=` to `:` typoEsteban Küber-7/+7
When a `Local` is fully parsed, but not followed by a `;`, keep the `:` span arround and mention it. If the type could continue being parsed as an expression, suggest replacing the `:` with a `=`. ``` error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `.` --> file.rs:2:32 | 2 | let _: std::env::temp_dir().join("foo"); | - ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=` | | | while parsing the type for `_` | help: use `=` if you meant to assign ``` Fix #119665.
2024-02-18macro_rules: Preserve all metavariable spans in a global side tableVadim Petrochenkov-6/+11
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-116/+116
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-20/+43
2024-02-05Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillotMatthias Krüger-1/+0
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing https://github.com/rust-lang/rfcs/pull/3535. Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint. https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-01-31Remove a has_errors check that does not prevent follow up error noiseOli Scherer-1/+18
2024-01-28Handle methodcalls & operators in patternsLieselotte-8/+8
2024-01-26remove illegal_floating_point_literal_pattern lintRalf Jung-1/+0
2024-01-13Bless testsGeorge-lewis-0/+1
Update tests
2024-01-11Silence follow up errors if astconv already erroredOli Scherer-15/+3
2024-01-09Avoid silencing relevant follow-up errorsOli Scherer-1/+8
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-2/+2
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-04macro_rules: Less hacky heuristic for using `tt` metavariable spansVadim Petrochenkov-6/+6
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-2/+2
2023-12-28Don't expect bodyless arms if the pattern can never be a never patternLieselotte-3/+3
2023-12-12Improve an error involving attribute values.Nicholas Nethercote-3/+5
Attribute values must be literals. The error you get when that doesn't hold is pretty bad, e.g.: ``` unexpected expression: 1 + 1 ``` You also get the same error if the attribute value is a literal, but an invalid literal, e.g.: ``` unexpected expression: "foo"suffix ``` This commit does two things. - Changes the error message to "attribute value must be a literal", which gives a better idea of what the problem is and how to fix it. It also no longer prints the invalid expression, because the carets below highlight it anyway. - Separates the "not a literal" case from the "invalid literal" case. Which means invalid literals now get the specific error at the literal level, rather than at the attribute level.
2023-12-08Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errorsbors-3/+3
never_patterns: Parse match arms with no body Never patterns are meant to signal unreachable cases, and thus don't take bodies: ```rust let ptr: *const Option<!> = ...; match *ptr { None => { foo(); } Some(!), } ``` This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser). ~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit r? `@compiler-errors`
2023-12-03Parse a pattern with no armNadrieril-3/+3