about summary refs log tree commit diff
path: root/src/libsyntax_expand/mbe.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-11-06 02:29:21 +0000
committerbors <bors@rust-lang.org>2019-11-06 02:29:21 +0000
commite4931eaaa3d95189b30e90d3af9f0db17c41bbb0 (patch)
treed121150066de905b1877e0a1fb81884ac4656918 /src/libsyntax_expand/mbe.rs
parent1423bec54cf2db283b614e527cfd602b481485d1 (diff)
parent35a5ffc8eab6d0aceb2f7dba207a0aa42d0264e5 (diff)
downloadrust-e4931eaaa3d95189b30e90d3af9f0db17c41bbb0.tar.gz
rust-e4931eaaa3d95189b30e90d3af9f0db17c41bbb0.zip
Auto merge of #66141 - Centril:rollup-n2fcvp9, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #65892 (Remove `PartialEq` and `Eq` from the `SpecialDerives`.)
 - #66014 (Show type parameter name and definition in type mismatch error messages )
 - #66027 (Move has_panic_handler to query)
 - #66054 (syntax: Avoid span arithmetic for delimiter tokens)
 - #66068 (use silent emitter for rustdoc highlighting pass)
 - #66081 (let caller of check_ptr_access_align control the error message)
 - #66093 (Do not ICE with a precision flag in formatting str and no format arguments)
 - #66098 (Detect `::` -> `:` typo when involving turbofish)
 - #66101 (Tweak type mismatch caused by break on tail expr)
 - #66106 (Fix typo in explanation of `E0080`)
 - #66115 (rustc: remove "GlobalMetaData" dead code from hir::map::definitions.)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libsyntax_expand/mbe.rs')
-rw-r--r--src/libsyntax_expand/mbe.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/libsyntax_expand/mbe.rs b/src/libsyntax_expand/mbe.rs
index d0f790638ef..06e0cde3ad8 100644
--- a/src/libsyntax_expand/mbe.rs
+++ b/src/libsyntax_expand/mbe.rs
@@ -13,7 +13,7 @@ use syntax::ast;
 use syntax::parse::token::{self, Token, TokenKind};
 use syntax::tokenstream::{DelimSpan};
 
-use syntax_pos::{BytePos, Span};
+use syntax_pos::Span;
 
 use rustc_data_structures::sync::Lrc;
 
@@ -27,23 +27,13 @@ struct Delimited {
 
 impl Delimited {
     /// Returns a `self::TokenTree` with a `Span` corresponding to the opening delimiter.
-    fn open_tt(&self, span: Span) -> TokenTree {
-        let open_span = if span.is_dummy() {
-            span
-        } else {
-            span.with_hi(span.lo() + BytePos(self.delim.len() as u32))
-        };
-        TokenTree::token(token::OpenDelim(self.delim), open_span)
+    fn open_tt(&self, span: DelimSpan) -> TokenTree {
+        TokenTree::token(token::OpenDelim(self.delim), span.open)
     }
 
     /// Returns a `self::TokenTree` with a `Span` corresponding to the closing delimiter.
-    fn close_tt(&self, span: Span) -> TokenTree {
-        let close_span = if span.is_dummy() {
-            span
-        } else {
-            span.with_lo(span.hi() - BytePos(self.delim.len() as u32))
-        };
-        TokenTree::token(token::CloseDelim(self.delim), close_span)
+    fn close_tt(&self, span: DelimSpan) -> TokenTree {
+        TokenTree::token(token::CloseDelim(self.delim), span.close)
     }
 }
 
@@ -138,10 +128,10 @@ impl TokenTree {
             }
             (&TokenTree::Delimited(span, ref delimed), _) => {
                 if index == 0 {
-                    return delimed.open_tt(span.open);
+                    return delimed.open_tt(span);
                 }
                 if index == delimed.tts.len() + 1 {
-                    return delimed.close_tt(span.close);
+                    return delimed.close_tt(span);
                 }
                 delimed.tts[index - 1].clone()
             }