@@ -21,7 +21,7 @@ use itertools::{izip, Itertools};
2121use la_arena:: Idx ;
2222use limit:: Limit ;
2323use rustc_hash:: { FxHashMap , FxHashSet } ;
24- use span:: { Edition , ErasedFileAstId , FileAstId , Span , SyntaxContextId } ;
24+ use span:: { Edition , ErasedFileAstId , FileAstId , SyntaxContextId } ;
2525use syntax:: ast;
2626use triomphe:: Arc ;
2727
@@ -75,36 +75,23 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, def_map: DefMap, tree_id: TreeI
7575
7676 let proc_macros = if krate. is_proc_macro {
7777 match db. proc_macros ( ) . get ( & def_map. krate ) {
78- Some ( Ok ( proc_macros) ) => {
79- Ok ( proc_macros
80- . iter ( )
81- . enumerate ( )
82- . map ( |( idx, it) | {
83- // FIXME: a hacky way to create a Name from string.
84- let name = tt:: Ident {
85- text : it. name . clone ( ) ,
86- span : Span {
87- range : syntax:: TextRange :: empty ( syntax:: TextSize :: new ( 0 ) ) ,
88- anchor : span:: SpanAnchor {
89- file_id : FileId :: BOGUS ,
90- ast_id : span:: ROOT_ERASED_FILE_AST_ID ,
91- } ,
92- ctx : SyntaxContextId :: ROOT ,
93- } ,
94- } ;
95- (
96- name. as_name ( ) ,
97- if it. disabled {
98- CustomProcMacroExpander :: disabled ( )
99- } else {
100- CustomProcMacroExpander :: new (
101- hir_expand:: proc_macro:: ProcMacroId :: new ( idx as u32 ) ,
102- )
103- } ,
104- )
105- } )
106- . collect ( ) )
107- }
78+ Some ( Ok ( proc_macros) ) => Ok ( proc_macros
79+ . iter ( )
80+ . enumerate ( )
81+ . map ( |( idx, it) | {
82+ let name = Name :: new_text_dont_use ( it. name . clone ( ) ) ;
83+ (
84+ name,
85+ if it. disabled {
86+ CustomProcMacroExpander :: disabled ( )
87+ } else {
88+ CustomProcMacroExpander :: new ( hir_expand:: proc_macro:: ProcMacroId :: new (
89+ idx as u32 ,
90+ ) )
91+ } ,
92+ )
93+ } )
94+ . collect ( ) ) ,
10895 Some ( Err ( e) ) => Err ( e. clone ( ) . into_boxed_str ( ) ) ,
10996 None => Err ( "No proc-macros present for crate" . to_owned ( ) . into_boxed_str ( ) ) ,
11097 }
@@ -2154,19 +2141,7 @@ impl ModCollector<'_, '_> {
21542141 let name;
21552142 let name = match attrs. by_key ( "rustc_builtin_macro" ) . string_value ( ) {
21562143 Some ( it) => {
2157- // FIXME: a hacky way to create a Name from string.
2158- name = tt:: Ident {
2159- text : it. into ( ) ,
2160- span : Span {
2161- range : syntax:: TextRange :: empty ( syntax:: TextSize :: new ( 0 ) ) ,
2162- anchor : span:: SpanAnchor {
2163- file_id : FileId :: BOGUS ,
2164- ast_id : span:: ROOT_ERASED_FILE_AST_ID ,
2165- } ,
2166- ctx : SyntaxContextId :: ROOT ,
2167- } ,
2168- }
2169- . as_name ( ) ;
2144+ name = Name :: new_text_dont_use ( it. into ( ) ) ;
21702145 & name
21712146 }
21722147 None => {
0 commit comments