Skip to content

Commit 8e24499

Browse files
committed
Auto merge of #134177 - matthiaskrgr:rollup-hgp8q60, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #132975 (De-duplicate and improve definition of core::ffi::c_char) - #133598 (Change `GetManyMutError` to match T-libs-api decision) - #134148 (add comments in check_expr_field) - #134163 (coverage: Rearrange the code for embedding per-function coverage metadata) - #134165 (wasm(32|64): update alignment string) - #134170 (Subtree update of `rust-analyzer`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4c05bc7 + 48f34bb commit 8e24499

File tree

226 files changed

+7515
-2865
lines changed

Some content is hidden

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

226 files changed

+7515
-2865
lines changed

Cargo.lock

+31-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ tt = { path = "./crates/tt", version = "0.0.0" }
8484
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8585
vfs = { path = "./crates/vfs", version = "0.0.0" }
8686

87-
ra-ap-rustc_lexer = { version = "0.80", default-features = false }
88-
ra-ap-rustc_parse_format = { version = "0.80", default-features = false }
89-
ra-ap-rustc_index = { version = "0.80", default-features = false }
90-
ra-ap-rustc_abi = { version = "0.80", default-features = false }
91-
ra-ap-rustc_pattern_analysis = { version = "0.80", default-features = false }
87+
ra-ap-rustc_lexer = { version = "0.85", default-features = false }
88+
ra-ap-rustc_parse_format = { version = "0.85", default-features = false }
89+
ra-ap-rustc_index = { version = "0.85", default-features = false }
90+
ra-ap-rustc_abi = { version = "0.85", default-features = false }
91+
ra-ap-rustc_pattern_analysis = { version = "0.85", default-features = false }
9292

9393
# local crates that aren't published to crates.io. These should not have versions.
9494
test-fixture = { path = "./crates/test-fixture" }

crates/base-db/src/input.rs

-23
Original file line numberDiff line numberDiff line change
@@ -547,29 +547,6 @@ impl CrateGraph {
547547
None
548548
}
549549

550-
// Work around for https://github.com/rust-lang/rust-analyzer/issues/6038.
551-
// As hacky as it gets.
552-
pub fn patch_cfg_if(&mut self) -> bool {
553-
// we stupidly max by version in an attempt to have all duplicated std's depend on the same cfg_if so that deduplication still works
554-
let cfg_if =
555-
self.hacky_find_crate("cfg_if").max_by_key(|&it| self.arena[it].version.clone());
556-
let std = self.hacky_find_crate("std").next();
557-
match (cfg_if, std) {
558-
(Some(cfg_if), Some(std)) => {
559-
self.arena[cfg_if].dependencies.clear();
560-
self.arena[std]
561-
.dependencies
562-
.push(Dependency::new(CrateName::new("cfg_if").unwrap(), cfg_if));
563-
true
564-
}
565-
_ => false,
566-
}
567-
}
568-
569-
fn hacky_find_crate<'a>(&'a self, display_name: &'a str) -> impl Iterator<Item = CrateId> + 'a {
570-
self.iter().filter(move |it| self[*it].display_name.as_deref() == Some(display_name))
571-
}
572-
573550
/// Removes all crates from this crate graph except for the ones in `to_keep` and fixes up the dependencies.
574551
/// Returns a mapping from old crate ids to new crate ids.
575552
pub fn remove_crates_except(&mut self, to_keep: &[CrateId]) -> Vec<Option<CrateId>> {

crates/hir-def/src/body.rs

+133-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
path::{ModPath, Path},
3232
src::HasSource,
3333
type_ref::{TypeRef, TypeRefId, TypesMap, TypesSourceMap},
34-
BlockId, DefWithBodyId, HasModule, Lookup,
34+
BlockId, DefWithBodyId, HasModule, Lookup, SyntheticSyntax,
3535
};
3636

3737
/// A wrapper around [`span::SyntaxContextId`] that is intended only for comparisons.
@@ -141,7 +141,7 @@ pub struct BodySourceMap {
141141
field_map_back: FxHashMap<ExprId, FieldSource>,
142142
pat_field_map_back: FxHashMap<PatId, PatFieldSource>,
143143

144-
types: TypesSourceMap,
144+
pub types: TypesSourceMap,
145145

146146
// FIXME: Make this a sane struct.
147147
template_map: Option<
@@ -160,9 +160,6 @@ pub struct BodySourceMap {
160160
diagnostics: Vec<BodyDiagnostic>,
161161
}
162162

163-
#[derive(Default, Debug, Eq, PartialEq, Clone, Copy)]
164-
pub struct SyntheticSyntax;
165-
166163
#[derive(Debug, Eq, PartialEq)]
167164
pub enum BodyDiagnostic {
168165
InactiveCode { node: InFile<SyntaxNodePtr>, cfg: CfgExpr, opts: CfgOptions },
@@ -408,7 +405,8 @@ impl Body {
408405
f(else_branch);
409406
}
410407
}
411-
Expr::Let { expr, .. } => {
408+
Expr::Let { expr, pat } => {
409+
self.walk_exprs_in_pat(*pat, &mut f);
412410
f(*expr);
413411
}
414412
Expr::Block { statements, tail, .. }
@@ -444,7 +442,10 @@ impl Body {
444442
}
445443
Expr::Match { expr, arms } => {
446444
f(*expr);
447-
arms.iter().map(|arm| arm.expr).for_each(f);
445+
arms.iter().for_each(|arm| {
446+
f(arm.expr);
447+
self.walk_exprs_in_pat(arm.pat, &mut f);
448+
});
448449
}
449450
Expr::Break { expr, .. }
450451
| Expr::Return { expr }
@@ -505,6 +506,131 @@ impl Body {
505506
}
506507
}
507508

509+
pub fn walk_child_exprs_without_pats(&self, expr_id: ExprId, mut f: impl FnMut(ExprId)) {
510+
let expr = &self[expr_id];
511+
match expr {
512+
Expr::Continue { .. }
513+
| Expr::Const(_)
514+
| Expr::Missing
515+
| Expr::Path(_)
516+
| Expr::OffsetOf(_)
517+
| Expr::Literal(_)
518+
| Expr::Underscore => {}
519+
Expr::InlineAsm(it) => it.operands.iter().for_each(|(_, op)| match op {
520+
AsmOperand::In { expr, .. }
521+
| AsmOperand::Out { expr: Some(expr), .. }
522+
| AsmOperand::InOut { expr, .. } => f(*expr),
523+
AsmOperand::SplitInOut { in_expr, out_expr, .. } => {
524+
f(*in_expr);
525+
if let Some(out_expr) = out_expr {
526+
f(*out_expr);
527+
}
528+
}
529+
AsmOperand::Out { expr: None, .. }
530+
| AsmOperand::Const(_)
531+
| AsmOperand::Label(_)
532+
| AsmOperand::Sym(_) => (),
533+
}),
534+
Expr::If { condition, then_branch, else_branch } => {
535+
f(*condition);
536+
f(*then_branch);
537+
if let &Some(else_branch) = else_branch {
538+
f(else_branch);
539+
}
540+
}
541+
Expr::Let { expr, .. } => {
542+
f(*expr);
543+
}
544+
Expr::Block { statements, tail, .. }
545+
| Expr::Unsafe { statements, tail, .. }
546+
| Expr::Async { statements, tail, .. } => {
547+
for stmt in statements.iter() {
548+
match stmt {
549+
Statement::Let { initializer, else_branch, .. } => {
550+
if let &Some(expr) = initializer {
551+
f(expr);
552+
}
553+
if let &Some(expr) = else_branch {
554+
f(expr);
555+
}
556+
}
557+
Statement::Expr { expr: expression, .. } => f(*expression),
558+
Statement::Item(_) => (),
559+
}
560+
}
561+
if let &Some(expr) = tail {
562+
f(expr);
563+
}
564+
}
565+
Expr::Loop { body, .. } => f(*body),
566+
Expr::Call { callee, args, .. } => {
567+
f(*callee);
568+
args.iter().copied().for_each(f);
569+
}
570+
Expr::MethodCall { receiver, args, .. } => {
571+
f(*receiver);
572+
args.iter().copied().for_each(f);
573+
}
574+
Expr::Match { expr, arms } => {
575+
f(*expr);
576+
arms.iter().map(|arm| arm.expr).for_each(f);
577+
}
578+
Expr::Break { expr, .. }
579+
| Expr::Return { expr }
580+
| Expr::Yield { expr }
581+
| Expr::Yeet { expr } => {
582+
if let &Some(expr) = expr {
583+
f(expr);
584+
}
585+
}
586+
Expr::Become { expr } => f(*expr),
587+
Expr::RecordLit { fields, spread, .. } => {
588+
for field in fields.iter() {
589+
f(field.expr);
590+
}
591+
if let &Some(expr) = spread {
592+
f(expr);
593+
}
594+
}
595+
Expr::Closure { body, .. } => {
596+
f(*body);
597+
}
598+
Expr::BinaryOp { lhs, rhs, .. } => {
599+
f(*lhs);
600+
f(*rhs);
601+
}
602+
Expr::Range { lhs, rhs, .. } => {
603+
if let &Some(lhs) = rhs {
604+
f(lhs);
605+
}
606+
if let &Some(rhs) = lhs {
607+
f(rhs);
608+
}
609+
}
610+
Expr::Index { base, index, .. } => {
611+
f(*base);
612+
f(*index);
613+
}
614+
Expr::Field { expr, .. }
615+
| Expr::Await { expr }
616+
| Expr::Cast { expr, .. }
617+
| Expr::Ref { expr, .. }
618+
| Expr::UnaryOp { expr, .. }
619+
| Expr::Box { expr } => {
620+
f(*expr);
621+
}
622+
Expr::Tuple { exprs, .. } => exprs.iter().copied().for_each(f),
623+
Expr::Array(a) => match a {
624+
Array::ElementList { elements, .. } => elements.iter().copied().for_each(f),
625+
Array::Repeat { initializer, repeat } => {
626+
f(*initializer);
627+
f(*repeat)
628+
}
629+
},
630+
&Expr::Assignment { target: _, value } => f(value),
631+
}
632+
}
633+
508634
pub fn walk_exprs_in_pat(&self, pat_id: PatId, f: &mut impl FnMut(ExprId)) {
509635
self.walk_pats(pat_id, &mut |pat| {
510636
if let Pat::Expr(expr) | Pat::ConstBlock(expr) = self[pat] {

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -1510,20 +1510,20 @@ impl ExprCollector<'_> {
15101510
BuiltinShadowMode::Other,
15111511
None,
15121512
);
1513+
// Funnily enough, record structs/variants *can* be shadowed
1514+
// by pattern bindings (but unit or tuple structs/variants
1515+
// can't).
15131516
match resolved.take_values() {
15141517
Some(ModuleDefId::ConstId(_)) => (None, Pat::Path(name.into())),
1515-
Some(ModuleDefId::EnumVariantId(_)) => {
1516-
// this is only really valid for unit variants, but
1517-
// shadowing other enum variants with a pattern is
1518-
// an error anyway
1518+
Some(ModuleDefId::EnumVariantId(variant))
1519+
if self.db.variant_data(variant.into()).kind()
1520+
!= StructKind::Record =>
1521+
{
15191522
(None, Pat::Path(name.into()))
15201523
}
15211524
Some(ModuleDefId::AdtId(AdtId::StructId(s)))
15221525
if self.db.struct_data(s).variant_data.kind() != StructKind::Record =>
15231526
{
1524-
// Funnily enough, record structs *can* be shadowed
1525-
// by pattern bindings (but unit or tuple structs
1526-
// can't).
15271527
(None, Pat::Path(name.into()))
15281528
}
15291529
// shadowing statics is an error as well, so we just ignore that case here

0 commit comments

Comments
 (0)