Skip to content

Commit 4bc746b

Browse files
committed
Merge commit '862a3004e958082d0e9cbdf1172c5fe2bab6cf2d' into sync-from-ra
2 parents 8c04c06 + 862a300 commit 4bc746b

Some content is hidden

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

57 files changed

+2182
-235
lines changed

src/tools/rust-analyzer/Cargo.lock

+24-14
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
177177

178178
[[package]]
179179
name = "chalk-derive"
180-
version = "0.92.0"
180+
version = "0.93.0"
181181
source = "registry+https://github.com/rust-lang/crates.io-index"
182-
checksum = "ff5053a8a42dbff5279a82423946fc56dc1253b76cf211b2b3c14b3aad4e1281"
182+
checksum = "264726159011fc7f22c23eb51f49021ece6e71bc358b96e7f2e842db0b14162b"
183183
dependencies = [
184184
"proc-macro2",
185185
"quote",
@@ -189,9 +189,9 @@ dependencies = [
189189

190190
[[package]]
191191
name = "chalk-ir"
192-
version = "0.92.0"
192+
version = "0.93.0"
193193
source = "registry+https://github.com/rust-lang/crates.io-index"
194-
checksum = "8a56de2146a8ed0fcd54f4bd50db852f1de4eac9e1efe568494f106c21b77d2a"
194+
checksum = "d65c17407d4c756b8f7f84344acb0fb96364d0298822743219bb25769b6d00df"
195195
dependencies = [
196196
"bitflags 1.3.2",
197197
"chalk-derive",
@@ -200,9 +200,9 @@ dependencies = [
200200

201201
[[package]]
202202
name = "chalk-recursive"
203-
version = "0.92.0"
203+
version = "0.93.0"
204204
source = "registry+https://github.com/rust-lang/crates.io-index"
205-
checksum = "5cc09e6e9531f3544989ef89b189e80fbc7ad9e2f73f1c5e03ddc9ffb0527463"
205+
checksum = "80e2cf7b70bedaaf3a8cf3c93b6120c2bb65be89389124028e724d19e209686e"
206206
dependencies = [
207207
"chalk-derive",
208208
"chalk-ir",
@@ -213,9 +213,9 @@ dependencies = [
213213

214214
[[package]]
215215
name = "chalk-solve"
216-
version = "0.92.0"
216+
version = "0.93.0"
217217
source = "registry+https://github.com/rust-lang/crates.io-index"
218-
checksum = "b392e02b4c81ec76d3748da839fc70a5539b83d27c9030668463d34d5110b860"
218+
checksum = "afc67c548d3854f64e97e67dc5b7c88513425c5bfa347cff96b7992ae6379288"
219219
dependencies = [
220220
"chalk-derive",
221221
"chalk-ir",
@@ -531,8 +531,6 @@ dependencies = [
531531
"fst",
532532
"hashbrown 0.12.3",
533533
"hir-expand",
534-
"hkalbasi-rustc-ap-rustc_abi",
535-
"hkalbasi-rustc-ap-rustc_index",
536534
"indexmap 2.0.0",
537535
"intern",
538536
"itertools",
@@ -541,7 +539,7 @@ dependencies = [
541539
"mbe",
542540
"once_cell",
543541
"profile",
544-
"ra-ap-rustc_parse_format",
542+
"rustc-dependencies",
545543
"rustc-hash",
546544
"smallvec",
547545
"stdx",
@@ -594,7 +592,6 @@ dependencies = [
594592
"expect-test",
595593
"hir-def",
596594
"hir-expand",
597-
"hkalbasi-rustc-ap-rustc_index",
598595
"intern",
599596
"itertools",
600597
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -604,6 +601,7 @@ dependencies = [
604601
"oorandom",
605602
"profile",
606603
"project-model",
604+
"rustc-dependencies",
607605
"rustc-hash",
608606
"scoped-tls",
609607
"smallvec",
@@ -1277,7 +1275,7 @@ dependencies = [
12771275
"drop_bomb",
12781276
"expect-test",
12791277
"limit",
1280-
"ra-ap-rustc_lexer",
1278+
"rustc-dependencies",
12811279
"sourcegen",
12821280
"stdx",
12831281
]
@@ -1594,10 +1592,12 @@ dependencies = [
15941592
"oorandom",
15951593
"parking_lot 0.12.1",
15961594
"parking_lot_core 0.9.6",
1595+
"parser",
15971596
"proc-macro-api",
15981597
"profile",
15991598
"project-model",
16001599
"rayon",
1600+
"rustc-dependencies",
16011601
"rustc-hash",
16021602
"scip",
16031603
"serde",
@@ -1626,6 +1626,16 @@ version = "0.1.23"
16261626
source = "registry+https://github.com/rust-lang/crates.io-index"
16271627
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
16281628

1629+
[[package]]
1630+
name = "rustc-dependencies"
1631+
version = "0.0.0"
1632+
dependencies = [
1633+
"hkalbasi-rustc-ap-rustc_abi",
1634+
"hkalbasi-rustc-ap-rustc_index",
1635+
"ra-ap-rustc_lexer",
1636+
"ra-ap-rustc_parse_format",
1637+
]
1638+
16291639
[[package]]
16301640
name = "rustc-hash"
16311641
version = "1.1.0"
@@ -1853,9 +1863,9 @@ dependencies = [
18531863
"proc-macro2",
18541864
"profile",
18551865
"quote",
1856-
"ra-ap-rustc_lexer",
18571866
"rayon",
18581867
"rowan",
1868+
"rustc-dependencies",
18591869
"rustc-hash",
18601870
"smol_str",
18611871
"sourcegen",

src/tools/rust-analyzer/Cargo.toml

+7-11
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ toolchain = { path = "./crates/toolchain", version = "0.0.0" }
7979
tt = { path = "./crates/tt", version = "0.0.0" }
8080
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8181
vfs = { path = "./crates/vfs", version = "0.0.0" }
82+
rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }
8283

8384
# local crates that aren't published to crates.io. These should not have versions.
8485
proc-macro-test = { path = "./crates/proc-macro-test" }
@@ -90,9 +91,9 @@ lsp-server = { version = "0.7.4" }
9091

9192
# non-local crates
9293
smallvec = { version = "1.10.0", features = [
93-
"const_new",
94-
"union",
95-
"const_generics",
94+
"const_new",
95+
"union",
96+
"const_generics",
9697
] }
9798
smol_str = "0.2.0"
9899
nohash-hasher = "0.2.0"
@@ -101,11 +102,6 @@ serde = { version = "1.0.156", features = ["derive"] }
101102
serde_json = "1.0.96"
102103
triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
103104
# can't upgrade due to dashmap depending on 0.12.3 currently
104-
hashbrown = { version = "0.12.3", features = ["inline-more"], default-features = false }
105-
106-
rustc_lexer = { version = "0.10.0", package = "ra-ap-rustc_lexer" }
107-
rustc_parse_format = { version = "0.10.0", package = "ra-ap-rustc_parse_format", default-features = false }
108-
109-
# Upstream broke this for us so we can't update it
110-
rustc_abi = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_abi", default-features = false }
111-
rustc_index = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }
105+
hashbrown = { version = "0.12.3", features = [
106+
"inline-more",
107+
], default-features = false }

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

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe {
257257
) -> Result<Subtree, ProcMacroExpansionError>;
258258
}
259259

260+
#[derive(Debug)]
260261
pub enum ProcMacroExpansionError {
261262
Panic(String),
262263
/// Things like "proc macro server was killed by OOM".

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ smallvec.workspace = true
3131
hashbrown.workspace = true
3232
triomphe.workspace = true
3333

34-
rustc_abi.workspace = true
35-
rustc_index.workspace = true
36-
rustc_parse_format.workspace = true
37-
34+
rustc-dependencies.workspace = true
3835

3936
# local deps
4037
stdx.workspace = true
@@ -53,3 +50,6 @@ expect-test = "1.4.0"
5350

5451
# local deps
5552
test-utils.workspace = true
53+
54+
[features]
55+
in-rust-tree = ["rustc-dependencies/in-rust-tree"]

src/tools/rust-analyzer/crates/hir-def/src/body/scope.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Name resolution for expressions.
22
use hir_expand::name::Name;
3-
use la_arena::{Arena, Idx, IdxRange, RawIdx};
4-
use rustc_hash::FxHashMap;
3+
use la_arena::{Arena, ArenaMap, Idx, IdxRange, RawIdx};
54
use triomphe::Arc;
65

76
use crate::{
@@ -17,7 +16,7 @@ pub type ScopeId = Idx<ScopeData>;
1716
pub struct ExprScopes {
1817
scopes: Arena<ScopeData>,
1918
scope_entries: Arena<ScopeEntry>,
20-
scope_by_expr: FxHashMap<ExprId, ScopeId>,
19+
scope_by_expr: ArenaMap<ExprId, ScopeId>,
2120
}
2221

2322
#[derive(Debug, PartialEq, Eq)]
@@ -77,10 +76,10 @@ impl ExprScopes {
7776
}
7877

7978
pub fn scope_for(&self, expr: ExprId) -> Option<ScopeId> {
80-
self.scope_by_expr.get(&expr).copied()
79+
self.scope_by_expr.get(expr).copied()
8180
}
8281

83-
pub fn scope_by_expr(&self) -> &FxHashMap<ExprId, ScopeId> {
82+
pub fn scope_by_expr(&self) -> &ArenaMap<ExprId, ScopeId> {
8483
&self.scope_by_expr
8584
}
8685
}
@@ -94,7 +93,7 @@ impl ExprScopes {
9493
let mut scopes = ExprScopes {
9594
scopes: Arena::default(),
9695
scope_entries: Arena::default(),
97-
scope_by_expr: FxHashMap::default(),
96+
scope_by_expr: ArenaMap::with_capacity(body.exprs.len()),
9897
};
9998
let mut root = scopes.root_scope();
10099
scopes.add_params_bindings(body, root, &body.params);

src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use hir_expand::{
1111
};
1212
use intern::Interned;
1313
use la_arena::{Arena, ArenaMap};
14-
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
14+
use rustc_dependencies::abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
1515
use syntax::ast::{self, HasName, HasVisibility};
1616
use triomphe::Arc;
1717

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::mem;
33

44
use hir_expand::name::Name;
5-
use rustc_parse_format as parse;
5+
use rustc_dependencies::parse_format as parse;
66
use syntax::{
77
ast::{self, IsString},
88
AstToken, SmolStr, TextRange,

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! A map of all publicly exported items in a crate.
22
3-
use std::collections::hash_map::Entry;
4-
use std::{fmt, hash::BuildHasherDefault};
3+
use std::{collections::hash_map::Entry, fmt, hash::BuildHasherDefault};
54

65
use base_db::CrateId;
76
use fst::{self, Streamer};
@@ -11,10 +10,12 @@ use itertools::Itertools;
1110
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
1211
use triomphe::Arc;
1312

14-
use crate::item_scope::ImportOrExternCrate;
1513
use crate::{
16-
db::DefDatabase, item_scope::ItemInNs, nameres::DefMap, visibility::Visibility, AssocItemId,
17-
ModuleDefId, ModuleId, TraitId,
14+
db::DefDatabase,
15+
item_scope::{ImportOrExternCrate, ItemInNs},
16+
nameres::DefMap,
17+
visibility::Visibility,
18+
AssocItemId, ModuleDefId, ModuleId, TraitId,
1819
};
1920

2021
type FxIndexMap<K, V> = IndexMap<K, V, BuildHasherDefault<FxHasher>>;
@@ -94,7 +95,7 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> FxIndexMap<ItemIn
9495

9596
// We look only into modules that are public(ly reexported), starting with the crate root.
9697
let root = def_map.module_id(DefMap::ROOT);
97-
let mut worklist = vec![(root, 0)];
98+
let mut worklist = vec![(root, 0u32)];
9899
// Records items' minimum module depth.
99100
let mut depth_map = FxHashMap::default();
100101

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! actually true.
99
1010
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
11+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
1112

1213
#[allow(unused)]
1314
macro_rules! eprintln {
@@ -48,7 +49,7 @@ pub mod visibility;
4849
pub mod find_path;
4950
pub mod import_map;
5051

51-
pub use rustc_abi as layout;
52+
pub use rustc_dependencies::abi as layout;
5253
use triomphe::Arc;
5354

5455
#[cfg(test)]
@@ -498,10 +499,7 @@ impl_from!(Macro2Id, MacroRulesId, ProcMacroId for MacroId);
498499

499500
impl MacroId {
500501
pub fn is_attribute(self, db: &dyn db::DefDatabase) -> bool {
501-
match self {
502-
MacroId::ProcMacroId(it) => it.lookup(db).kind == ProcMacroKind::Attr,
503-
_ => false,
504-
}
502+
matches!(self, MacroId::ProcMacroId(it) if it.lookup(db).kind == ProcMacroKind::Attr)
505503
}
506504
}
507505

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ oorandom = "11.1.3"
2323
tracing = "0.1.35"
2424
rustc-hash = "1.1.0"
2525
scoped-tls = "1.0.0"
26-
chalk-solve = { version = "0.92.0", default-features = false }
27-
chalk-ir = "0.92.0"
28-
chalk-recursive = { version = "0.92.0", default-features = false }
29-
chalk-derive = "0.92.0"
26+
chalk-solve = { version = "0.93.0", default-features = false }
27+
chalk-ir = "0.93.0"
28+
chalk-recursive = { version = "0.93.0", default-features = false }
29+
chalk-derive = "0.93.0"
3030
la-arena.workspace = true
3131
once_cell = "1.17.0"
3232
triomphe.workspace = true
3333
nohash-hasher.workspace = true
3434
typed-arena = "2.0.1"
3535

36-
rustc_index.workspace = true
36+
rustc-dependencies.workspace = true
3737

3838
# local deps
3939
stdx.workspace = true
@@ -56,3 +56,6 @@ project-model = { path = "../project-model" }
5656

5757
# local deps
5858
test-utils.workspace = true
59+
60+
[features]
61+
in-rust-tree = ["rustc-dependencies/in-rust-tree"]

src/tools/rust-analyzer/crates/hir-ty/src/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mod target;
3434
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3535
pub struct RustcEnumVariantIdx(pub LocalEnumVariantId);
3636

37-
impl rustc_index::vec::Idx for RustcEnumVariantIdx {
37+
impl rustc_dependencies::index::vec::Idx for RustcEnumVariantIdx {
3838
fn new(idx: usize) -> Self {
3939
RustcEnumVariantIdx(Idx::from_raw(RawIdx::from(idx as u32)))
4040
}

src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ fn scope_for_offset(
888888
.scope_by_expr()
889889
.iter()
890890
.filter_map(|(id, scope)| {
891-
let InFile { file_id, value } = source_map.expr_syntax(*id).ok()?;
891+
let InFile { file_id, value } = source_map.expr_syntax(id).ok()?;
892892
if from_file == file_id {
893893
return Some((value.text_range(), scope));
894894
}
@@ -923,7 +923,7 @@ fn adjust(
923923
.scope_by_expr()
924924
.iter()
925925
.filter_map(|(id, scope)| {
926-
let source = source_map.expr_syntax(*id).ok()?;
926+
let source = source_map.expr_syntax(id).ok()?;
927927
// FIXME: correctly handle macro expansion
928928
if source.file_id != from_file {
929929
return None;

0 commit comments

Comments
 (0)