@@ -19,7 +19,6 @@ use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, DefIndex,
1919use rustc:: hir:: def:: { Def , NonMacroAttrKind } ;
2020use rustc:: hir:: map:: { self , DefCollector } ;
2121use rustc:: { ty, lint} ;
22- use rustc:: middle:: cstore:: CrateStore ;
2322use syntax:: ast:: { self , Name , Ident } ;
2423use syntax:: attr;
2524use syntax:: errors:: DiagnosticBuilder ;
@@ -110,14 +109,6 @@ pub struct ParentScope<'a> {
110109 crate derives : Vec < ast:: Path > ,
111110}
112111
113- pub struct ProcMacError {
114- crate_name : Symbol ,
115- name : Symbol ,
116- module : ast:: NodeId ,
117- use_span : Span ,
118- warn_msg : & ' static str ,
119- }
120-
121112// Macro namespace is separated into two sub-namespaces, one for bang macros and
122113// one for attribute-like macros (attributes, derives).
123114// We ignore resolutions from one sub-namespace when searching names in scope for another.
@@ -980,7 +971,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
980971 check_consistency ( self , binding. def_ignoring_ambiguity ( ) ) ;
981972 if from_prelude {
982973 self . record_use ( ident, MacroNS , binding) ;
983- self . err_if_macro_use_proc_macro ( ident. name , span, binding) ;
984974 }
985975 }
986976 } ;
@@ -1132,69 +1122,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
11321122 }
11331123 }
11341124
1135- /// Error if `ext` is a Macros 1.1 procedural macro being imported by `#[macro_use]`
1136- fn err_if_macro_use_proc_macro ( & mut self , name : Name , use_span : Span ,
1137- binding : & NameBinding < ' a > ) {
1138- let krate = match binding. def ( ) {
1139- Def :: NonMacroAttr ( ..) | Def :: Err => return ,
1140- Def :: Macro ( def_id, _) => def_id. krate ,
1141- _ => unreachable ! ( ) ,
1142- } ;
1143-
1144- // Plugin-based syntax extensions are exempt from this check
1145- if krate == CrateNum :: BuiltinMacros { return ; }
1146-
1147- let ext = binding. get_macro ( self ) ;
1148-
1149- match * ext {
1150- // If `ext` is a procedural macro, check if we've already warned about it
1151- SyntaxExtension :: AttrProcMacro ( ..) | SyntaxExtension :: ProcMacro { .. } =>
1152- if !self . warned_proc_macros . insert ( name) { return ; } ,
1153- _ => return ,
1154- }
1155-
1156- let warn_msg = match * ext {
1157- SyntaxExtension :: AttrProcMacro ( ..) =>
1158- "attribute procedural macros cannot be imported with `#[macro_use]`" ,
1159- SyntaxExtension :: ProcMacro { .. } =>
1160- "procedural macros cannot be imported with `#[macro_use]`" ,
1161- _ => return ,
1162- } ;
1163-
1164- let def_id = self . current_module . normal_ancestor_id ;
1165- let node_id = self . definitions . as_local_node_id ( def_id) . unwrap ( ) ;
1166-
1167- self . proc_mac_errors . push ( ProcMacError {
1168- crate_name : self . cstore . crate_name_untracked ( krate) ,
1169- name,
1170- module : node_id,
1171- use_span,
1172- warn_msg,
1173- } ) ;
1174- }
1175-
1176- pub fn report_proc_macro_import ( & mut self , krate : & ast:: Crate ) {
1177- for err in self . proc_mac_errors . drain ( ..) {
1178- let ( span, found_use) = :: UsePlacementFinder :: check ( krate, err. module ) ;
1179-
1180- if let Some ( span) = span {
1181- let found_use = if found_use { "" } else { "\n " } ;
1182- self . session . struct_span_err ( err. use_span , err. warn_msg )
1183- . span_suggestion_with_applicability (
1184- span,
1185- "instead, import the procedural macro like any other item" ,
1186- format ! ( "use {}::{};{}" , err. crate_name, err. name, found_use) ,
1187- Applicability :: MachineApplicable
1188- ) . emit ( ) ;
1189- } else {
1190- self . session . struct_span_err ( err. use_span , err. warn_msg )
1191- . help ( & format ! ( "instead, import the procedural macro like any other item: \
1192- `use {}::{};`", err. crate_name, err. name) )
1193- . emit ( ) ;
1194- }
1195- }
1196- }
1197-
11981125 fn gate_legacy_custom_derive ( & mut self , name : Symbol , span : Span ) {
11991126 if !self . session . features_untracked ( ) . custom_derive {
12001127 let sess = & self . session . parse_sess ;
0 commit comments