Skip to content

Commit 6cbfed8

Browse files
committed
Auto merge of #131832 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? `@ghost`
2 parents e85a873 + 8dd53a3 commit 6cbfed8

File tree

154 files changed

+2098
-1113
lines changed

Some content is hidden

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

154 files changed

+2098
-1113
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ proc-macro-srv = { path = "./crates/proc-macro-srv", version = "0.0.0" }
7474
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
7575
profile = { path = "./crates/profile", version = "0.0.0" }
7676
project-model = { path = "./crates/project-model", version = "0.0.0" }
77-
salsa = { path = "./crates/salsa", version = "0.0.0" }
77+
ra-salsa = { path = "./crates/ra-salsa", package = "salsa", version = "0.0.0" }
7878
span = { path = "./crates/span", version = "0.0.0" }
7979
stdx = { path = "./crates/stdx", version = "0.0.0" }
8080
syntax = { path = "./crates/syntax", version = "0.0.0" }
@@ -85,11 +85,11 @@ tt = { path = "./crates/tt", version = "0.0.0" }
8585
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8686
vfs = { path = "./crates/vfs", version = "0.0.0" }
8787

88-
ra-ap-rustc_lexer = { version = "0.68.0", default-features = false }
89-
ra-ap-rustc_parse_format = { version = "0.68.0", default-features = false }
90-
ra-ap-rustc_index = { version = "0.68.0", default-features = false }
91-
ra-ap-rustc_abi = { version = "0.68.0", default-features = false }
92-
ra-ap-rustc_pattern_analysis = { version = "0.68.0", default-features = false }
88+
ra-ap-rustc_lexer = { version = "0.71.0", default-features = false }
89+
ra-ap-rustc_parse_format = { version = "0.71.0", default-features = false }
90+
ra-ap-rustc_index = { version = "0.71.0", default-features = false }
91+
ra-ap-rustc_abi = { version = "0.71.0", default-features = false }
92+
ra-ap-rustc_pattern_analysis = { version = "0.71.0", default-features = false }
9393

9494
# local crates that aren't published to crates.io. These should not have versions.
9595
test-fixture = { path = "./crates/test-fixture" }
@@ -153,6 +153,9 @@ tracing-tree = "0.3.0"
153153
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
154154
"registry",
155155
"fmt",
156+
"local-time",
157+
"std",
158+
"time",
156159
"tracing-log",
157160
] }
158161
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }

crates/base-db/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ doctest = false
1616
lz4_flex = { version = "0.11", default-features = false }
1717

1818
la-arena.workspace = true
19-
salsa.workspace = true
19+
ra-salsa.workspace = true
2020
rustc-hash.workspace = true
2121
triomphe.workspace = true
2222
semver.workspace = true

crates/base-db/src/change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
44
use std::fmt;
55

6+
use ra_salsa::Durability;
67
use rustc_hash::FxHashMap;
7-
use salsa::Durability;
88
use triomphe::Arc;
99
use vfs::FileId;
1010

crates/base-db/src/input.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ pub struct CrateData {
288288
/// The cfg options that could be used by the crate
289289
pub potential_cfg_options: Option<Arc<CfgOptions>>,
290290
pub env: Env,
291+
/// The dependencies of this crate.
292+
///
293+
/// Note that this may contain more dependencies than the crate actually uses.
294+
/// A common example is the test crate which is included but only actually is active when
295+
/// declared in source via `extern crate test`.
291296
pub dependencies: Vec<Dependency>,
292297
pub origin: CrateOrigin,
293298
pub is_proc_macro: bool,

crates/base-db/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ mod input;
55

66
use std::panic;
77

8+
use ra_salsa::Durability;
89
use rustc_hash::FxHashMap;
9-
use salsa::Durability;
1010
use span::EditionedFileId;
1111
use syntax::{ast, Parse, SourceFile, SyntaxError};
1212
use triomphe::Arc;
@@ -20,19 +20,19 @@ pub use crate::{
2020
TargetLayoutLoadResult,
2121
},
2222
};
23-
pub use salsa::{self, Cancelled};
23+
pub use ra_salsa::{self, Cancelled};
2424
pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, VfsPath};
2525

2626
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
2727

2828
#[macro_export]
2929
macro_rules! impl_intern_key {
3030
($name:ident) => {
31-
impl $crate::salsa::InternKey for $name {
32-
fn from_intern_id(v: $crate::salsa::InternId) -> Self {
31+
impl $crate::ra_salsa::InternKey for $name {
32+
fn from_intern_id(v: $crate::ra_salsa::InternId) -> Self {
3333
$name(v)
3434
}
35-
fn as_intern_id(&self) -> $crate::salsa::InternId {
35+
fn as_intern_id(&self) -> $crate::ra_salsa::InternId {
3636
self.0
3737
}
3838
}
@@ -55,30 +55,30 @@ pub trait FileLoader {
5555

5656
/// Database which stores all significant input facts: source code and project
5757
/// model. Everything else in rust-analyzer is derived from these queries.
58-
#[salsa::query_group(SourceDatabaseStorage)]
58+
#[ra_salsa::query_group(SourceDatabaseStorage)]
5959
pub trait SourceDatabase: FileLoader + std::fmt::Debug {
60-
#[salsa::input]
60+
#[ra_salsa::input]
6161
fn compressed_file_text(&self, file_id: FileId) -> Arc<[u8]>;
6262

6363
/// Text of the file.
64-
#[salsa::lru]
64+
#[ra_salsa::lru]
6565
fn file_text(&self, file_id: FileId) -> Arc<str>;
6666

6767
/// Parses the file into the syntax tree.
68-
#[salsa::lru]
68+
#[ra_salsa::lru]
6969
fn parse(&self, file_id: EditionedFileId) -> Parse<ast::SourceFile>;
7070

7171
/// Returns the set of errors obtained from parsing the file including validation errors.
7272
fn parse_errors(&self, file_id: EditionedFileId) -> Option<Arc<[SyntaxError]>>;
7373

7474
/// The crate graph.
75-
#[salsa::input]
75+
#[ra_salsa::input]
7676
fn crate_graph(&self) -> Arc<CrateGraph>;
7777

78-
#[salsa::input]
78+
#[ra_salsa::input]
7979
fn crate_workspace_data(&self) -> Arc<FxHashMap<CrateId, Arc<CrateWorkspaceData>>>;
8080

81-
#[salsa::transparent]
81+
#[ra_salsa::transparent]
8282
fn toolchain_channel(&self, krate: CrateId) -> Option<ReleaseChannel>;
8383
}
8484

@@ -126,14 +126,14 @@ fn file_text(db: &dyn SourceDatabase, file_id: FileId) -> Arc<str> {
126126

127127
/// We don't want to give HIR knowledge of source roots, hence we extract these
128128
/// methods into a separate DB.
129-
#[salsa::query_group(SourceRootDatabaseStorage)]
129+
#[ra_salsa::query_group(SourceRootDatabaseStorage)]
130130
pub trait SourceRootDatabase: SourceDatabase {
131131
/// Path to a file, relative to the root of its source root.
132132
/// Source root of the file.
133-
#[salsa::input]
133+
#[ra_salsa::input]
134134
fn file_source_root(&self, file_id: FileId) -> SourceRootId;
135135
/// Contents of the source root.
136-
#[salsa::input]
136+
#[ra_salsa::input]
137137
fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
138138

139139
/// Crates whose root fool is in `id`.

crates/hir-def/src/data.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,17 @@ impl ExternCrateDeclData {
506506
let crate_id = if name == sym::self_.clone() {
507507
Some(krate)
508508
} else {
509-
db.crate_def_map(krate)
510-
.extern_prelude()
511-
.find(|&(prelude_name, ..)| *prelude_name == name)
512-
.map(|(_, (root, _))| root.krate())
509+
db.crate_graph()[krate].dependencies.iter().find_map(|dep| {
510+
if dep.name.symbol() == name.symbol() {
511+
Some(dep.crate_id)
512+
} else {
513+
None
514+
}
515+
})
513516
};
514517

515518
Arc::new(Self {
516-
name: extern_crate.name.clone(),
519+
name,
517520
visibility: item_tree[extern_crate.visibility].clone(),
518521
alias: extern_crate.alias.clone(),
519522
crate_id,

0 commit comments

Comments
 (0)