@@ -24,9 +24,8 @@ use crate::equiv::{GlobalEquivSet, LocalEquivSet};
24
24
use crate :: labeled_ty:: LabeledTyCtxt ;
25
25
use crate :: log:: init_logger;
26
26
use crate :: panic_detail:: PanicDetail ;
27
- use crate :: util:: Callee ;
27
+ use crate :: util:: { Callee , TestAttr } ;
28
28
use context:: AdtMetadataTable ;
29
- use rustc_ast:: ast:: AttrKind ;
30
29
use rustc_hir:: def:: DefKind ;
31
30
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
32
31
use rustc_index:: vec:: IndexVec ;
@@ -36,7 +35,6 @@ use rustc_middle::mir::{
36
35
Rvalue , StatementKind ,
37
36
} ;
38
37
use rustc_middle:: ty:: { Ty , TyCtxt , TyKind , WithOptConstParam } ;
39
- use rustc_span:: symbol:: Symbol ;
40
38
use rustc_span:: Span ;
41
39
use std:: collections:: { HashMap , HashSet } ;
42
40
use std:: env;
@@ -500,7 +498,7 @@ fn run(tcx: TyCtxt) {
500
498
// For testing, putting #[c2rust_analyze_test::fixed_signature] on a function makes all
501
499
// pointers in its signature FIXED.
502
500
for & ldid in & all_fn_ldids {
503
- if !has_test_attr ( tcx, ldid, "fixed_signature" ) {
501
+ if !util :: has_test_attr ( tcx, ldid, TestAttr :: FixedSignature ) {
504
502
continue ;
505
503
}
506
504
let lsig = match gacx. fn_sigs . get ( & ldid. to_def_id ( ) ) {
@@ -512,7 +510,7 @@ fn run(tcx: TyCtxt) {
512
510
513
511
// For testing, putting #[c2rust_analyze_test::fail_analysis] on a function marks it as failed.
514
512
for & ldid in & all_fn_ldids {
515
- if !has_test_attr ( tcx, ldid, "fail_analysis" ) {
513
+ if !util :: has_test_attr ( tcx, ldid, TestAttr :: FailAnalysis ) {
516
514
continue ;
517
515
}
518
516
gacx. mark_fn_failed (
@@ -593,7 +591,7 @@ fn run(tcx: TyCtxt) {
593
591
continue ;
594
592
}
595
593
596
- if has_test_attr ( tcx, ldid, "skip_rewrite" ) {
594
+ if util :: has_test_attr ( tcx, ldid, TestAttr :: SkipRewrite ) {
597
595
continue ;
598
596
}
599
597
@@ -967,26 +965,6 @@ fn for_each_callee(tcx: TyCtxt, ldid: LocalDefId, f: impl FnMut(LocalDefId)) {
967
965
CalleeVisitor { tcx, mir, f } . visit_body ( mir) ;
968
966
}
969
967
970
- fn has_test_attr ( tcx : TyCtxt , ldid : LocalDefId , name : & str ) -> bool {
971
- let tool_sym = Symbol :: intern ( "c2rust_analyze_test" ) ;
972
- let name_sym = Symbol :: intern ( name) ;
973
-
974
- for attr in tcx. get_attrs_unchecked ( ldid. to_def_id ( ) ) {
975
- let path = match attr. kind {
976
- AttrKind :: Normal ( ref item, _) => & item. path ,
977
- AttrKind :: DocComment ( ..) => continue ,
978
- } ;
979
- let ( a, b) = match & path. segments [ ..] {
980
- & [ ref a, ref b] => ( a, b) ,
981
- _ => continue ,
982
- } ;
983
- if a. ident . name == tool_sym && b. ident . name == name_sym {
984
- return true ;
985
- }
986
- }
987
- false
988
- }
989
-
990
968
struct AnalysisCallbacks ;
991
969
992
970
impl rustc_driver:: Callbacks for AnalysisCallbacks {
0 commit comments