@@ -47,11 +47,11 @@ pub fn inject(sess: &Session, resolver: &mut dyn ResolverExpand, krate: &mut ast
47
47
// unconditional, so that the attribute is still marked as used in
48
48
// non-test builds.
49
49
let reexport_test_harness_main =
50
- sess . first_attr_value_str_by_name ( & krate. attrs , sym:: reexport_test_harness_main) ;
50
+ attr :: first_attr_value_str_by_name ( & krate. attrs , sym:: reexport_test_harness_main) ;
51
51
52
52
// Do this here so that the test_runner crate attribute gets marked as used
53
53
// even in non-test builds
54
- let test_runner = get_test_runner ( sess , span_diagnostic, & krate) ;
54
+ let test_runner = get_test_runner ( span_diagnostic, & krate) ;
55
55
56
56
if sess. opts . test {
57
57
let panic_strategy = match ( panic_strategy, sess. opts . unstable_opts . panic_abort_tests ) {
@@ -123,7 +123,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
123
123
124
124
fn flat_map_item ( & mut self , i : P < ast:: Item > ) -> SmallVec < [ P < ast:: Item > ; 1 ] > {
125
125
let mut item = i. into_inner ( ) ;
126
- if let Some ( name) = get_test_name ( & self . cx . ext_cx . sess , & item) {
126
+ if let Some ( name) = get_test_name ( & item) {
127
127
debug ! ( "this is a test item" ) ;
128
128
129
129
let test = Test { span : item. span , ident : item. ident , name } ;
@@ -145,12 +145,12 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
145
145
146
146
// Beware, this is duplicated in librustc_passes/entry.rs (with
147
147
// `rustc_hir::Item`), so make sure to keep them in sync.
148
- fn entry_point_type ( sess : & Session , item : & ast:: Item , depth : usize ) -> EntryPointType {
148
+ fn entry_point_type ( item : & ast:: Item , depth : usize ) -> EntryPointType {
149
149
match item. kind {
150
150
ast:: ItemKind :: Fn ( ..) => {
151
- if sess . contains_name ( & item. attrs , sym:: start) {
151
+ if attr :: contains_name ( & item. attrs , sym:: start) {
152
152
EntryPointType :: Start
153
- } else if sess . contains_name ( & item. attrs , sym:: rustc_main) {
153
+ } else if attr :: contains_name ( & item. attrs , sym:: rustc_main) {
154
154
EntryPointType :: RustcMainAttr
155
155
} else if item. ident . name == sym:: main {
156
156
if depth == 0 {
@@ -184,7 +184,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
184
184
// Remove any #[rustc_main] or #[start] from the AST so it doesn't
185
185
// clash with the one we're going to add, but mark it as
186
186
// #[allow(dead_code)] to avoid printing warnings.
187
- let item = match entry_point_type ( self . sess , & item, self . depth ) {
187
+ let item = match entry_point_type ( & item, self . depth ) {
188
188
EntryPointType :: MainNamed | EntryPointType :: RustcMainAttr | EntryPointType :: Start => {
189
189
item. map ( |ast:: Item { id, ident, attrs, kind, vis, span, tokens } | {
190
190
let allow_dead_code = attr:: mk_attr_nested_word (
@@ -373,16 +373,12 @@ fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P<ast::Expr> {
373
373
)
374
374
}
375
375
376
- fn get_test_name ( sess : & Session , i : & ast:: Item ) -> Option < Symbol > {
377
- sess . first_attr_value_str_by_name ( & i. attrs , sym:: rustc_test_marker)
376
+ fn get_test_name ( i : & ast:: Item ) -> Option < Symbol > {
377
+ attr :: first_attr_value_str_by_name ( & i. attrs , sym:: rustc_test_marker)
378
378
}
379
379
380
- fn get_test_runner (
381
- sess : & Session ,
382
- sd : & rustc_errors:: Handler ,
383
- krate : & ast:: Crate ,
384
- ) -> Option < ast:: Path > {
385
- let test_attr = sess. find_by_name ( & krate. attrs , sym:: test_runner) ?;
380
+ fn get_test_runner ( sd : & rustc_errors:: Handler , krate : & ast:: Crate ) -> Option < ast:: Path > {
381
+ let test_attr = attr:: find_by_name ( & krate. attrs , sym:: test_runner) ?;
386
382
let meta_list = test_attr. meta_item_list ( ) ?;
387
383
let span = test_attr. span ;
388
384
match & * meta_list {
0 commit comments