Commit graph

1077 commits

Author SHA1 Message Date
Matthias Krüger 81da2a19fa
Rollup merge of #106846 - WaffleLapkin:pico_parse_ref, r=TaKO8Ki
Improve some comments and names in parser

Just a tiny drive-by cleanup.
2023-01-14 13:04:27 +01:00
Matthias Krüger 8e0eecdba6
Rollup merge of #106566 - clubby789:contiguous-weird-unicode, r=cjgillot
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-14 13:04:24 +01:00
Maybe Waffle f7850c5368 Improve comments in parser/expr.rs 2023-01-14 11:29:22 +00:00
Maybe Waffle ecb1ad11d9 Make LhsExpr::AlreadyParsed a named struct 2023-01-14 11:28:14 +00:00
bors 279f1c9d8c Auto merge of #106004 - fee1-dead-contrib:const-closures, r=oli-obk
Const closures

cc https://github.com/rust-lang/rust/issues/106003
2023-01-13 05:04:48 +00:00
Deadbeef 4fb10c0ce4 parse const closures 2023-01-12 02:28:37 +00:00
bors d4203eda5f Auto merge of #106537 - 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-12 02:16:16 +00:00
clubby789 a3d6bc3468 Emit a single error for contiguous sequences of Unicode homoglyphs 2023-01-12 00:15:32 +00:00
León Orell Valerian Liehr 70ddde76df
parser: recover from where clauses placed before tuple struct bodies 2023-01-11 17:54:48 +01:00
Esteban Küber 5311938531 Detect struct literal needing parentheses
Fix #82051.
2023-01-11 16:53:21 +00:00
Esteban Küber 6fdb54d2f1 Do not emit structured suggestion for turbofish with wrong span
Fix #79161.
2023-01-08 22:27:13 +00:00
Esteban Küber 0edca66a90 Tiny formatting fix 2023-01-06 05:34:56 +00:00
bors e5e5fcb0b7 Auto merge of #106268 - kraktus:patch-2, r=Nilstrieb
fix comment for `TokenCursor::desugar`

the hashes of the text were forgotten.
2022-12-30 06:59:13 +00:00
bors ad8ae0504c Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params)
 - #105899 (`./x doc library --open` opens `std`)
 - #106190 (Account for multiple multiline spans with empty padding)
 - #106202 (Trim more paths in obligation types)
 - #106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing)
 - #106236 (docs/test: add docs and a UI test for `E0514` and `E0519`)
 - #106259 (Update Clippy)
 - #106260 (Fix index out of bounds issues in rustdoc)
 - #106263 (Formatter should not try to format non-Rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-29 19:40:06 +00:00
kraktus d08134f1d2
fix comment for TokenCursor::desugar
the hashes of the text were forgotten.
2022-12-29 19:45:31 +01:00
Matthias Krüger 031a2143f0
Rollup merge of #106242 - estebank:diff-markers, r=jyn514
Detect diff markers in the parser

Partly address #32059.
2022-12-29 13:16:06 +01:00
Matthias Krüger c610aeb592
Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, r=compiler-errors
Rename `Rptr` to `Ref` in AST and HIR

The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-29 13:16:04 +01:00
Yutaro Ohno e5281c389d Provide a better error for Fn traits with lifetime params
Currently, given `Fn`-family traits with lifetime params like
`Fn<'a>(&'a str) -> bool`, many unhelpful errors show up. These are a
bit confusing.

This commit allows these situations to suggest simply using
higher-ranked trait bounds like `for<'a> Fn(&'a str) -> bool`.
2022-12-29 15:08:30 +09:00
Esteban Küber 62c8e3144a Add support for diff3 format 2022-12-28 20:55:46 -08:00
Esteban Küber 698ebe357f Tweak wording 2022-12-28 20:45:07 -08:00
Esteban Küber 38fd5a9acf Account for ADT bodies and struct expressions 2022-12-28 18:30:18 -08:00
Esteban Küber 375f025805 Detect diff markers in the parser
Partly address #32059.
2022-12-28 17:56:22 -08:00
Matthias Krüger c52d58f346
Rollup merge of #105570 - Nilstrieb:actual-best-failure, r=compiler-errors
Properly calculate best failure in macro matching

Previously, we used spans. This was not good. Sometimes, the span of the token that failed to match may come from a position later in the file which has been transcribed into a token stream way earlier in the file. If precisely this token fails to match, we think that it was the best match because its span is so high, even though other arms might have gotten further in the token stream.

We now try to properly use the location in the token stream.

This needs a little cleanup as the `best_failure` field is getting out of hand but it should be mostly good to go. I hope I didn't violate too many abstraction boundaries..
2022-12-28 22:22:19 +01:00
Nilstrieb 9067e4417e Rename Rptr to Ref in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.
2022-12-28 18:52:36 +01:00
Matthias Krüger d07be1a304
Rollup merge of #106176 - compiler-errors:fn-kw-as-fn-trait, r=estebank
Recover `fn` keyword as `Fn` trait in bounds

`impl fn()` -> `impl Fn()`

Fixes #82515
2022-12-28 14:40:01 +01:00
Matthias Krüger b7657e9cec
Rollup merge of #106066 - JohnTitor:rm-bindings-after-at-fixme, r=compiler-errors
Always suggest as `MachineApplicable` in `recover_intersection_pat`

This resolves one FIXME in `recover_intersection_pat` by always applying `MachineApplicable` when suggesting, as `bindings_after_at` is now stable.
This also separates a test to apply `// run-rustfix`.

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-12-27 16:37:48 +01:00
Michael Goulet aff403cf68 Recover fn keyword as Fn trait in bounds 2022-12-27 06:14:46 +00:00
bors 58f5a0180c Auto merge of #103020 - lyming2007:issue-102598-fix, r=jackh726
error parsing lifetime following by Sized and message + between them

Fixes #102598
2022-12-26 21:50:05 +00:00
fee1-dead 24265827c8
Rollup merge of #106151 - TaKO8Ki:remove-unused-imports, r=jackh726
Remove unused imports
2022-12-27 00:34:53 +08:00
Takayuki Maeda a8f468f5c6 remove unused imports 2022-12-26 15:01:20 +09:00
bors 300aa907a6 Auto merge of #105701 - RedDocMD:bug-105634, r=cjgillot
Allow .. to be parsed as let initializer

.. and ..= are valid expressions, however when used in a let statement
it is not parsed.
Fixes #105634
2022-12-25 14:42:49 +00:00
Yuki Okushi 668d9fd7bc
Always suggest as MachineApplicable in recover_intersection_pat
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-12-23 07:18:48 +09:00
Dylan DPC a9005b6cc0
Rollup merge of #105864 - matthiaskrgr:compl, r=Nilstrieb
clippy::complexity fixes

filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool

r? `@compiler-errors`
2022-12-19 14:41:35 +05:30
Matthias Krüger 1da4a49912 clippy::complexity fixes
filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool
2022-12-19 00:04:28 +01:00
Matthias Krüger 0aa4cde747 avoid .into() conversion to identical types 2022-12-18 16:20:32 +01:00
Deep Majumder 4af9e6a1c2 Little fixes 2022-12-16 18:41:08 +05:30
Deep Majumder c4d0c91161 Allow .. to be parsed as let initializer
.. and ..= are valid expressions, however when used in a let statement
it is not parsed.
2022-12-14 19:12:30 +05:30
Matthias Krüger c8fd654d7c
Rollup merge of #105502 - chenyukang:yukang/fix-105366-impl, r=estebank
Suggest impl in the scenario of typo with fn

Fixes #105366
2022-12-14 10:31:06 +01:00
bors 309c469eec Auto merge of #104875 - chenyukang:yukang/fix-104867-inc, r=estebank
Properly handle postfix inc/dec in standalone and subexpr scenarios

Fixes #104867
r? `@estebank`
2022-12-14 04:00:05 +00:00
Yiming Lei 419df5f4a0 error parsing lifetime following by Sized and message + between them
detect the pattern at the general site parse_impl_ty()
this will fix #102598
2022-12-13 16:49:20 -08:00
Nilstrieb d72a0c437b Properly calculate best failure in macro matching
Previously, we used spans. This was not good. Sometimes, the span of the
token that failed to match may come from a position later in the file
which has been transcribed into a token stream way earlier in the file.
If precisely this token fails to match, we think that it was the best
match because its span is so high, even though other arms might have
gotten further in the token stream.

We now try to properly use the location in the token stream.
2022-12-12 17:05:27 +01:00
bors 2cd2070af7 Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
Remove `token::Lit` from `ast::MetaItemLit`.

Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time.

r? `@petrochenkov`
2022-12-12 05:16:50 +00:00
Matthias Krüger 4154e14f9a
Rollup merge of #105369 - chenyukang:yukang/fix-105226, r=TaKO8Ki
Detect spurious ; before assoc fn body

Fixes #105226

r? ``@TaKO8Ki``
2022-12-11 23:36:46 +01:00
KaDiWa 9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
yukang b70a869d8f fix #105366, suggest impl in the scenario of typo with fn 2022-12-10 11:01:52 +08:00
yukang 5599f2ad09 fix #105226, Detect spurious ; before assoc fn body 2022-12-07 16:13:39 +08:00
Matthias Krüger 48172ff64b
Rollup merge of #105098 - lyming2007:issue-103869-fix, r=eholk
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-06 13:27:41 +01:00
Matthias Krüger 66a4cb5368
Rollup merge of #105223 - lukas-code:(ExprWithBlock), r=petrochenkov
suggest parenthesis around ExprWithBlock BinOp ExprWithBlock

fix https://github.com/rust-lang/rust/issues/105179
fix https://github.com/rust-lang/rust/issues/102171
2022-12-05 20:43:44 +01:00
Nicholas Nethercote d887615b4c Parameterise Parser::{recover_unclosed_char,handle_missing_lit}.
These two methods both produce a `MetaItemLit`, and then some of the
call sites convert the `MetaItemLit` to a `token::Lit` with
`as_token_lit`.

This commit parameterises these two methods with a `mk_lit_char`
closure, which can be used to produce either `MetaItemLit` or
`token::Lit` directly as necessary.
2022-12-05 15:04:33 +11:00
Matthias Krüger b1816833bd
Rollup merge of #105141 - ohno418:fix-ice-on-invalid-var-decl-in-macro-call, r=compiler-errors
Fix ICE on invalid variable declarations in macro calls

This fixes ICE that happens with invalid variable declarations in macro calls like:

```rust
macro_rules! m { ($s:stmt) => {} }
m! { var x }
m! { auto x }
m! { mut x }
```

Found this is because of not collecting tokens on recovery, so I changed to force collect them.

Fixes https://github.com/rust-lang/rust/issues/103529.
2022-12-04 16:25:32 +01:00