rust-analyzer/crates/syntax/src
bors c9ee892263 Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril
fix: Properly account for editions in names

This PR touches a lot of parts. But the main changes are changing `hir_expand::Name` to be raw edition-dependently and only when necessary (unrelated to how the user originally wrote the identifier), and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware (this was done in #17896, but the FIXMEs were fixed here).

It is possible that I missed some cases, but most IDE parts should properly escape (or not escape) identifiers now.

The rules of thumb are:

 - If we show the identifier to the user, its rawness should be determined by the edition of the edited crate. This is nice for IDE features, but really important for changes we insert to the source code.
 - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update tests when an edition becomes stable, to avoid churn).
 - For debugging tools (helper methods and logs), I used `Edition::LATEST`.

Reviewing notes:

This is a really big PR but most of it is mechanical translation. I changed `Name` displayers to require an edition, and followed the compiler errors. Most methods just propagate the edition requirement. The interesting cases are mostly in `ide-assists`, as sometimes the correct crate to fetch the edition from requires awareness (there may be two). `ide-completions` and `ide-diagnostics` were solved pretty easily by introducing an edition field to their context. `ide` contains many features, for most of them it was propagated to the top level function and there the edition was fetched based on the file.

I also fixed all FIXMEs from #17896. Some required introducing an edition parameter (usually not for many methods after the changes to `Name`), some were changed to a new method `is_any_identifier()` because they really want any possible keyword.

Fixes #17895.
Fixes #17774.
2024-08-16 13:49:32 +00:00
..
ast Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykril 2024-08-16 07:05:59 +00:00
parsing Fix edition used for include macro parsing 2024-07-19 20:29:53 +02:00
validation Implement unsafe attribute parsing 2024-05-06 12:11:29 +02:00
algo.rs Avoid ref when using format! in compiler 2024-07-19 14:41:59 -04:00
ast.rs HasGenericArgs syntax trait 2024-07-07 11:18:28 +02:00
fuzz.rs internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros 2024-04-14 16:02:38 +02:00
hacks.rs internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros 2024-04-14 16:02:38 +02:00
lib.rs Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
parsing.rs Fix edition used for include macro parsing 2024-07-19 20:29:53 +02:00
ptr.rs internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros 2024-04-14 16:02:38 +02:00
syntax_error.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
syntax_node.rs ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
ted.rs ⬆️ rust-analyzer 2023-01-09 10:36:22 -08:00
tests.rs internal: Remove AbsPathBuf::TryFrom impl that checks too many things at once 2024-08-02 11:08:19 +02:00
token_text.rs Merge commit '457b966b171b09a7e57acb710fbca29a4b3526f0' into sync-from-ra 2023-12-11 11:16:01 +02:00
utils.rs Properly account for editions in names 2024-08-16 16:46:24 +03:00
validation.rs chore: Prefer tracing span shorthand macros 2024-06-06 16:52:25 -07:00