rust-analyzer/crates/hir-def/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
..
body Properly account for editions in names 2024-08-16 16:46:24 +03:00
data Remove unused trace module 2024-07-25 14:08:48 +02:00
dyn_map Try caching macro calls more aggressively 2024-06-04 15:23:00 +02:00
hir Properly account for editions in names 2024-08-16 16:46:24 +03:00
item_tree Properly account for editions in names 2024-08-16 16:46:24 +03:00
macro_expansion_tests internal: Properly check the edition for edition dependent syntax kinds 2024-08-15 15:57:47 +02:00
nameres Properly account for editions in names 2024-08-16 16:46:24 +03:00
path fix: Insert a generic arg for impl Trait when lowering generic args 2024-08-05 00:06:29 +09:00
attr.rs Split out syntax-bridge into a separate crate 2024-08-05 13:45:00 +02:00
body.rs Properly account for editions in names 2024-08-16 16:46:24 +03:00
builtin_type.rs Switch token trees to use Symbols 2024-07-16 10:11:59 +02:00
child_by_source.rs Make GenericParams::lifetimes private 2024-07-02 13:45:53 +02:00
data.rs fix: Correctly support #[rustc_deprecated_safe_2024] 2024-08-12 10:56:59 +02:00
db.rs Auto merge of #17863 - Veykril:include-diags, r=Veykril 2024-08-12 11:48:32 +00:00
dyn_map.rs Merge commit '3b7c7f97e4a7bb253a8d398ee4f8346f6cf2817b' into sync-from-ra 2023-11-08 08:15:03 +02:00
expander.rs Make basic use of spans for macro expansion errors 2024-07-29 14:52:40 +02:00
find_path.rs Properly account for editions in names 2024-08-16 16:46:24 +03:00
generics.rs Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/Lock 2024-08-16 09:53:37 +03:00
hir.rs internal: Shrink size of Binding 2024-07-22 17:14:17 +02:00
import_map.rs Properly account for editions in names 2024-08-16 16:46:24 +03:00
item_scope.rs Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril 2024-08-16 13:49:32 +00:00
item_tree.rs Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril 2024-08-16 13:49:32 +00:00
lang_item.rs More symbol usage 2024-07-16 12:05:16 +02:00
lib.rs fix: Fix find_path not respecting non-std preference config correctly 2024-08-10 10:32:10 +02:00
lower.rs Disallow nested impl traits 2024-07-04 23:31:55 +09:00
nameres.rs Properly account for editions in names 2024-08-16 16:46:24 +03:00
path.rs Properly account for editions in names 2024-08-16 16:46:24 +03:00
per_ns.rs chore: Prefer tracing span shorthand macros 2024-06-06 16:52:25 -07:00
pretty.rs Properly account for editions in names 2024-08-16 16:46:24 +03:00
resolver.rs Fix stable iteration ordering for Map<Name, ...> usages 2024-07-15 11:25:46 +02:00
src.rs Remove unused trace module 2024-07-25 14:08:48 +02:00
test_db.rs Simplify FileDelegate 2024-08-05 13:03:03 +02:00
visibility.rs Intern ModPath within RawVisibility 2024-06-24 10:07:32 +02:00