Skip to content

Commit bf3c6c5

Browse files
committed
Auto merge of rust-lang#120447 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? ghost
2 parents 11f32b7 + 7159d88 commit bf3c6c5

Some content is hidden

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

79 files changed

+1391
-2796
lines changed

src/tools/rust-analyzer/Cargo.lock

+69-22
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ checksum = "5676cea088c32290fe65c82895be9d06dd21e0fa49bb97ca840529e9417ab71a"
166166
dependencies = [
167167
"proc-macro2",
168168
"quote",
169-
"syn",
169+
"syn 2.0.39",
170170
"synstructure",
171171
]
172172

@@ -312,6 +312,17 @@ dependencies = [
312312
"parking_lot_core",
313313
]
314314

315+
[[package]]
316+
name = "derivative"
317+
version = "2.2.0"
318+
source = "registry+https://github.com/rust-lang/crates.io-index"
319+
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
320+
dependencies = [
321+
"proc-macro2",
322+
"quote",
323+
"syn 1.0.109",
324+
]
325+
315326
[[package]]
316327
name = "derive_arbitrary"
317328
version = "1.3.2"
@@ -320,7 +331,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611"
320331
dependencies = [
321332
"proc-macro2",
322333
"quote",
323-
"syn",
334+
"syn 2.0.39",
324335
]
325336

326337
[[package]]
@@ -582,6 +593,7 @@ dependencies = [
582593
"project-model",
583594
"ra-ap-rustc_abi",
584595
"ra-ap-rustc_index",
596+
"ra-ap-rustc_pattern_analysis",
585597
"rustc-hash",
586598
"scoped-tls",
587599
"smallvec",
@@ -1407,20 +1419,20 @@ dependencies = [
14071419

14081420
[[package]]
14091421
name = "ra-ap-rustc_abi"
1410-
version = "0.21.0"
1422+
version = "0.33.0"
14111423
source = "registry+https://github.com/rust-lang/crates.io-index"
1412-
checksum = "7816f980fab89e878ff2e916e2077d484e3aa1c619a3cc982c8a417c3dfe45fa"
1424+
checksum = "8ce9100fc66c6c60aeeb076868ead9c2eaa65d6a5a90404f08c242327a92ff4b"
14131425
dependencies = [
1414-
"bitflags 1.3.2",
1426+
"bitflags 2.4.1",
14151427
"ra-ap-rustc_index",
14161428
"tracing",
14171429
]
14181430

14191431
[[package]]
14201432
name = "ra-ap-rustc_index"
1421-
version = "0.21.0"
1433+
version = "0.33.0"
14221434
source = "registry+https://github.com/rust-lang/crates.io-index"
1423-
checksum = "8352918d61aa4afab9f2ed7314cf638976b20949b3d61d2f468c975b0d251f24"
1435+
checksum = "5e5313d7f243b63ef9e58d94355b11aa8499f1328055f1f58adf0a5ea7d2faca"
14241436
dependencies = [
14251437
"arrayvec",
14261438
"ra-ap-rustc_index_macros",
@@ -1429,36 +1441,50 @@ dependencies = [
14291441

14301442
[[package]]
14311443
name = "ra-ap-rustc_index_macros"
1432-
version = "0.21.0"
1444+
version = "0.33.0"
14331445
source = "registry+https://github.com/rust-lang/crates.io-index"
1434-
checksum = "66a9424018828155a3e3596515598f90e68427d8f35eff6df7f0856c73fc58a8"
1446+
checksum = "a83108ebf3e73dde205b9c25706209bcd7736480820f90ded28eabaf8b469f25"
14351447
dependencies = [
14361448
"proc-macro2",
14371449
"quote",
1438-
"syn",
1450+
"syn 2.0.39",
14391451
"synstructure",
14401452
]
14411453

14421454
[[package]]
14431455
name = "ra-ap-rustc_lexer"
1444-
version = "0.21.0"
1456+
version = "0.33.0"
14451457
source = "registry+https://github.com/rust-lang/crates.io-index"
1446-
checksum = "dc741c7a78103efab416b562e35bd73c8d4967478575010c86c6062f8d3cbf29"
1458+
checksum = "d2d221356e5717595e8a0afa5fba1620dcb4032ab784dc4d98fdc7284e3feb66"
14471459
dependencies = [
14481460
"unicode-properties",
14491461
"unicode-xid",
14501462
]
14511463

14521464
[[package]]
14531465
name = "ra-ap-rustc_parse_format"
1454-
version = "0.21.0"
1466+
version = "0.33.0"
14551467
source = "registry+https://github.com/rust-lang/crates.io-index"
1456-
checksum = "d557201d71792487bd2bab637ab5be9aa6fff59b88e25e12de180b0f9d2df60f"
1468+
checksum = "ab62fc925612374103b4f178da347b535b35d9eb1ff5ba42105c990b2e25a164"
14571469
dependencies = [
14581470
"ra-ap-rustc_index",
14591471
"ra-ap-rustc_lexer",
14601472
]
14611473

1474+
[[package]]
1475+
name = "ra-ap-rustc_pattern_analysis"
1476+
version = "0.33.0"
1477+
source = "registry+https://github.com/rust-lang/crates.io-index"
1478+
checksum = "6c4085e0c771fd4b883930b599ef42966b855762bbe4052c17673b3253421a6d"
1479+
dependencies = [
1480+
"derivative",
1481+
"ra-ap-rustc_index",
1482+
"rustc-hash",
1483+
"rustc_apfloat",
1484+
"smallvec",
1485+
"tracing",
1486+
]
1487+
14621488
[[package]]
14631489
name = "rayon"
14641490
version = "1.8.0"
@@ -1593,7 +1619,7 @@ dependencies = [
15931619
"heck",
15941620
"proc-macro2",
15951621
"quote",
1596-
"syn",
1622+
"syn 2.0.39",
15971623
]
15981624

15991625
[[package]]
@@ -1608,6 +1634,16 @@ version = "1.1.0"
16081634
source = "registry+https://github.com/rust-lang/crates.io-index"
16091635
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
16101636

1637+
[[package]]
1638+
name = "rustc_apfloat"
1639+
version = "0.2.0+llvm-462a31f5a5ab"
1640+
source = "registry+https://github.com/rust-lang/crates.io-index"
1641+
checksum = "465187772033a5ee566f69fe008df03628fce549a0899aae76f0a0c2e34696be"
1642+
dependencies = [
1643+
"bitflags 1.3.2",
1644+
"smallvec",
1645+
]
1646+
16111647
[[package]]
16121648
name = "ryu"
16131649
version = "1.0.13"
@@ -1670,7 +1706,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
16701706
dependencies = [
16711707
"proc-macro2",
16721708
"quote",
1673-
"syn",
1709+
"syn 2.0.39",
16741710
]
16751711

16761712
[[package]]
@@ -1693,7 +1729,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab"
16931729
dependencies = [
16941730
"proc-macro2",
16951731
"quote",
1696-
"syn",
1732+
"syn 2.0.39",
16971733
]
16981734

16991735
[[package]]
@@ -1707,9 +1743,9 @@ dependencies = [
17071743

17081744
[[package]]
17091745
name = "smallvec"
1710-
version = "1.10.0"
1746+
version = "1.12.0"
17111747
source = "registry+https://github.com/rust-lang/crates.io-index"
1712-
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
1748+
checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e"
17131749

17141750
[[package]]
17151751
name = "smol_str"
@@ -1770,6 +1806,17 @@ dependencies = [
17701806
"winapi",
17711807
]
17721808

1809+
[[package]]
1810+
name = "syn"
1811+
version = "1.0.109"
1812+
source = "registry+https://github.com/rust-lang/crates.io-index"
1813+
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
1814+
dependencies = [
1815+
"proc-macro2",
1816+
"quote",
1817+
"unicode-ident",
1818+
]
1819+
17731820
[[package]]
17741821
name = "syn"
17751822
version = "2.0.39"
@@ -1789,7 +1836,7 @@ checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06"
17891836
dependencies = [
17901837
"proc-macro2",
17911838
"quote",
1792-
"syn",
1839+
"syn 2.0.39",
17931840
"unicode-xid",
17941841
]
17951842

@@ -1876,7 +1923,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
18761923
dependencies = [
18771924
"proc-macro2",
18781925
"quote",
1879-
"syn",
1926+
"syn 2.0.39",
18801927
]
18811928

18821929
[[package]]
@@ -1977,7 +2024,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
19772024
dependencies = [
19782025
"proc-macro2",
19792026
"quote",
1980-
"syn",
2027+
"syn 2.0.39",
19812028
]
19822029

19832030
[[package]]

src/tools/rust-analyzer/Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ tt = { path = "./crates/tt", version = "0.0.0" }
7979
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8080
vfs = { path = "./crates/vfs", version = "0.0.0" }
8181

82-
ra-ap-rustc_lexer = { version = "0.21.0", default-features = false }
83-
ra-ap-rustc_parse_format = { version = "0.21.0", default-features = false }
84-
ra-ap-rustc_index = { version = "0.21.0", default-features = false }
85-
ra-ap-rustc_abi = { version = "0.21.0", default-features = false }
82+
ra-ap-rustc_lexer = { version = "0.33.0", default-features = false }
83+
ra-ap-rustc_parse_format = { version = "0.33.0", default-features = false }
84+
ra-ap-rustc_index = { version = "0.33.0", default-features = false }
85+
ra-ap-rustc_abi = { version = "0.33.0", default-features = false }
86+
ra-ap-rustc_pattern_analysis = { version = "0.33.0", default-features = false }
8687

8788
# local crates that aren't published to crates.io. These should not have versions.
8889
sourcegen = { path = "./crates/sourcegen" }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
#![warn(rust_2018_idioms, unused_lifetimes)]
44

5-
mod input;
65
mod change;
6+
mod input;
77

88
use std::panic;
99

src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs

-22
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,6 @@ pub enum CfgAtom {
1818
KeyValue { key: SmolStr, value: SmolStr },
1919
}
2020

21-
impl CfgAtom {
22-
/// Returns `true` when the atom comes from the target specification.
23-
///
24-
/// If this returns `true`, then changing this atom requires changing the compilation target. If
25-
/// it returns `false`, the atom might come from a build script or the build system.
26-
pub fn is_target_defined(&self) -> bool {
27-
match self {
28-
CfgAtom::Flag(flag) => matches!(&**flag, "unix" | "windows"),
29-
CfgAtom::KeyValue { key, value: _ } => matches!(
30-
&**key,
31-
"target_arch"
32-
| "target_os"
33-
| "target_env"
34-
| "target_family"
35-
| "target_endian"
36-
| "target_pointer_width"
37-
| "target_vendor" // NOTE: `target_feature` is left out since it can be configured via `-Ctarget-feature`
38-
),
39-
}
40-
}
41-
}
42-
4321
impl fmt::Display for CfgAtom {
4422
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4523
match self {

src/tools/rust-analyzer/crates/cfg/src/lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,9 @@ impl CfgDiff {
131131
/// of both.
132132
pub fn new(enable: Vec<CfgAtom>, disable: Vec<CfgAtom>) -> Option<CfgDiff> {
133133
let mut occupied = FxHashSet::default();
134-
for item in enable.iter().chain(disable.iter()) {
135-
if !occupied.insert(item) {
136-
// was present
137-
return None;
138-
}
134+
if enable.iter().chain(disable.iter()).any(|item| !occupied.insert(item)) {
135+
// was present
136+
return None;
139137
}
140138

141139
Some(CfgDiff { enable, disable })

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::{
3232
VariantId,
3333
};
3434

35+
/// Desugared attributes of an item post `cfg_attr` expansion.
3536
#[derive(Default, Debug, Clone, PartialEq, Eq)]
3637
pub struct Attrs(RawAttrs);
3738

@@ -228,7 +229,6 @@ pub enum DocAtom {
228229
KeyValue { key: SmolStr, value: SmolStr },
229230
}
230231

231-
// Adapted from `CfgExpr` parsing code
232232
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
233233
pub enum DocExpr {
234234
Invalid,
@@ -448,10 +448,7 @@ impl AttrsWithOwner {
448448
let map = db.fields_attrs_source_map(id.parent);
449449
let file_id = id.parent.file_id(db);
450450
let root = db.parse_or_expand(file_id);
451-
let owner = match &map[id.local_id] {
452-
Either::Left(it) => ast::AnyHasAttrs::new(it.to_node(&root)),
453-
Either::Right(it) => ast::AnyHasAttrs::new(it.to_node(&root)),
454-
};
451+
let owner = ast::AnyHasAttrs::new(map[id.local_id].to_node(&root));
455452
InFile::new(file_id, owner)
456453
}
457454
AttrDefId::AdtId(adt) => match adt {
@@ -634,7 +631,7 @@ fn attrs_from_item_tree_assoc<'db, N: ItemTreeModItemNode>(
634631
pub(crate) fn fields_attrs_source_map(
635632
db: &dyn DefDatabase,
636633
def: VariantId,
637-
) -> Arc<ArenaMap<LocalFieldId, Either<AstPtr<ast::TupleField>, AstPtr<ast::RecordField>>>> {
634+
) -> Arc<ArenaMap<LocalFieldId, AstPtr<Either<ast::TupleField, ast::RecordField>>>> {
638635
let mut res = ArenaMap::default();
639636
let child_source = def.child_source(db);
640637

@@ -643,7 +640,7 @@ pub(crate) fn fields_attrs_source_map(
643640
idx,
644641
variant
645642
.as_ref()
646-
.either(|l| Either::Left(AstPtr::new(l)), |r| Either::Right(AstPtr::new(r))),
643+
.either(|l| AstPtr::new(l).wrap_left(), |r| AstPtr::new(r).wrap_right()),
647644
);
648645
}
649646

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Defines `Body`: a lowered representation of bodies of functions, statics and
22
//! consts.
33
mod lower;
4+
mod pretty;
5+
pub mod scope;
46
#[cfg(test)]
57
mod tests;
6-
pub mod scope;
7-
mod pretty;
88

99
use std::ops::Index;
1010

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

+1
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ impl ExprCollector<'_> {
13351335
let args = record_pat_field_list
13361336
.fields()
13371337
.filter_map(|f| {
1338+
self.check_cfg(&f)?;
13381339
let ast_pat = f.pat()?;
13391340
let pat = self.collect_pat(ast_pat, binding_list);
13401341
let name = f.field_name()?.as_name();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
194194
fn fields_attrs_source_map(
195195
&self,
196196
def: VariantId,
197-
) -> Arc<ArenaMap<LocalFieldId, Either<AstPtr<ast::TupleField>, AstPtr<ast::RecordField>>>>;
197+
) -> Arc<ArenaMap<LocalFieldId, AstPtr<Either<ast::TupleField, ast::RecordField>>>>;
198198

199199
#[salsa::invoke(AttrsWithOwner::attrs_query)]
200200
fn attrs(&self, def: AttrDefId) -> Attrs;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
//!
1313
//! See also a neighboring `body` module.
1414
15-
pub mod type_ref;
1615
pub mod format_args;
16+
pub mod type_ref;
1717

1818
use std::fmt;
1919

0 commit comments

Comments
 (0)