X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_builtin_macros%2Fsrc%2Ftest.rs;h=3bcb60478efbc58db96665ce497c42373806fac3;hb=e72ea1dc376e9c302c68faefafd967a8a7ef255a;hp=b62840d4bc8221d72d4a45d5d5e3144a3a050d01;hpb=aeeac5dd0c079cbe36ea5ba6eed702e88906eb16;p=rust.git diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index b62840d4bc8..3bcb60478ef 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -2,7 +2,6 @@ /// Ideally, this code would be in libtest but for efficiency and error messages it lives here. use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute}; use rustc_ast as ast; -use rustc_ast::attr; use rustc_ast::ptr::P; use rustc_ast_pretty::pprust; use rustc_errors::Applicability; @@ -13,13 +12,13 @@ use std::iter; use thin_vec::thin_vec; -// #[test_case] is used by custom test authors to mark tests -// When building for test, it needs to make the item public and gensym the name -// Otherwise, we'll omit the item. This behavior means that any item annotated -// with #[test_case] is never addressable. -// -// We mark item with an inert attribute "rustc_test_marker" which the test generation -// logic will pick up on. +/// #[test_case] is used by custom test authors to mark tests +/// When building for test, it needs to make the item public and gensym the name +/// Otherwise, we'll omit the item. This behavior means that any item annotated +/// with #[test_case] is never addressable. +/// +/// We mark item with an inert attribute "rustc_test_marker" which the test generation +/// logic will pick up on. pub fn expand_test_case( ecx: &mut ExtCtxt<'_>, attr_sp: Span, @@ -47,11 +46,7 @@ pub fn expand_test_case( tokens: None, }; item.ident.span = item.ident.span.with_ctxt(sp.ctxt()); - item.attrs.push(ecx.attribute(attr::mk_name_value_item_str( - Ident::new(sym::rustc_test_marker, sp), - test_path_symbol, - sp, - ))); + item.attrs.push(ecx.attr_name_value_str(sym::rustc_test_marker, test_path_symbol, sp)); item }); @@ -241,16 +236,9 @@ pub fn expand_test_or_bench( Ident::new(item.ident.name, sp), thin_vec![ // #[cfg(test)] - cx.attribute(attr::mk_list_item( - Ident::new(sym::cfg, attr_sp), - vec![attr::mk_nested_word_item(Ident::new(sym::test, attr_sp))], - )), + cx.attr_nested_word(sym::cfg, sym::test, attr_sp), // #[rustc_test_marker = "test_case_sort_key"] - cx.attribute(attr::mk_name_value_item_str( - Ident::new(sym::rustc_test_marker, attr_sp), - test_path_symbol, - attr_sp, - )), + cx.attr_name_value_str(sym::rustc_test_marker, test_path_symbol, attr_sp), ] .into(), // const $ident: test::TestDescAndFn =