Skip to content

Commit f43cea0

Browse files
committed
Merge commit '7219414e81810fd4d967136c4a0650523892c157' into sync-from-ra
1 parent 858f4ac commit f43cea0

Some content is hidden

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

78 files changed

+1390
-2796
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 4 deletions
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" }

crates/base-db/src/lib.rs

Lines changed: 1 addition & 1 deletion
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

crates/cfg/src/cfg_expr.rs

Lines changed: 0 additions & 22 deletions
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 {

crates/cfg/src/lib.rs

Lines changed: 3 additions & 5 deletions
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 })

crates/hir-def/src/attr.rs

Lines changed: 4 additions & 7 deletions
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

crates/hir-def/src/body.rs

Lines changed: 2 additions & 2 deletions
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

crates/hir-def/src/body/lower.rs

Lines changed: 1 addition & 0 deletions
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();

crates/hir-def/src/db.rs

Lines changed: 1 addition & 1 deletion
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;

crates/hir-def/src/hir.rs

Lines changed: 1 addition & 1 deletion
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)