@@ -19,7 +19,6 @@ use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, DefIndex,
19
19
use rustc:: hir:: def:: { Def , NonMacroAttrKind } ;
20
20
use rustc:: hir:: map:: { self , DefCollector } ;
21
21
use rustc:: { ty, lint} ;
22
- use rustc:: middle:: cstore:: CrateStore ;
23
22
use syntax:: ast:: { self , Name , Ident } ;
24
23
use syntax:: attr;
25
24
use syntax:: errors:: DiagnosticBuilder ;
@@ -110,14 +109,6 @@ pub struct ParentScope<'a> {
110
109
crate derives : Vec < ast:: Path > ,
111
110
}
112
111
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
-
121
112
// Macro namespace is separated into two sub-namespaces, one for bang macros and
122
113
// one for attribute-like macros (attributes, derives).
123
114
// We ignore resolutions from one sub-namespace when searching names in scope for another.
@@ -980,7 +971,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
980
971
check_consistency ( self , binding. def_ignoring_ambiguity ( ) ) ;
981
972
if from_prelude {
982
973
self . record_use ( ident, MacroNS , binding) ;
983
- self . err_if_macro_use_proc_macro ( ident. name , span, binding) ;
984
974
}
985
975
}
986
976
} ;
@@ -1132,69 +1122,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
1132
1122
}
1133
1123
}
1134
1124
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
-
1198
1125
fn gate_legacy_custom_derive ( & mut self , name : Symbol , span : Span ) {
1199
1126
if !self . session . features_untracked ( ) . custom_derive {
1200
1127
let sess = & self . session . parse_sess ;
0 commit comments