mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
resolve range patterns to the their struct types
This commit is contained in:
parent
2f6923b844
commit
271f64f94d
4 changed files with 141 additions and 8 deletions
|
@ -348,6 +348,26 @@ impl SourceAnalyzer {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn resolve_range_pat(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
range_pat: &ast::RangePat,
|
||||
) -> Option<StructId> {
|
||||
let path: ModPath = match (range_pat.op_kind()?, range_pat.start(), range_pat.end()) {
|
||||
(RangeOp::Exclusive, None, Some(_)) => path![core::ops::RangeTo],
|
||||
(RangeOp::Exclusive, Some(_), None) => path![core::ops::RangeFrom],
|
||||
(RangeOp::Exclusive, Some(_), Some(_)) => path![core::ops::Range],
|
||||
(RangeOp::Inclusive, None, Some(_)) => path![core::ops::RangeToInclusive],
|
||||
(RangeOp::Inclusive, Some(_), Some(_)) => path![core::ops::RangeInclusive],
|
||||
|
||||
(RangeOp::Exclusive, None, None) => return None,
|
||||
(RangeOp::Inclusive, None, None) => return None,
|
||||
(RangeOp::Inclusive, Some(_), None) => return None,
|
||||
};
|
||||
let s = self.resolver.resolve_known_struct(db.upcast(), &path);
|
||||
return s;
|
||||
}
|
||||
|
||||
pub(crate) fn resolve_range_expr(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue