Skip to content

Commit 147c6dc

Browse files
committed
Auto merge of #155046 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update Subtree update of `rust-analyzer` to 64ddb54. Created using https://github.com/rust-lang/josh-sync. r? @ghost
2 parents ec550d4 + 64ddb54 commit 147c6dc

208 files changed

Lines changed: 6888 additions & 2775 deletions

File tree

Some content is hidden

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

.github/workflows/gen-lints.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Generate lints and feature flags
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '50 23 * * 6'
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
12+
jobs:
13+
lints-gen:
14+
name: Generate lints
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
20+
- name: Install nightly
21+
run: rustup default nightly
22+
23+
- name: Generate lints/feature flags
24+
run: cargo codegen lint-definitions
25+
26+
- name: Submit PR
27+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
28+
with:
29+
commit-message: "internal: update generated lints"
30+
branch: "ci/gen-lints"
31+
delete-branch: true
32+
sign-commits: true
33+
title: "Update generated lints"
34+
body: "Weekly lint updates for `crates/ide-db/src/generated/lints.rs`."
35+
labels: "A-infra"

.github/workflows/release.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ jobs:
264264
name: ${{ env.TAG }}
265265
token: ${{ secrets.GITHUB_TOKEN }}
266266

267-
- run: rm dist/rust-analyzer-no-server.vsix
268-
269267
- run: npm ci
270268
working-directory: ./editors/code
271269

.github/workflows/rustc-pull.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main
1313
with:
1414
github-app-id: ${{ vars.APP_CLIENT_ID }}
15+
pr-author: "workflows-rust-analyzer[bot]"
1516
zulip-stream-id: 185405
1617
zulip-bot-email: "rust-analyzer-ci-bot@rust-lang.zulipchat.com"
1718
pr-base-branch: master

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ process-wrap = { version = "8.2.1", features = ["std"] }
132132
pulldown-cmark-to-cmark = "10.0.4"
133133
pulldown-cmark = { version = "0.9.6", default-features = false }
134134
rayon = "1.10.0"
135-
rowan = "=0.15.17"
135+
rowan = "=0.15.18"
136136
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
137137
# on impls without it
138138
salsa = { version = "0.25.2", default-features = false, features = [

crates/base-db/src/change.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use triomphe::Arc;
99
use vfs::FileId;
1010

1111
use crate::{
12-
CrateGraphBuilder, CratesIdMap, LibraryRoots, LocalRoots, RootQueryDb, SourceRoot, SourceRootId,
12+
CrateGraphBuilder, CratesIdMap, LibraryRoots, LocalRoots, SourceDatabase, SourceRoot,
13+
SourceRootId,
1314
};
1415

1516
/// Encapsulate a bunch of raw `.set` calls on the database.
@@ -49,7 +50,7 @@ impl FileChange {
4950
self.crate_graph = Some(graph);
5051
}
5152

52-
pub fn apply(self, db: &mut dyn RootQueryDb) -> Option<CratesIdMap> {
53+
pub fn apply(self, db: &mut dyn SourceDatabase) -> Option<CratesIdMap> {
5354
let _p = tracing::info_span!("FileChange::apply").entered();
5455
if let Some(roots) = self.roots {
5556
let mut local_roots = FxHashSet::default();

crates/base-db/src/editioned_file_id.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,71 @@ use std::hash::Hash;
55

66
use salsa::Database;
77
use span::Edition;
8+
use syntax::{SyntaxError, ast};
89
use vfs::FileId;
910

11+
use crate::SourceDatabase;
12+
1013
#[salsa::interned(debug, constructor = from_span_file_id, no_lifetime)]
1114
#[derive(PartialOrd, Ord)]
1215
pub struct EditionedFileId {
1316
field: span::EditionedFileId,
1417
}
1518

19+
// Currently does not work due to a salsa bug
20+
// #[salsa::tracked]
21+
// impl EditionedFileId {
22+
// #[salsa::tracked(lru = 128)]
23+
// pub fn parse(self, db: &dyn SourceDatabase) -> syntax::Parse<ast::SourceFile> {
24+
// let _p = tracing::info_span!("parse", ?self).entered();
25+
// let (file_id, edition) = self.unpack(db);
26+
// let text = db.file_text(file_id).text(db);
27+
// ast::SourceFile::parse(text, edition)
28+
// }
29+
30+
// // firewall query
31+
// #[salsa::tracked(returns(as_deref))]
32+
// pub fn parse_errors(self, db: &dyn SourceDatabase) -> Option<Box<[SyntaxError]>> {
33+
// let errors = self.parse(db).errors();
34+
// match &*errors {
35+
// [] => None,
36+
// [..] => Some(errors.into()),
37+
// }
38+
// }
39+
// }
40+
41+
impl EditionedFileId {
42+
pub fn parse(self, db: &dyn SourceDatabase) -> syntax::Parse<ast::SourceFile> {
43+
#[salsa::tracked(lru = 128)]
44+
pub fn parse(
45+
db: &dyn SourceDatabase,
46+
file_id: EditionedFileId,
47+
) -> syntax::Parse<ast::SourceFile> {
48+
let _p = tracing::info_span!("parse", ?file_id).entered();
49+
let (file_id, edition) = file_id.unpack(db);
50+
let text = db.file_text(file_id).text(db);
51+
ast::SourceFile::parse(text, edition)
52+
}
53+
parse(db, self)
54+
}
55+
56+
// firewall query
57+
pub fn parse_errors(self, db: &dyn SourceDatabase) -> Option<&[SyntaxError]> {
58+
#[salsa::tracked(returns(as_deref))]
59+
pub fn parse_errors(
60+
db: &dyn SourceDatabase,
61+
file_id: EditionedFileId,
62+
) -> Option<Box<[SyntaxError]>> {
63+
let errors = file_id.parse(db).errors();
64+
match &*errors {
65+
[] => None,
66+
[..] => Some(errors.into()),
67+
}
68+
}
69+
parse_errors(db, self)
70+
}
71+
}
72+
1673
impl EditionedFileId {
1774
#[inline]
1875
pub fn new(db: &dyn Database, file_id: FileId, edition: Edition) -> Self {

crates/base-db/src/input.rs

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ use span::Edition;
2121
use triomphe::Arc;
2222
use vfs::{AbsPathBuf, AnchoredPath, FileId, VfsPath, file_set::FileSet};
2323

24-
use crate::{CrateWorkspaceData, EditionedFileId, FxIndexSet, RootQueryDb};
24+
use crate::{
25+
CrateWorkspaceData, EditionedFileId, FxIndexSet, SourceDatabase, all_crates,
26+
set_all_crates_with_durability,
27+
};
2528

2629
pub type ProcMacroPaths =
2730
FxHashMap<CrateBuilderId, Result<(String, AbsPathBuf), ProcMacroLoadingError>>;
@@ -490,13 +493,13 @@ impl Crate {
490493
/// including the crate itself.
491494
///
492495
/// **Warning**: do not use this query in `hir-*` crates! It kills incrementality across crate metadata modifications.
493-
pub fn transitive_rev_deps(self, db: &dyn RootQueryDb) -> Box<[Crate]> {
496+
pub fn transitive_rev_deps(self, db: &dyn SourceDatabase) -> Box<[Crate]> {
494497
let mut worklist = vec![self];
495498
let mut rev_deps = FxHashSet::default();
496499
rev_deps.insert(self);
497500

498501
let mut inverted_graph = FxHashMap::<_, Vec<_>>::default();
499-
db.all_crates().iter().for_each(|&krate| {
502+
all_crates(db).iter().for_each(|&krate| {
500503
krate
501504
.data(db)
502505
.dependencies
@@ -586,15 +589,15 @@ impl CrateGraphBuilder {
586589
Ok(())
587590
}
588591

589-
pub fn set_in_db(self, db: &mut dyn RootQueryDb) -> CratesIdMap {
592+
pub fn set_in_db(self, db: &mut dyn SourceDatabase) -> CratesIdMap {
593+
let old_all_crates = all_crates(db);
594+
590595
// For some reason in some repositories we have duplicate crates, so we use a set and not `Vec`.
591596
// We use an `IndexSet` because the list needs to be topologically sorted.
592597
let mut all_crates = FxIndexSet::with_capacity_and_hasher(self.arena.len(), FxBuildHasher);
593598
let mut visited = FxHashMap::default();
594599
let mut visited_root_files = FxHashSet::default();
595600

596-
let old_all_crates = db.all_crates();
597-
598601
let crates_map = db.crates_map();
599602
// salsa doesn't compare new input to old input to see if they are the same, so here we are doing all the work ourselves.
600603
for krate in self.iter() {
@@ -612,17 +615,14 @@ impl CrateGraphBuilder {
612615
if old_all_crates.len() != all_crates.len()
613616
|| old_all_crates.iter().any(|&krate| !all_crates.contains(&krate))
614617
{
615-
db.set_all_crates_with_durability(
616-
Arc::new(Vec::from_iter(all_crates).into_boxed_slice()),
617-
Durability::MEDIUM,
618-
);
618+
set_all_crates_with_durability(db, all_crates, Durability::MEDIUM);
619619
}
620620

621621
return visited;
622622

623623
fn go(
624624
graph: &CrateGraphBuilder,
625-
db: &mut dyn RootQueryDb,
625+
db: &mut dyn SourceDatabase,
626626
crates_map: &CratesMap,
627627
visited: &mut FxHashMap<CrateBuilderId, Crate>,
628628
visited_root_files: &mut FxHashSet<FileId>,
@@ -929,6 +929,27 @@ impl<'a> IntoIterator for &'a Env {
929929
}
930930
}
931931

932+
/// The crate graph had a cycle. This is typically a bug, and
933+
/// rust-analyzer logs a warning when it encounters a cycle. Generally
934+
/// rust-analyzer will continue working OK in the presence of cycle,
935+
/// but it's better to have an accurate crate graph.
936+
///
937+
/// ## dev-dependencies
938+
///
939+
/// Note that it's actually legal for a cargo package (i.e. a thing
940+
/// with a Cargo.toml) to depend on itself in dev-dependencies. This
941+
/// can enable additional features, and is typically used when a
942+
/// project wants features to be enabled in tests. Dev-dependencies
943+
/// are not propagated, so they aren't visible to package that depend
944+
/// on this one.
945+
///
946+
/// <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#development-dependencies>
947+
///
948+
/// However, rust-analyzer constructs its crate graph from Cargo
949+
/// metadata, so it can end up producing a cyclic crate graph from a
950+
/// well-formed package graph.
951+
///
952+
/// <https://github.com/rust-lang/rust-analyzer/issues/14167>
932953
#[derive(Debug)]
933954
pub struct CyclicDependenciesError {
934955
path: Vec<(CrateBuilderId, Option<CrateDisplayName>)>,

0 commit comments

Comments
 (0)