@@ -10,7 +10,7 @@ use rustc_ast::{self as ast, Crate, NodeId, attr};
1010use rustc_ast_pretty:: pprust;
1111use rustc_attr_parsing:: { AttributeKind , StabilityLevel , find_attr} ;
1212use rustc_data_structures:: intern:: Interned ;
13- use rustc_errors:: { Applicability , StashKey } ;
13+ use rustc_errors:: { Applicability , DiagCtxtHandle , StashKey } ;
1414use rustc_expand:: base:: {
1515 DeriveResolution , Indeterminate , ResolverExpand , SyntaxExtension , SyntaxExtensionKind ,
1616} ;
@@ -124,22 +124,29 @@ fn fast_print_path(path: &ast::Path) -> Symbol {
124124}
125125
126126pub ( crate ) fn registered_tools ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> RegisteredTools {
127- let mut registered_tools = RegisteredTools :: default ( ) ;
128127 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 ( ) ;
129136 for attr in attr:: filter_by_name ( pre_configured_attrs, sym:: register_tool) {
130137 for meta_item_inner in attr. meta_item_list ( ) . unwrap_or_default ( ) {
131138 match meta_item_inner. ident ( ) {
132139 Some ( ident) => {
133140 if let Some ( old_ident) = registered_tools. replace ( ident) {
134- tcx . dcx ( ) . emit_err ( errors:: ToolWasAlreadyRegistered {
141+ dcx. emit_err ( errors:: ToolWasAlreadyRegistered {
135142 span : ident. span ,
136143 tool : ident,
137144 old_ident_span : old_ident. span ,
138145 } ) ;
139146 }
140147 }
141148 None => {
142- tcx . dcx ( ) . emit_err ( errors:: ToolOnlyAcceptsIdentifiers {
149+ dcx. emit_err ( errors:: ToolOnlyAcceptsIdentifiers {
143150 span : meta_item_inner. span ( ) ,
144151 tool : sym:: register_tool,
145152 } ) ;
0 commit comments