Skip to content

Commit cd4da1f

Browse files
committed
Auto merge of #144887 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update Subtree update of `rust-analyzer` to rust-lang/rust-analyzer@8d75311. Created using https://github.com/rust-lang/josh-sync. r? `@ghost`
2 parents 0060d5a + efbe625 commit cd4da1f

File tree

224 files changed

+5513
-4814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+5513
-4814
lines changed

src/tools/rust-analyzer/.github/workflows/rustc-pull.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ jobs:
1111
if: github.repository == 'rust-lang/rust-analyzer'
1212
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main
1313
with:
14+
github-app-id: ${{ vars.APP_CLIENT_ID }}
1415
zulip-stream-id: 185405
1516
zulip-bot-email: "[email protected]"
1617
pr-base-branch: master
1718
branch-name: rustc-pull
1819
secrets:
1920
zulip-api-token: ${{ secrets.ZULIP_API_TOKEN }}
20-
token: ${{ secrets.GITHUB_TOKEN }}
21+
github-app-secret: ${{ secrets.APP_PRIVATE_KEY }}

src/tools/rust-analyzer/Cargo.lock

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ version = "0.2.21"
2323
source = "registry+https://github.com/rust-lang/crates.io-index"
2424
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
2525

26+
[[package]]
27+
name = "anstyle"
28+
version = "1.0.11"
29+
source = "registry+https://github.com/rust-lang/crates.io-index"
30+
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
31+
2632
[[package]]
2733
name = "anyhow"
2834
version = "1.0.98"
@@ -44,6 +50,15 @@ version = "0.7.6"
4450
source = "registry+https://github.com/rust-lang/crates.io-index"
4551
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
4652

53+
[[package]]
54+
name = "atomic-polyfill"
55+
version = "1.0.3"
56+
source = "registry+https://github.com/rust-lang/crates.io-index"
57+
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
58+
dependencies = [
59+
"critical-section",
60+
]
61+
4762
[[package]]
4863
name = "autocfg"
4964
version = "1.4.0"
@@ -119,6 +134,12 @@ version = "0.2.13"
119134
source = "registry+https://github.com/rust-lang/crates.io-index"
120135
checksum = "26c4925bc979b677330a8c7fe7a8c94af2dbb4a2d37b4a20a80d884400f46baa"
121136

137+
[[package]]
138+
name = "byteorder"
139+
version = "1.5.0"
140+
source = "registry+https://github.com/rust-lang/crates.io-index"
141+
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
142+
122143
[[package]]
123144
name = "camino"
124145
version = "1.1.10"
@@ -287,6 +308,40 @@ dependencies = [
287308
"tracing",
288309
]
289310

311+
[[package]]
312+
name = "clap"
313+
version = "4.5.42"
314+
source = "registry+https://github.com/rust-lang/crates.io-index"
315+
checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882"
316+
dependencies = [
317+
"clap_builder",
318+
]
319+
320+
[[package]]
321+
name = "clap_builder"
322+
version = "4.5.42"
323+
source = "registry+https://github.com/rust-lang/crates.io-index"
324+
checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966"
325+
dependencies = [
326+
"anstyle",
327+
"clap_lex",
328+
]
329+
330+
[[package]]
331+
name = "clap_lex"
332+
version = "0.7.5"
333+
source = "registry+https://github.com/rust-lang/crates.io-index"
334+
checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
335+
336+
[[package]]
337+
name = "cobs"
338+
version = "0.3.0"
339+
source = "registry+https://github.com/rust-lang/crates.io-index"
340+
checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
341+
dependencies = [
342+
"thiserror 2.0.12",
343+
]
344+
290345
[[package]]
291346
name = "countme"
292347
version = "3.0.1"
@@ -308,6 +363,12 @@ dependencies = [
308363
"cfg-if",
309364
]
310365

366+
[[package]]
367+
name = "critical-section"
368+
version = "1.2.0"
369+
source = "registry+https://github.com/rust-lang/crates.io-index"
370+
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
371+
311372
[[package]]
312373
name = "crossbeam-channel"
313374
version = "0.5.15"
@@ -565,6 +626,15 @@ version = "0.31.1"
565626
source = "registry+https://github.com/rust-lang/crates.io-index"
566627
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
567628

629+
[[package]]
630+
name = "hash32"
631+
version = "0.2.1"
632+
source = "registry+https://github.com/rust-lang/crates.io-index"
633+
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
634+
dependencies = [
635+
"byteorder",
636+
]
637+
568638
[[package]]
569639
name = "hashbrown"
570640
version = "0.14.5"
@@ -591,6 +661,20 @@ dependencies = [
591661
"hashbrown 0.15.4",
592662
]
593663

664+
[[package]]
665+
name = "heapless"
666+
version = "0.7.17"
667+
source = "registry+https://github.com/rust-lang/crates.io-index"
668+
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
669+
dependencies = [
670+
"atomic-polyfill",
671+
"hash32",
672+
"rustc_version",
673+
"serde",
674+
"spin",
675+
"stable_deref_trait",
676+
]
677+
594678
[[package]]
595679
name = "hermit-abi"
596680
version = "0.5.2"
@@ -1561,6 +1645,17 @@ version = "1.11.1"
15611645
source = "registry+https://github.com/rust-lang/crates.io-index"
15621646
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
15631647

1648+
[[package]]
1649+
name = "postcard"
1650+
version = "1.1.3"
1651+
source = "registry+https://github.com/rust-lang/crates.io-index"
1652+
checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24"
1653+
dependencies = [
1654+
"cobs",
1655+
"heapless",
1656+
"serde",
1657+
]
1658+
15641659
[[package]]
15651660
name = "potential_utf"
15661661
version = "0.1.2"
@@ -1608,13 +1703,16 @@ dependencies = [
16081703
"ra-ap-rustc_lexer 0.123.0",
16091704
"span",
16101705
"syntax-bridge",
1706+
"temp-dir",
16111707
"tt",
16121708
]
16131709

16141710
[[package]]
16151711
name = "proc-macro-srv-cli"
16161712
version = "0.0.0"
16171713
dependencies = [
1714+
"clap",
1715+
"postcard",
16181716
"proc-macro-api",
16191717
"proc-macro-srv",
16201718
"tt",
@@ -1991,6 +2089,15 @@ dependencies = [
19912089
"smallvec",
19922090
]
19932091

2092+
[[package]]
2093+
name = "rustc_version"
2094+
version = "0.4.1"
2095+
source = "registry+https://github.com/rust-lang/crates.io-index"
2096+
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
2097+
dependencies = [
2098+
"semver",
2099+
]
2100+
19942101
[[package]]
19952102
name = "ryu"
19962103
version = "1.0.20"
@@ -2208,6 +2315,15 @@ dependencies = [
22082315
"vfs",
22092316
]
22102317

2318+
[[package]]
2319+
name = "spin"
2320+
version = "0.9.8"
2321+
source = "registry+https://github.com/rust-lang/crates.io-index"
2322+
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
2323+
dependencies = [
2324+
"lock_api",
2325+
]
2326+
22112327
[[package]]
22122328
name = "stable_deref_trait"
22132329
version = "1.2.0"

src/tools/rust-analyzer/crates/base-db/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ impl EditionedFileId {
206206

207207
#[salsa_macros::input(debug)]
208208
pub struct FileText {
209+
#[returns(ref)]
209210
pub text: Arc<str>,
210211
pub file_id: vfs::FileId,
211212
}
@@ -357,7 +358,7 @@ fn parse(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Parse<ast::SourceFil
357358
let _p = tracing::info_span!("parse", ?file_id).entered();
358359
let (file_id, edition) = file_id.unpack(db.as_dyn_database());
359360
let text = db.file_text(file_id).text(db);
360-
ast::SourceFile::parse(&text, edition)
361+
ast::SourceFile::parse(text, edition)
361362
}
362363

363364
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<&[SyntaxError]> {

src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ fn next_cfg_expr<S: Copy>(it: &mut tt::iter::TtIter<'_, S>) -> Option<CfgExpr> {
134134
};
135135

136136
// Eat comma separator
137-
if let Some(TtElement::Leaf(tt::Leaf::Punct(punct))) = it.peek() {
138-
if punct.char == ',' {
139-
it.next();
140-
}
137+
if let Some(TtElement::Leaf(tt::Leaf::Punct(punct))) = it.peek()
138+
&& punct.char == ','
139+
{
140+
it.next();
141141
}
142142
Some(ret)
143143
}

src/tools/rust-analyzer/crates/hir-def/src/attr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,10 @@ fn parse_repr_tt(tt: &crate::tt::TopSubtree) -> Option<ReprOptions> {
377377
let mut align = None;
378378
if let Some(TtElement::Subtree(_, mut tt_iter)) = tts.peek() {
379379
tts.next();
380-
if let Some(TtElement::Leaf(tt::Leaf::Literal(lit))) = tt_iter.next() {
381-
if let Ok(a) = lit.symbol.as_str().parse() {
382-
align = Align::from_bytes(a).ok();
383-
}
380+
if let Some(TtElement::Leaf(tt::Leaf::Literal(lit))) = tt_iter.next()
381+
&& let Ok(a) = lit.symbol.as_str().parse()
382+
{
383+
align = Align::from_bytes(a).ok();
384384
}
385385
}
386386
ReprOptions { align, ..Default::default() }

src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,13 +1487,13 @@ impl ExprCollector<'_> {
14871487
ast::Expr::UnderscoreExpr(_) => self.alloc_pat_from_expr(Pat::Wild, syntax_ptr),
14881488
ast::Expr::ParenExpr(e) => {
14891489
// We special-case `(..)` for consistency with patterns.
1490-
if let Some(ast::Expr::RangeExpr(range)) = e.expr() {
1491-
if range.is_range_full() {
1492-
return Some(self.alloc_pat_from_expr(
1493-
Pat::Tuple { args: Box::default(), ellipsis: Some(0) },
1494-
syntax_ptr,
1495-
));
1496-
}
1490+
if let Some(ast::Expr::RangeExpr(range)) = e.expr()
1491+
&& range.is_range_full()
1492+
{
1493+
return Some(self.alloc_pat_from_expr(
1494+
Pat::Tuple { args: Box::default(), ellipsis: Some(0) },
1495+
syntax_ptr,
1496+
));
14971497
}
14981498
return e.expr().and_then(|expr| self.maybe_collect_expr_as_pat(&expr));
14991499
}
@@ -2569,19 +2569,18 @@ impl ExprCollector<'_> {
25692569
}
25702570
}
25712571
RibKind::MacroDef(macro_id) => {
2572-
if let Some((parent_ctx, label_macro_id)) = hygiene_info {
2573-
if label_macro_id == **macro_id {
2574-
// A macro is allowed to refer to labels from before its declaration.
2575-
// Therefore, if we got to the rib of its declaration, give up its hygiene
2576-
// and use its parent expansion.
2577-
2578-
hygiene_id =
2579-
HygieneId::new(parent_ctx.opaque_and_semitransparent(self.db));
2580-
hygiene_info = parent_ctx.outer_expn(self.db).map(|expansion| {
2581-
let expansion = self.db.lookup_intern_macro_call(expansion.into());
2582-
(parent_ctx.parent(self.db), expansion.def)
2583-
});
2584-
}
2572+
if let Some((parent_ctx, label_macro_id)) = hygiene_info
2573+
&& label_macro_id == **macro_id
2574+
{
2575+
// A macro is allowed to refer to labels from before its declaration.
2576+
// Therefore, if we got to the rib of its declaration, give up its hygiene
2577+
// and use its parent expansion.
2578+
2579+
hygiene_id = HygieneId::new(parent_ctx.opaque_and_semitransparent(self.db));
2580+
hygiene_info = parent_ctx.outer_expn(self.db).map(|expansion| {
2581+
let expansion = self.db.lookup_intern_macro_call(expansion.into());
2582+
(parent_ctx.parent(self.db), expansion.def)
2583+
});
25852584
}
25862585
}
25872586
_ => {}

src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower/asm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ impl ExprCollector<'_> {
259259
}
260260
};
261261

262-
if let Some(operand_idx) = operand_idx {
263-
if let Some(position_span) = to_span(arg.position_span) {
264-
mappings.push((position_span, operand_idx));
265-
}
262+
if let Some(operand_idx) = operand_idx
263+
&& let Some(position_span) = to_span(arg.position_span)
264+
{
265+
mappings.push((position_span, operand_idx));
266266
}
267267
}
268268
}

src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower/path.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,17 @@ pub(super) fn lower_path(
211211
// Basically, even in rustc it is quite hacky:
212212
// https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456
213213
// We follow what it did anyway :)
214-
if segments.len() == 1 && kind == PathKind::Plain {
215-
if let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) {
216-
let syn_ctxt = collector.expander.ctx_for_range(path.segment()?.syntax().text_range());
217-
if let Some(macro_call_id) = syn_ctxt.outer_expn(collector.db) {
218-
if collector.db.lookup_intern_macro_call(macro_call_id.into()).def.local_inner {
219-
kind = match resolve_crate_root(collector.db, syn_ctxt) {
220-
Some(crate_root) => PathKind::DollarCrate(crate_root),
221-
None => PathKind::Crate,
222-
}
223-
}
214+
if segments.len() == 1
215+
&& kind == PathKind::Plain
216+
&& let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast)
217+
{
218+
let syn_ctxt = collector.expander.ctx_for_range(path.segment()?.syntax().text_range());
219+
if let Some(macro_call_id) = syn_ctxt.outer_expn(collector.db)
220+
&& collector.db.lookup_intern_macro_call(macro_call_id.into()).def.local_inner
221+
{
222+
kind = match resolve_crate_root(collector.db, syn_ctxt) {
223+
Some(crate_root) => PathKind::DollarCrate(crate_root),
224+
None => PathKind::Crate,
224225
}
225226
}
226227
}

src/tools/rust-analyzer/crates/hir-def/src/expr_store/pretty.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -900,14 +900,12 @@ impl Printer<'_> {
900900
let field_name = arg.name.display(self.db, edition).to_string();
901901

902902
let mut same_name = false;
903-
if let Pat::Bind { id, subpat: None } = &self.store[arg.pat] {
904-
if let Binding { name, mode: BindingAnnotation::Unannotated, .. } =
903+
if let Pat::Bind { id, subpat: None } = &self.store[arg.pat]
904+
&& let Binding { name, mode: BindingAnnotation::Unannotated, .. } =
905905
&self.store.assert_expr_only().bindings[*id]
906-
{
907-
if name.as_str() == field_name {
908-
same_name = true;
909-
}
910-
}
906+
&& name.as_str() == field_name
907+
{
908+
same_name = true;
911909
}
912910

913911
w!(p, "{}", field_name);

0 commit comments

Comments
 (0)