From 73dee258c19a6e9e8249a0d7ff1db54014d0c7a1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 11 Aug 2019 03:00:05 +0300 Subject: hygiene: Remove `Option`s from functions returning `ExpnInfo` The expansion info is not optional and should always exist --- src/libsyntax/source_map.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/source_map.rs') diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index 74cab00d3c1..da7eb6add41 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -31,12 +31,13 @@ mod tests; /// otherwise return the call site span up to the `enclosing_sp` by /// following the `expn_info` chain. pub fn original_sp(sp: Span, enclosing_sp: Span) -> Span { - let call_site1 = sp.ctxt().outer_expn_info().map(|ei| ei.call_site); - let call_site2 = enclosing_sp.ctxt().outer_expn_info().map(|ei| ei.call_site); - match (call_site1, call_site2) { - (None, _) => sp, - (Some(call_site1), Some(call_site2)) if call_site1 == call_site2 => sp, - (Some(call_site1), _) => original_sp(call_site1, enclosing_sp), + let expn_info1 = sp.ctxt().outer_expn_info(); + let expn_info2 = enclosing_sp.ctxt().outer_expn_info(); + if expn_info1.is_root() || + !expn_info2.is_root() && expn_info1.call_site == expn_info2.call_site { + sp + } else { + original_sp(expn_info1.call_site, enclosing_sp) } } -- cgit 1.4.1-3-g733a5