about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
AgeCommit message (Collapse)AuthorLines
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-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
2022-11-03Use `Mode` less.Nicholas Nethercote-7/+7
It's passed to numerous places where we just need an `is_byte` bool. Passing the bool avoids the need for some assertions. Also rename `is_bytes()` as `is_byte()`, to better match `Mode::Byte`, `Mode::ByteStr`, and `Mode::RawByteStr`.
2022-11-02Rollup merge of #103703 - Nilstrieb:flag-recovery-1, r=compiler-errorsDylan DPC-6/+32
Gate some parser recovery behind the check Mainly in `expr.rs`. `may_recover` doesn't do anything useful yet until I implement that on top of #103439. r? `@compiler-errors`
2022-11-01Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwcoManish Goregaokar-24/+47
Change #[suggestion_*] attributes to use style="..." As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter. It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all. Best reviewed commit-by-commit, there's a bit of noise in there. cc #100717 `@compiler-errors` r? `@davidtwco`
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-0/+2
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```
2022-10-31Add more track_callermejrs-0/+2
2022-10-28Gate some recovery behind a flagNilstrieb-6/+32
Mainly in `expr.rs`
2022-10-27Rollup merge of #103544 - Nilstrieb:no-recovery-pls, r=compiler-errorsMatthias Krüger-2/+30
Add flag to forbid recovery in the parser To start the effort of fixing #103534, this adds a new flag to the parser, which forbids the parser from doing recovery, which it shouldn't do in macros. This doesn't add any new checks for recoveries yet and is just here to bikeshed the names for the functions here before doing more. r? `@compiler-errors`
2022-10-26Fix typonils-1/+1
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-10-26Add documentationNilstrieb-1/+8
2022-10-26Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]Xiretza-24/+47
Using the following command: find compiler/ -type f -name '*.rs' -exec perl -i -gpe \ 's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \ '{}' +
2022-10-26Rollup merge of #103444 - chenyukang:yukang/fix-103425-extra-diag, r=davidtwcoDylan DPC-29/+36
Remove extra type error after missing semicolon error Fixes #103425
2022-10-25Add flag to forbid recovery in the parserNilstrieb-2/+23
2022-10-25Rollup merge of #103333 - chenyukang:yukang/fix-103143, r=wesleywiserYuki Okushi-5/+11
Fix assertion failed for break_last_token and trailing token Fixes #103143
2022-10-24fix parentheses surrounding spacing issue in parseryukang-7/+23
2022-10-24fix #103425, remove extra type error after missing semicolon erroryukang-29/+36
2022-10-23Auto merge of #103431 - Dylan-DPC:rollup-oozfo89, r=Dylan-DPCbors-11/+94
Rollup of 6 pull requests Successful merges: - #101293 (Recover when unclosed char literal is parsed as a lifetime in some positions) - #101908 (Suggest let for assignment, and some code refactor) - #103192 (rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`) - #103226 (Check `needs_infer` before `needs_drop` during HIR generator analysis) - #103249 (resolve: Revert "Set effective visibilities for imports more precisely") - #103305 (Move some tests to more reasonable places) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-23Rollup merge of #101293 - compiler-errors:lt-is-actually-char, r=estebankDylan DPC-11/+94
Recover when unclosed char literal is parsed as a lifetime in some positions Fixes #101278
2022-10-23Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errorsbors-199/+185
Flatten diagnostic slug modules This makes it easier to grep for the slugs in the code. See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it. This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know. r? `@davidtwco`
2022-10-23Migrate all diagnosticsNilstrieb-199/+185
2022-10-23Rollup merge of #103354 - clubby789:escape-string-literals, r=compiler-errorsMatthias Krüger-2/+17
Escape string literals when fixing overlong char literal Fixes #103323 ````@rustbot```` label +A-diagnostics +A-suggestion-diagnostics
2022-10-22Don't erroneously deny semicolons after closure expr within parentheses in a ↵Michael Goulet-0/+4
macro
2022-10-22Recover unclosed char literal being parsed as lifetimeMichael Goulet-11/+94
2022-10-22Properly escape quotes when suggesting switching between char/string literalsclubby789-2/+17
2022-10-21Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obkDylan DPC-1/+9
Filtering spans when emitting json According to the issue #102902, we shouldn't emit spans which have an empty span and no suggested replacement.
2022-10-20fix assertion failed for break_last_token and trailing tokenyukang-5/+11
2022-10-20Implement assertions and fixes to not emit empty spans without suggestionsKevin Per-1/+9
2022-10-18Fix the bug of next_point in spanyukang-4/+4