@@ -32,7 +32,6 @@ use crate::ty::TyCtxt;
3232use crate :: ty:: query:: Providers ;
3333use crate :: util:: nodemap:: NodeMap ;
3434use errors:: { DiagnosticBuilder , DiagnosticId } ;
35- use std:: { hash, ptr} ;
3635use syntax:: ast;
3736use syntax:: source_map:: { MultiSpan , ExpnKind , DesugaringKind } ;
3837use syntax:: symbol:: Symbol ;
@@ -43,72 +42,7 @@ pub use crate::lint::context::{LateContext, EarlyContext, LintContext, LintStore
4342 check_crate, check_ast_crate, late_lint_mod, CheckLintNameResult ,
4443 BufferedEarlyLint , } ;
4544
46- pub use rustc_session:: lint:: { Lint , Level , FutureIncompatibleInfo } ;
47-
48- /// Declares a static item of type `&'static Lint`.
49- #[ macro_export]
50- macro_rules! declare_lint {
51- ( $vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
52- declare_lint!(
53- $vis $NAME, $Level, $desc,
54- ) ;
55- ) ;
56- ( $vis: vis $NAME: ident, $Level: ident, $desc: expr,
57- $( @future_incompatible = $fi: expr; ) ? $( $v: ident) ,* ) => (
58- $vis static $NAME: & $crate:: lint:: Lint = & $crate:: lint:: Lint {
59- name: stringify!( $NAME) ,
60- default_level: $crate:: lint:: $Level,
61- desc: $desc,
62- edition_lint_opts: None ,
63- is_plugin: false ,
64- $( $v: true , ) *
65- $( future_incompatible: Some ( $fi) , ) *
66- ..$crate:: lint:: Lint :: default_fields_for_macro( )
67- } ;
68- ) ;
69- ( $vis: vis $NAME: ident, $Level: ident, $desc: expr,
70- $lint_edition: expr => $edition_level: ident
71- ) => (
72- $vis static $NAME: & $crate:: lint:: Lint = & $crate:: lint:: Lint {
73- name: stringify!( $NAME) ,
74- default_level: $crate:: lint:: $Level,
75- desc: $desc,
76- edition_lint_opts: Some ( ( $lint_edition, $crate:: lint:: Level :: $edition_level) ) ,
77- report_in_external_macro: false ,
78- is_plugin: false ,
79- } ;
80- ) ;
81- }
82-
83- #[ macro_export]
84- macro_rules! declare_tool_lint {
85- (
86- $( #[ $attr: meta] ) * $vis: vis $tool: ident :: $NAME: ident, $Level: ident, $desc: expr
87- ) => (
88- declare_tool_lint!{ $( #[ $attr] ) * $vis $tool:: $NAME, $Level, $desc, false }
89- ) ;
90- (
91- $( #[ $attr: meta] ) * $vis: vis $tool: ident :: $NAME: ident, $Level: ident, $desc: expr,
92- report_in_external_macro: $rep: expr
93- ) => (
94- declare_tool_lint!{ $( #[ $attr] ) * $vis $tool:: $NAME, $Level, $desc, $rep}
95- ) ;
96- (
97- $( #[ $attr: meta] ) * $vis: vis $tool: ident :: $NAME: ident, $Level: ident, $desc: expr,
98- $external: expr
99- ) => (
100- $( #[ $attr] ) *
101- $vis static $NAME: & $crate:: lint:: Lint = & $crate:: lint:: Lint {
102- name: & concat!( stringify!( $tool) , "::" , stringify!( $NAME) ) ,
103- default_level: $crate:: lint:: $Level,
104- desc: $desc,
105- edition_lint_opts: None ,
106- report_in_external_macro: $external,
107- future_incompatible: None ,
108- is_plugin: true ,
109- } ;
110- ) ;
111- }
45+ pub use rustc_session:: lint:: { Lint , LintId , Level , FutureIncompatibleInfo } ;
11246
11347/// Declares a static `LintArray` and return it as an expression.
11448#[ macro_export]
@@ -420,46 +354,6 @@ pub type EarlyLintPassObject = Box<dyn EarlyLintPass + sync::Send + sync::Sync +
420354pub type LateLintPassObject = Box < dyn for < ' a , ' tcx > LateLintPass < ' a , ' tcx > + sync:: Send
421355 + sync:: Sync + ' static > ;
422356
423- /// Identifies a lint known to the compiler.
424- #[ derive( Clone , Copy , Debug ) ]
425- pub struct LintId {
426- // Identity is based on pointer equality of this field.
427- lint : & ' static Lint ,
428- }
429-
430- impl PartialEq for LintId {
431- fn eq ( & self , other : & LintId ) -> bool {
432- ptr:: eq ( self . lint , other. lint )
433- }
434- }
435-
436- impl Eq for LintId { }
437-
438- impl hash:: Hash for LintId {
439- fn hash < H : hash:: Hasher > ( & self , state : & mut H ) {
440- let ptr = self . lint as * const Lint ;
441- ptr. hash ( state) ;
442- }
443- }
444-
445- impl LintId {
446- /// Gets the `LintId` for a `Lint`.
447- pub fn of ( lint : & ' static Lint ) -> LintId {
448- LintId {
449- lint,
450- }
451- }
452-
453- pub fn lint_name_raw ( & self ) -> & ' static str {
454- self . lint . name
455- }
456-
457- /// Gets the name of the lint.
458- pub fn to_string ( & self ) -> String {
459- self . lint . name_lower ( )
460- }
461- }
462-
463357/// How a lint level was set.
464358#[ derive( Clone , Copy , PartialEq , Eq , HashStable ) ]
465359pub enum LintSource {
0 commit comments