Lukas Wirth
f9bb5476c3
fix: Fix pat fragment parsers choking on <eoi>
2024-06-17 19:42:56 +02:00
Wilfred Hughes
d68e549205
internal: Fix rustdoc warnings
...
`cargo doc` generates a bunch of warnings on rust-analyzer. Fix all the
bare URL and empty code block warnings.
2024-06-13 17:29:10 -07:00
Wilfred Hughes
27182bb96b
chore: Prefer tracing span shorthand macros
2024-06-06 16:52:25 -07:00
Hamir Mahal
7c34eb3880
style: simplify string interpolation
2024-05-30 16:18:49 -07:00
Laurențiu Nicola
49cae17fa2
Merge from rust-lang/rust
2024-05-19 11:20:26 +03:00
Lukas Wirth
e1aeed3aed
Implement unsafe attribute parsing
2024-05-06 12:11:29 +02:00
Laurențiu Nicola
c8c635a3f8
Merge commit '55d9a533b309119c8acd13061581b43ae8840823' into sync-from-ra
2024-04-20 19:17:08 +03:00
davidsemakula
69fe457cb5
internal: simplify TokenSet
implementation
2024-04-15 17:33:09 +03:00
davidsemakula
e326b634d1
internal: add reserved keywords
2024-04-15 15:06:26 +03:00
davidsemakula
89779ca55e
internal: improve TokenSet
implementation
2024-04-15 15:06:26 +03:00
Lukas Wirth
83370fe5d7
Use Edition::CURRENT
2024-04-14 15:30:29 +02:00
Lukas Wirth
9c75e9fa7d
Deduplicate Edition enum
2024-04-14 15:29:01 +02:00
Johann Hemmann
e7852803c5
Mark edition field as unused
2024-04-14 15:11:38 +02:00
Johann Hemmann
454e481422
Add edition to all parse
functions of the parser crate
2024-04-14 15:07:43 +02:00
Johann Hemmann
392538c830
Add edition to parser struct
2024-04-14 15:06:09 +02:00
Esteban Küber
8677ebbc73
Properly handle emojis as literal prefix in macros
...
Do not accept the following
```rust
macro_rules! lexes {($($_:tt)*) => {}}
lexes!(🐛 "foo");
```
Before, invalid emoji identifiers were gated during parsing instead of lexing in all cases, but this didn't account for macro expansion of literal prefixes.
Fix #123696 .
2024-04-10 23:19:27 +00:00
Lukas Wirth
dc4e5987a4
fix: Improve error recovery for match arms
2024-03-19 10:55:47 +01:00
bors
2397e7a887
Auto merge of #16787 - pksunkara:remove-macro-call-check, r=lnicola
...
Remove unncessary check for macro call
Since `macro_rules` is a contextual keyword, it is an `IDENT` token and thus `is_path_start` already identifies it correctly. You can tell the previous check is unnecessary because the relevant tests still pass.
2024-03-08 13:23:31 +00:00
bors
2b7b44bf27
Auto merge of #16786 - pksunkara:improve-readability, r=lnicola
...
internal: Improve readability of the parser code
The code is basically equivalent to the previous version, but it improves the readability by making it much more simpler and concise.
2024-03-08 12:21:18 +00:00
Pavan Kumar Sunkara
a838e44032
Remove unncessary check for macro call
2024-03-08 12:03:35 +00:00
Pavan Kumar Sunkara
2a41b2cd94
Improve readability of the parser code
2024-03-08 12:00:24 +00:00
Pavan Kumar Sunkara
b37ccfce44
Remove unused keyword from visibility recovery
2024-03-08 11:53:03 +00:00
roife
91d181feff
minor: fmt and clippy
2024-03-06 23:32:40 +08:00
roife
e2daee61bc
test: add test for float_split_scientific_notation
2024-03-06 22:51:22 +08:00
roife
03420c330e
fix: panic when split float numbers in scientific notation
2024-03-06 22:50:50 +08:00
Lukas Wirth
4303e741de
Cleanup
2024-03-04 11:10:06 +01:00
Michael Goulet
3e4deab3d8
Add support for const and async trait bounds
2024-02-16 16:00:04 +00:00
Maybe Waffle
e146139957
Add support for become
expr/tail calls
2024-02-14 14:57:18 +00:00
Lukas Wirth
bf115a6064
fix: Recover from =
in record pattern field
2024-02-13 18:25:40 +01:00
Lukas Wirth
ccccc299c8
fix: Recover from =
in record constructor field assignment
2024-02-13 18:23:33 +01:00
Tetsuharu Ohzeki
f474bd77be
parser: Fix warnings about clippy str_to_string
rule
2024-02-10 01:00:40 +09:00
Lukas Wirth
974e69b0c5
Recover from missing slots in delimited parsing
2024-02-08 11:14:37 +01:00
Yutaro Ohno
e865d45904
fix: Recover from missing argument in call expressions
...
Previously, when parsing an argument list with a missing argument (e.g.,
`(a, , b)` in `foo(a, , b)`), the parser would stop upon an unexpected
token (at the second comma in the example), resulting in an incorrect
parse tree.
This commit improves error handling in such cases, ensuring a more
accurate parse tree is built.
2024-02-08 10:54:04 +01:00
bors
66cec4d11a
Auto merge of #16470 - Veykril:clippy-disallow, r=lnicola
...
internal: Lint debug prints and disallowed types with clippy
2024-02-05 17:20:43 +00:00
Young-Flash
864c3d5880
test: add method_call_missing_argument_list error test
2024-02-05 17:54:09 +08:00
Young-Flash
c495e3f00f
fix: emit parser error for missing argument list
2024-02-05 17:54:09 +08:00
Lukas Wirth
9e8a0fae0c
Lint debug prints and disallowed types with clippy
2024-02-01 17:57:27 +01:00
Laurențiu Nicola
f43cea0878
Merge commit '7219414e81810fd4d967136c4a0650523892c157' into sync-from-ra
2024-01-28 15:56:54 +02:00
Lukas Wirth
8a5829cf28
Re-order mod declarations
2024-01-27 11:02:34 +01:00
Laurențiu Nicola
b1b6e0c41a
Reapply "Detect NulInCStr
error earlier."
...
This reverts commit 0ea056552a
.
2024-01-25 06:40:07 +02:00
Nicholas Nethercote
858f4aca6c
Rename the unescaping functions.
...
`unescape_literal` becomes `unescape_unicode`, and `unescape_c_string`
becomes `unescape_mixed`. Because rfc3349 will mean that C string
literals will no longer be the only mixed utf8 literals.
2024-01-25 12:28:11 +11:00
Laurențiu Nicola
e4866b6ddb
Merge commit 'a9116523604c998e7781f60d3b5a6f586e0414a9' into sync-from-ra
2024-01-21 16:53:06 +02:00
Johann Hemmann
6709eaba2a
never_loop
2024-01-19 17:31:01 +01:00
Johann Hemmann
b599de193f
Refactor macro_call
to be consistent with other functions
2024-01-18 12:50:36 +01:00
bors
1ab8c7fd27
Auto merge of #16349 - Young-Flash:use_error_recovery, r=Veykril
...
fix: add error recovery for use_tree_list parsing
This PR adds error recovery for USE_TREE_LIST parsing, avoid the wrong USE_TREE_LIST making the rest parsing incorrectly.
before
![before](https://github.com/rust-lang/rust-analyzer/assets/71162630/c6643690-f25c-4ad9-93d9-e661ba5b1dc3 )
after
![after](https://github.com/rust-lang/rust-analyzer/assets/71162630/30a58c40-2711-48d2-b2e5-fb208fc8636c )
close https://github.com/rust-lang/rust-analyzer/issues/16227
2024-01-18 09:52:37 +00:00
Matthias Krüger
7d4980a4d8
Rollup merge of #119172 - nnethercote:earlier-NulInCStr, r=petrochenkov
...
Detect `NulInCStr` error earlier.
By making it an `EscapeError` instead of a `LitError`. This makes it like the other errors produced when checking string literals contents, e.g. for invalid escape sequences or bare CR chars.
NOTE: this means these errors are issued earlier, before expansion, which changes behaviour. It will be possible to move the check back to the later point if desired. If that happens, it's likely that all the string literal contents checks will be delayed together.
One nice thing about this: the old approach had some code in `report_lit_error` to calculate the span of the nul char from a range. This code used a hardwired `+2` to account for the `c"` at the start of a C string literal, but this should have changed to a `+3` for raw C string literals to account for the `cr"`, which meant that the caret in `cr"` nul error messages was one short of where it should have been. The new approach doesn't need any of this and avoids the off-by-one error.
r? ```@fee1-dead```
2024-01-18 10:34:17 +01:00
Johann Hemmann
76c67dd229
Fix test
2024-01-17 12:49:58 +01:00
Johann Hemmann
5916da2c29
Handle macro_rules!
as MACRO_CALL
...
It's a call of the third token is neither IDENT or TRY
2024-01-17 12:07:17 +01:00
Laurențiu Nicola
6bbd106c70
Merge commit '9d8889cdfcc3aa0302353fc988ed21ff9bc9925c' into sync-from-ra
2024-01-15 11:40:09 +02:00
Young-Flash
6033b66ce0
test: correct expected test result
2024-01-12 17:42:18 +08:00
Young-Flash
d0b310fc93
fix: add USE_TREE_LIST_FIRST_SET
2024-01-12 17:41:46 +08:00
Nicholas Nethercote
6001c50cac
Detect NulInCStr
error earlier.
...
By making it an `EscapeError` instead of a `LitError`. This makes it
like the other errors produced when checking string literals contents,
e.g. for invalid escape sequences or bare CR chars.
NOTE: this means these errors are issued earlier, before expansion,
which changes behaviour. It will be possible to move the check back to
the later point if desired. If that happens, it's likely that all the
string literal contents checks will be delayed together.
One nice thing about this: the old approach had some code in
`report_lit_error` to calculate the span of the nul char from a range.
This code used a hardwired `+2` to account for the `c"` at the start of
a C string literal, but this should have changed to a `+3` for raw C
string literals to account for the `cr"`, which meant that the caret in
`cr"` nul error messages was one short of where it should have been. The
new approach doesn't need any of this and avoids the off-by-one error.
2024-01-12 16:19:37 +11:00
Young-Flash
45eea57115
add in-comment test case for use_tree_list_err_recovery
2024-01-11 19:52:23 +08:00
Young-Flash
afe05fe1d8
fix broken test
2024-01-11 19:51:45 +08:00
Young-Flash
e6dd522761
fix: add err recovery for use_tree_list parsing
2024-01-11 19:50:35 +08:00
bors
c246ecfd55
Auto merge of #16310 - Veykril:range-access-parse, r=Veykril
...
fix: Fix incorrect parsing error on method call on range
Fixes https://github.com/rust-lang/rust-analyzer/issues/16289
2024-01-09 09:49:25 +00:00
Lukas Wirth
b97ab00bd4
Split out rustc_lexer from rustc_dependencies
2024-01-08 15:24:46 +01:00
Lukas Wirth
72200641c1
fix: Fix incorrect parsing error on method call on range
2024-01-08 15:09:26 +01:00
Laurențiu Nicola
932d85b529
Merge commit '426d2842c1f0e5cc5e34bb37c7ac3ee0945f9746' into sync-from-ra2
2024-01-03 11:35:07 +02:00
Tetsuharu Ohzeki
efc87092b3
Use Cargo's [workspace.lints.*] to config clippy
2023-12-29 23:51:32 +09:00
Laurențiu Nicola
f532576ac5
Merge commit '457b966b171b09a7e57acb710fbca29a4b3526f0' into sync-from-ra
2023-12-11 11:16:01 +02:00
Igor Matuszewski
a7224c998d
Don't explicitly warn against semicolon_in_expressions_from_macros
...
This has been warn-by-default for two years now and has already been
added to the future-incompat lints in 1.68.
2023-12-05 11:35:09 +01:00
Laurențiu Nicola
30fc9329d1
Merge commit 'e402c494b7c7d94a37c6d789a216187aaf9ccd3e' into sync-from-ra
2023-12-04 09:19:15 +02:00
Yutaro Ohno
e076192dd8
Improve error handling for top-level let
statements
...
This commit addresses the issue of excessive and unrelated errors
generated by top-level `let` statements. Now, only a single error is
produced, indicating that `let` statements are invalid at the top level.
2023-12-01 10:37:21 +09:00
Chayim Refael Friedman
2fd19ed598
Err for comma after functional update syntax
2023-11-30 14:04:36 +02:00
Laurențiu Nicola
59f5d51852
Merge commit '141fc695dca1df7cfc3c9803972ec19bb178dcbc' into sync-from-ra
2023-11-16 22:27:35 +02:00
Laurențiu Nicola
610eafe009
Merge commit '76633199f4316b9c659d4ec0c102774d693cd940' into sync-from-rust
2023-11-15 09:45:17 +02:00
Gaxx
fa7a91844a
Try to update parser doc
2023-11-08 16:29:21 -08:00
Laurențiu Nicola
d1d111d09e
Merge commit '3b7c7f97e4a7bb253a8d398ee4f8346f6cf2817b' into sync-from-ra
2023-11-08 08:15:03 +02:00
bohan
d20471334f
use visibility to check unused imports and delete some stmts
2023-10-22 21:27:46 +08:00
Pol Valletbó
6845c80a2f
fix: format
2023-10-11 15:52:22 +02:00
Pol Valletbó
4b281ffdf2
chore: format imports
2023-10-11 15:52:05 +02:00
Pol Valletbó
b769f34f63
chore: move common code to function
2023-10-11 15:45:45 +02:00
Pol Valletbó
e1aeb7fa79
fix: handle errors for string byte string and c_string
2023-10-11 15:25:52 +02:00
Pol Valletbó
677e6f3439
fix: use unescape_byte function for Byte literals
2023-10-11 13:09:15 +02:00
Pol Valletbó
f58a8250dc
fix: cargo fmt
2023-10-11 12:36:53 +02:00
Pol Valletbó
1fe6ac87e9
add diagnosis messages for chars and byte literal errors
2023-10-11 12:19:00 +02:00
Lukas Wirth
a382e649ca
Recover better on missing parameter in param list
2023-09-29 12:50:16 +02:00
bors
11ffcc08a3
Auto merge of #15615 - shogo-nakano-desu:refactor/fix-clippy-lints, r=Veykril
...
Refactor/fix clippy lints
As title says.
2023-09-22 06:46:29 +00:00
Laurențiu Nicola
bcfc997eac
Merge commit '258b15c506a2d3ad862fd17ae24eaf272443f477' into sync-from-ra
2023-09-18 12:33:49 +03:00
hkalbasi
f4704bc8ae
Switch to in-tree rustc dependencies with a cfg flag
2023-09-15 18:10:11 +03:30
shogo-nakano-desu
ebbbaaa90f
refactor: fix clippy lints
2023-09-15 16:43:21 +09:00
Lukas Wirth
3fa0bf0dd3
Fix ide-diagnostics test fixture
2023-09-06 18:31:16 +02:00
Lukas Wirth
abe8f1ece4
Implement builtin#format_args, using rustc's format_args parser
2023-09-05 19:19:46 +02:00
Lukas Wirth
3431d586e5
Insert builtin#asm into asm! expansion
2023-09-05 14:00:49 +02:00
Lukas Wirth
15048304e3
Implement offset_of in hir-def and hir-ty
2023-09-05 12:27:52 +02:00
Lukas Wirth
9b8eb807a3
Parse builtin# syntax
2023-09-05 10:36:35 +02:00
Laurențiu Nicola
30d8aa1bec
Merge commit '9b3d03408c66749d56466bb09baf2a7177deb6ce' into sync-from-ra
2023-08-21 12:44:09 +03:00
bors
b771de3fdc
Auto merge of #15179 - ponyii:fix/default-values-of-const-params-are-ignored, r=HKalbasi
...
the "add missing members" assists: implemented substitution of default values of const params
To achieve this, I've made `hir::ConstParamData` store the default values
2023-08-15 10:17:43 +00:00
Lukas Wirth
9ac88d8d36
Fix parser being stuck in eager macro inputs
2023-08-12 08:27:27 +02:00
ponyii
4ebdc6f052
syntax update: the default value of ConstParam
turned from Expr
into ConstArg
2023-08-08 21:57:54 +04:00
Lukas Wirth
cba39f8553
fix: Fix float parser hack creating empty NameRef tokens
2023-08-08 14:44:33 +02:00
Laurențiu Nicola
aa55ce9567
Merge commit 'baee6b338b0ea076cd7a9f18d47f175dd2ba0e5d' into sync-from-ra
2023-08-07 12:03:15 +03:00
Lukas Wirth
042be329a7
Turn unresolved proc macro expansions into missing expressions
2023-08-05 20:00:37 +02:00
Lukas Wirth
bcff166b3a
Add ExternCrateDecl to HIR
2023-08-02 11:52:55 +02:00
Lukas Wirth
7c765d9f9e
fix: Expand eager macros to delimited comma separated expression list
2023-07-30 17:31:26 +02:00
Laurențiu Nicola
0155385b57
Merge commit '99718d0c8bc5aadd993acdcabc1778fc7b5cc572' into sync-from-ra
2023-07-24 12:21:34 +03:00
Laurențiu Nicola
4704881b64
Merge commit '37f84c101bca43b11027f30ab0c2852f9325bc3d' into sync-from-ra
2023-07-17 16:49:15 +03:00
Ryo Yoshida
004971f3f0
Remove crate
visibility modifier
2023-07-16 00:01:11 +09:00
Ryo Yoshida
49b039f1d1
Recover from missing associated items and generic const defaults
2023-07-05 00:24:11 +09:00