aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-02 13:25:54 +0000
committerGitHub <[email protected]>2020-12-02 13:25:54 +0000
commit3e1fb112af3968110704125301646d6a3fc20c8c (patch)
tree6f2051a39485da5766aecb2bc13e890b107fc0dc /crates
parentdc09d97fb2f4c7f938a76b4ba7b0b483f96ceb5d (diff)
parent319fcd01ac768c05f24c1d3d306ab68632c8de3e (diff)
Merge #6698
6698: Attach macro expansion errors to the right file r=jonas-schievink a=jonas-schievink Previously it attached them to the result of the macro expansion (or, if no result was produced, to the file containing the invocation). Always use the file containing the invocation. This doesn't seem to have any observable difference, but seems better in theory. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/body/lower.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index 2c41c0005..689a3274c 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -560,6 +560,9 @@ impl ExprCollector<'_> {
560 // FIXME: do we still need to allocate this as missing ? 560 // FIXME: do we still need to allocate this as missing ?
561 self.alloc_expr(Expr::Missing, syntax_ptr) 561 self.alloc_expr(Expr::Missing, syntax_ptr)
562 } else { 562 } else {
563 // File containing the macro call. Expansion errors will be attached here.
564 let outer_file = self.expander.current_file_id;
565
563 let macro_call = self.expander.to_source(AstPtr::new(&e)); 566 let macro_call = self.expander.to_source(AstPtr::new(&e));
564 let res = self.expander.enter_expand(self.db, Some(&self.body.item_scope), e); 567 let res = self.expander.enter_expand(self.db, Some(&self.body.item_scope), e);
565 568
@@ -567,7 +570,7 @@ impl ExprCollector<'_> {
567 Some(ExpandError::UnresolvedProcMacro) => { 570 Some(ExpandError::UnresolvedProcMacro) => {
568 self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedProcMacro( 571 self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedProcMacro(
569 UnresolvedProcMacro { 572 UnresolvedProcMacro {
570 file: self.expander.current_file_id, 573 file: outer_file,
571 node: syntax_ptr.clone().into(), 574 node: syntax_ptr.clone().into(),
572 precise_location: None, 575 precise_location: None,
573 macro_name: None, 576 macro_name: None,
@@ -577,7 +580,7 @@ impl ExprCollector<'_> {
577 Some(err) => { 580 Some(err) => {
578 self.source_map.diagnostics.push(BodyDiagnostic::MacroError( 581 self.source_map.diagnostics.push(BodyDiagnostic::MacroError(
579 MacroError { 582 MacroError {
580 file: self.expander.current_file_id, 583 file: outer_file,
581 node: syntax_ptr.clone().into(), 584 node: syntax_ptr.clone().into(),
582 message: err.to_string(), 585 message: err.to_string(),
583 }, 586 },