summary refs log tree commit diff
path: root/src/test/ui/parser
AgeCommit message (Collapse)AuthorLines
2022-12-06Rollup merge of #105098 - lyming2007:issue-103869-fix, r=eholkMatthias Krüger-0/+28
propagate the error from parsing enum variant to the parser and emit out While parsing enum variant, the error message always disappear Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case https://github.com/rust-lang/rust/issues/103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix https://github.com/rust-lang/rust/issues/103869
2022-12-03suggest parenthesis around ExprWithBlock BinOp ExprWithBlockLukas Markeffsky-1/+66
2022-12-01While parsing enum variant, the error message always disappearYiming Lei-0/+28
Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case #103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix #103869
2022-11-23Fix an ICE parsing a malformed attribute.Nicholas Nethercote-0/+12
Fixes #104620.
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-14/+6
2022-11-18Rollup merge of #103405 - chenyukang:yukang/fix-103381-and-if, r=compiler-errorsMatthias Krüger-0/+168
Detect incorrect chaining of if and if let conditions and recover Fixes #103381
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-43/+29
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
2022-11-16Add some more bad suffix cases in a test.Nicholas Nethercote-17/+75
2022-11-15Rollup merge of #104309 - chenyukang:yukang/fix-104088-identifier-error, ↵Matthias Krüger-0/+67
r=davidtwco Slightly improve error message for invalid identifier fixes #104088
2022-11-15Rollup merge of #103439 - Nilstrieb:help-me-with-my-macro, r=estebankMatthias Krüger-0/+12
Show note where the macro failed to match When feeding the wrong tokens, it used to fail with a very generic error that wasn't very helpful. This change tries to help by noting where specifically the matching went wrong. ```rust macro_rules! uwu { (a a a b) => {}; } uwu! { a a a c } ``` ```diff error: no rules expected the token `c` --> macros.rs:5:14 | 1 | macro_rules! uwu { | ---------------- when calling this macro ... 4 | uwu! { a a a c } | ^ no rules expected this token in macro call | +note: while trying to match `b` + --> macros.rs:2:12 + | +2 | (a a a b) => {}; + | ^ ```
2022-11-15move testcase for tidyyukang-0/+12
2022-11-15fix #104088, Slightly improve error message for invalid identifieryukang-0/+55
2022-11-15move testcase for tidyyukang-0/+12
2022-11-15fix #103381, Detect incorrect chaining of if and if let conditionsyukang-0/+168
2022-11-14Show a note where a macro failed to matchNilstrieb-0/+12
This shows a small note on what the macro matcher was currently processing to aid with "no rules expected the token X" errors.
2022-11-14Rollup merge of #104223 - fmease:recover-fn-ptr-with-generics, r=estebankMatthias Krüger-0/+142
Recover from function pointer types with generic parameter list Give a more helpful error when encountering function pointer types with a generic parameter list like `fn<'a>(&'a str) -> bool` or `fn<T>(T) -> T` and suggest moving lifetime parameters to a `for<>` parameter list. I've added a bunch of extra code to properly handle (unlikely?) corner cases like `for<'a> fn<'b>()` (where there already exists a `for<>` parameter list) correctly suggesting `for<'a, 'b> fn()` (merging the lists). If you deem this useless, I can simplify the code by suggesting nothing at all in this case. I am quite open to suggestions regarding the wording of the diagnostic messages. Fixes #103487. ``@rustbot`` label A-diagnostics r? diagnostics
2022-11-11Rollup merge of #104202 - camsteffen:103748, r=estebankDylan DPC-0/+59
Fix ICE #103748 Fixes #103748
2022-11-11Recover from fn ptr tys with generic param listLeón Orell Valerian Liehr-0/+142
2022-11-11Auto merge of #99918 - WaffleLapkin:fnFnfun, r=estebankbors-0/+154
Recover wrong-cased keywords that start items (_this pr was inspired by [this tweet](https://twitter.com/Azumanga/status/1552982326409367561)_) r? `@estebank` We've talked a bit about this recovery, but I just wanted to make sure that this is the right approach :) For now I've only added the case insensitive recovery to `use`s, since most other items like `impl` blocks, modules, functions can start with multiple keywords which complicates the matter.
2022-11-09Rollup merge of #103443 - mucinoab:recover-colon-as-path-separetor, ↵Michael Goulet-0/+39
r=compiler-errors Parser: Recover from using colon as path separator in imports I don't know if this is the right approach, any feedback is welcome. r? ```@compiler-errors``` Fixes #103269
2022-11-09Add domain size check to fix ICECameron Steffen-0/+59
2022-11-09Rollup merge of #103919 - nnethercote:unescaping-cleanups, r=matkladDylan DPC-30/+30
Unescaping cleanups Some code improvements, and some error message improvements. Best reviewed one commit at a time. r? ````@matklad````
2022-11-08Parser: Recover from using colon as path separator in importsBruno A. Muciño-0/+39
2022-11-08Rollup merge of #103521 - chenyukang:yukang/fix-103451-avoid-hang, ↵Manish Goregaokar-0/+37
r=jackh726,wesleywiser Avoid possible infinite loop when next_point reaching the end of file Fixes #103451 If we return a span with `lo` = `hi`, `span_to_snippet` will always get `Ok("")`, which may introduce infinite loop if we don't care. This PR make `find_width_of_character_at_span` return `width` with 1, so that `span_to_snippet` will get an `Err`.
2022-11-07Rollup merge of #103986 - ↵Dylan DPC-0/+219
compiler-errors:oh-no-bad-block-should-not-have-label, r=lcnr Don't silently eat label before block in block-like expr Fixes #103983 cc #92823 (where the regression was introduced)
2022-11-07Rollup merge of #103914 - nnethercote:close-42326, r=petrochenkovYuki Okushi-9/+21
Make underscore_literal_suffix a hard error. It's been a warning for 5.5 years. Time to make it a hard error. Closes #42326. r? ``@pnkfelix``
2022-11-07Make underscore_literal_suffix a hard error.Nicholas Nethercote-9/+21
It's been a warning for 5.5 years. Time to make it a hard error. Closes #42326.
2022-11-06Auto merge of #99943 - compiler-errors:tuple-trait, r=jackh726bors-8/+8
Implement `std::marker::Tuple`, use it in `extern "rust-call"` and `Fn`-family traits Implements rust-lang/compiler-team#537 I made a few opinionated decisions in this implementation, specifically: 1. Enforcing `extern "rust-call"` on fn items during wfcheck, 2. Enforcing this for all functions (not just ones that have bodies), 3. Gating this `Tuple` marker trait behind its own feature, instead of grouping it into (e.g.) `unboxed_closures`. Still needing to be done: 1. Enforce that `extern "rust-call"` `fn`-ptrs are well-formed only if they have 1/2 args and the second one implements `Tuple`. (Doing this would fix ICE in #66696.) 2. Deny all explicit/user `impl`s of the `Tuple` trait, kinda like `Sized`. 3. Fixing `Tuple` trait built-in impl for chalk, so that chalkification tests are un-broken. Open questions: 1. Does this need t-lang or t-libs signoff? Fixes #99820
2022-11-05Merge conflicts and rebase onto masterMichael Goulet-8/+8
2022-11-04Don't silently eat label before block in block-like exprMichael Goulet-0/+219
2022-11-04fake a base to suppress later extra error messageyukang-24/+21
2022-11-04Make non-ASCII errors more consistent.Nicholas Nethercote-30/+30
There are three kinds of "byte" literals: byte literals, byte string literals, and raw byte string literals. None are allowed to have non-ASCII chars in them. Two `EscapeError` variants exist for when that constraint is violated. - `NonAsciiCharInByte`: used for byte literals and byte string literals. - `NonAsciiCharInByteString`: used for raw byte string literals. As a result, the messages for raw byte string literals use different wording, without good reason. Also, byte string literals are incorrectly described as "byte constants" in some error messages. This commit eliminates `NonAsciiCharInByteString` so the three cases are handled similarly, and described correctly. The `mode` is enough to distinguish them. Note: Some existing error messages mention "byte constants" and some mention "byte literals". I went with the latter here, because it's a more correct name, as used by the Reference.
2022-11-04fix #102806, suggest use .. to fill in the rest of the fields of Structyukang-0/+73
2022-10-26Rollup merge of #95710 - ↵Dylan DPC-59/+0
fee1-dead-contrib:stabilize_arbitrary_enum_discriminant, r=joshtriplett Stabilize arbitrary_enum_discriminant, take 2 Documentation has been updated in https://github.com/rust-lang/reference/pull/1055. cc #86860 for previous stabilization report. Not yet marks https://github.com/rust-lang/rust/issues/60553 as done: need documentation in the rust reference.
2022-10-26Rollup merge of #103444 - chenyukang:yukang/fix-103425-extra-diag, r=davidtwcoDylan DPC-0/+44
Remove extra type error after missing semicolon error Fixes #103425
2022-10-25Fix #103451, find_width_of_character_at_span return width with 1 when ↵yukang-0/+37
reaching end
2022-10-25Rollup merge of #103333 - chenyukang:yukang/fix-103143, r=wesleywiserYuki Okushi-0/+25
Fix assertion failed for break_last_token and trailing token Fixes #103143
2022-10-24fix #103425, remove extra type error after missing semicolon erroryukang-0/+44
2022-10-23Rollup merge of #101293 - compiler-errors:lt-is-actually-char, r=estebankDylan DPC-12/+112
Recover when unclosed char literal is parsed as a lifetime in some positions Fixes #101278
2022-10-22Don't erroneously deny semicolons after closure expr within parentheses in a ↵Michael Goulet-0/+14
macro
2022-10-22Recover unclosed char literal being parsed as lifetimeMichael Goulet-12/+112
2022-10-22Stabilize arbitrary_enum_discriminant, take 2Deadbeef-59/+0
2022-10-20fix assertion failed for break_last_token and trailing tokenyukang-0/+25
2022-10-18Clean up query descriptionsnils-3/+3
Use the same tense everywhere and prefer display over debug, as these descriptions are user facing.
2022-10-14Rollup merge of #102938 - c410-f3r:here-we-go-again, r=petrochenkovDylan DPC-0/+7
Move some tests to more reasonable directories r? ``@petrochenkov``
2022-10-13Move some tests to more reasonable directoriesCaio-0/+7
2022-10-11Fix let removal suggestion in structMichael Goulet-6/+70
2022-10-10Rollup merge of #101789 - gimbles:let, r=estebankMatthias Krüger-2/+8
`let`'s not needed in struct field definitions Fixes #101683
2022-10-10`let` is not allowed in struct field definitionsgimbles-2/+8
Co-authored-by: jyn514 <jyn514@gmail.com> Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-10-10Rollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebankYuki Okushi-0/+17
Recover from impl Trait in type param bound Fixes #102182 r? ``@estebank``