about summary refs log tree commit diff
path: root/compiler/rustc_parse
AgeCommit message (Collapse)AuthorLines
2022-11-24Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiserbors-1/+1
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-2/+3
2022-11-23Auto merge of #104410 - WaffleLapkin:unregress, r=estebankbors-10/+22
Fix perf regression by correctly matching keywords This should (hopefully) fix regression from #99918 r? `@estebank`
2022-11-22`rustc_parse`: remove `ref` patternsMaybe Waffle-39/+39
2022-11-22Rollup merge of #104559 - nnethercote:split-MacArgs, r=petrochenkovMatthias Krüger-62/+61
Split `MacArgs` in two. `MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values. r? `@petrochenkov`
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-62/+61
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Match crate and slug namesmejrs-127/+121
2022-11-19Cleanup macro matching recoveryNilstrieb-5/+0
The retry has been implemented already.
2022-11-19Rollup merge of #104566 - matthiaskrgr:clippy_perf_nov18, r=oli-obkDylan DPC-2/+2
couple of clippy::perf fixes
2022-11-18Auto merge of #104573 - matthiaskrgr:rollup-k36ybtp, r=matthiaskrgrbors-2/+21
Rollup of 8 pull requests Successful merges: - #101162 (Migrate rustc_resolve to use SessionDiagnostic, part # 1) - #103386 (Don't allow `CoerceUnsized` into `dyn*` (except for trait upcasting)) - #103405 (Detect incorrect chaining of if and if let conditions and recover) - #103594 (Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets) - #104006 (Add variant_name function to `LangItem`) - #104494 (Migrate GUI test to use functions) - #104516 (rustdoc: clean up sidebar width CSS) - #104550 (fix a typo) Failed merges: - #104554 (Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less) r? `@ghost` `@rustbot` modify labels: rollup
2022-11-18Rollup merge of #103405 - chenyukang:yukang/fix-103381-and-if, r=compiler-errorsMatthias Krüger-2/+21
Detect incorrect chaining of if and if let conditions and recover Fixes #103381
2022-11-18couple of clippy::perf fixesMatthias Krüger-2/+2
2022-11-17Use `ThinVec` in `ast::Path`.Nicholas Nethercote-18/+24
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-26/+38
patterns.
2022-11-16Auto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkovbors-244/+119
Use `token::Lit` in `ast::ExprKind::Lit`. 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. r? `@petrochenkov`
2022-11-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-1/+1
2022-11-16Fix perf regression by correctly matching keywordsMaybe Waffle-10/+22
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-244/+119
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-15Only do parser recovery on retried macro matchingNilstrieb-2/+2
This prevents issues with eager parser recovery during macro matching.
2022-11-15comment feedbackyukang-2/+1
2022-11-15fix #104088, Slightly improve error message for invalid identifieryukang-2/+23
2022-11-15fix #103381, Detect incorrect chaining of if and if let conditionsyukang-2/+21
2022-11-14Rollup merge of #104223 - fmease:recover-fn-ptr-with-generics, r=estebankMatthias Krüger-3/+77
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-13Add `delay_span_bug` to `AttrWrapper::take_for_recovery`Maybe Waffle-13/+26
2022-11-12Auto merge of #103812 - clubby789:improve-include-bytes, r=petrochenkovbors-1/+3
Delay `include_bytes` to AST lowering Hopefully addresses #65818. This PR introduces a new `ExprKind::IncludedBytes` which stores the path and bytes of a file included with `include_bytes!()`. We can then create a literal from the bytes during AST lowering, which means we don't need to escape the bytes into valid UTF8 which is the cause of most of the overhead of embedding large binary blobs.
2022-11-11Rollup merge of #103468 - chenyukang:yukang/fix-103435-extra-parentheses, ↵Manish Goregaokar-7/+23
r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes #103435
2022-11-11Introduce `ExprKind::IncludedBytes`clubby789-1/+3
2022-11-11Recover from fn ptr tys with generic param listLeón Orell Valerian Liehr-3/+77
2022-11-11Auto merge of #99918 - WaffleLapkin:fnFnfun, r=estebankbors-42/+115
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-10Auto merge of #104236 - compiler-errors:rollup-adjshd6, r=compiler-errorsbors-1/+18
Rollup of 9 pull requests Successful merges: - #102763 (Some diagnostic-related nits) - #103443 (Parser: Recover from using colon as path separator in imports) - #103675 (remove redundent "<>" for ty::Slice with reference type) - #104046 (bootstrap: add support for running Miri on a file) - #104115 (Migrate crate-search element to CSS variables) - #104190 (Ignore "Change InferCtxtBuilder from enter to build" in git blame) - #104201 (Add check in GUI test for file loading failure) - #104211 (:arrow_up: rust-analyzer) - #104231 (Update mailmap) Failed merges: - #104169 (Migrate `:target` rules to use CSS variables) r? `@ghost` `@rustbot` modify labels: rollup
2022-11-09Rollup merge of #103443 - mucinoab:recover-colon-as-path-separetor, ↵Michael Goulet-0/+17
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-09Rollup merge of #102763 - compiler-errors:nits, r=cjgillotMichael Goulet-1/+1
Some diagnostic-related nits 1. Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` 2. Make `diag.span_suggestions` take an `IntoIterator` instead of `Iterator`, just to remove some `.into_iter` calls on the caller. idk if I should add a lint to make sure people use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` in cases where we're just, e.g., adding subdiagnostics to the diagnostic... maybe a followup.
2022-11-10Auto merge of #103636 - chenyukang:yukang/fix-103587-sugg-if-let, ↵bors-4/+21
r=jackh276,davidtwco Recover from common if let syntax mistakes/typos Fixes #103587
2022-11-09Make span_suggestions take IntoIteratorMichael Goulet-1/+1
2022-11-09Rollup merge of #103919 - nnethercote:unescaping-cleanups, r=matkladDylan DPC-83/+66
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/+17
2022-11-08Fix outdated commentWaffle Maybe-1/+1
Co-authored-by: clubby789 <jamie@hill-daniel.co.uk>
2022-11-08Remove an address comparison from the parserMaybe Waffle-6/+1
2022-11-08use subdiagnostic for sugesting add letyukang-1/+1
2022-11-08fix #103587, Recover from common if let syntax mistakes/typosyukang-4/+21
2022-11-07Rollup merge of #103986 - ↵Dylan DPC-4/+8
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-11/+1
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-11/+1
It's been a warning for 5.5 years. Time to make it a hard error. Closes #42326.
2022-11-05Fix typoMichael Goulet-2/+2
2022-11-04Don't silently eat label before block in block-like exprMichael Goulet-4/+8
2022-11-04fake a base to suppress later extra error messageyukang-17/+14
2022-11-04Inline and remove `validate_int_literal`.Nicholas Nethercote-18/+13
It has a single callsite, and is fairly small. The `Float` match arm already has base-specific checking inline, so this makes things more consistent.
2022-11-04Refactor `cook_lexer_literal`.Nicholas Nethercote-42/+36
It deals with eight cases: ints, floats, and the six quoted types (char/byte/strings). For ints and floats we have an early return, and the other six types fall through to the code at the end, which makes the function hard to read. This commit rearranges things to avoid the early returns.
2022-11-04Make non-ASCII errors more consistent.Nicholas Nethercote-19/+13
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-3/+27