Skip to content

Commit

Permalink
⬆️ rust-analyzer
Browse files Browse the repository at this point in the history
Merge commit '368e0bb32f1178cf162c2ce5f7e10b7ae211eb26'
  • Loading branch information
arcnmx committed Jan 9, 2023
2 parents af58fc8 + 368e0bb commit 06e705f
Show file tree
Hide file tree
Showing 395 changed files with 14,558 additions and 5,744 deletions.
89 changes: 81 additions & 8 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"

[[package]]
name = "byteorder"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"

[[package]]
name = "camino"
version = "1.1.1"
Expand Down Expand Up @@ -171,9 +177,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chalk-derive"
version = "0.86.0"
version = "0.88.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5499d415d855b5094366a824815341893ad3de0ecb6048c430118bdae6d27402"
checksum = "4df80a3fbc1f0e59f560eeeebca94bf655566a8ad3023c210a109deb6056455a"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -183,9 +189,9 @@ dependencies = [

[[package]]
name = "chalk-ir"
version = "0.86.0"
version = "0.88.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3800118c76a48507b0eece3a01f3a429b5c478d203c493096e6040c67ab960e1"
checksum = "f39e5272016916956298cceea5147006f897972c274a768ed4d6e074efe5d3fb"
dependencies = [
"bitflags",
"chalk-derive",
Expand All @@ -194,9 +200,9 @@ dependencies = [

[[package]]
name = "chalk-recursive"
version = "0.86.0"
version = "0.88.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1baf60628fd73104d1f8562586a52d48f37f1e84435aab2e62674b1fd935b8c8"
checksum = "d9d60b42ad7478d3e027e2f9ea4e99fbbb8fdee0c8c3cf068be269f57e603618"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand All @@ -207,9 +213,9 @@ dependencies = [

[[package]]
name = "chalk-solve"
version = "0.86.0"
version = "0.88.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e9c3c068f9358786348e58a1b94ef0a5cf90a9810fc1f10fda896f0b5d80185"
checksum = "ab30620ea5b36819525eaab2204f4b8e1842fc7ee36826424a28bef59ae7fecf"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand Down Expand Up @@ -510,6 +516,8 @@ dependencies = [
"fst",
"hashbrown",
"hir-expand",
"hkalbasi-rustc-ap-rustc_abi",
"hkalbasi-rustc-ap-rustc_index",
"indexmap",
"itertools",
"la-arena",
Expand Down Expand Up @@ -555,6 +563,7 @@ version = "0.0.0"
dependencies = [
"arrayvec",
"base-db",
"bitflags",
"chalk-derive",
"chalk-ir",
"chalk-recursive",
Expand All @@ -564,6 +573,7 @@ dependencies = [
"expect-test",
"hir-def",
"hir-expand",
"hkalbasi-rustc-ap-rustc_index",
"itertools",
"la-arena",
"limit",
Expand All @@ -581,6 +591,27 @@ dependencies = [
"typed-arena",
]

[[package]]
name = "hkalbasi-rustc-ap-rustc_abi"
version = "0.0.20221221"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adabaadad9aa7576f97af02241cdf5554d62fb3d51a84cb05d77ba28edd3013f"
dependencies = [
"bitflags",
"hkalbasi-rustc-ap-rustc_index",
"tracing",
]

[[package]]
name = "hkalbasi-rustc-ap-rustc_index"
version = "0.0.20221221"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4d3c48474e09afb0f5efbd6f758e05411699301a113c47d454d28ec7059d00e"
dependencies = [
"arrayvec",
"smallvec",
]

[[package]]
name = "home"
version = "0.5.4"
Expand Down Expand Up @@ -631,6 +662,7 @@ dependencies = [
"ide-db",
"itertools",
"profile",
"smallvec",
"sourcegen",
"stdx",
"syntax",
Expand Down Expand Up @@ -1750,6 +1782,33 @@ dependencies = [
"tikv-jemalloc-sys",
]

[[package]]
name = "time"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376"
dependencies = [
"itoa",
"serde",
"time-core",
"time-macros",
]

[[package]]
name = "time-core"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd"

[[package]]
name = "time-macros"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2"
dependencies = [
"time-core",
]

[[package]]
name = "tinyvec"
version = "1.6.0"
Expand Down Expand Up @@ -2148,4 +2207,18 @@ dependencies = [
"write-json",
"xflags",
"xshell",
"zip",
]

[[package]]
name = "zip"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "537ce7411d25e54e8ae21a7ce0b15840e7bfcff15b51d697ec3266cc76bdf080"
dependencies = [
"byteorder",
"crc32fast",
"crossbeam-utils",
"flate2",
"time",
]
14 changes: 11 additions & 3 deletions src/tools/rust-analyzer/crates/base-db/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl ChangeFixture {
Ok(Vec::new()),
false,
origin,
meta.target_data_layout.as_deref().map(Arc::from),
);
let prev = crates.insert(crate_name.clone(), crate_id);
assert!(prev.is_none());
Expand Down Expand Up @@ -197,6 +198,7 @@ impl ChangeFixture {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
} else {
for (from, to, prelude) in crate_deps {
Expand All @@ -210,6 +212,8 @@ impl ChangeFixture {
.unwrap();
}
}
let target_layout =
crate_graph.iter().next().and_then(|it| crate_graph[it].target_layout.clone());

if let Some(mini_core) = mini_core {
let core_file = file_id;
Expand All @@ -234,6 +238,7 @@ impl ChangeFixture {
Ok(Vec::new()),
false,
CrateOrigin::Lang(LangCrateOrigin::Core),
target_layout.clone(),
);

for krate in all_crates {
Expand Down Expand Up @@ -271,6 +276,7 @@ impl ChangeFixture {
Ok(proc_macro),
true,
CrateOrigin::CratesIo { repo: None, name: None },
target_layout,
);

for krate in all_crates {
Expand Down Expand Up @@ -391,6 +397,7 @@ struct FileMeta {
edition: Edition,
env: Env,
introduce_new_source_root: Option<SourceRootKind>,
target_data_layout: Option<String>,
}

fn parse_crate(crate_str: String) -> (String, CrateOrigin, Option<String>) {
Expand All @@ -400,9 +407,9 @@ fn parse_crate(crate_str: String) -> (String, CrateOrigin, Option<String>) {
Some((version, url)) => {
(version, CrateOrigin::CratesIo { repo: Some(url.to_owned()), name: None })
}
_ => panic!("Bad crates.io parameter: {}", data),
_ => panic!("Bad crates.io parameter: {data}"),
},
_ => panic!("Bad string for crate origin: {}", b),
_ => panic!("Bad string for crate origin: {b}"),
};
(a.to_owned(), origin, Some(version.to_string()))
} else {
Expand Down Expand Up @@ -432,8 +439,9 @@ impl From<Fixture> for FileMeta {
introduce_new_source_root: f.introduce_new_source_root.map(|kind| match &*kind {
"local" => SourceRootKind::Local,
"library" => SourceRootKind::Library,
invalid => panic!("invalid source root kind '{}'", invalid),
invalid => panic!("invalid source root kind '{invalid}'"),
}),
target_data_layout: f.target_data_layout,
}
}
}
Expand Down
21 changes: 17 additions & 4 deletions src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl fmt::Display for CrateName {
impl ops::Deref for CrateName {
type Target = str;
fn deref(&self) -> &str {
&*self.0
&self.0
}
}

Expand Down Expand Up @@ -211,7 +211,7 @@ impl fmt::Display for CrateDisplayName {
impl ops::Deref for CrateDisplayName {
type Target = str;
fn deref(&self) -> &str {
&*self.crate_name
&self.crate_name
}
}

Expand Down Expand Up @@ -270,6 +270,7 @@ pub struct CrateData {
pub display_name: Option<CrateDisplayName>,
pub cfg_options: CfgOptions,
pub potential_cfg_options: CfgOptions,
pub target_layout: Option<Arc<str>>,
pub env: Env,
pub dependencies: Vec<Dependency>,
pub proc_macro: ProcMacroLoadResult,
Expand Down Expand Up @@ -328,6 +329,7 @@ impl CrateGraph {
proc_macro: ProcMacroLoadResult,
is_proc_macro: bool,
origin: CrateOrigin,
target_layout: Option<Arc<str>>,
) -> CrateId {
let data = CrateData {
root_file_id,
Expand All @@ -340,6 +342,7 @@ impl CrateGraph {
proc_macro,
dependencies: Vec::new(),
origin,
target_layout,
is_proc_macro,
};
let crate_id = CrateId(self.arena.len() as u32);
Expand Down Expand Up @@ -615,8 +618,8 @@ impl CyclicDependenciesError {
impl fmt::Display for CyclicDependenciesError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let render = |(id, name): &(CrateId, Option<CrateDisplayName>)| match name {
Some(it) => format!("{}({:?})", it, id),
None => format!("{:?}", id),
Some(it) => format!("{it}({id:?})"),
None => format!("{id:?}"),
};
let path = self.path.iter().rev().map(render).collect::<Vec<String>>().join(" -> ");
write!(
Expand Down Expand Up @@ -649,6 +652,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
let crate2 = graph.add_crate_root(
FileId(2u32),
Expand All @@ -661,6 +665,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
let crate3 = graph.add_crate_root(
FileId(3u32),
Expand All @@ -673,6 +678,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
assert!(graph
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
Expand All @@ -699,6 +705,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
let crate2 = graph.add_crate_root(
FileId(2u32),
Expand All @@ -711,6 +718,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
assert!(graph
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
Expand All @@ -734,6 +742,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
let crate2 = graph.add_crate_root(
FileId(2u32),
Expand All @@ -746,6 +755,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
let crate3 = graph.add_crate_root(
FileId(3u32),
Expand All @@ -758,6 +768,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
assert!(graph
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
Expand All @@ -781,6 +792,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
let crate2 = graph.add_crate_root(
FileId(2u32),
Expand All @@ -793,6 +805,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
assert!(graph
.add_dep(
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug {
}

fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
let _p = profile::span("parse_query").detail(|| format!("{:?}", file_id));
let _p = profile::span("parse_query").detail(|| format!("{file_id:?}"));
let text = db.file_text(file_id);
SourceFile::parse(&*text)
SourceFile::parse(&text)
}

/// We don't want to give HIR knowledge of source roots, hence we extract these
Expand Down
Loading

0 comments on commit 06e705f

Please sign in to comment.