mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 10:17:15 +00:00
Equip infer_pat_* with declaration origin
This commit is contained in:
parent
5a3488a43e
commit
7befcb32e4
4 changed files with 101 additions and 26 deletions
|
|
@ -1049,3 +1049,21 @@ pub fn known_const_to_ast(
|
|||
}
|
||||
Some(make::expr_const_value(konst.display(db, edition).to_string().as_str()))
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub(crate) enum DeclOrigin {
|
||||
// from an `if let` expression
|
||||
LetExpr,
|
||||
// from `let x = ..`
|
||||
LocalDecl,
|
||||
}
|
||||
|
||||
/// Provides context for checking patterns in declarations. More specifically this
|
||||
/// allows us to infer array types if the pattern is irrefutable and allows us to infer
|
||||
/// the size of the array. See issue #76342.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub(crate) struct DeclContext {
|
||||
// whether we're in a let-else context
|
||||
pub(crate) has_else: bool,
|
||||
pub(crate) origin: DeclOrigin,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue