Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
c1245e1
Add new assist toggle_macro_delimiter
alibektas Aug 1, 2024
662f02f
Make toggle_macro_delimiters work only for macro_calls
alibektas Aug 2, 2024
aa6e8d3
Allow declaring cfg groups in rust-project.json, to help sharing comm…
ChayimFriedman2 Aug 11, 2024
5e058db
docs: Add a doc comment for OpQueue
Wilfred Aug 13, 2024
54ecca0
Auto merge of #17885 - Wilfred:op_queue_docs, r=lnicola
bors Aug 14, 2024
4a14155
Be more resilient to bad language item definitions in binop inference
lnicola Aug 14, 2024
e2f2e73
Auto merge of #17891 - lnicola:binop-bad-lang-items, r=flodiebold
bors Aug 14, 2024
81b68b2
fix: Panic while canonicalizing erroneous projection type
ShoyuVanilla Aug 14, 2024
89cd585
Auto merge of #17882 - ShoyuVanilla:issue-17866, r=lnicola
bors Aug 14, 2024
b0183f8
fix: Panic while displaying associated function with a type annotation
ShoyuVanilla Aug 14, 2024
e20180d
Auto merge of #17893 - ShoyuVanilla:issue-17871, r=flodiebold
bors Aug 15, 2024
6ed283b
rustdoc-json: Add test for `Self` type
aDotInTheVoid Aug 15, 2024
a783e30
internal: Properly check the edition for edition dependent syntax kinds
Veykril Aug 15, 2024
a594a2d
Auto merge of #17896 - Veykril:editioned-syntax-kinds, r=Veykril
bors Aug 15, 2024
bf4d31d
Add scip/lsif flag to exclude vendored libaries
darichey Aug 15, 2024
23c8dcd
Allow flycheck process to exit gracefully
tmandry Aug 15, 2024
642a0f8
Replace once_cell with std's recently stabilized OnceCell/Lock and La…
ChayimFriedman2 Aug 16, 2024
0cbf6a7
Test for word boundary in `FindUsages`
ChayimFriedman2 Aug 16, 2024
b68992a
Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykril
bors Aug 16, 2024
95f5e4b
Auto merge of #17908 - ChayimFriedman2:usages-word-boundaries, r=Veykril
bors Aug 16, 2024
fdd5294
Auto merge of #17903 - tmandry:graceful-exit, r=Veykril
bors Aug 16, 2024
4ca597a
implement basic inferring of lifetimes
dfireBird Jun 29, 2024
2071778
Auto merge of #17595 - dfireBird:infer-lt, r=flodiebold
bors Aug 16, 2024
3d6129d
Properly account for editions in names
ChayimFriedman2 Aug 15, 2024
6908451
Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword,…
bors Aug 16, 2024
995a014
Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidba…
bors Aug 16, 2024
6fc487d
Remove rust-analyzer.workspace.discoverProjectRunner
darichey Aug 16, 2024
01245bd
Auto merge of #17909 - darichey:remove-discoverProjectRunner, r=lnicola
bors Aug 16, 2024
d3fa5e9
Pin `rowan` to `0.15.15`
ShoyuVanilla Aug 17, 2024
d2d41b4
Auto merge of #17917 - ShoyuVanilla:pin-rowan, r=lnicola
bors Aug 17, 2024
c4b8c65
fix: Wrong BoundVar index when lowering impl trait parameter of paren…
ShoyuVanilla Aug 17, 2024
eb12861
Auto merge of #17916 - ShoyuVanilla:issue-17711, r=Veykril
bors Aug 17, 2024
d0ce97f
feat: Make rust-analyzer work partially when missing an internet conn…
Veykril Aug 17, 2024
324cf83
Adress new clippy::large_enum_variant diagnostics
Veykril Aug 17, 2024
51e3775
Auto merge of #17915 - Veykril:offline-no-deps, r=Veykril
bors Aug 17, 2024
74db4d3
Include generics when lowering extern type
darichey Aug 18, 2024
2c18533
Auto merge of #17925 - darichey:issue-17767, r=Veykril
bors Aug 19, 2024
1bfb362
chore(config): remove `invocationLocation` in favor of `invocationStr…
Tyrubias Aug 14, 2024
85f6d15
Auto merge of #17888 - Tyrubias:remove-invocation-location, r=Veykril
bors Aug 19, 2024
036affc
fix: keep comments in convert_while_to_loop
roife Aug 19, 2024
05f5c77
Auto merge of #17928 - roife:fix-issue-17869, r=Veykril
bors Aug 19, 2024
b2062ea
Improve documentation for `InvocationStrategy`
Veykril Aug 19, 2024
f17e9a0
Auto merge of #17929 - Veykril:invocation-loc-docs, r=Veykril
bors Aug 19, 2024
bd6ea75
Remove the ability to configure the user config path
Veykril Aug 19, 2024
879fa66
Allow user config to not exist
Veykril Aug 19, 2024
ea12d79
fix: Panic when a TAIT exists in a RPIT
ShoyuVanilla Aug 18, 2024
f9c0c8a
Auto merge of #17924 - ShoyuVanilla:issue-17921, r=Veykril
bors Aug 19, 2024
f25cb80
ServerStatusParams should consider 'prime caches' in quiescent status
Wilfred Aug 13, 2024
df6ce96
Auto merge of #17886 - Wilfred:prime_caches_quiescent, r=Veykril
bors Aug 19, 2024
a7d15a8
fix: Fix panics for semantic highlighting at startup
Veykril Aug 20, 2024
a9e3555
Auto merge of #17932 - Veykril:default-reply-lat-sensitive, r=Veykril
bors Aug 20, 2024
a42c732
Define workspace level configs.
alibektas Aug 16, 2024
8e31598
Next up : generating configs for workspace level configs
alibektas Aug 16, 2024
1b2eaa5
Old configs are back
alibektas Aug 17, 2024
085aac3
Auto merge of #17930 - Veykril:config-user-config, r=alibektas
bors Aug 20, 2024
9cb66c2
Auto merge of #17913 - alibektas:ratoml_improvements, r=alibektas
bors Aug 20, 2024
94f206a
Run flycheck only on crate if target is binary.
alibektas Aug 20, 2024
3f89eeb
internal: Implement `module_path` macro
Veykril Aug 21, 2024
db2e8e1
fix: Wrong `Sized` predicate for `generic_predicates_for_param`
ShoyuVanilla Aug 21, 2024
614fb24
Auto merge of #17939 - ShoyuVanilla:maybe-sized-fix, r=Veykril
bors Aug 22, 2024
f845536
Remove DescendPreference::SameText
Veykril Aug 22, 2024
d893dcc
Drop MacroInputKind
Veykril Aug 22, 2024
aeb9c7b
Implement floating point casts in const eval
HKalbasi Aug 22, 2024
1179cbb
Remove DescendPreference::SameKind
Veykril Aug 22, 2024
8e82e44
Fully remove old macro descension API
Veykril Aug 22, 2024
4d61444
Rename macro descension functions
Veykril Aug 22, 2024
d79999a
Thread file id through descension API for semantic highlighting
Veykril Aug 22, 2024
b0e7ef4
Sort hover results by relevance
Veykril Aug 22, 2024
f9db48f
Consider interleaving hover kinds
Veykril Aug 22, 2024
06228b9
Auto merge of #17942 - HKalbasi:fp-const-eval, r=HKalbasi
bors Aug 22, 2024
71c7cea
Fix sorting order for tokens in hover
Veykril Aug 22, 2024
81a9956
Auto merge of #17898 - Veykril:descend-2.0, r=Veykril
bors Aug 22, 2024
0a27711
Improve proc-macro panic message and workspace loading failure diagno…
Veykril Aug 22, 2024
1b0e158
Auto merge of #17943 - Veykril:diags, r=Veykril
bors Aug 22, 2024
f65d605
When descending into macros in search, first check if there is a need…
ChayimFriedman2 Aug 16, 2024
a57def2
Speed up search for short associated functions, especially very commo…
ChayimFriedman2 Aug 18, 2024
a44152a
Add cov_marks to test #17927
ChayimFriedman2 Aug 22, 2024
0251cfa
Apply changes
alibektas Aug 22, 2024
b88a4f0
Auto merge of #17912 - alibektas:cargo_check_on_binary, r=Veykril
bors Aug 23, 2024
916c559
Remove incorrect FIXME comment
Veykril Aug 23, 2024
39cc5b6
Auto merge of #17927 - ChayimFriedman2:speedup-new-usages, r=Veykril
bors Aug 23, 2024
ac912c7
Auto merge of #17936 - Veykril:module_path, r=Veykril
bors Aug 23, 2024
5f7489a
internal: Don't requery crates_for for flycheck when crates are known
Veykril Aug 23, 2024
e030cf0
Auto merge of #17946 - Veykril:flycheck-crates-for, r=Veykril
bors Aug 23, 2024
3a097e1
Auto merge of #17857 - ChayimFriedman2:rust-project-cfg-group, r=Veykril
bors Aug 23, 2024
eb896a5
fix: Wrong `Self: Sized` predicate for trait assoc items
ShoyuVanilla Aug 23, 2024
3bd42d3
Auto merge of #17948 - ShoyuVanilla:parent-self-sized, r=Veykril
bors Aug 23, 2024
bdbc057
Include buildfile path in watcher list
Wilfred Aug 23, 2024
a074e1a
Auto merge of #17949 - Wilfred:include_build_file_in_watchers, r=lnicola
bors Aug 24, 2024
12faedd
Fix few bugs in closure capture computation, and add tests
ChayimFriedman2 Aug 24, 2024
77ab568
Preserve all spans for closure captures, not just one
ChayimFriedman2 Aug 24, 2024
cf243e5
Add `gen` modifier to functions
ChayimFriedman2 Aug 22, 2024
1e0df17
Handle associated types that are lang items
ChayimFriedman2 Aug 22, 2024
2c6a521
Provide `Future::Output` and `Iterator` lang items
ChayimFriedman2 Aug 22, 2024
737a969
Add helper methods to retrieve `Future::Output` and `Iterator::Item`
ChayimFriedman2 Aug 22, 2024
7339337
Modify `hacks::parse_expr_from_str()` to take an edition too
ChayimFriedman2 Aug 22, 2024
6340522
Provide `impl From<ast::TypeOrConstParam> for ast::GenericParam`
ChayimFriedman2 Aug 22, 2024
becfc5a
Impl PartialEq and Eq for `IndentLevel`
ChayimFriedman2 Aug 22, 2024
7bd3ca1
Don't enable the search fast path for short associated functions when…
ChayimFriedman2 Aug 25, 2024
cba00a8
Auto merge of #17955 - ChayimFriedman2:fix-fast-search-with-scope, r=…
bors Aug 25, 2024
d9d8d94
fix: Fix metadata retrying eating original errors
Veykril Aug 25, 2024
c223013
Auto merge of #17956 - Veykril:metadata-err, r=Veykril
bors Aug 25, 2024
606401f
fix: Fix trait method completions not acknowledging Deref impls
Veykril Aug 25, 2024
bdee5c9
Auto merge of #17958 - Veykril:deref-chain-method-completions, r=Veykril
bors Aug 25, 2024
2703ea1
fix: add extra_test_bin_args to test explorer test runner
Aug 25, 2024
98e23d3
internal: Don't allocate autoderef steps when not needed
Veykril Aug 25, 2024
31a532a
Auto merge of #17961 - Veykril:autoderef-alloc, r=Veykril
bors Aug 25, 2024
e0b1719
Auto merge of #17960 - duncanawoods:master, r=HKalbasi
bors Aug 25, 2024
326a1c6
Fix Return Type Syntax to include `..` (i.e. `method(..)` and not `me…
ChayimFriedman2 Aug 25, 2024
a3f1196
Auto merge of #17962 - ChayimFriedman2:update-rtn, r=Veykril
bors Aug 26, 2024
239dc5d
Auto merge of #17941 - ChayimFriedman2:pre-closure-to-fn, r=Veykril
bors Aug 26, 2024
9dad25a
Show and render error lifetime args as `'_`
avrong Aug 26, 2024
9d4fdc0
Show lifetime args if there are only error ones
avrong Aug 26, 2024
05e6fb6
Auto merge of #17963 - avrong:avrong/error-lifetimes, r=Veykril
bors Aug 26, 2024
65e9f8b
Fix "Unwrap block" assist with block modifiers
ChayimFriedman2 Aug 26, 2024
c61f85b
Don't make pattern nonterminals match statement nonterminals
compiler-errors Jan 22, 2024
0763a3a
Bump backtrace to rust-lang/backtrace@fc37b22
workingjubilee Aug 27, 2024
65d25fe
Revert "feat: Implement `module_path` macro"
Veykril Aug 27, 2024
f0bfd43
Auto merge of #17972 - rust-lang:revert-17936-module_path, r=Veykril
bors Aug 27, 2024
6593688
Auto merge of #17970 - ChayimFriedman2:unwrap-unsafe-block, r=Veykril
bors Aug 27, 2024
df4580b
Expand proc-macros in workspace root, not package root
Veykril Aug 27, 2024
b592256
Drop Apache license appendices
lnicola Aug 27, 2024
e4c404e
Auto merge of #17973 - Veykril:proc-macro-curr-dir, r=Veykril
bors Aug 27, 2024
2dce250
Auto merge of #17974 - lnicola:rm-apache-appendix, r=lnicola
bors Aug 27, 2024
c9a3b02
Fix tests
Veykril Aug 27, 2024
199c01d
Auto merge of #17757 - alibektas:toggle_macro_delimiters, r=Veykril
bors Aug 27, 2024
34e50f5
Create an assist to convert closure to freestanding fn
ChayimFriedman2 Aug 22, 2024
51055f7
Fix cwd used for proc macro expansion
lnicola Aug 28, 2024
248a557
Auto merge of #17981 - lnicola:proc-macro-cwd, r=Veykril
bors Aug 28, 2024
ae6f8a7
allow BufReader::peek to be called on unsized types
lolbinarycat Aug 28, 2024
4880eee
Fix name resolution of shadowed builtin macro
ChayimFriedman2 Aug 28, 2024
2a7ec0b
Consider all expressions that autoderef in "Extract variable", not ju…
ChayimFriedman2 Aug 28, 2024
fe5f91e
Don't add reference when it isn't needed for the "Extract variable" a…
ChayimFriedman2 Aug 28, 2024
5aefe78
internal: Avoid newlines in fetch workspace errors
Wilfred Aug 28, 2024
3ff3d39
Also handle deref expressions in "Extract variable"
ChayimFriedman2 Aug 28, 2024
b3fcd8e
Consider field attributes when converting from tuple to named struct …
ChayimFriedman2 Aug 28, 2024
c2c1bd0
Fix incorrect symbol definitions in SCIP output
darichey Aug 28, 2024
9200452
Stop using ty::GenericPredicates for non-predicates_of queries
compiler-errors Aug 29, 2024
3a14e30
Auto merge of #17992 - Wilfred:newlines_in_logs, r=Veykril
bors Aug 29, 2024
14ec120
fix: Fix proc-macro server crashing when parsing a non-lexable string…
Veykril Aug 29, 2024
03d6745
fix: Fix TokenStream::to_string implementation dropping quotation marks
Veykril Aug 29, 2024
266bb1f
Auto merge of #17994 - Veykril:proc-macro-srv-from-str-panic, r=Veykril
bors Aug 29, 2024
2ec71c8
Preparing for merge from rust-lang/rust
lnicola Aug 29, 2024
26888c3
Merge from rust-lang/rust
lnicola Aug 29, 2024
f05888d
Auto merge of #17995 - lnicola:sync-from-rust, r=lnicola
bors Aug 29, 2024
b195ff3
Auto merge of #17940 - ChayimFriedman2:closure-to-fn, r=Veykril
bors Aug 29, 2024
e0625d5
Auto merge of #17988 - darichey:fix-scip-def, r=Veykril
bors Aug 29, 2024
b6d0fd0
Auto merge of #17987 - ChayimFriedman2:column-macro, r=Veykril
bors Aug 29, 2024
cd377d9
Auto merge of #17991 - ChayimFriedman2:extract-variable-ref, r=Veykril
bors Aug 29, 2024
34e7e79
Auto merge of #17993 - ChayimFriedman2:convert-to-tuple-attrs, r=Veykril
bors Aug 29, 2024
de34a91
interpret/visitor: make memory order iteration slightly more efficient
RalfJung Aug 29, 2024
8c798c8
Simplify some extern providers
compiler-errors Aug 29, 2024
518b41c
Try latest backtrace
workingjubilee Aug 29, 2024
fa4f892
Remove `Option<!>` return types.
nnethercote Aug 29, 2024
0f29560
Rollup merge of #120221 - compiler-errors:statements-are-not-patterns…
workingjubilee Aug 30, 2024
e411e44
Rollup merge of #129123 - aDotInTheVoid:rustdoc-json-self, r=fmease
workingjubilee Aug 30, 2024
19ccc23
Rollup merge of #129642 - workingjubilee:bump-backtrace-fc37b22, r=wo…
workingjubilee Aug 30, 2024
e3aec4f
Rollup merge of #129675 - lolbinarycat:bufreader_peek_unsized, r=work…
workingjubilee Aug 30, 2024
f88a091
Rollup merge of #129723 - compiler-errors:extern-providers, r=lcnr
workingjubilee Aug 30, 2024
8d3be01
Rollup merge of #129724 - nnethercote:rm-Option-bang, r=fee1-dead
workingjubilee Aug 30, 2024
2baed45
Rollup merge of #129725 - compiler-errors:predicates-of, r=fmease
workingjubilee Aug 30, 2024
a9531e3
Rollup merge of #129733 - lnicola:sync-from-ra, r=lnicola
workingjubilee Aug 30, 2024
1b5c216
Rollup merge of #129751 - RalfJung:interpret-visit-field-order, r=com…
workingjubilee Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
internal: Properly check the edition for edition dependent syntax kinds
  • Loading branch information
Veykril committed Aug 15, 2024
commit a783e30c931a64f4862ab65c104449df846b0c3c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use hir_expand::{
InFile, MacroFileId, MacroFileIdExt,
};
use intern::Symbol;
use span::Span;
use span::{Edition, Span};
use stdx::{format_to, format_to_acc};
use syntax::{
ast::{self, edit::IndentLevel},
Expand Down Expand Up @@ -257,21 +257,25 @@ fn pretty_print_macro_expansion(
(T![;] | T!['{'] | T!['}'], _) => "\n",
(_, T!['}']) => "\n",
(IDENT | LIFETIME_IDENT, IDENT | LIFETIME_IDENT) => " ",
_ if prev_kind.is_keyword() && curr_kind.is_keyword() => " ",
(IDENT, _) if curr_kind.is_keyword() => " ",
(_, IDENT) if prev_kind.is_keyword() => " ",
_ if prev_kind.is_keyword(Edition::CURRENT)
&& curr_kind.is_keyword(Edition::CURRENT) =>
{
" "
}
(IDENT, _) if curr_kind.is_keyword(Edition::CURRENT) => " ",
(_, IDENT) if prev_kind.is_keyword(Edition::CURRENT) => " ",
(T![>], IDENT) => " ",
(T![>], _) if curr_kind.is_keyword() => " ",
(T![>], _) if curr_kind.is_keyword(Edition::CURRENT) => " ",
(T![->], _) | (_, T![->]) => " ",
(T![&&], _) | (_, T![&&]) => " ",
(T![,], _) => " ",
(T![:], IDENT | T!['(']) => " ",
(T![:], _) if curr_kind.is_keyword() => " ",
(T![:], _) if curr_kind.is_keyword(Edition::CURRENT) => " ",
(T![fn], T!['(']) => "",
(T![']'], _) if curr_kind.is_keyword() => " ",
(T![']'], _) if curr_kind.is_keyword(Edition::CURRENT) => " ",
(T![']'], T![#]) => "\n",
(T![Self], T![::]) => "",
_ if prev_kind.is_keyword() => " ",
_ if prev_kind.is_keyword(Edition::CURRENT) => " ",
_ => "",
};

Expand Down
7 changes: 5 additions & 2 deletions src/tools/rust-analyzer/crates/hir-expand/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,17 @@ impl Name {

/// Resolve a name from the text of token.
fn resolve(raw_text: &str) -> Name {
// FIXME: Edition
match raw_text.strip_prefix("r#") {
// When `raw_text` starts with "r#" but the name does not coincide with any
// keyword, we never need the prefix so we strip it.
Some(text) if !is_raw_identifier(text) => Name::new_ref(text),
Some(text) if !is_raw_identifier(text, span::Edition::CURRENT) => Name::new_ref(text),
// Keywords (in the current edition) *can* be used as a name in earlier editions of
// Rust, e.g. "try" in Rust 2015. Even in such cases, we keep track of them in their
// escaped form.
None if is_raw_identifier(raw_text) => Name::new_text(&format!("r#{}", raw_text)),
None if is_raw_identifier(raw_text, span::Edition::CURRENT) => {
Name::new_text(&format!("r#{}", raw_text))
}
_ => Name::new_text(raw_text),
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/tools/rust-analyzer/crates/ide-completion/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ide_db::{
};
use syntax::{
ast::{self, AttrKind, NameOrNameRef},
AstNode, SmolStr,
AstNode, Edition, SmolStr,
SyntaxKind::{self, *},
SyntaxToken, TextRange, TextSize, T,
};
Expand Down Expand Up @@ -468,7 +468,8 @@ impl CompletionContext<'_> {
TextRange::at(self.original_token.text_range().start(), TextSize::from(1))
}
IDENT | LIFETIME_IDENT | UNDERSCORE | INT_NUMBER => self.original_token.text_range(),
_ if kind.is_keyword() => self.original_token.text_range(),
// FIXME: Edition
_ if kind.is_keyword(Edition::CURRENT) => self.original_token.text_range(),
_ => TextRange::empty(self.position.offset),
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Utilities for formatting macro expanded nodes until we get a proper formatter.
use span::Edition;
use syntax::{
ast::make,
ted::{self, Position},
Expand Down Expand Up @@ -131,5 +132,6 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
}

fn is_text(k: SyntaxKind) -> bool {
k.is_keyword() || k.is_literal() || k == IDENT || k == UNDERSCORE
// FIXME: Edition
k.is_keyword(Edition::CURRENT) || k.is_literal() || k == IDENT || k == UNDERSCORE
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Various helper functions to work with SyntaxNodes.
use itertools::Itertools;
use parser::T;
use span::Edition;
use syntax::{
ast::{self, HasLoopBody, MacroCall, PathSegmentKind, VisibilityKind},
AstNode, AstToken, Preorder, RustLanguage, WalkEvent,
Expand Down Expand Up @@ -461,7 +462,8 @@ pub fn parse_tt_as_comma_sep_paths(input: ast::TokenTree) -> Option<Vec<ast::Pat
let tokens =
input.syntax().children_with_tokens().skip(1).map_while(|it| match it.into_token() {
// seeing a keyword means the attribute is unclosed so stop parsing here
Some(tok) if tok.kind().is_keyword() => None,
// FIXME: Edition
Some(tok) if tok.kind().is_keyword(Edition::CURRENT) => None,
// don't include the right token tree parenthesis if it exists
tok @ Some(_) if tok == r_paren => None,
// only nodes that we can find are other TokenTrees, those are unexpected in this parse though
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/ide/src/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ide_db::{
};
use itertools::Itertools;

use span::FileId;
use span::{Edition, FileId};
use syntax::{
ast::{self, HasLoopBody},
match_ast, AstNode, AstToken,
Expand Down Expand Up @@ -55,7 +55,7 @@ pub(crate) fn goto_definition(
| COMMENT => 4,
// index and prefix ops
T!['['] | T![']'] | T![?] | T![*] | T![-] | T![!] => 3,
kind if kind.is_keyword() => 2,
kind if kind.is_keyword(Edition::CURRENT) => 2,
T!['('] | T![')'] => 2,
kind if kind.is_trivia() => 0,
_ => 1,
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/ide/src/highlight_related.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ide_db::{
},
FxHashMap, FxHashSet, RootDatabase,
};
use span::EditionedFileId;
use span::{Edition, EditionedFileId};
use syntax::{
ast::{self, HasLoopBody},
match_ast, AstNode,
Expand Down Expand Up @@ -65,7 +65,7 @@ pub(crate) fn highlight_related(
let token = pick_best_token(syntax.token_at_offset(offset), |kind| match kind {
T![?] => 4, // prefer `?` when the cursor is sandwiched like in `await$0?`
T![->] => 4,
kind if kind.is_keyword() => 3,
kind if kind.is_keyword(Edition::CURRENT) => 3,
IDENT | INT_NUMBER => 2,
T![|] => 1,
_ => 0,
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/ide/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use ide_db::{
FileRange, FxIndexSet, RootDatabase,
};
use itertools::{multizip, Itertools};
use span::Edition;
use syntax::{ast, AstNode, SyntaxKind::*, SyntaxNode, T};

use crate::{
Expand Down Expand Up @@ -140,7 +141,7 @@ fn hover_simple(
| T![_] => 4,
// index and prefix ops and closure pipe
T!['['] | T![']'] | T![?] | T![*] | T![-] | T![!] | T![|] => 3,
kind if kind.is_keyword() => 2,
kind if kind.is_keyword(Edition::CURRENT) => 2,
T!['('] | T![')'] => 2,
kind if kind.is_trivia() => 0,
_ => 1,
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/ide/src/hover/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use rustc_apfloat::{
ieee::{Half as f16, Quad as f128},
Float,
};
use span::Edition;
use stdx::format_to;
use syntax::{algo, ast, match_ast, AstNode, AstToken, Direction, SyntaxToken, T};

Expand Down Expand Up @@ -251,7 +252,7 @@ pub(super) fn keyword(
config: &HoverConfig,
token: &SyntaxToken,
) -> Option<HoverResult> {
if !token.kind().is_keyword() || !config.documentation || !config.keywords {
if !token.kind().is_keyword(Edition::CURRENT) || !config.documentation || !config.keywords {
return None;
}
let parent = token.parent()?;
Expand Down
4 changes: 3 additions & 1 deletion src/tools/rust-analyzer/crates/ide/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use ide_db::{
};
use itertools::Itertools;
use nohash_hasher::IntMap;
use span::Edition;
use syntax::{
ast::{self, HasName},
match_ast, AstNode,
Expand Down Expand Up @@ -305,7 +306,8 @@ fn handle_control_flow_keywords(
FilePosition { file_id, offset }: FilePosition,
) -> Option<ReferenceSearchResult> {
let file = sema.parse_guess_edition(file_id);
let token = file.syntax().token_at_offset(offset).find(|t| t.kind().is_keyword())?;
let token =
file.syntax().token_at_offset(offset).find(|t| t.kind().is_keyword(Edition::CURRENT))?;

let references = match token.kind() {
T![fn] | T![return] | T![try] => highlight_related::highlight_exit_points(sema, token),
Expand Down
12 changes: 7 additions & 5 deletions src/tools/rust-analyzer/crates/ide/src/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use hir::{AsAssocItem, HirFileIdExt, InFile, Semantics};
use ide_db::{
base_db::SourceDatabase,
defs::{Definition, NameClass, NameRefClass},
rename::{bail, format_err, source_edit_from_references, IdentifierKind},
source_change::SourceChangeBuilder,
Expand Down Expand Up @@ -162,11 +163,12 @@ pub(crate) fn will_rename_file(
let sema = Semantics::new(db);
let module = sema.file_to_module_def(file_id)?;
let def = Definition::Module(module);
let mut change = if is_raw_identifier(new_name_stem) {
def.rename(&sema, &SmolStr::from_iter(["r#", new_name_stem])).ok()?
} else {
def.rename(&sema, new_name_stem).ok()?
};
let mut change =
if is_raw_identifier(new_name_stem, db.crate_graph()[module.krate().into()].edition) {
def.rename(&sema, &SmolStr::from_iter(["r#", new_name_stem])).ok()?
} else {
def.rename(&sema, new_name_stem).ok()?
};
change.file_system_edits.clear();
Some(change)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use ide_db::{
defs::{Definition, IdentClass, NameClass, NameRefClass},
FxHashMap, RootDatabase, SymbolKind,
};
use span::Edition;
use stdx::hash_once;
use syntax::{
ast, match_ast, AstNode, AstToken, NodeOrToken,
Expand Down Expand Up @@ -41,7 +42,7 @@ pub(super) fn token(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> O
HlTag::None.into()
}
p if p.is_punct() => punctuation(sema, token, p),
k if k.is_keyword() => keyword(sema, token, k)?,
k if k.is_keyword(Edition::CURRENT) => keyword(sema, token, k)?,
_ => return None,
};
Some(highlight)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Syntax highlighting for macro_rules!.
use span::Edition;
use syntax::{SyntaxKind, SyntaxToken, TextRange, T};

use crate::{HlRange, HlTag};
Expand Down Expand Up @@ -117,7 +118,7 @@ fn update_macro_state(state: &mut MacroMatcherParseState, tok: &SyntaxToken) {

fn is_metavariable(token: &SyntaxToken) -> Option<TextRange> {
match token.kind() {
kind if kind == SyntaxKind::IDENT || kind.is_keyword() => {
kind if kind == SyntaxKind::IDENT || kind.is_keyword(Edition::CURRENT) => {
if let Some(_dollar) = token.prev_token().filter(|t| t.kind() == T![$]) {
return Some(token.text_range());
}
Expand Down
13 changes: 1 addition & 12 deletions src/tools/rust-analyzer/crates/parser/src/lexed_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,8 @@ impl<'a> Converter<'a> {
rustc_lexer::TokenKind::Whitespace => WHITESPACE,

rustc_lexer::TokenKind::Ident if token_text == "_" => UNDERSCORE,
rustc_lexer::TokenKind::Ident
if ["async", "await", "dyn", "try"].contains(&token_text)
&& !self.edition.at_least_2018() =>
{
IDENT
}
rustc_lexer::TokenKind::Ident
if token_text == "gen" && !self.edition.at_least_2024() =>
{
IDENT
}
rustc_lexer::TokenKind::Ident => {
SyntaxKind::from_keyword(token_text).unwrap_or(IDENT)
SyntaxKind::from_keyword(token_text, self.edition).unwrap_or(IDENT)
}
rustc_lexer::TokenKind::InvalidPrefix | rustc_lexer::TokenKind::InvalidIdent => {
err = "Ident contains invalid characters";
Expand Down
10 changes: 4 additions & 6 deletions src/tools/rust-analyzer/crates/parser/src/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ impl LexedStr<'_> {
was_joint = false
} else if kind == SyntaxKind::IDENT {
let token_text = self.text(i);
let contextual_kw = if !edition.at_least_2018() && token_text == "dyn" {
SyntaxKind::DYN_KW
} else {
SyntaxKind::from_contextual_keyword(token_text).unwrap_or(SyntaxKind::IDENT)
};
res.push_ident(contextual_kw);
res.push_ident(
SyntaxKind::from_contextual_keyword(token_text, edition)
.unwrap_or(SyntaxKind::IDENT),
)
} else {
if was_joint {
res.was_joint();
Expand Down
Loading