Skip to content

Commit 371a880

Browse files
Feature a "type annotations needed diagnostic" when an infer var cannot be resolved at the end of inference
1 parent 7dab289 commit 371a880

45 files changed

Lines changed: 851 additions & 308 deletions

Some content is hidden

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

crates/hir-def/src/expr_store.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ impl ExpressionStore {
561561
| Pat::ConstBlock(..)
562562
| Pat::Wild
563563
| Pat::Missing
564+
| Pat::Rest
564565
| Pat::Expr(_) => {}
565566
&Pat::Bind { subpat, .. } => {
566567
if let Some(subpat) = subpat {

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,15 +2622,7 @@ impl<'db> ExprCollector<'db> {
26222622
let expr_id = self.alloc_expr(expr, expr_ptr);
26232623
Pat::Lit(expr_id)
26242624
}
2625-
ast::Pat::RestPat(_) => {
2626-
// `RestPat` requires special handling and should not be mapped
2627-
// to a Pat. Here we are using `Pat::Missing` as a fallback for
2628-
// when `RestPat` is mapped to `Pat`, which can easily happen
2629-
// when the source code being analyzed has a malformed pattern
2630-
// which includes `..` in a place where it isn't valid.
2631-
2632-
Pat::Missing
2633-
}
2625+
ast::Pat::RestPat(_) => Pat::Rest,
26342626
ast::Pat::BoxPat(boxpat) => {
26352627
let inner = self.collect_pat_opt(boxpat.pat(), binding_list);
26362628
Pat::Box { inner }

crates/hir-def/src/expr_store/pretty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ impl Printer<'_> {
895895

896896
match pat {
897897
Pat::Missing => w!(self, "�"),
898+
Pat::Rest => w!(self, ".."),
898899
Pat::Wild => w!(self, "_"),
899900
Pat::Tuple { args, ellipsis } => {
900901
w!(self, "(");

crates/hir-def/src/hir.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,8 @@ pub struct RecordFieldPat {
666666
#[derive(Debug, Clone, Eq, PartialEq)]
667667
pub enum Pat {
668668
Missing,
669+
/// A rest pattern. Not valid outside special context.
670+
Rest,
669671
Wild,
670672
Tuple {
671673
args: Box<[PatId]>,
@@ -721,6 +723,7 @@ impl Pat {
721723
| Pat::ConstBlock(..)
722724
| Pat::Wild
723725
| Pat::Missing
726+
| Pat::Rest
724727
| Pat::Expr(_) => {}
725728
Pat::Bind { subpat, .. } => {
726729
subpat.iter().copied().for_each(f);

crates/hir-ty/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
147147

148148
#[salsa::invoke(crate::lower::const_param_ty_query)]
149149
#[salsa::transparent]
150-
fn const_param_ty_ns<'db>(&'db self, def: ConstParamId) -> Ty<'db>;
150+
fn const_param_ty<'db>(&'db self, def: ConstParamId) -> Ty<'db>;
151151

152152
#[salsa::invoke(crate::lower::impl_trait_with_diagnostics)]
153153
#[salsa::transparent]

crates/hir-ty/src/diagnostics/unsafe_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'db> UnsafeVisitor<'db> {
258258
self.on_unsafe_op(current.into(), UnsafetyReason::UnionField)
259259
}
260260
// `Or` only wraps other patterns, and `Missing`/`Wild` do not constitute a read.
261-
Pat::Missing | Pat::Wild | Pat::Or(_) => {}
261+
Pat::Missing | Pat::Rest | Pat::Wild | Pat::Or(_) => {}
262262
}
263263
}
264264

0 commit comments

Comments
 (0)