diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-06-25 01:00:21 +0300 | 
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-06-30 01:53:32 +0300 | 
| commit | 9f92fce77c74cf3c47035e9ff69c29daee0517b3 (patch) | |
| tree | e724e8e72a43d71053f4de32fa893a661ee163bf /src/libsyntax_pos/lib.rs | |
| parent | 297109ea3263a4ea90a7143a82e46903a8890269 (diff) | |
| download | rust-9f92fce77c74cf3c47035e9ff69c29daee0517b3.tar.gz rust-9f92fce77c74cf3c47035e9ff69c29daee0517b3.zip  | |
Fortify dummy span checking
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 9 | 
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 308fb118f07..491ce720f36 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -248,6 +248,13 @@ impl Span { self.data().with_ctxt(ctxt) } + /// Returns `true` if this is a dummy span with any hygienic context. + #[inline] + pub fn is_dummy(self) -> bool { + let span = self.data(); + span.lo.0 == 0 && span.hi.0 == 0 + } + /// Returns a new span representing an empty span at the beginning of this span #[inline] pub fn shrink_to_lo(self) -> Span { @@ -263,7 +270,7 @@ impl Span { /// Returns `self` if `self` is not the dummy span, and `other` otherwise. pub fn substitute_dummy(self, other: Span) -> Span { - if self.source_equal(&DUMMY_SP) { other } else { self } + if self.is_dummy() { other } else { self } } /// Return true if `self` fully encloses `other`.  | 
