about summary refs log tree commit diff
path: root/tests/ui/parser
AgeCommit message (Collapse)AuthorLines
2023-03-20feat: implement error recovery in `expected_ident_found`Ezra Shaw-33/+96
2023-03-19refactor: improve "ident starts with number" errorEzra Shaw-4/+20
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-130/+19
Remove `identity_future` indirection This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-12Add recovery for use of removed `box` syntaxclubby789-9/+76
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-0/+18
2023-03-12Remove uses of `box_syntax` in rustc and toolsclubby789-68/+63
2023-03-09feat/refactor: improve errors in case of ident with number at startEzra Shaw-9/+27
2023-03-08Remove `identity_future` indirectionArpad Borsos-130/+19
This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]` annotation.
2023-03-05add test for https://github.com/rust-lang/rust/issues/108242Lukas Markeffsky-0/+18
2023-03-03check if snippet is `)`Takayuki Maeda-0/+13
2023-03-01Add testcase for issue 105209yukang-0/+25
2023-03-01Fix #104367, add test case for mismatched open/close delimsyukang-0/+32
2023-03-01Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgrbors-0/+108
Rollup of 10 pull requests Successful merges: - #108376 (compiler/rustc_session: fix sysroot detection logic) - #108400 (add llvm cgu instructions stats to perf) - #108496 (fix #108495, postfix decrement and prefix decrement has no warning) - #108505 (Further unify validity intrinsics) - #108520 (Small cleanup to `one_bound_for_assoc_type`) - #108560 (Some `infer/mod.rs` cleanups) - #108563 (Make mailmap more correct) - #108564 (Fix `x clean` with specific paths) - #108571 (Add contains_key to SortedIndexMultiMap) - #108578 (Update Fuchsia platform team members) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-01Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkinMatthias Krüger-0/+108
fix #108495, postfix decrement and prefix decrement has no warning Fixes #108495
2023-03-01Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petrochenkovMatthias Krüger-974/+200
Exit when there are unmatched delims to avoid noisy diagnostics From https://github.com/rust-lang/rust/pull/104012#issuecomment-1311764832 r? ``@petrochenkov``
2023-02-28micro fmt changesMaybe Waffle-12/+10
2023-02-28remove duplicated diagnostic for unclosed delimiteryukang-214/+62
2023-02-28Exit when there are unmatched delims to avoid noisy diagnosticsyukang-807/+185
2023-02-27handle only postfix decrementnx2k3-48/+0
2023-02-27check double negationnx2k3-81/+80
2023-02-26fix #108495, postfix decrement and prefix decrement has no warningnx2k3-0/+159
2023-02-26generalize help messagey21-3/+7
2023-02-18Rollup merge of #108031 - jieyouxu:issue-108019, r=estebankMatthias Krüger-4/+4
Don't recover lifetimes/labels containing emojis as character literals Fixes #108019. Note that at the time of this commit, `unic-emoji-char` seems to have data tables only up to Unicode 5.0, but Unicode is already newer than this. A newer emoji such as `🥺` will not be recognized as an emoji but older emojis such as `🐱` will. This PR leaves a couple of FIXMEs where `unic_emoji_char::is_emoji` is used.
2023-02-16Add feature gate for non_lifetime_bindersMichael Goulet-6/+6
2023-02-14Rollup merge of #103478 - SpanishPear:spanishpear/issue_103366_fix, r=TaKO8KiMatthias Krüger-0/+231
Suggest fix for misplaced generic params on fn item #103366 fixes #103366 This still has some work to go, but works for 2/3 of the initial base cases described in #1033366 simple fn: ``` error: expected identifier, found `<` --> shreys/test_1.rs:1:3 | 1 | fn<T> id(x: T) -> T { x } | ^ expected identifier | help: help: place the generic parameter list after the function name: | 1 | fn id<T>(x: T) -> T { x } | ~~~~ ``` Complicated bounds ``` error: expected identifier, found `<` --> spanishpear/test_2.rs:1:3 | 1 | fn<'a, B: 'a + std::ops::Add<Output = u32>> f(_x: B) { } | ^ expected identifier | help: help: place the generic parameter list after the function name: | 1 | fn f<'a, B: 'a + std::ops::Add<Output = u32>>(_x: B) { } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Opening a draft PR for comments on approach, particularly I have the following questions: - [x] Is it okay to be using `err.span_suggestion` over struct derives? I struggled to get the initial implementation (particularly the correct suggestion message) on struct derives, although I think given what I've learned since starting, I could attempt re-doing it with that approach. - [x] in the case where the snippet cannot be obtained from a span, is the `help` but no suggestion okay? I think yes (also, when does this case occur?) - [x] are there any red flags for the generalisation of this work for relevant item kinds (i.e. `struct`, `enum`, `trait`, and `union`). My basic testing indicates it does work for those types except the help tip is currently hardcoded to `after the function name` - which should change dependent on the item. - [x] I am planning to not show the suggestion if there is already a `<` after the item identifier, (i.e. if there are already generics, as after a function name per the original issue). Any major objections? - [x] Is the style of error okay? I wasn't sure if there was a way to make it display nicer, or if thats handled by span_suggestion These aren't blocking questions, and I will keep working on: - check if there is a `<` after the ident (and if so, not showing the suggestion) - generalize the help message - figuring out how to write/run/etc ui tests (including reading the docs for them) - logic cleanups
2023-02-14Update numeric lifetime test许杰友 Jieyou Xu (Joe)-4/+4
2023-02-10Rollup merge of #107789 - jieyouxu:issue-107745, r=lcnrMatthias Krüger-7/+7
Avoid exposing type parameters and implementation details sourced from macro expansions Fixes #107745. ~~I would like to **request some guidance** for this issue, because I don't think this is a good fix (a band-aid at best).~~ ### The Problem The code ```rust fn main() { println!("{:?}", []); } ``` gets desugared into (`rustc +nightly --edition=2018 issue-107745.rs -Z unpretty=hir`): ```rust #[prelude_import] use std::prelude::rust_2018::*; #[macro_use] extern crate std; fn main() { { ::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["", "\n"], &[<#[lang = "format_argument"]>::new_debug(&[])])); }; } ``` so the diagnostics code tries to be as specific and helpful as possible, and I think it finds that `[]` needs a type parameter and so does `new_debug`. But since `[]` doesn't have an origin for the type parameter definition, it points to `new_debug` instead and leaks the internal implementation detail since all `[]` has is an type inference variable. ### ~~The Bad Fix~~ ~~This PR currently tries to fix the problem by bypassing the generated function `<#[lang = "format_argument"]>::new_debug` to avoid its generic parameter (I think it is auto-generated from the argument `[_; 0]`?) from getting collected as an `InsertableGenericArg`. This is problematic because it also prevents the help from getting displayed.~~ ~~I think this fix is not ideal and hard-codes the format generated code pattern, but I can't think of a better fix. I have tried asking on Zulip but no responses there yet.~~
2023-02-09Rollup merge of #107446 - clubby789:rustc-parse-diag-migrate, r=compiler-errorsMatthias Krüger-0/+14
Migrate some of `rustc_parse` to derive diagnostics `@rustbot` label +A-translation r? rust-lang/diagnostics cc #100717
2023-02-09Don't expose type parameters and implementation details from macro expansion许杰友 Jieyou Xu (Joe)-7/+7
2023-02-08Do not eagerly recover for bad impl-trait in macrosMichael Goulet-0/+32
2023-02-06Migrate `rustc_parse` to derive diagnosticsclubby789-0/+14
2023-02-05Add ui test for missing expression in for loopObei Sideg-0/+18
2023-02-03Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obkMichael Goulet-3/+3
Replace `ConstFnMutClosure` with const closures Also fixes a parser bug. cc `@oli-obk` for compiler changes
2023-02-03Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obkDylan DPC-6/+6
Don't cause a cycle when formatting query description that references a FnDef When a function returns `-> _`, we use typeck to compute what the resulting type of the body _should_ be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack. However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a *second* cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the *second* cycle reporting code, we try to look for a job that isn't in the active jobs list. We can avoid this by using `with_no_queries!` when computing these query descriptions. Fixes #107089 The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...
2023-02-03Rollup merge of #107602 - estebank:anon-enum-access, r=compiler-errorsMatthias Krüger-27/+125
Parse and recover from type ascription in patterns Reintroduce part of #106960, which was reverted in #107478. r? `@compiler-errors`
2023-02-02Parse and recover from type ascription in patternsEsteban Küber-27/+125
2023-02-02Rollup merge of #106919 - compiler-errors:underscore-typo-in-field-pat, ↵Matthias Krüger-2/+12
r=jackh726 Recover `_` as `..` in field pattern
2023-02-02Recover _ as .. in field patternMichael Goulet-2/+12
2023-02-02Add a testMichael Goulet-0/+26
2023-02-02Revert "Teach parser to understand fake anonymous enum syntax" and related ↵Michael Goulet-160/+27
commits Revert "review comment: Remove AST AnonTy" This reverts commit 020cca8d36cb678e3ddc2ead41364be314d19e93. Revert "Ensure macros are not affected" This reverts commit 12d18e403139eeeeb339e8611b2bed4910864edb. Revert "Emit fewer errors on patterns with possible type ascription" This reverts commit c847a01a3b1f620c4fdb98c75805033e768975d1. Revert "Teach parser to understand fake anonymous enum syntax" This reverts commit 2d824206655bfb26cb5eed43490ee396542b153e.
2023-02-02Don't cause a cycle when formatting query description that references a FnDefMichael Goulet-6/+6
2023-02-01fix formatting + test syntaxSpanishPear-12/+0
2023-02-01fix parser mistaking const closures for const itemDeadbeef-3/+3
2023-01-31Auto merge of #106399 - estebank:type-err-span-label, r=nagisabors-5/+5
Modify primary span label for E0308 Looking at the reactions to https://hachyderm.io/`@ekuber/109622160673605438,` a lot of people seem to have trouble understanding the current output, where the primary span label on type errors talks about the specific types that diverged, but these can be deeply nested type parameters. Because of that we could see "expected i32, found u32" in the label while the note said "expected Vec<i32>, found Vec<u32>". This understandably confuses people. I believe that once people learn to read these errors it starts to make more sense, but this PR changes the output to be more in line with what people might expect, without sacrificing terseness. Fix #68220.
2023-01-31move to multipart spansSpanishPear-12/+18
2023-01-30Modify primary span label for E0308Esteban Küber-5/+5
The previous output was unintuitive to users.
2023-01-30Update bastion-of-the-turbofish.rsLucille Blumire-1/+1
The original tweet in the chain linked to, and thus the through line of links back to Anna's tweet where she named the turbofish (https://web.archive.org/web/20210911061514/https://twitter.com/whoisaldeka/status/914914008225816576) are lost as the user whoisaldeka has deleted their twitter account. Switching to an archive link preserves this through line, allowing someone to browse back to see the point at which Anna created the turbofish, as was the original intent of including this context.
2023-01-29Insert whitespace to avoid ident concatenation in suggestionRyo Yoshida-8/+22
2023-01-28Auto merge of #107408 - matthiaskrgr:rollup-b5vz2ow, r=matthiaskrgrbors-15/+240
Rollup of 9 pull requests Successful merges: - #104012 (Improve unexpected close and mismatch delimiter hint in TokenTreesReader) - #104252 (Stabilize the const_socketaddr feature) - #105524 (Replace libc::{type} with crate::ffi::{type}) - #107096 (Detect references to non-existant messages in Fluent resources) - #107355 (Add regression test for #60755) - #107384 (Remove `BOOL_TY_FOR_UNIT_TESTING`) - #107385 (Use `FallibleTypeFolder` for `ConstInferUnifier` not `TypeRelation`) - #107391 (rustdoc: remove inline javascript from copy-path button) - #107398 (Remove `ControlFlow::{BREAK, CONTINUE}`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-28Rollup merge of #104012 - chenyukang:yukang/fix-103882-deli-indentation, ↵Matthias Krüger-15/+240
r=petrochenkov Improve unexpected close and mismatch delimiter hint in TokenTreesReader Fixes #103882 Fixes #68987 Fixes #69259 The inner indentation mismatching will be covered by outer block, the new added function `report_error_prone_delim_block` will find out the error prone candidates for reporting.