aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body/lower.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/body/lower.rs')
-rw-r--r--crates/hir_def/src/body/lower.rs33
1 files changed, 13 insertions, 20 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index bdba4c33e..0f404be1b 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -233,8 +233,7 @@ impl ExprCollector<'_> {
233 let res = self.collect_block(block); 233 let res = self.collect_block(block);
234 match &mut self.body.exprs[res] { 234 match &mut self.body.exprs[res] {
235 Expr::Block { label: block_label, .. } => { 235 Expr::Block { label: block_label, .. } => {
236 *block_label = 236 *block_label = label.lifetime().map(|t| Name::new_lifetime(&t))
237 label.lifetime_token().map(|t| Name::new_lifetime(&t))
238 } 237 }
239 _ => unreachable!(), 238 _ => unreachable!(),
240 } 239 }
@@ -254,10 +253,7 @@ impl ExprCollector<'_> {
254 self.alloc_expr( 253 self.alloc_expr(
255 Expr::Loop { 254 Expr::Loop {
256 body, 255 body,
257 label: e 256 label: e.label().and_then(|l| l.lifetime()).map(|l| Name::new_lifetime(&l)),
258 .label()
259 .and_then(|l| l.lifetime_token())
260 .map(|l| Name::new_lifetime(&l)),
261 }, 257 },
262 syntax_ptr, 258 syntax_ptr,
263 ) 259 )
@@ -288,7 +284,7 @@ impl ExprCollector<'_> {
288 body: match_expr, 284 body: match_expr,
289 label: e 285 label: e
290 .label() 286 .label()
291 .and_then(|l| l.lifetime_token()) 287 .and_then(|l| l.lifetime())
292 .map(|l| Name::new_lifetime(&l)), 288 .map(|l| Name::new_lifetime(&l)),
293 }, 289 },
294 syntax_ptr, 290 syntax_ptr,
@@ -301,10 +297,7 @@ impl ExprCollector<'_> {
301 Expr::While { 297 Expr::While {
302 condition, 298 condition,
303 body, 299 body,
304 label: e 300 label: e.label().and_then(|l| l.lifetime()).map(|l| Name::new_lifetime(&l)),
305 .label()
306 .and_then(|l| l.lifetime_token())
307 .map(|l| Name::new_lifetime(&l)),
308 }, 301 },
309 syntax_ptr, 302 syntax_ptr,
310 ) 303 )
@@ -318,10 +311,7 @@ impl ExprCollector<'_> {
318 iterable, 311 iterable,
319 pat, 312 pat,
320 body, 313 body,
321 label: e 314 label: e.label().and_then(|l| l.lifetime()).map(|l| Name::new_lifetime(&l)),
322 .label()
323 .and_then(|l| l.lifetime_token())
324 .map(|l| Name::new_lifetime(&l)),
325 }, 315 },
326 syntax_ptr, 316 syntax_ptr,
327 ) 317 )
@@ -380,13 +370,13 @@ impl ExprCollector<'_> {
380 self.alloc_expr(path, syntax_ptr) 370 self.alloc_expr(path, syntax_ptr)
381 } 371 }
382 ast::Expr::ContinueExpr(e) => self.alloc_expr( 372 ast::Expr::ContinueExpr(e) => self.alloc_expr(
383 Expr::Continue { label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, 373 Expr::Continue { label: e.lifetime().map(|l| Name::new_lifetime(&l)) },
384 syntax_ptr, 374 syntax_ptr,
385 ), 375 ),
386 ast::Expr::BreakExpr(e) => { 376 ast::Expr::BreakExpr(e) => {
387 let expr = e.expr().map(|e| self.collect_expr(e)); 377 let expr = e.expr().map(|e| self.collect_expr(e));
388 self.alloc_expr( 378 self.alloc_expr(
389 Expr::Break { expr, label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, 379 Expr::Break { expr, label: e.lifetime().map(|l| Name::new_lifetime(&l)) },
390 syntax_ptr, 380 syntax_ptr,
391 ) 381 )
392 } 382 }
@@ -772,7 +762,10 @@ impl ExprCollector<'_> {
772 | ast::Item::Module(_) 762 | ast::Item::Module(_)
773 | ast::Item::MacroCall(_) => return None, 763 | ast::Item::MacroCall(_) => return None,
774 ast::Item::MacroRules(def) => { 764 ast::Item::MacroRules(def) => {
775 return Some(Either::Right(def)); 765 return Some(Either::Right(ast::Macro::from(def)));
766 }
767 ast::Item::MacroDef(def) => {
768 return Some(Either::Right(ast::Macro::from(def)));
776 } 769 }
777 }; 770 };
778 771
@@ -800,7 +793,7 @@ impl ExprCollector<'_> {
800 } 793 }
801 Either::Right(e) => { 794 Either::Right(e) => {
802 let mac = MacroDefId { 795 let mac = MacroDefId {
803 krate: Some(self.expander.module.krate), 796 krate: self.expander.module.krate,
804 ast_id: Some(self.expander.ast_id(&e)), 797 ast_id: Some(self.expander.ast_id(&e)),
805 kind: MacroDefKind::Declarative, 798 kind: MacroDefKind::Declarative,
806 local_inner: false, 799 local_inner: false,
@@ -970,7 +963,7 @@ impl ExprCollector<'_> {
970 /// Returns `None` (and emits diagnostics) when `owner` if `#[cfg]`d out, and `Some(())` when 963 /// Returns `None` (and emits diagnostics) when `owner` if `#[cfg]`d out, and `Some(())` when
971 /// not. 964 /// not.
972 fn check_cfg(&mut self, owner: &dyn ast::AttrsOwner) -> Option<()> { 965 fn check_cfg(&mut self, owner: &dyn ast::AttrsOwner) -> Option<()> {
973 match self.expander.parse_attrs(owner).cfg() { 966 match self.expander.parse_attrs(self.db, owner).cfg() {
974 Some(cfg) => { 967 Some(cfg) => {
975 if self.expander.cfg_options().check(&cfg) != Some(false) { 968 if self.expander.cfg_options().check(&cfg) != Some(false) {
976 return Some(()); 969 return Some(());