about summary refs log tree commit diff
path: root/src/libsyntax/source_map.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-05-09 23:56:18 +0200
committerGitHub <noreply@github.com>2019-05-09 23:56:18 +0200
commit45b09453dbf120cc23d889435aac3ed7d2ec8eb7 (patch)
tree67af0001a1a6863dba991d2b1ebe7592cd9c40c4 /src/libsyntax/source_map.rs
parentf6df1f6c30b469cb9e65c5453a0efa03cbb6005e (diff)
parentd5e04067cb23df91070fea1a01aa6417afa714ed (diff)
downloadrust-45b09453dbf120cc23d889435aac3ed7d2ec8eb7.tar.gz
rust-45b09453dbf120cc23d889435aac3ed7d2ec8eb7.zip
Rollup merge of #60676 - davidtwco:issue-60674, r=cramertj
Fix async desugaring providing wrong input to procedural macros.

Fixes #60674.

This PR fixes a minor oversight introduced by #60535 where unused `mut` binding modes were removed from the arguments to an `async fn` (as they were added to the statement that we insert into the closure body). However, this meant that the input to procedural macros was incorrect. This removes that and instead fixes the `unused_mut` error that it avoided.

r? @cramertj
cc @taiki-e
Diffstat (limited to 'src/libsyntax/source_map.rs')
-rw-r--r--src/libsyntax/source_map.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs
index 08abbf5e8a4..215618bd09c 100644
--- a/src/libsyntax/source_map.rs
+++ b/src/libsyntax/source_map.rs
@@ -930,6 +930,27 @@ impl SourceMap {
 
         None
     }
+
+    /// Reuses the span but adds information like the kind of the desugaring and features that are
+    /// allowed inside this span.
+    pub fn mark_span_with_reason(
+        &self,
+        reason: hygiene::CompilerDesugaringKind,
+        span: Span,
+        allow_internal_unstable: Option<Lrc<[symbol::Symbol]>>,
+    ) -> Span {
+        let mark = Mark::fresh(Mark::root());
+        mark.set_expn_info(ExpnInfo {
+            call_site: span,
+            def_site: Some(span),
+            format: CompilerDesugaring(reason),
+            allow_internal_unstable,
+            allow_internal_unsafe: false,
+            local_inner_macros: false,
+            edition: hygiene::default_edition(),
+        });
+        span.with_ctxt(SyntaxContext::empty().apply_mark(mark))
+    }
 }
 
 impl SourceMapper for SourceMap {