1717use errors:: { Applicability , DiagnosticBuilder } ;
1818use lint:: { LintPass , LateLintPass , LintArray } ;
1919use session:: Session ;
20+ use syntax:: ast;
2021use syntax:: codemap:: Span ;
2122
2223declare_lint ! {
@@ -285,6 +286,12 @@ declare_lint! {
285286 "warns about duplicate associated type bindings in generics"
286287}
287288
289+ declare_lint ! {
290+ pub DUPLICATE_MACRO_EXPORTS ,
291+ Deny ,
292+ "detects duplicate macro exports"
293+ }
294+
288295/// Does nothing as a lint pass, but registers some `Lint`s
289296/// which are used by other parts of the compiler.
290297#[ derive( Copy , Clone ) ]
@@ -337,6 +344,7 @@ impl LintPass for HardwiredLints {
337344 ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE ,
338345 UNSTABLE_NAME_COLLISIONS ,
339346 DUPLICATE_ASSOCIATED_TYPE_BINDINGS ,
347+ DUPLICATE_MACRO_EXPORTS ,
340348 )
341349 }
342350}
@@ -348,6 +356,7 @@ pub enum BuiltinLintDiagnostics {
348356 Normal ,
349357 BareTraitObject ( Span , /* is_global */ bool ) ,
350358 AbsPathWithModule ( Span ) ,
359+ DuplicatedMacroExports ( ast:: Ident , Span , Span ) ,
351360}
352361
353362impl BuiltinLintDiagnostics {
@@ -380,6 +389,10 @@ impl BuiltinLintDiagnostics {
380389 } ;
381390 db. span_suggestion_with_applicability ( span, "use `crate`" , sugg, app) ;
382391 }
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+ }
383396 }
384397 }
385398}
0 commit comments