about summary refs log tree commit diff
path: root/tests/ui/parser
AgeCommit message (Collapse)AuthorLines
2024-03-05AST validation: Improve handling of inherent impls nested within functions ↵León Orell Valerian Liehr-0/+72
and anon consts
2024-03-02Auto merge of #121657 - estebank:issue-119665, r=davidtwcobors-21/+37
Detect more cases of `=` to `:` typo 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-03-01Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errorsbors-0/+104
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
2024-03-01Detect more cases of `=` to `:` typoEsteban Küber-21/+37
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-28Add a basic test for `f16` and `f128`Trevor Gross-0/+104
2024-02-28Use `LitKind::Err` for floats with unsupported bases.Nicholas Nethercote-66/+74
This slightly changes error messages in `float-field.rs`, but nothing of real importance.
2024-02-28Reformat `float-field.rs` test.Nicholas Nethercote-113/+142
- Put every literal in its own braces, rather than just some of them, for maximal error recovery. - Add a blank line between every case, for readability.
2024-02-26Properly emit `expected ;` on `#[attr] expr`Lieselotte-2/+43
2024-02-22Deduplicate some logic and reword outputEsteban Küber-1/+1
2024-02-22Make confusable suggestions `verbose`Esteban Küber-4/+5
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-1/+1
2024-05-23Rollup merge of #123623 - surechen:fix_123261, r=estebankMatthias Krüger-19/+19
Fix OutsideLoop's error suggestion: adding label `'block` for `if` block. For OutsideLoop we should not suggest add `'block` label in `if` block, or we wiil get another err: block label not supported here. fixes #123261
2024-05-22Rollup merge of #125049 - dtolnay:castbrace, r=compiler-errorsLeón Orell Valerian Liehr-282/+101
Disallow cast with trailing braced macro in let-else This fixes an edge case I noticed while porting #118880 and #119062 to syn. Previously, rustc incorrectly accepted code such as: ```rust let foo = &std::ptr::null as &'static dyn std::ops::Fn() -> *const primitive! { 8 } else { return; }; ``` even though a right curl brace `}` directly before `else` in a `let...else` statement is not supposed to be valid syntax.
2024-05-22For OutsideLoop we should not suggest add 'block label in if block, or we ↵surechen-19/+19
wiil get another err: block label not supported here. fixes #123261
2024-05-21Rollup merge of #125310 - workingjubilee:muck-out-the-test-stables, r=NilstriebMatthias Krüger-0/+22
Move ~100 tests from tests/ui to subdirs new dirs for some, the rest in old sweep tests up before they turn cold to stop our code from growing mold
2024-05-20Move 100 entries from tests/ui into subdirsJubilee Young-0/+22
- Move super-fast-paren-parsing test into ui/parser - Move stmt_expr_attrs test into ui/feature-gates - Move macro tests into ui/macros - Move global_asm tests into ui/asm - Move env tests into ui/process - Move xcrate tests into ui/cross-crate - Move unop tests into ui/unop - Move backtrace tests into ui/backtrace - Move check-static tests into ui/statics - Move expr tests into ui/expr - Move optimization fuel tests into ui/fuel - Move ffi attribute tests into ui/ffi-attrs - Move suggestion tests into ui/suggestions - Move main tests into ui/fn-main - Move lint tests into ui/lint - Move repr tests into ui/repr - Move intrinsics tests into ui/intrinsics - Move tool lint tests into ui/tool-attributes - Move return tests into ui/return - Move pattern tests into ui/patttern - Move range tests into ui/range - Move foreign-fn tests into ui/foreign - Move orphan-check tests into ui/coherence - Move inference tests into ui/inference - Reduce ROOT_ENTRY_LIMIT
2024-05-20Fix parsing of erroneously placed semicolonsardi-4/+33
2024-05-18Fix typos (taking into account review comments)blyxyas-1/+1
2024-05-12Disallow cast with trailing braced macro in let-elseDavid Tolnay-2/+16
2024-05-12Add test of trailing brace in a cast expressionDavid Tolnay-1/+27
2024-05-12Clean up unneeded warnings from let-else syntax testDavid Tolnay-290/+69
2024-05-11Remove MacCall special case from recovery after missing 'if' after 'else'David Tolnay-6/+4
The change to the test is a little goofy because the compiler was guessing "correctly" before that `falsy! {}` is the condition as opposed to the else body. But I believe this change is fundamentally correct. Braced macro invocations in statement position are most often item-like (`thread_local! {...}`) as opposed to parenthesized macro invocations which are condition-like (`cfg!(...)`).
2024-05-11Add macro calls to else-no-if parser testDavid Tolnay-5/+83
2024-05-11Add parser tests for statement boundary insertionDavid Tolnay-0/+104
2024-05-11Rollup merge of #124930 - compiler-errors:consume-arg, r=petrochenkov许杰友 Jieyou Xu (Joe)-0/+20
Make sure we consume a generic arg when checking mistyped turbofish When recovering un-turbofish-ed args in expr position (e.g. `let x = a<T, U>();` in `check_mistyped_turbofish_with_multiple_type_params`, we used `parse_seq_to_before_end` to parse the fake generic args; however, it used `parse_generic_arg` which *optionally* parses a generic arg. If it doesn't end up parsing an arg, it returns `Ok(None)` and consumes no tokens. If we don't find a delimiter after this (`,`), we try parsing *another* element. In this case, we just infinitely loop looking for a subsequent element. We can fix this by making sure that we either parse a generic arg or error in `parse_seq_to_before_end`'s callback. Fixes #124897
2024-05-10Fix parse error message for meta itemsLeón Orell Valerian Liehr-30/+51
2024-05-09Make sure we consume a generic arg when checking mistyped turbofishMichael Goulet-0/+20
2024-05-05Rollup merge of #124749 - RossSmyth:stable_range, r=davidtwcoGuillaume Gomez-73/+70
Stabilize exclusive_range_pattern (v2) This PR is identical to #124459, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Stabilization report: https://github.com/rust-lang/rust/issues/37854#issuecomment-1842398130 FCP: https://github.com/rust-lang/rust/issues/37854#issuecomment-1872520294 Stabilization was blocked by a lint that was merged here: #118879 Documentation PR is here: rust-lang/reference#1484 `@rustbot` label +F-exclusive_range_pattern +T-lang
2024-05-04compiletest: add enable-by-default check-cfgUrgau-2/+6
2024-05-02Stabilize exclusive_rangeRoss Smyth-73/+70
2024-04-25Fix substitution parts having a shifted underline in some casesLieselotte-1/+1
2024-04-24Fix tests and blessGary Guo-39/+38
2024-04-23Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, r=davidtwcoMatthias Krüger-0/+76
Disallow ambiguous attributes on expressions This implements the suggestion in [#15701](https://github.com/rust-lang/rust/issues/15701#issuecomment-2033124217) to disallow ambiguous outer attributes on expressions. This should resolve one of the concerns blocking the stabilization of `stmt_expr_attributes`.
2024-04-23Rollup merge of #124200 - scrabsha:sasha/->, r=compiler-errors,fmeaseMatthias Krüger-4/+121
Improve handling of expr->field errors 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](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7f8b6f4433aa7866124123575456f54e)) 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)
2024-04-22Improve handling of expr->field errorsSasha Pourcelot-4/+121
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-21Move some testsCaio-0/+44
2024-04-18Disallow ambiguous attributes on expressionsDominik Stolz-0/+76
2024-02-20Support async trait bounds in macrosMichael Goulet-4/+29
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)-305/+305
2024-02-15Auto merge of #121142 - GuillaumeGomez:rollup-5qmksjw, r=GuillaumeGomezbors-16/+46
Rollup of 8 pull requests Successful merges: - #120449 (Document requirements for unsized {Rc,Arc}::from_raw) - #120505 (Fix BTreeMap's Cursor::remove_{next,prev}) - #120672 (std::thread update freebsd stack guard handling.) - #121088 (Implicitly enable evex512 if avx512 is enabled) - #121104 (Ignore unsized types when trying to determine the size of the original type) - #121107 (Fix msg for verbose suggestions with confusable capitalization) - #121113 (Continue compilation even if inherent impl checks fail) - #121120 (Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`.) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-15Rollup merge of #121113 - oli-obk:track_errors10, r=compiler-errorsGuillaume Gomez-6/+36
Continue compilation even if inherent impl checks fail We should not be hiding errors behind unrelated errors
2024-02-15Rollup merge of #121107 - estebank:capitalization-suggestion, r=michaelwoeristerGuillaume Gomez-10/+10
Fix msg for verbose suggestions with confusable capitalization When encountering a verbose/multipart suggestion that has changes that are only caused by different capitalization of ASCII letters that have little differenciation, expand the message to highlight that fact (like we already do for inline suggestions). The logic to do this was already present, but implemented incorrectly.
2024-02-15Auto merge of #120931 - chenyukang:yukang-cleanup-hashmap, r=michaelwoeristerbors-8/+8
Clean up potential_query_instability with FxIndexMap and UnordMap From https://github.com/rust-lang/rust/pull/120485#issuecomment-1916437191 r? `@michaelwoerister`
2024-02-14Continue compilation even if inherent impl checks failOli Scherer-6/+36
2024-02-14Fix msg for verbose suggestions with confusable capitalizationEsteban Küber-10/+10
When encountering a verbose/multipart suggestion that has changes that are only caused by different capitalization of ASCII letters that have little differenciation, expand the message to highlight that fact (like we already do for inline suggestions). The logic to do this was already present, but implemented incorrectly.
2024-02-14Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errorsbors-6/+12
Continue compilation after check_mod_type_wf errors The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too. The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication. fixes https://github.com/rust-lang/rust/issues/120860
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-6/+12
2024-02-14clean up potential_query_instability with FxIndexMap and UnordMapyukang-8/+8
2024-02-09Be less confident when `dyn` suggestion is not checked for object safetytrevyn-3/+3