From 196833ccf2742f0975cd084aac4f354c025638d4 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sat, 19 Jul 2025 13:38:01 +0800 Subject: [PATCH 01/10] Fix ide-assist: Deref transtive --- .../src/handlers/generate_deref.rs | 26 +++++++++++++++++-- .../crates/ide-assists/src/utils.rs | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_deref.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_deref.rs index c7b97dcd231d1..55a09c5d775d2 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_deref.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_deref.rs @@ -10,7 +10,7 @@ use syntax::{ use crate::{ AssistId, assist_context::{AssistContext, Assists, SourceChangeBuilder}, - utils::generate_trait_impl_text, + utils::generate_trait_impl_text_intransitive, }; // Assist: generate_deref @@ -150,7 +150,7 @@ fn generate_edit( ), }; let strukt_adt = ast::Adt::Struct(strukt); - let deref_impl = generate_trait_impl_text( + let deref_impl = generate_trait_impl_text_intransitive( &strukt_adt, &trait_path.display(db, edition).to_string(), &impl_code, @@ -227,6 +227,28 @@ impl core::ops::Deref for B { ); } + #[test] + fn test_generate_record_deref_with_generic() { + check_assist( + generate_deref, + r#" +//- minicore: deref +struct A($0T); +"#, + r#" +struct A(T); + +impl core::ops::Deref for A { + type Target = T; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} +"#, + ); + } + #[test] fn test_generate_record_deref_short_path() { check_assist( diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs b/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs index b1606fb7ba741..a302964e17bcd 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs @@ -567,6 +567,7 @@ pub(crate) fn generate_impl_text(adt: &ast::Adt, code: &str) -> String { /// /// This is useful for traits like `PartialEq`, since `impl PartialEq for U` often requires `T: PartialEq`. // FIXME: migrate remaining uses to `generate_trait_impl` +#[allow(dead_code)] pub(crate) fn generate_trait_impl_text(adt: &ast::Adt, trait_text: &str, code: &str) -> String { generate_impl_text_inner(adt, Some(trait_text), true, code) } From 54d974324c9770b9368194ca3c916fb5a5b6c9a4 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sat, 19 Jul 2025 15:00:54 +0800 Subject: [PATCH 02/10] Add Deref -> DerefMut for generate_mut_trait_impl --- .../src/handlers/generate_mut_trait_impl.rs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs index 4ddab2cfad006..dc26ec79a74eb 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs @@ -134,6 +134,9 @@ fn get_trait_mut(apply_trait: &hir::Trait, famous: FamousDefs<'_, '_>) -> Option if trait_ == famous.core_borrow_Borrow().as_ref() { return Some("BorrowMut"); } + if trait_ == famous.core_ops_Deref().as_ref() { + return Some("DerefMut"); + } None } @@ -142,6 +145,7 @@ fn process_method_name(name: ast::Name) -> Option<(ast::Name, &'static str)> { "index" => "index_mut", "as_ref" => "as_mut", "borrow" => "borrow_mut", + "deref" => "deref_mut", _ => return None, }; Some((name, new_name)) @@ -258,6 +262,39 @@ impl core::convert::AsRef for Foo { &self.0 } } +"#, + ); + + check_assist( + generate_mut_trait_impl, + r#" +//- minicore: deref +struct Foo(i32); + +impl core::ops::Deref$0 for Foo { + type Target = i32; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} +"#, + r#" +struct Foo(i32); + +$0impl core::ops::DerefMut for Foo { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl core::ops::Deref for Foo { + type Target = i32; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} "#, ); } From 2f46cde9a4d23c60a3e79680f917da664064c4e1 Mon Sep 17 00:00:00 2001 From: Young-Flash Date: Sat, 19 Jul 2025 16:19:20 +0800 Subject: [PATCH 03/10] minor: remove unused var --- src/tools/rust-analyzer/crates/ide/src/folding_ranges.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide/src/folding_ranges.rs b/src/tools/rust-analyzer/crates/ide/src/folding_ranges.rs index c081796d078c8..698fd147789f5 100755 --- a/src/tools/rust-analyzer/crates/ide/src/folding_ranges.rs +++ b/src/tools/rust-analyzer/crates/ide/src/folding_ranges.rs @@ -48,7 +48,6 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec { let mut res = vec![]; let mut visited_comments = FxHashSet::default(); let mut visited_nodes = FxHashSet::default(); - let mut merged_fn_bodies = FxHashSet::default(); // regions can be nested, here is a LIFO buffer let mut region_starts: Vec = vec![]; @@ -73,7 +72,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec { continue; } - if let Some(body) = fn_node.body() { + if fn_node.body().is_some() { res.push(Fold { range: TextRange::new( node.text_range().start(), @@ -81,7 +80,6 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec { ), kind: FoldKind::Function, }); - merged_fn_bodies.insert(body.syntax().text_range()); continue; } } From a6c7ceaae3a918caf7b2e4443441e781405af926 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Sun, 20 Jul 2025 01:20:09 +0300 Subject: [PATCH 04/10] Fix search of raw labels and lifetimes It used to search for `'foo` which won't find `'r#foo`, now we search for `foo` instead. --- .../rust-analyzer/crates/ide-db/src/search.rs | 9 ++++- .../crates/ide/src/references.rs | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-db/src/search.rs b/src/tools/rust-analyzer/crates/ide-db/src/search.rs index 4efb83ba3235a..9cf0bcf919011 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/search.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/search.rs @@ -531,7 +531,7 @@ impl<'a> FindUsages<'a> { node.token_at_offset(offset) .find(|it| { // `name` is stripped of raw ident prefix. See the comment on name retrieval below. - it.text().trim_start_matches("r#") == name + it.text().trim_start_matches('\'').trim_start_matches("r#") == name }) .into_iter() .flat_map(move |token| { @@ -938,7 +938,12 @@ impl<'a> FindUsages<'a> { }) }; // We need to search without the `r#`, hence `as_str` access. - self.def.name(sema.db).or_else(self_kw_refs).map(|it| it.as_str().to_smolstr()) + // We strip `'` from lifetimes and labels as otherwise they may not match with raw-escaped ones, + // e.g. if we search `'foo` we won't find `'r#foo`. + self.def + .name(sema.db) + .or_else(self_kw_refs) + .map(|it| it.as_str().trim_start_matches('\'').to_smolstr()) } }; let name = match &name { diff --git a/src/tools/rust-analyzer/crates/ide/src/references.rs b/src/tools/rust-analyzer/crates/ide/src/references.rs index fe874bc99b407..86b88a17c75fc 100644 --- a/src/tools/rust-analyzer/crates/ide/src/references.rs +++ b/src/tools/rust-analyzer/crates/ide/src/references.rs @@ -3088,4 +3088,42 @@ fn main() { "#]], ); } + + #[test] + fn raw_labels_and_lifetimes() { + check( + r#" +fn foo<'r#fn>(s: &'r#fn str) { + let _a: &'r#fn str = s; + let _b: &'r#fn str; + 'r#break$0: { + break 'r#break; + } +} + "#, + expect![[r#" + 'r#break Label FileId(0) 87..96 87..95 + + FileId(0) 113..121 + "#]], + ); + check( + r#" +fn foo<'r#fn$0>(s: &'r#fn str) { + let _a: &'r#fn str = s; + let _b: &'r#fn str; + 'r#break: { + break 'r#break; + } +} + "#, + expect![[r#" + 'r#fn LifetimeParam FileId(0) 7..12 + + FileId(0) 18..23 + FileId(0) 44..49 + FileId(0) 72..77 + "#]], + ); + } } From 8b6559b05b5c9c94888b6db2bc89b3da975578c5 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Sun, 20 Jul 2025 11:56:45 +0300 Subject: [PATCH 05/10] Support `cfg_select!` --- .../rust-analyzer/crates/cfg/src/cfg_expr.rs | 14 +++- .../macro_expansion_tests/builtin_fn_macro.rs | 48 ++++++++++++++ .../crates/hir-expand/src/builtin/fn_macro.rs | 66 +++++++++++++++++++ .../crates/intern/src/symbol/symbols.rs | 1 + src/tools/rust-analyzer/crates/tt/src/iter.rs | 11 ++++ 5 files changed, 139 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs b/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs index 0ec082dfa7fcb..aed00aa9fc447 100644 --- a/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs +++ b/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs @@ -68,6 +68,11 @@ impl CfgExpr { next_cfg_expr(&mut tt.iter()).unwrap_or(CfgExpr::Invalid) } + #[cfg(feature = "tt")] + pub fn parse_from_iter(tt: &mut tt::iter::TtIter<'_, S>) -> CfgExpr { + next_cfg_expr(tt).unwrap_or(CfgExpr::Invalid) + } + /// Fold the cfg by querying all basic `Atom` and `KeyValue` predicates. pub fn fold(&self, query: &dyn Fn(&CfgAtom) -> bool) -> Option { match self { @@ -96,7 +101,14 @@ fn next_cfg_expr(it: &mut tt::iter::TtIter<'_, S>) -> Option { }; let ret = match it.peek() { - Some(TtElement::Leaf(tt::Leaf::Punct(punct))) if punct.char == '=' => { + Some(TtElement::Leaf(tt::Leaf::Punct(punct))) + // Don't consume on e.g. `=>`. + if punct.char == '=' + && (punct.spacing == tt::Spacing::Alone + || it.remaining().flat_tokens().get(1).is_none_or(|peek2| { + !matches!(peek2, tt::TokenTree::Leaf(tt::Leaf::Punct(_))) + })) => + { match it.remaining().flat_tokens().get(1) { Some(tt::TokenTree::Leaf(tt::Leaf::Literal(literal))) => { it.next(); diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs index 1c3af47d522c5..eeaf865338bd6 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs @@ -550,3 +550,51 @@ fn main() { "\"hello\""; } "##]], ); } + +#[test] +fn cfg_select() { + check( + r#" +#[rustc_builtin_macro] +pub macro cfg_select($($tt:tt)*) {} + +cfg_select! { + false => { fn false_1() {} } + any(false, true) => { fn true_1() {} } +} + +cfg_select! { + false => { fn false_2() {} } + _ => { fn true_2() {} } +} + +cfg_select! { + false => { fn false_3() {} } +} + +cfg_select! { + false +} + +cfg_select! { + false => +} + + "#, + expect![[r#" +#[rustc_builtin_macro] +pub macro cfg_select($($tt:tt)*) {} + +fn true_1() {} + +fn true_2() {} + +/* error: none of the predicates in this `cfg_select` evaluated to true */ + +/* error: expected `=>` after cfg expression */ + +/* error: expected a token tree after `=>` */ + + "#]], + ); +} diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs b/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs index 60fbc660652f5..4a9af01091f2e 100644 --- a/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs +++ b/src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs @@ -127,6 +127,7 @@ register_builtin! { (asm, Asm) => asm_expand, (global_asm, GlobalAsm) => global_asm_expand, (naked_asm, NakedAsm) => naked_asm_expand, + (cfg_select, CfgSelect) => cfg_select_expand, (cfg, Cfg) => cfg_expand, (core_panic, CorePanic) => panic_expand, (std_panic, StdPanic) => panic_expand, @@ -355,6 +356,71 @@ fn naked_asm_expand( ExpandResult::ok(expanded) } +fn cfg_select_expand( + db: &dyn ExpandDatabase, + id: MacroCallId, + tt: &tt::TopSubtree, + span: Span, +) -> ExpandResult { + let loc = db.lookup_intern_macro_call(id); + let cfg_options = loc.krate.cfg_options(db); + + let mut iter = tt.iter(); + let mut expand_to = None; + while let Some(next) = iter.peek() { + let active = if let tt::TtElement::Leaf(tt::Leaf::Ident(ident)) = next + && ident.sym == sym::underscore + { + iter.next(); + true + } else { + cfg_options.check(&CfgExpr::parse_from_iter(&mut iter)) != Some(false) + }; + match iter.expect_glued_punct() { + Ok(it) if it.len() == 2 && it[0].char == '=' && it[1].char == '>' => {} + _ => { + let err_span = iter.peek().map(|it| it.first_span()).unwrap_or(span); + return ExpandResult::new( + tt::TopSubtree::empty(tt::DelimSpan::from_single(span)), + ExpandError::other(err_span, "expected `=>` after cfg expression"), + ); + } + } + let expand_to_if_active = match iter.next() { + Some(tt::TtElement::Subtree(_, tt)) => tt.remaining(), + _ => { + let err_span = iter.peek().map(|it| it.first_span()).unwrap_or(span); + return ExpandResult::new( + tt::TopSubtree::empty(tt::DelimSpan::from_single(span)), + ExpandError::other(err_span, "expected a token tree after `=>`"), + ); + } + }; + + if expand_to.is_none() && active { + expand_to = Some(expand_to_if_active); + } + } + match expand_to { + Some(expand_to) => { + let mut builder = tt::TopSubtreeBuilder::new(tt::Delimiter { + kind: tt::DelimiterKind::Invisible, + open: span, + close: span, + }); + builder.extend_with_tt(expand_to); + ExpandResult::ok(builder.build()) + } + None => ExpandResult::new( + tt::TopSubtree::empty(tt::DelimSpan::from_single(span)), + ExpandError::other( + span, + "none of the predicates in this `cfg_select` evaluated to true", + ), + ), + } +} + fn cfg_expand( db: &dyn ExpandDatabase, id: MacroCallId, diff --git a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs index 1ccd20c25e906..4780743c4d92a 100644 --- a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs +++ b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs @@ -156,6 +156,7 @@ define_symbols! { cfg_attr, cfg_eval, cfg, + cfg_select, char, clone, Clone, diff --git a/src/tools/rust-analyzer/crates/tt/src/iter.rs b/src/tools/rust-analyzer/crates/tt/src/iter.rs index 3246156f1cb76..2e89d762a0e40 100644 --- a/src/tools/rust-analyzer/crates/tt/src/iter.rs +++ b/src/tools/rust-analyzer/crates/tt/src/iter.rs @@ -217,6 +217,17 @@ pub enum TtElement<'a, S> { Subtree(&'a Subtree, TtIter<'a, S>), } +impl fmt::Debug for TtElement<'_, S> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Leaf(leaf) => f.debug_tuple("Leaf").field(leaf).finish(), + Self::Subtree(subtree, inner) => { + f.debug_tuple("Subtree").field(subtree).field(inner).finish() + } + } + } +} + impl TtElement<'_, S> { #[inline] pub fn first_span(&self) -> S { From 750c1e9c39633de1242acf086ef1c053961219b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 21 Jul 2025 09:17:54 +0300 Subject: [PATCH 06/10] Preparing for merge from rust-lang/rust --- src/tools/rust-analyzer/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/rust-version b/src/tools/rust-analyzer/rust-version index 57ff326ce5a26..c2b1c151b834a 100644 --- a/src/tools/rust-analyzer/rust-version +++ b/src/tools/rust-analyzer/rust-version @@ -1 +1 @@ -a9fb6103b05c6ad6eee6bed4c0bb5a2e8e1024c6 +e05ab47e6c418fb2b9faa2eae9a7e70c65c98eaa From 1482809fc16f11ecedb92e688922cf52a2441ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 21 Jul 2025 09:19:24 +0300 Subject: [PATCH 07/10] Bump rustc crates --- src/tools/rust-analyzer/Cargo.lock | 40 +++++++++++++++++------------- src/tools/rust-analyzer/Cargo.toml | 10 ++++---- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index e55cd80943df5..f3adc4006acf4 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -1505,7 +1505,7 @@ dependencies = [ "edition", "expect-test", "ra-ap-rustc_lexer", - "rustc-literal-escaper", + "rustc-literal-escaper 0.0.4", "stdx", "tracing", ] @@ -1756,9 +1756,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_abi" -version = "0.121.0" +version = "0.122.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee51482d1c9d3e538acda8cce723db8eea1a81540544bf362bf4c3d841b2329" +checksum = "fb01e1fec578003c85481c1cad4ff8cd8195b07c2dc85ae3f716108507ae15d5" dependencies = [ "bitflags 2.9.1", "ra-ap-rustc_hashes", @@ -1768,18 +1768,18 @@ dependencies = [ [[package]] name = "ra-ap-rustc_hashes" -version = "0.121.0" +version = "0.122.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19c8f1e0c28e24e1b4c55dc08058c6c9829df2204497d4034259f491d348c204" +checksum = "e0ec056e72a472ffef8761ce96ece6c626eb07368c09d0105b6df30d27d07673" dependencies = [ "rustc-stable-hash", ] [[package]] name = "ra-ap-rustc_index" -version = "0.121.0" +version = "0.122.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33f429cec6b92fa2c7243883279fb29dd233fdc3e94099aff32aa91aa87f50" +checksum = "0fcdd1001db0295e59052e9f53aeda588bbe81e362534f4687d41bd44777b5a7" dependencies = [ "ra-ap-rustc_index_macros", "smallvec", @@ -1787,9 +1787,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_index_macros" -version = "0.121.0" +version = "0.122.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b55910dbe1fe7ef34bdc1d1bcb41e99b377eb680ea58a1218d95d6b4152257" +checksum = "728d64dd98e25530b32e3f7c7c1e844e52722b269360daa1cdeba9dff9727a26" dependencies = [ "proc-macro2", "quote", @@ -1798,9 +1798,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_lexer" -version = "0.121.0" +version = "0.122.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22944e31fb91e9b3e75bcbc91e37d958b8c0825a6160927f2856831d2ce83b36" +checksum = "415f0821f512608d825b3215489a6a6a2c18ed9f0045953d514e7ec23d4b90ab" dependencies = [ "memchr", "unicode-properties", @@ -1809,19 +1809,19 @@ dependencies = [ [[package]] name = "ra-ap-rustc_parse_format" -version = "0.121.0" +version = "0.122.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81057891bc2063ad9e353f29462fbc47a0f5072560af34428ae9313aaa5e9d97" +checksum = "18d2c4b48fa26e031b1cca0c8ca7433770f5e35e33da56da8636dae2cd45d4e1" dependencies = [ "ra-ap-rustc_lexer", - "rustc-literal-escaper", + "rustc-literal-escaper 0.0.5", ] [[package]] name = "ra-ap-rustc_pattern_analysis" -version = "0.121.0" +version = "0.122.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe21a3542980d56d2435e96c2720773cac1c63fd4db666417e414729da192eb3" +checksum = "4657fcfdfe06e2a02ec8180d4e7c95aecf4811ba50367e363d1a2300b7623284" dependencies = [ "ra-ap-rustc_index", "rustc-hash 2.1.1", @@ -1972,6 +1972,12 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab03008eb631b703dd16978282ae36c73282e7922fe101a4bd072a40ecea7b8b" +[[package]] +name = "rustc-literal-escaper" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ee29da77c5a54f42697493cd4c9b9f31b74df666a6c04dfc4fde77abe0438b" + [[package]] name = "rustc-stable-hash" version = "0.1.2" @@ -2259,7 +2265,7 @@ dependencies = [ "rayon", "rowan", "rustc-hash 2.1.1", - "rustc-literal-escaper", + "rustc-literal-escaper 0.0.4", "rustc_apfloat", "smol_str", "stdx", diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml index 41fa06a76a7bd..b21ac158d8e7e 100644 --- a/src/tools/rust-analyzer/Cargo.toml +++ b/src/tools/rust-analyzer/Cargo.toml @@ -89,11 +89,11 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" } vfs = { path = "./crates/vfs", version = "0.0.0" } edition = { path = "./crates/edition", version = "0.0.0" } -ra-ap-rustc_lexer = { version = "0.121", default-features = false } -ra-ap-rustc_parse_format = { version = "0.121", default-features = false } -ra-ap-rustc_index = { version = "0.121", default-features = false } -ra-ap-rustc_abi = { version = "0.121", default-features = false } -ra-ap-rustc_pattern_analysis = { version = "0.121", default-features = false } +ra-ap-rustc_lexer = { version = "0.122", default-features = false } +ra-ap-rustc_parse_format = { version = "0.122", default-features = false } +ra-ap-rustc_index = { version = "0.122", default-features = false } +ra-ap-rustc_abi = { version = "0.122", default-features = false } +ra-ap-rustc_pattern_analysis = { version = "0.122", default-features = false } # local crates that aren't published to crates.io. These should not have versions. From f2633640d6e4dbc544b7c722bcda491a8f564285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 21 Jul 2025 09:27:37 +0300 Subject: [PATCH 08/10] Bump rustc-literal-escaper --- src/tools/rust-analyzer/Cargo.lock | 12 +++--------- src/tools/rust-analyzer/Cargo.toml | 2 +- .../rust-analyzer/crates/syntax/src/ast/token_ext.rs | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index f3adc4006acf4..711d032246446 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -1505,7 +1505,7 @@ dependencies = [ "edition", "expect-test", "ra-ap-rustc_lexer", - "rustc-literal-escaper 0.0.4", + "rustc-literal-escaper", "stdx", "tracing", ] @@ -1814,7 +1814,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18d2c4b48fa26e031b1cca0c8ca7433770f5e35e33da56da8636dae2cd45d4e1" dependencies = [ "ra-ap-rustc_lexer", - "rustc-literal-escaper 0.0.5", + "rustc-literal-escaper", ] [[package]] @@ -1966,12 +1966,6 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" -[[package]] -name = "rustc-literal-escaper" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab03008eb631b703dd16978282ae36c73282e7922fe101a4bd072a40ecea7b8b" - [[package]] name = "rustc-literal-escaper" version = "0.0.5" @@ -2265,7 +2259,7 @@ dependencies = [ "rayon", "rowan", "rustc-hash 2.1.1", - "rustc-literal-escaper 0.0.4", + "rustc-literal-escaper", "rustc_apfloat", "smol_str", "stdx", diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml index b21ac158d8e7e..1ca258abf4b47 100644 --- a/src/tools/rust-analyzer/Cargo.toml +++ b/src/tools/rust-analyzer/Cargo.toml @@ -149,7 +149,7 @@ serde = { version = "1.0.219" } serde_derive = { version = "1.0.219" } serde_json = "1.0.140" rustc-hash = "2.1.1" -rustc-literal-escaper = "0.0.4" +rustc-literal-escaper = "0.0.5" smallvec = { version = "1.15.1", features = [ "const_new", "union", diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs index 4afdda78a0e70..742c452616ef3 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs @@ -309,8 +309,8 @@ impl ast::CString { let mut prev_end = 0; let mut has_error = None; let extend_unit = |buf: &mut Vec, unit: MixedUnit| match unit { - MixedUnit::Char(c) => buf.extend(c.encode_utf8(&mut [0; 4]).as_bytes()), - MixedUnit::HighByte(b) => buf.push(b), + MixedUnit::Char(c) => buf.extend(c.get().encode_utf8(&mut [0; 4]).as_bytes()), + MixedUnit::HighByte(b) => buf.push(b.get()), }; unescape_c_str(text, |char_range, unescaped| match (unescaped, buf.capacity() == 0) { (Ok(u), false) => extend_unit(&mut buf, u), From 2050358679088b319cde837f9c6e9d9e58249503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 21 Jul 2025 09:31:28 +0300 Subject: [PATCH 09/10] Revert "Bump rustc-literal-escaper" This reverts commit 9f3adc540b51a4c2d0472d94033f6d9147b36f6e. --- src/tools/rust-analyzer/Cargo.lock | 12 +++++++++--- src/tools/rust-analyzer/Cargo.toml | 2 +- .../rust-analyzer/crates/syntax/src/ast/token_ext.rs | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index 711d032246446..f3adc4006acf4 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -1505,7 +1505,7 @@ dependencies = [ "edition", "expect-test", "ra-ap-rustc_lexer", - "rustc-literal-escaper", + "rustc-literal-escaper 0.0.4", "stdx", "tracing", ] @@ -1814,7 +1814,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18d2c4b48fa26e031b1cca0c8ca7433770f5e35e33da56da8636dae2cd45d4e1" dependencies = [ "ra-ap-rustc_lexer", - "rustc-literal-escaper", + "rustc-literal-escaper 0.0.5", ] [[package]] @@ -1966,6 +1966,12 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +[[package]] +name = "rustc-literal-escaper" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab03008eb631b703dd16978282ae36c73282e7922fe101a4bd072a40ecea7b8b" + [[package]] name = "rustc-literal-escaper" version = "0.0.5" @@ -2259,7 +2265,7 @@ dependencies = [ "rayon", "rowan", "rustc-hash 2.1.1", - "rustc-literal-escaper", + "rustc-literal-escaper 0.0.4", "rustc_apfloat", "smol_str", "stdx", diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml index 1ca258abf4b47..b21ac158d8e7e 100644 --- a/src/tools/rust-analyzer/Cargo.toml +++ b/src/tools/rust-analyzer/Cargo.toml @@ -149,7 +149,7 @@ serde = { version = "1.0.219" } serde_derive = { version = "1.0.219" } serde_json = "1.0.140" rustc-hash = "2.1.1" -rustc-literal-escaper = "0.0.5" +rustc-literal-escaper = "0.0.4" smallvec = { version = "1.15.1", features = [ "const_new", "union", diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs index 742c452616ef3..4afdda78a0e70 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/token_ext.rs @@ -309,8 +309,8 @@ impl ast::CString { let mut prev_end = 0; let mut has_error = None; let extend_unit = |buf: &mut Vec, unit: MixedUnit| match unit { - MixedUnit::Char(c) => buf.extend(c.get().encode_utf8(&mut [0; 4]).as_bytes()), - MixedUnit::HighByte(b) => buf.push(b.get()), + MixedUnit::Char(c) => buf.extend(c.encode_utf8(&mut [0; 4]).as_bytes()), + MixedUnit::HighByte(b) => buf.push(b), }; unescape_c_str(text, |char_range, unescaped| match (unescaped, buf.capacity() == 0) { (Ok(u), false) => extend_unit(&mut buf, u), From da90db796d0cf39658eac0074c63e5e9ffec2ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 21 Jul 2025 09:36:14 +0300 Subject: [PATCH 10/10] Downgrade ra-ap-rustc_parse_format --- src/tools/rust-analyzer/Cargo.lock | 37 +++++++++++++++++------------- src/tools/rust-analyzer/Cargo.toml | 2 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index f3adc4006acf4..c471234bbe3a5 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -1268,7 +1268,7 @@ dependencies = [ "expect-test", "intern", "parser", - "ra-ap-rustc_lexer", + "ra-ap-rustc_lexer 0.122.0", "rustc-hash 2.1.1", "smallvec", "span", @@ -1504,8 +1504,8 @@ dependencies = [ "drop_bomb", "edition", "expect-test", - "ra-ap-rustc_lexer", - "rustc-literal-escaper 0.0.4", + "ra-ap-rustc_lexer 0.122.0", + "rustc-literal-escaper", "stdx", "tracing", ] @@ -1614,7 +1614,7 @@ dependencies = [ "object", "paths", "proc-macro-test", - "ra-ap-rustc_lexer", + "ra-ap-rustc_lexer 0.122.0", "span", "syntax-bridge", "tt", @@ -1796,6 +1796,17 @@ dependencies = [ "syn", ] +[[package]] +name = "ra-ap-rustc_lexer" +version = "0.121.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22944e31fb91e9b3e75bcbc91e37d958b8c0825a6160927f2856831d2ce83b36" +dependencies = [ + "memchr", + "unicode-properties", + "unicode-xid", +] + [[package]] name = "ra-ap-rustc_lexer" version = "0.122.0" @@ -1809,12 +1820,12 @@ dependencies = [ [[package]] name = "ra-ap-rustc_parse_format" -version = "0.122.0" +version = "0.121.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d2c4b48fa26e031b1cca0c8ca7433770f5e35e33da56da8636dae2cd45d4e1" +checksum = "81057891bc2063ad9e353f29462fbc47a0f5072560af34428ae9313aaa5e9d97" dependencies = [ - "ra-ap-rustc_lexer", - "rustc-literal-escaper 0.0.5", + "ra-ap-rustc_lexer 0.121.0", + "rustc-literal-escaper", ] [[package]] @@ -1972,12 +1983,6 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab03008eb631b703dd16978282ae36c73282e7922fe101a4bd072a40ecea7b8b" -[[package]] -name = "rustc-literal-escaper" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ee29da77c5a54f42697493cd4c9b9f31b74df666a6c04dfc4fde77abe0438b" - [[package]] name = "rustc-stable-hash" version = "0.1.2" @@ -2265,7 +2270,7 @@ dependencies = [ "rayon", "rowan", "rustc-hash 2.1.1", - "rustc-literal-escaper 0.0.4", + "rustc-literal-escaper", "rustc_apfloat", "smol_str", "stdx", @@ -2587,7 +2592,7 @@ version = "0.0.0" dependencies = [ "arrayvec", "intern", - "ra-ap-rustc_lexer", + "ra-ap-rustc_lexer 0.122.0", "stdx", "text-size", ] diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml index b21ac158d8e7e..700c116ec1828 100644 --- a/src/tools/rust-analyzer/Cargo.toml +++ b/src/tools/rust-analyzer/Cargo.toml @@ -90,7 +90,7 @@ vfs = { path = "./crates/vfs", version = "0.0.0" } edition = { path = "./crates/edition", version = "0.0.0" } ra-ap-rustc_lexer = { version = "0.122", default-features = false } -ra-ap-rustc_parse_format = { version = "0.122", default-features = false } +ra-ap-rustc_parse_format = { version = "0.121", default-features = false } ra-ap-rustc_index = { version = "0.122", default-features = false } ra-ap-rustc_abi = { version = "0.122", default-features = false } ra-ap-rustc_pattern_analysis = { version = "0.122", default-features = false }