17
17
use errors:: { Applicability , DiagnosticBuilder } ;
18
18
use lint:: { LintPass , LateLintPass , LintArray } ;
19
19
use session:: Session ;
20
+ use syntax:: ast;
20
21
use syntax:: codemap:: Span ;
21
22
22
23
declare_lint ! {
@@ -285,6 +286,12 @@ declare_lint! {
285
286
"warns about duplicate associated type bindings in generics"
286
287
}
287
288
289
+ declare_lint ! {
290
+ pub DUPLICATE_MACRO_EXPORTS ,
291
+ Deny ,
292
+ "detects duplicate macro exports"
293
+ }
294
+
288
295
/// Does nothing as a lint pass, but registers some `Lint`s
289
296
/// which are used by other parts of the compiler.
290
297
#[ derive( Copy , Clone ) ]
@@ -337,6 +344,7 @@ impl LintPass for HardwiredLints {
337
344
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE ,
338
345
UNSTABLE_NAME_COLLISIONS ,
339
346
DUPLICATE_ASSOCIATED_TYPE_BINDINGS ,
347
+ DUPLICATE_MACRO_EXPORTS ,
340
348
)
341
349
}
342
350
}
@@ -348,6 +356,7 @@ pub enum BuiltinLintDiagnostics {
348
356
Normal ,
349
357
BareTraitObject ( Span , /* is_global */ bool ) ,
350
358
AbsPathWithModule ( Span ) ,
359
+ DuplicatedMacroExports ( ast:: Ident , Span , Span ) ,
351
360
}
352
361
353
362
impl BuiltinLintDiagnostics {
@@ -380,6 +389,10 @@ impl BuiltinLintDiagnostics {
380
389
} ;
381
390
db. span_suggestion_with_applicability ( span, "use `crate`" , sugg, app) ;
382
391
}
392
+ BuiltinLintDiagnostics :: DuplicatedMacroExports ( ident, earlier_span, later_span) => {
393
+ db. span_label ( later_span, format ! ( "`{}` already exported" , ident) ) ;
394
+ db. span_note ( earlier_span, "previous macro export is now shadowed" ) ;
395
+ }
383
396
}
384
397
}
385
398
}
0 commit comments