Skip to content

Commit a9ac6de

Browse files
authored
Unrolled build for #143246
Rollup merge of #143246 - lnicola:sync-from-ra, r=lnicola Subtree update of `rust-analyzer` r? ``@ghost``
2 parents f26e580 + c5f4b80 commit a9ac6de

File tree

149 files changed

+2252
-848
lines changed

Some content is hidden

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

149 files changed

+2252
-848
lines changed

src/tools/rust-analyzer/.github/workflows/ci.yaml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ env:
1717
RUST_BACKTRACE: short
1818
RUSTUP_MAX_RETRIES: 10
1919

20+
defaults:
21+
run:
22+
shell: bash
23+
2024
jobs:
2125
changes:
2226
runs-on: ubuntu-latest
@@ -80,6 +84,7 @@ jobs:
8084
CC: deny_c
8185

8286
strategy:
87+
fail-fast: false
8388
matrix:
8489
os: [ubuntu-latest, windows-latest, macos-latest]
8590

@@ -99,7 +104,7 @@ jobs:
99104
rustup toolchain install nightly --profile minimal --component rustfmt
100105
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json
101106
- name: Install Rust Problem Matcher
102-
if: matrix.os == 'ubuntu-latest'
107+
if: matrix.os == 'macos-latest'
103108
run: echo "::add-matcher::.github/rust.json"
104109

105110
# - name: Cache Dependencies
@@ -116,23 +121,9 @@ jobs:
116121
if: matrix.os == 'ubuntu-latest'
117122
run: cargo codegen --check
118123

119-
- name: Compile tests
120-
run: cargo test --no-run
121-
122124
- name: Run tests
123125
run: cargo nextest run --no-fail-fast --hide-progress-bar --status-level fail
124126

125-
- name: Cancel parallel jobs
126-
if: failure()
127-
run: |
128-
# https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#cancel-a-workflow-run
129-
curl -L \
130-
-X POST \
131-
-H "Accept: application/vnd.github.v3+json" \
132-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
133-
-H "X-GitHub-Api-Version: 2022-11-28" \
134-
https://github.com/api/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
135-
136127
- name: Run Clippy
137128
if: matrix.os == 'macos-latest'
138129
run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
@@ -333,3 +324,21 @@ jobs:
333324
jq -C <<< '${{ toJson(needs) }}'
334325
# Check if all jobs that we depend on (in the needs array) were successful (or have been skipped).
335326
jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
327+
328+
cancel-if-matrix-failed:
329+
needs: rust
330+
if: ${{ always() }}
331+
runs-on: ubuntu-latest
332+
steps:
333+
- name: Cancel parallel jobs
334+
run: |
335+
if jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'; then
336+
exit 0
337+
fi
338+
# https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#cancel-a-workflow-run
339+
curl -L \
340+
-X POST \
341+
-H "Accept: application/vnd.github.v3+json" \
342+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
343+
-H "X-GitHub-Api-Version: 2022-11-28" \
344+
https://github.com/api/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel

src/tools/rust-analyzer/.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ jobs:
134134

135135
- name: Run analysis-stats on rust-analyzer
136136
if: matrix.target == 'x86_64-unknown-linux-gnu'
137-
run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats .
137+
run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats . -q
138138

139139
- name: Run analysis-stats on rust std library
140140
if: matrix.target == 'x86_64-unknown-linux-gnu'
141141
env:
142142
RUSTC_BOOTSTRAP: 1
143-
run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
143+
run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std -q
144144

145145
- name: Upload artifacts
146146
uses: actions/upload-artifact@v4

src/tools/rust-analyzer/Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ dependencies = [
14581458
"edition",
14591459
"expect-test",
14601460
"ra-ap-rustc_lexer",
1461-
"rustc-literal-escaper 0.0.3",
1461+
"rustc-literal-escaper 0.0.4",
14621462
"stdx",
14631463
"tracing",
14641464
]
@@ -1927,9 +1927,9 @@ checksum = "0041b6238913c41fe704213a4a9329e2f685a156d1781998128b4149c230ad04"
19271927

19281928
[[package]]
19291929
name = "rustc-literal-escaper"
1930-
version = "0.0.3"
1930+
version = "0.0.4"
19311931
source = "registry+https://github.com/rust-lang/crates.io-index"
1932-
checksum = "78744cd17f5d01c75b709e49807d1363e02a940ccee2e9e72435843fdb0d076e"
1932+
checksum = "ab03008eb631b703dd16978282ae36c73282e7922fe101a4bd072a40ecea7b8b"
19331933

19341934
[[package]]
19351935
name = "rustc-stable-hash"
@@ -2207,7 +2207,7 @@ dependencies = [
22072207
"rayon",
22082208
"rowan",
22092209
"rustc-hash 2.1.1",
2210-
"rustc-literal-escaper 0.0.3",
2210+
"rustc-literal-escaper 0.0.4",
22112211
"rustc_apfloat",
22122212
"smol_str",
22132213
"stdx",

src/tools/rust-analyzer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ serde = { version = "1.0.219" }
143143
serde_derive = { version = "1.0.219" }
144144
serde_json = "1.0.140"
145145
rustc-hash = "2.1.1"
146-
rustc-literal-escaper = "0.0.3"
146+
rustc-literal-escaper = "0.0.4"
147147
smallvec = { version = "1.15.1", features = [
148148
"const_new",
149149
"union",

src/tools/rust-analyzer/crates/base-db/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13+
doctest = false
1314

1415
[dependencies]
1516
la-arena.workspace = true

src/tools/rust-analyzer/crates/cfg/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13+
doctest = false
1314

1415
[dependencies]
1516
rustc-hash.workspace = true

src/tools/rust-analyzer/crates/hir-def/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13+
doctest = false
1314

1415
[dependencies]
1516
arrayvec.workspace = true

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ use crate::{
2525
import_map::ImportMap,
2626
item_tree::{ItemTree, file_item_tree_query},
2727
lang_item::{self, LangItem},
28-
nameres::{assoc::TraitItems, crate_def_map, diagnostics::DefDiagnostics},
28+
nameres::crate_def_map,
2929
signatures::{
3030
ConstSignature, EnumSignature, FunctionSignature, ImplSignature, StaticSignature,
3131
StructSignature, TraitAliasSignature, TraitSignature, TypeAliasSignature, UnionSignature,
32-
VariantFields,
3332
},
3433
tt,
3534
visibility::{self, Visibility},
@@ -113,24 +112,6 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + SourceDatabase {
113112

114113
// region:data
115114

116-
#[salsa::invoke(VariantFields::query)]
117-
fn variant_fields_with_source_map(
118-
&self,
119-
id: VariantId,
120-
) -> (Arc<VariantFields>, Arc<ExpressionStoreSourceMap>);
121-
122-
#[salsa::transparent]
123-
#[salsa::invoke(TraitItems::trait_items_query)]
124-
fn trait_items(&self, e: TraitId) -> Arc<TraitItems>;
125-
126-
#[salsa::invoke(TraitItems::trait_items_with_diagnostics_query)]
127-
fn trait_items_with_diagnostics(&self, tr: TraitId) -> (Arc<TraitItems>, DefDiagnostics);
128-
129-
#[salsa::tracked]
130-
fn variant_fields(&self, id: VariantId) -> Arc<VariantFields> {
131-
self.variant_fields_with_source_map(id).0
132-
}
133-
134115
#[salsa::tracked]
135116
fn trait_signature(&self, trait_: TraitId) -> Arc<TraitSignature> {
136117
self.trait_signature_with_source_map(trait_).0

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ pub mod scope;
99
#[cfg(test)]
1010
mod tests;
1111

12-
use std::ops::{Deref, Index};
12+
use std::{
13+
ops::{Deref, Index},
14+
sync::LazyLock,
15+
};
1316

1417
use cfg::{CfgExpr, CfgOptions};
1518
use either::Either;
@@ -19,6 +22,7 @@ use rustc_hash::FxHashMap;
1922
use smallvec::SmallVec;
2023
use span::{Edition, SyntaxContext};
2124
use syntax::{AstPtr, SyntaxNodePtr, ast};
25+
use triomphe::Arc;
2226
use tt::TextRange;
2327

2428
use crate::{
@@ -220,6 +224,12 @@ impl ExpressionStoreBuilder {
220224
}
221225

222226
impl ExpressionStore {
227+
pub fn empty_singleton() -> Arc<Self> {
228+
static EMPTY: LazyLock<Arc<ExpressionStore>> =
229+
LazyLock::new(|| Arc::new(ExpressionStoreBuilder::default().finish()));
230+
EMPTY.clone()
231+
}
232+
223233
/// Returns an iterator over all block expressions in this store that define inner items.
224234
pub fn blocks<'a>(
225235
&'a self,
@@ -636,6 +646,12 @@ impl Index<PathId> for ExpressionStore {
636646
// FIXME: Change `node_` prefix to something more reasonable.
637647
// Perhaps `expr_syntax` and `expr_id`?
638648
impl ExpressionStoreSourceMap {
649+
pub fn empty_singleton() -> Arc<Self> {
650+
static EMPTY: LazyLock<Arc<ExpressionStoreSourceMap>> =
651+
LazyLock::new(|| Arc::new(ExpressionStoreSourceMap::default()));
652+
EMPTY.clone()
653+
}
654+
639655
pub fn expr_or_pat_syntax(&self, id: ExprOrPatId) -> Result<ExprOrPatSource, SyntheticSyntax> {
640656
match id {
641657
ExprOrPatId::ExprId(id) => self.expr_syntax(id),

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,7 @@ impl ExprCollector<'_> {
22502250
Some(ModuleDefId::ConstId(_)) => (None, Pat::Path(name.into())),
22512251
Some(ModuleDefId::EnumVariantId(variant))
22522252
// FIXME: This can cause a cycle if the user is writing invalid code
2253-
if self.db.variant_fields(variant.into()).shape != FieldsShape::Record =>
2253+
if variant.fields(self.db).shape != FieldsShape::Record =>
22542254
{
22552255
(None, Pat::Path(name.into()))
22562256
}
@@ -2825,14 +2825,7 @@ impl ExprCollector<'_> {
28252825
let use_format_args_since_1_89_0 = fmt_args().is_some() && fmt_unsafe_arg().is_none();
28262826

28272827
let idx = if use_format_args_since_1_89_0 {
2828-
self.collect_format_args_impl(
2829-
syntax_ptr,
2830-
fmt,
2831-
hygiene,
2832-
argmap,
2833-
lit_pieces,
2834-
format_options,
2835-
)
2828+
self.collect_format_args_impl(syntax_ptr, fmt, argmap, lit_pieces, format_options)
28362829
} else {
28372830
self.collect_format_args_before_1_89_0_impl(
28382831
syntax_ptr,
@@ -2962,7 +2955,6 @@ impl ExprCollector<'_> {
29622955
&mut self,
29632956
syntax_ptr: AstPtr<ast::Expr>,
29642957
fmt: FormatArgs,
2965-
hygiene: HygieneId,
29662958
argmap: FxIndexSet<(usize, ArgumentType)>,
29672959
lit_pieces: ExprId,
29682960
format_options: ExprId,
@@ -2997,8 +2989,11 @@ impl ExprCollector<'_> {
29972989
let args =
29982990
self.alloc_expr_desugared(Expr::Array(Array::ElementList { elements: args }));
29992991
let args_name = Name::new_symbol_root(sym::args);
3000-
let args_binding =
3001-
self.alloc_binding(args_name.clone(), BindingAnnotation::Unannotated, hygiene);
2992+
let args_binding = self.alloc_binding(
2993+
args_name.clone(),
2994+
BindingAnnotation::Unannotated,
2995+
HygieneId::ROOT,
2996+
);
30022997
let args_pat = self.alloc_pat_desugared(Pat::Bind { id: args_binding, subpat: None });
30032998
self.add_definition_to_binding(args_binding, args_pat);
30042999
// TODO: We don't have `super let` yet.
@@ -3008,13 +3003,16 @@ impl ExprCollector<'_> {
30083003
initializer: Some(args),
30093004
else_branch: None,
30103005
};
3011-
(vec![let_stmt], self.alloc_expr_desugared(Expr::Path(Path::from(args_name))))
3006+
(vec![let_stmt], self.alloc_expr_desugared(Expr::Path(args_name.into())))
30123007
} else {
30133008
// Generate:
30143009
// super let args = (&arg0, &arg1, &...);
30153010
let args_name = Name::new_symbol_root(sym::args);
3016-
let args_binding =
3017-
self.alloc_binding(args_name.clone(), BindingAnnotation::Unannotated, hygiene);
3011+
let args_binding = self.alloc_binding(
3012+
args_name.clone(),
3013+
BindingAnnotation::Unannotated,
3014+
HygieneId::ROOT,
3015+
);
30183016
let args_pat = self.alloc_pat_desugared(Pat::Bind { id: args_binding, subpat: None });
30193017
self.add_definition_to_binding(args_binding, args_pat);
30203018
let elements = arguments
@@ -3057,8 +3055,11 @@ impl ExprCollector<'_> {
30573055
.collect();
30583056
let array =
30593057
self.alloc_expr_desugared(Expr::Array(Array::ElementList { elements: args }));
3060-
let args_binding =
3061-
self.alloc_binding(args_name.clone(), BindingAnnotation::Unannotated, hygiene);
3058+
let args_binding = self.alloc_binding(
3059+
args_name.clone(),
3060+
BindingAnnotation::Unannotated,
3061+
HygieneId::ROOT,
3062+
);
30623063
let args_pat = self.alloc_pat_desugared(Pat::Bind { id: args_binding, subpat: None });
30633064
self.add_definition_to_binding(args_binding, args_pat);
30643065
let let_stmt2 = Statement::Let {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn print_variant_body_hir(db: &dyn DefDatabase, owner: VariantId, edition: E
121121
VariantId::UnionId(it) => format!("union {}", item_name(db, it, "<missing>")),
122122
};
123123

124-
let fields = db.variant_fields(owner);
124+
let fields = owner.fields(db);
125125

126126
let mut p = Printer {
127127
db,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,13 @@ impl GenericParams {
331331
}
332332

333333
#[inline]
334-
pub fn no_predicates(&self) -> bool {
334+
pub fn has_no_predicates(&self) -> bool {
335335
self.where_predicates.is_empty()
336336
}
337337

338338
#[inline]
339-
pub fn where_predicates(&self) -> std::slice::Iter<'_, WherePredicate> {
340-
self.where_predicates.iter()
339+
pub fn where_predicates(&self) -> &[WherePredicate] {
340+
&self.where_predicates
341341
}
342342

343343
/// Iterator of type_or_consts field

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
AssocItemId, AttrDefId, Complete, FxIndexMap, ModuleDefId, ModuleId, TraitId,
1717
db::DefDatabase,
1818
item_scope::{ImportOrExternCrate, ItemInNs},
19-
nameres::{DefMap, crate_def_map},
19+
nameres::{DefMap, assoc::TraitItems, crate_def_map},
2020
visibility::Visibility,
2121
};
2222

@@ -221,7 +221,7 @@ impl ImportMap {
221221
trait_import_info: &ImportInfo,
222222
) {
223223
let _p = tracing::info_span!("collect_trait_assoc_items").entered();
224-
for &(ref assoc_item_name, item) in &db.trait_items(tr).items {
224+
for &(ref assoc_item_name, item) in &TraitItems::query(db, tr).items {
225225
let module_def_id = match item {
226226
AssocItemId::FunctionId(f) => ModuleDefId::from(f),
227227
AssocItemId::ConstId(c) => ModuleDefId::from(c),
@@ -482,7 +482,7 @@ mod tests {
482482
use expect_test::{Expect, expect};
483483
use test_fixture::WithFixture;
484484

485-
use crate::{ItemContainerId, Lookup, test_db::TestDB};
485+
use crate::{ItemContainerId, Lookup, nameres::assoc::TraitItems, test_db::TestDB};
486486

487487
use super::*;
488488

@@ -580,7 +580,7 @@ mod tests {
580580

581581
let trait_info = dependency_imports.import_info_for(ItemInNs::Types(trait_id.into()))?;
582582

583-
let trait_items = db.trait_items(trait_id);
583+
let trait_items = TraitItems::query(db, trait_id);
584584
let (assoc_item_name, _) = trait_items
585585
.items
586586
.iter()

0 commit comments

Comments
 (0)