mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Move parse_path to Expander
This commit is contained in:
parent
e7880db1d0
commit
5c720b256f
2 changed files with 10 additions and 10 deletions
|
@ -59,6 +59,10 @@ impl Expander {
|
|||
Source { file_id: self.current_file_id, ast }
|
||||
}
|
||||
|
||||
fn parse_path(&mut self, path: ast::Path) -> Option<Path> {
|
||||
Path::from_src(path, &self.hygiene)
|
||||
}
|
||||
|
||||
fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> {
|
||||
self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros()
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ where
|
|||
ast::Expr::PathExpr(e) => {
|
||||
let path = e
|
||||
.path()
|
||||
.and_then(|path| self.parse_path(path))
|
||||
.and_then(|path| self.expander.parse_path(path))
|
||||
.map(Expr::Path)
|
||||
.unwrap_or(Expr::Missing);
|
||||
self.alloc_expr(path, syntax_ptr)
|
||||
|
@ -286,7 +286,7 @@ where
|
|||
self.alloc_expr(Expr::Return { expr }, syntax_ptr)
|
||||
}
|
||||
ast::Expr::RecordLit(e) => {
|
||||
let path = e.path().and_then(|path| self.parse_path(path));
|
||||
let path = e.path().and_then(|path| self.expander.parse_path(path));
|
||||
let mut field_ptrs = Vec::new();
|
||||
let record_lit = if let Some(nfl) = e.record_field_list() {
|
||||
let fields = nfl
|
||||
|
@ -439,7 +439,7 @@ where
|
|||
self.db.ast_id_map(self.expander.current_file_id).ast_id(&e),
|
||||
);
|
||||
|
||||
if let Some(path) = e.path().and_then(|path| self.parse_path(path)) {
|
||||
if let Some(path) = e.path().and_then(|path| self.expander.parse_path(path)) {
|
||||
if let Some(def) = self.expander.resolve_path_as_macro(self.db, &path) {
|
||||
let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id });
|
||||
let file_id = call_id.as_file(MacroFileKind::Expr);
|
||||
|
@ -508,7 +508,7 @@ where
|
|||
Pat::Bind { name, mode: annotation, subpat }
|
||||
}
|
||||
ast::Pat::TupleStructPat(p) => {
|
||||
let path = p.path().and_then(|path| self.parse_path(path));
|
||||
let path = p.path().and_then(|path| self.expander.parse_path(path));
|
||||
let args = p.args().map(|p| self.collect_pat(p)).collect();
|
||||
Pat::TupleStruct { path, args }
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ where
|
|||
Pat::Ref { pat, mutability }
|
||||
}
|
||||
ast::Pat::PathPat(p) => {
|
||||
let path = p.path().and_then(|path| self.parse_path(path));
|
||||
let path = p.path().and_then(|path| self.expander.parse_path(path));
|
||||
path.map(Pat::Path).unwrap_or(Pat::Missing)
|
||||
}
|
||||
ast::Pat::TuplePat(p) => {
|
||||
|
@ -527,7 +527,7 @@ where
|
|||
}
|
||||
ast::Pat::PlaceholderPat(_) => Pat::Wild,
|
||||
ast::Pat::RecordPat(p) => {
|
||||
let path = p.path().and_then(|path| self.parse_path(path));
|
||||
let path = p.path().and_then(|path| self.expander.parse_path(path));
|
||||
let record_field_pat_list =
|
||||
p.record_field_pat_list().expect("every struct should have a field list");
|
||||
let mut fields: Vec<_> = record_field_pat_list
|
||||
|
@ -568,10 +568,6 @@ where
|
|||
self.missing_pat()
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_path(&mut self, path: ast::Path) -> Option<Path> {
|
||||
Path::from_src(path, &self.expander.hygiene)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ast::BinOp> for BinaryOp {
|
||||
|
|
Loading…
Reference in a new issue