about summary refs log tree commit diff
path: root/tests/ui/parser
AgeCommit message (Collapse)AuthorLines
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.
2023-01-28Auto merge of #106916 - lukas-code:overlapping-substs, r=estebankbors-2/+2
Remove overlapping parts of multipart suggestions This PR adds a debug assertion that the parts of a single substitution cannot overlap, fixes a overlapping substitution from the testsuite, and fixes https://github.com/rust-lang/rust/issues/106870. Note that a single suggestion can still have multiple overlapping substitutions / possible edits, we just don't suggest overlapping replacements in a single edit anymore. I've also included a fix for an unrelated bug where rustfix for `explicit_outlives_requirements` would produce multiple trailing commas for a where clause.
2023-01-27Improve unexpected close and mismatch delimiter hint in TokenTreesReaderyukang-48/+57
2023-01-26Rollup merge of #106960 - estebank:parse-anon-enums, r=cjgillotMatthias Krüger-27/+160
Teach parser to understand fake anonymous enum syntax Parse `Ty | OtherTy` in function argument and return types. Parse type ascription in top level patterns. Minimally address #100741.
2023-01-26add testcase for #104012yukang-0/+216
2023-01-22move tests to new rust-lang locationSpanishPear-0/+237
2023-01-20preserve delim spans during `macro_rules!` expansion if ableLukas Markeffsky-2/+2
2023-01-20Rollup merge of #107058 - clubby789:eqeq-homoglyph, r=wesleywiserMatthias Krüger-1/+15
Recognise double-equals homoglyph Recognise `⩵` as a homoglyph for `==`. The first commit switches `char` to `&str`, as all previous homoglyphs corresponded to a single ASCII character, while the second implements the fix. `@rustbot` label +A-diagnostics +A-parser
2023-01-20Rollup merge of #106783 - WaffleLapkin:break-my-ident, r=wesleywiserMatthias Krüger-0/+39
Recover labels written as identifiers This adds recovery for `break label expr` and `continue label`, as well as a test for `break label`.
2023-01-19Add double-equals homoglyphclubby789-1/+15
2023-01-17Ensure macros are not affectedEsteban Küber-0/+20
2023-01-17Emit fewer errors on patterns with possible type ascriptionEsteban Küber-29/+6
2023-01-17Teach parser to understand fake anonymous enum syntaxEsteban Küber-18/+154
Parse `-> Ty | OtherTy`. Parse type ascription in top level patterns.
2023-01-14Emit only one nbsp error per fileDavid Tolnay-40/+1
2023-01-14Add more nbsp to unicode-chars testDavid Tolnay-4/+43
2023-01-14Rollup merge of #106566 - clubby789:contiguous-weird-unicode, r=cjgillotMatthias Krüger-1/+17
Emit a single error for contiguous sequences of unknown tokens Closes #106101 On encountering a sequence of identical source characters which are unknown tokens, note the amount of subsequent characters and advance past them silently. The old behavior was to emit an error and 'help' note for every single one. `@rustbot` label +A-diagnostics +A-parser
2023-01-13Recover labels written as identifiersMaybe Waffle-13/+22
2023-01-13Rollup merge of #106608 - compiler-errors:missing-generics-verbose, r=estebankYuki Okushi-9/+3
Render missing generics suggestion verbosely It's a bit easier to read like this, especially ones that are appending new generics onto an existing list, like ": `, T`" which render somewhat poorly inline. Also don't suggest `dyn` as a type parameter to add, even if technically that's valid in edition 2015.
2023-01-13Auto merge of #106004 - fee1-dead-contrib:const-closures, r=oli-obkbors-3/+3
Const closures cc https://github.com/rust-lang/rust/issues/106003
2023-01-12Don't suggest dyn as parameter to addMichael Goulet-15/+0
2023-01-12Render missing generics suggestion verboselyMichael Goulet-9/+18
2023-01-12Add a test for recovery of unticked labelsMaybe Waffle-0/+30
2023-01-12parse const closuresDeadbeef-3/+3
2023-01-12Auto merge of #106537 - ↵bors-4/+117
fmease:recover-where-clause-before-tuple-struct-body, r=estebank Recover from where clauses placed before tuple struct bodies Open to any suggestions regarding the phrasing of the diagnostic. Fixes #100790. `@rustbot` label A-diagnostics r? diagnostics
2023-01-12Emit a single error for contiguous sequences of Unicode homoglyphsclubby789-1/+17
2023-01-11parser: recover from where clauses placed before tuple struct bodiesLeón Orell Valerian Liehr-4/+117
2023-01-11Detect struct literal needing parenthesesEsteban Küber-0/+26
Fix #82051.