Skip to content

Reduce size of InferenceResult #19891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ tracing-subscriber = { version = "0.3.19", default-features = false, features =
triomphe = { version = "0.1.14", default-features = false, features = ["std"] }
url = "2.5.4"
xshell = "0.2.7"
thin-vec = "0.2.14"

# We need to freeze the version of the crate, as the raw-api feature is considered unstable
dashmap = { version = "=6.1.0", features = ["raw-api", "inline"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ text-size.workspace = true
salsa.workspace = true
salsa-macros.workspace = true
query-group.workspace = true
thin-vec.workspace = true

ra-ap-rustc_parse_format.workspace = true
ra-ap-rustc_abi.workspace = true
Expand All @@ -44,7 +45,6 @@ mbe.workspace = true
cfg.workspace = true
tt.workspace = true
span.workspace = true
thin-vec = "0.2.14"

[dev-dependencies]
expect-test.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-ty/src/diagnostics/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ impl ExprValidator {
fn is_known_valid_scrutinee(&self, scrutinee_expr: ExprId, db: &dyn HirDatabase) -> bool {
if self
.infer
.expr_adjustments
.get(&scrutinee_expr)
.is_some_and(|adjusts| adjusts.iter().any(|a| matches!(a.kind, Adjust::Deref(..))))
.expr_adjustments(scrutinee_expr)
.iter()
.any(|a| matches!(a.kind, Adjust::Deref(..)))
{
return false;
}
Expand Down
10 changes: 3 additions & 7 deletions crates/hir-ty/src/diagnostics/match_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,9 @@ impl<'a> PatCtxt<'a> {
// Pattern adjustment is part of RFC 2005-match-ergonomics.
// More info https://github.com/rust-lang/rust/issues/42640#issuecomment-313535089
let unadjusted_pat = self.lower_pattern_unadjusted(pat);
self.infer.pat_adjustments.get(&pat).map(|it| &**it).unwrap_or_default().iter().rev().fold(
unadjusted_pat,
|subpattern, ref_ty| Pat {
ty: ref_ty.clone(),
kind: Box::new(PatKind::Deref { subpattern }),
},
)
self.infer.pat_adjustments(pat).iter().rev().fold(unadjusted_pat, |subpattern, ref_ty| {
Pat { ty: ref_ty.target.clone(), kind: Box::new(PatKind::Deref { subpattern }) }
})
}

fn lower_pattern_unadjusted(&mut self, pat: PatId) -> Pat {
Expand Down
Loading