about summary refs log tree commit diff
path: root/src/libsyntax/source_map.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-10 00:51:14 +0000
committerbors <bors@rust-lang.org>2019-05-10 00:51:14 +0000
commit03bd2f653f0d0adb69d862fbeec64663157e71e1 (patch)
tree3067cec05b04e1d4e72aef71a9be0d1a5f83affc /src/libsyntax/source_map.rs
parentadcd4aa8d07945d5ef09129b05e8e1ff1bcce58e (diff)
parent45b09453dbf120cc23d889435aac3ed7d2ec8eb7 (diff)
downloadrust-03bd2f653f0d0adb69d862fbeec64663157e71e1.tar.gz
rust-03bd2f653f0d0adb69d862fbeec64663157e71e1.zip
Auto merge of #60683 - Centril:rollup-p05qh5d, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #59348 (Clean up and add tests for slice drop shims)
 - #60188 (Identify when a stmt could have been parsed as an expr)
 - #60234 (std: Derive `Default` for `io::Cursor`)
 - #60618 (Comment ext::tt::transcribe)
 - #60648 (Skip codegen for one UI test with long file path)
 - #60671 (remove unneeded `extern crate`s from build tools)
 - #60675 (Remove the old await! macro)
 - #60676 (Fix async desugaring providing wrong input to procedural macros.)

Failed merges:

r? @ghost
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 {