León Orell Valerian Liehr
3ed77e98fa
Only suggest turbofish in patterns if we may recover
2023-09-12 16:38:59 +02:00
Matthias Krüger
4a31cc859b
Rollup merge of #115473 - gurry:113110-expected-item, r=compiler-errors
...
Add explanatory note to 'expected item' error
Fixes #113110
It changes the diagnostic from this:
```
error: expected item, found `5`
--> ../test.rs:1:1
|
1 | 5
| ^ expected item
```
to this:
```
error: expected item, found `5`
--> ../test.rs:1:1
|
1 | 5
| ^ expected item
|
= note: items are things that can appear at the root of a module
= note: for a full list see https://doc.rust-lang.org/reference/items.html
```
2023-09-06 19:31:48 +02:00
Gurinder Singh
6a286e775c
Add explanatory note to 'expected item' error
2023-09-06 09:05:07 +05:30
bors
25283f4e13
Auto merge of #115371 - matthewjasper:if-let-guard-parsing, r=cjgillot
...
Make if let guard parsing consistent with normal guards
- Add tests that struct expressions are not allowed in `if let` and `while let` (no change, consistent with `if` and `while`)
- Allow struct expressions in `if let` guards (consistent with `if` guards).
r? `@cjgillot`
Closes #93817
cc #51114
2023-09-06 00:46:21 +00:00
Matthias Krüger
639116505a
Rollup merge of #114704 - bvanjoi:fix-114636, r=compiler-errors
...
parser: not insert dummy field in struct
Fixes #114636
This PR eliminates the dummy field, initially introduced in #113999 , thereby enabling unrestricted use of `ident.unwrap()`. A side effect of this action is that we can only report the error of the first macro invocation field within the struct node.
An alternative solution might be giving a virtual name to the macro, but it appears more complex.(https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715 ). Furthermore, if you think https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715 is a better solution, feel free to close this PR.
2023-08-30 07:18:10 +02:00
Matthew Jasper
89235fd837
Allow stuct literals in if let guards
...
This is consistent with normal match guards.
2023-08-28 10:31:45 +01:00
Matthew Jasper
56c17dc280
Add tests for struct literals in if let/while let
2023-08-28 10:30:48 +01:00
bors
18be2728bd
Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov
...
Parse unnamed fields and anonymous structs or unions (no-recovery)
It is part of #114782 which implements #49804 . Only parse anonymous structs or unions in struct field definition positions.
r? `@petrochenkov`
2023-08-24 12:52:35 +00:00
Frank King
868706d9b5
Parse unnamed fields and anonymous structs or unions
...
Anonymous structs or unions are only allowed in struct field
definitions.
Co-authored-by: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com>
2023-08-24 11:17:54 +08:00
bohan
3ed435f8cb
discard dummy field for macro invocation when parse struct
2023-08-21 21:05:01 +08:00
bors
0768872680
Auto merge of #114802 - chenyukang:yukang-fix-114979-bad-parens-dyn, r=estebank
...
Fix bad suggestion when wrong parentheses around a dyn trait
Fixes #114797
2023-08-17 17:54:50 +00:00
yukang
ddcd7cac41
Fix bad suggestion when wrong parentheses around a dyn trait
2023-08-16 00:26:10 +08:00
Michael Goulet
dc946649f5
Clean up some bad ui testing annotations
2023-08-15 01:03:09 +00:00
darklyspaced
7c3a8aeea5
relocate tests to pass tidy
2023-08-07 22:40:09 +08:00
darklyspaced
9ed5267e61
fix tests
2023-08-07 22:31:32 +08:00
darklyspaced
6d256d9d0e
test infra added
2023-08-07 22:10:21 +08:00
Matthias Krüger
1f076fe1d8
Rollup merge of #113999 - Centri3:macro-arm-expand, r=wesleywiser
...
Specify macro is invalid in certain contexts
Adds a note when a macro is used where it really shouldn't be.
Closes #113766
2023-08-04 07:25:45 +02:00
Matthias Krüger
51d1dacdc2
Rollup merge of #114300 - MU001999:fix/turbofish-pat, r=estebank
...
Suggests turbofish in patterns
Fixes #114112
r? ```@estebank```
2023-08-03 17:29:07 +02:00
Catherine Flores
bbd69e4a4c
Add test for enum with fields
2023-08-02 23:59:30 +00:00
Mu001999
049c728c60
Suggests turbofish in patterns
2023-08-01 23:30:40 +08:00
bohan
8e32dade71
parser: more friendly hints for handling async move
in the 2015 edition
2023-07-31 11:04:28 +08:00
bors
a04e649c09
Auto merge of #114028 - Centri3:ternary-operator, r=compiler-errors
...
Gracefully handle ternary operator
Fixes #112578
~~May not be the best way to do this as it doesn't check for a single `:`, so it could perhaps appear even when the actual issue is just a missing semicolon. May not be the biggest deal, though?~~
Nevermind, got it working properly now ^^
2023-07-29 16:45:29 +00:00
León Orell Valerian Liehr
6636916b66
Add UI tests for generic const items
2023-07-28 22:23:20 +02:00
Catherine Flores
faa73953c0
Remove unnecessary maybe_ternary_lo
field
2023-07-25 18:37:56 +00:00
Catherine Flores
16481807f5
Gracefully handle missing ternary operator
2023-07-25 18:27:24 +00:00
Catherine Flores
dece622ee4
Recover from some macros
2023-07-24 17:05:10 +00:00
Catherine
287db04636
Specify macro is invalid in certain contexts
2023-07-24 00:25:17 -05:00
Michael Goulet
7b962d7543
Support interpolated block for try and async
2023-07-22 15:22:12 +00:00
León Orell Valerian Liehr
b809207dec
Lint against misplaced where-clauses on assoc tys in traits
2023-07-11 01:19:11 +02:00
yukang
f25463e848
Fix the issue of wrong diagnosis for extern pub fn
2023-07-05 16:25:46 +08:00
yukang
799d2917e7
Detect extra space in keyword for better hint
2023-07-04 18:13:31 +08:00
Matthias Krüger
e992895c1d
Rollup merge of #112978 - compiler-errors:bad-block-sugg, r=davidtwco
...
Add suggestion for bad block fragment error
Makes it a bit clearer how to fix this parser restriction
2023-06-27 17:48:45 +02:00
Matthias Krüger
9f2c21c11f
Rollup merge of #112518 - chenyukang:yukang-fix-112458, r=davidtwco
...
Detect actual span for getting unexpected token from parsing macros
Fixes #112458
2023-06-27 17:48:44 +02:00
Michael Goulet
2cc7782cfd
Add suggestion for bad block fragment error
2023-06-23 19:18:20 +00:00
Michael Goulet
9ef580fa6f
Handle interpolated literal errors
2023-06-15 01:55:37 +00:00
许杰友 Jieyou Xu (Joe)
72421bfb0c
Fix debug ICE for extern type with where clauses
2023-06-12 15:15:45 +08:00
yukang
0220c0b765
Detect actual span for getting unexpected token from parsing macros
2023-06-11 14:36:20 +08:00
Matthias Krüger
46b64aaef0
Rollup merge of #112498 - SamZhang3:rust-reference-link-update, r=Nilstrieb
...
Update links to Rust Reference in diagnostic
Instead of linking to the [old Rust Reference site](https://static.rust-lang.org/doc/master/reference.html#literals ), which is severely outdated (Rust 1.17), link to the [current website](https://doc.rust-lang.org/stable/reference/expressions/literal-expr.html ) in diagnostic about incorrect literals.
2023-06-11 01:57:28 +02:00
Hankai Zhang
6336da9a75
Use a better link
2023-06-10 14:46:11 -04:00
Hankai Zhang
e5fccf927d
Update links to Rust Reference page on literals in diagnostic
...
Instead of linking to the old Rust Reference site on static.rust-lang.org,
link to the current website doc.rust-lang.org/stable/reference instead in
diagnostic about incorrect literals.
2023-06-10 12:34:16 -04:00
yukang
e3071eaa60
reword the message to suggest surrounding with parentheses
2023-06-10 06:28:35 +08:00
yukang
3983881d4e
take care module name for suggesting surround the struct literal in parentheses
2023-06-10 06:28:35 +08:00
许杰友 Jieyou Xu (Joe)
2a7c6a99ef
Fix suggestion for matching struct with ..
on both ends
2023-06-03 15:02:13 +08:00
许杰友 Jieyou Xu (Joe)
41f5a30690
Recover upon encountering mistyped Const
in const param def
2023-05-28 16:55:21 +08:00
Matthias Krüger
97fae38bf9
Rollup merge of #111181 - bvanjoi:fix-issue-111148, r=davidtwco
...
fix(parse): return unpected when current token is EOF
close https://github.com/rust-lang/rust/issues/111148
#111148 panic occurred because [FatalError.raise()](https://github.com/bvanjoi/rust/blob/master/compiler/rustc_parse/src/parser/mod.rs#LL540C3-L540C3 ) was encountered which caused by `Eof` and `Pound`(the last token) had same span, when parsing `#` in `fn a<<i<Y<w<>#`.
<img width="825" alt="image" src="https://user-images.githubusercontent.com/30187863/236612589-9e2c6a0b-18cd-408c-b636-c12a51cbcf1c.png ">
There are a few ways to solve this problem:
- Change the action assign for [self.last_unexpected_token_span](https://github.com/rust-lang/rust/blob/master/compiler/rustc_parse/src/parser/diagnostics.rs#L592 ), for example, if current token is `Eof`, then return Error directly.
- Avoid triggering the `FatalError` when the current token is `Eof`.
I have chosen the second option because executing `expected_one_of_not_found` when the token is `Eof` but not in `ediable` seems reasonable.
2023-05-27 20:40:28 +02:00
Nilstrieb
87a0cd9a41
Rollup merge of #111449 - compiler-errors:recover-impl-generics-correctly, r=Nilstrieb
...
Recover `impl<T ?Sized>` correctly
Fixes #111327
r? ````@Nilstrieb```` but you can re-roll
Alternatively, happy to close this if we're okay with just saying "sorry #111327 is just a poor side-effect of parser ambiguity" 🤷
2023-05-16 11:39:38 +02:00
Nilstrieb
f65281534f
Rollup merge of #111428 - bvanjoi:fix-109250, r=Nilstrieb
...
refactor(resolve): clean up the early error return caused by non-call
closes https://github.com/rust-lang/rust/issues/109250
It seems no bad happened, r? ``@Nilstrieb``
2023-05-16 11:39:38 +02:00
Michael Goulet
a5763ff8d3
Recover impl<T ?Sized>
correctly
2023-05-15 17:14:59 +00:00
yukang
83789b8b06
fmt
2023-05-13 19:40:17 +08:00
yukang
ce6cfc37d0
Fix ice caused by shorthand fields in NoFieldsForFnCall
2023-05-13 18:06:16 +08:00