about summary refs log tree commit diff
path: root/src/libsyntax_ext/test.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-06-20 02:33:39 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-11 00:12:07 +0300
commitf1d4ebf01505877ff36ba63f8a26ea8ea0973969 (patch)
treefd28c53c8840af05b056f1469e7343455ac7bc66 /src/libsyntax_ext/test.rs
parent16918a8e28d4e7a476f31ff3d3c1e2d998c086af (diff)
downloadrust-f1d4ebf01505877ff36ba63f8a26ea8ea0973969.tar.gz
rust-f1d4ebf01505877ff36ba63f8a26ea8ea0973969.zip
Remove unnecessary expansions created by `#[test_case/test/bench]`
The expansions were created to allow unstable things inside `#[test_case/test/bench]`, but that's not a proper way to do that.
Put the required `allow_internal_unstable`s into the macros' properties instead.
Diffstat (limited to 'src/libsyntax_ext/test.rs')
-rw-r--r--src/libsyntax_ext/test.rs14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs
index 7f4f1fd7e01..c5c5ef57b31 100644
--- a/src/libsyntax_ext/test.rs
+++ b/src/libsyntax_ext/test.rs
@@ -3,13 +3,12 @@
 
 use syntax::ext::base::*;
 use syntax::ext::build::AstBuilder;
-use syntax::ext::hygiene::{Mark, SyntaxContext};
+use syntax::ext::hygiene::SyntaxContext;
 use syntax::attr;
 use syntax::ast;
 use syntax::print::pprust;
 use syntax::symbol::{Symbol, sym};
 use syntax_pos::Span;
-use syntax::source_map::{ExpnInfo, ExpnKind};
 use std::iter;
 
 pub fn expand_test(
@@ -60,15 +59,8 @@ pub fn expand_test_or_bench(
         return vec![Annotatable::Item(item)];
     }
 
-    let (sp, attr_sp) = {
-        let mark = Mark::fresh(Mark::root());
-        mark.set_expn_info(ExpnInfo::with_unstable(
-            ExpnKind::MacroAttribute(sym::test), attr_sp, cx.parse_sess.edition,
-            &[sym::rustc_attrs, sym::test],
-        ));
-        (item.span.with_ctxt(SyntaxContext::empty().apply_mark(mark)),
-         attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(mark)))
-    };
+    let ctxt = SyntaxContext::empty().apply_mark(cx.current_expansion.mark);
+    let (sp, attr_sp) = (item.span.with_ctxt(ctxt), attr_sp.with_ctxt(ctxt));
 
     // Gensym "test" so we can extern crate without conflicting with any local names
     let test_id = cx.ident_of("test").gensym();