diff options
author | Aleksey Kladov <[email protected]> | 2019-11-14 06:58:39 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-14 06:58:39 +0000 |
commit | 5c720b256f5d73434250072cc65fead746250d87 (patch) | |
tree | a3e7407ddbf0a5f398824eb7749b700d13eca587 /crates/ra_hir_def/src/body/lower.rs | |
parent | e7880db1d0f75c639ee561b586219648bd05c21c (diff) |
Move parse_path to Expander
Diffstat (limited to 'crates/ra_hir_def/src/body/lower.rs')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 5c291421a..29c1ec2a1 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -262,7 +262,7 @@ where | |||
262 | ast::Expr::PathExpr(e) => { | 262 | ast::Expr::PathExpr(e) => { |
263 | let path = e | 263 | let path = e |
264 | .path() | 264 | .path() |
265 | .and_then(|path| self.parse_path(path)) | 265 | .and_then(|path| self.expander.parse_path(path)) |
266 | .map(Expr::Path) | 266 | .map(Expr::Path) |
267 | .unwrap_or(Expr::Missing); | 267 | .unwrap_or(Expr::Missing); |
268 | self.alloc_expr(path, syntax_ptr) | 268 | self.alloc_expr(path, syntax_ptr) |
@@ -286,7 +286,7 @@ where | |||
286 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) | 286 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) |
287 | } | 287 | } |
288 | ast::Expr::RecordLit(e) => { | 288 | ast::Expr::RecordLit(e) => { |
289 | let path = e.path().and_then(|path| self.parse_path(path)); | 289 | let path = e.path().and_then(|path| self.expander.parse_path(path)); |
290 | let mut field_ptrs = Vec::new(); | 290 | let mut field_ptrs = Vec::new(); |
291 | let record_lit = if let Some(nfl) = e.record_field_list() { | 291 | let record_lit = if let Some(nfl) = e.record_field_list() { |
292 | let fields = nfl | 292 | let fields = nfl |
@@ -439,7 +439,7 @@ where | |||
439 | self.db.ast_id_map(self.expander.current_file_id).ast_id(&e), | 439 | self.db.ast_id_map(self.expander.current_file_id).ast_id(&e), |
440 | ); | 440 | ); |
441 | 441 | ||
442 | if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { | 442 | if let Some(path) = e.path().and_then(|path| self.expander.parse_path(path)) { |
443 | if let Some(def) = self.expander.resolve_path_as_macro(self.db, &path) { | 443 | if let Some(def) = self.expander.resolve_path_as_macro(self.db, &path) { |
444 | let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id }); | 444 | let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id }); |
445 | let file_id = call_id.as_file(MacroFileKind::Expr); | 445 | let file_id = call_id.as_file(MacroFileKind::Expr); |
@@ -508,7 +508,7 @@ where | |||
508 | Pat::Bind { name, mode: annotation, subpat } | 508 | Pat::Bind { name, mode: annotation, subpat } |
509 | } | 509 | } |
510 | ast::Pat::TupleStructPat(p) => { | 510 | ast::Pat::TupleStructPat(p) => { |
511 | let path = p.path().and_then(|path| self.parse_path(path)); | 511 | let path = p.path().and_then(|path| self.expander.parse_path(path)); |
512 | let args = p.args().map(|p| self.collect_pat(p)).collect(); | 512 | let args = p.args().map(|p| self.collect_pat(p)).collect(); |
513 | Pat::TupleStruct { path, args } | 513 | Pat::TupleStruct { path, args } |
514 | } | 514 | } |
@@ -518,7 +518,7 @@ where | |||
518 | Pat::Ref { pat, mutability } | 518 | Pat::Ref { pat, mutability } |
519 | } | 519 | } |
520 | ast::Pat::PathPat(p) => { | 520 | ast::Pat::PathPat(p) => { |
521 | let path = p.path().and_then(|path| self.parse_path(path)); | 521 | let path = p.path().and_then(|path| self.expander.parse_path(path)); |
522 | path.map(Pat::Path).unwrap_or(Pat::Missing) | 522 | path.map(Pat::Path).unwrap_or(Pat::Missing) |
523 | } | 523 | } |
524 | ast::Pat::TuplePat(p) => { | 524 | ast::Pat::TuplePat(p) => { |
@@ -527,7 +527,7 @@ where | |||
527 | } | 527 | } |
528 | ast::Pat::PlaceholderPat(_) => Pat::Wild, | 528 | ast::Pat::PlaceholderPat(_) => Pat::Wild, |
529 | ast::Pat::RecordPat(p) => { | 529 | ast::Pat::RecordPat(p) => { |
530 | let path = p.path().and_then(|path| self.parse_path(path)); | 530 | let path = p.path().and_then(|path| self.expander.parse_path(path)); |
531 | let record_field_pat_list = | 531 | let record_field_pat_list = |
532 | p.record_field_pat_list().expect("every struct should have a field list"); | 532 | p.record_field_pat_list().expect("every struct should have a field list"); |
533 | let mut fields: Vec<_> = record_field_pat_list | 533 | let mut fields: Vec<_> = record_field_pat_list |
@@ -568,10 +568,6 @@ where | |||
568 | self.missing_pat() | 568 | self.missing_pat() |
569 | } | 569 | } |
570 | } | 570 | } |
571 | |||
572 | fn parse_path(&mut self, path: ast::Path) -> Option<Path> { | ||
573 | Path::from_src(path, &self.expander.hygiene) | ||
574 | } | ||
575 | } | 571 | } |
576 | 572 | ||
577 | impl From<ast::BinOp> for BinaryOp { | 573 | impl From<ast::BinOp> for BinaryOp { |