@@ -10,7 +10,7 @@ use rustc_ast::{self as ast, Crate, NodeId, attr};
10
10
use rustc_ast_pretty:: pprust;
11
11
use rustc_attr_parsing:: { AttributeKind , StabilityLevel , find_attr} ;
12
12
use rustc_data_structures:: intern:: Interned ;
13
- use rustc_errors:: { Applicability , StashKey } ;
13
+ use rustc_errors:: { Applicability , DiagCtxtHandle , StashKey } ;
14
14
use rustc_expand:: base:: {
15
15
DeriveResolution , Indeterminate , ResolverExpand , SyntaxExtension , SyntaxExtensionKind ,
16
16
} ;
@@ -124,22 +124,29 @@ fn fast_print_path(path: &ast::Path) -> Symbol {
124
124
}
125
125
126
126
pub ( crate ) fn registered_tools ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> RegisteredTools {
127
- let mut registered_tools = RegisteredTools :: default ( ) ;
128
127
let ( _, pre_configured_attrs) = & * tcx. crate_for_resolver ( ( ) ) . borrow ( ) ;
128
+ registered_tools_ast ( tcx. dcx ( ) , pre_configured_attrs)
129
+ }
130
+
131
+ pub fn registered_tools_ast (
132
+ dcx : DiagCtxtHandle < ' _ > ,
133
+ pre_configured_attrs : & [ ast:: Attribute ] ,
134
+ ) -> RegisteredTools {
135
+ let mut registered_tools = RegisteredTools :: default ( ) ;
129
136
for attr in attr:: filter_by_name ( pre_configured_attrs, sym:: register_tool) {
130
137
for meta_item_inner in attr. meta_item_list ( ) . unwrap_or_default ( ) {
131
138
match meta_item_inner. ident ( ) {
132
139
Some ( ident) => {
133
140
if let Some ( old_ident) = registered_tools. replace ( ident) {
134
- tcx . dcx ( ) . emit_err ( errors:: ToolWasAlreadyRegistered {
141
+ dcx. emit_err ( errors:: ToolWasAlreadyRegistered {
135
142
span : ident. span ,
136
143
tool : ident,
137
144
old_ident_span : old_ident. span ,
138
145
} ) ;
139
146
}
140
147
}
141
148
None => {
142
- tcx . dcx ( ) . emit_err ( errors:: ToolOnlyAcceptsIdentifiers {
149
+ dcx. emit_err ( errors:: ToolOnlyAcceptsIdentifiers {
143
150
span : meta_item_inner. span ( ) ,
144
151
tool : sym:: register_tool,
145
152
} ) ;
0 commit comments