@@ -6,7 +6,6 @@ use rustc::lint as lint;
66use rustc:: middle:: privacy:: AccessLevels ;
77use rustc:: util:: nodemap:: DefIdSet ;
88use std:: mem;
9- use std:: fmt;
109use syntax:: ast:: NodeId ;
1110use syntax_pos:: { DUMMY_SP , Span } ;
1211use std:: ops:: Range ;
@@ -46,84 +45,14 @@ pub use self::collect_trait_impls::COLLECT_TRAIT_IMPLS;
4645mod check_code_block_syntax;
4746pub use self :: check_code_block_syntax:: CHECK_CODE_BLOCK_SYNTAX ;
4847
49- /// Represents a single pass.
48+ /// A single pass over the cleaned documentation.
49+ ///
50+ /// Runs in the compiler context, so it has access to types and traits and the like.
5051#[ derive( Copy , Clone ) ]
51- pub enum Pass {
52- /// An "early pass" is run in the compiler context, and can gather information about types and
53- /// traits and the like.
54- EarlyPass {
55- name : & ' static str ,
56- pass : fn ( clean:: Crate , & DocContext < ' _ , ' _ , ' _ > ) -> clean:: Crate ,
57- description : & ' static str ,
58- } ,
59- /// A "late pass" is run between crate cleaning and page generation.
60- LatePass {
61- name : & ' static str ,
62- pass : fn ( clean:: Crate ) -> clean:: Crate ,
63- description : & ' static str ,
64- } ,
65- }
66-
67- impl fmt:: Debug for Pass {
68- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
69- let mut dbg = match * self {
70- Pass :: EarlyPass { .. } => f. debug_struct ( "EarlyPass" ) ,
71- Pass :: LatePass { .. } => f. debug_struct ( "LatePass" ) ,
72- } ;
73-
74- dbg. field ( "name" , & self . name ( ) )
75- . field ( "pass" , & "..." )
76- . field ( "description" , & self . description ( ) )
77- . finish ( )
78- }
79- }
80-
81- impl Pass {
82- /// Constructs a new early pass.
83- pub const fn early ( name : & ' static str ,
84- pass : fn ( clean:: Crate , & DocContext < ' _ , ' _ , ' _ > ) -> clean:: Crate ,
85- description : & ' static str ) -> Pass {
86- Pass :: EarlyPass { name, pass, description }
87- }
88-
89- /// Constructs a new late pass.
90- pub const fn late ( name : & ' static str ,
91- pass : fn ( clean:: Crate ) -> clean:: Crate ,
92- description : & ' static str ) -> Pass {
93- Pass :: LatePass { name, pass, description }
94- }
95-
96- /// Returns the name of this pass.
97- pub fn name ( self ) -> & ' static str {
98- match self {
99- Pass :: EarlyPass { name, .. } |
100- Pass :: LatePass { name, .. } => name,
101- }
102- }
103-
104- /// Returns the description of this pass.
105- pub fn description ( self ) -> & ' static str {
106- match self {
107- Pass :: EarlyPass { description, .. } |
108- Pass :: LatePass { description, .. } => description,
109- }
110- }
111-
112- /// If this pass is an early pass, returns the pointer to its function.
113- pub fn early_fn ( self ) -> Option < fn ( clean:: Crate , & DocContext < ' _ , ' _ , ' _ > ) -> clean:: Crate > {
114- match self {
115- Pass :: EarlyPass { pass, .. } => Some ( pass) ,
116- _ => None ,
117- }
118- }
119-
120- /// If this pass is a late pass, returns the pointer to its function.
121- pub fn late_fn ( self ) -> Option < fn ( clean:: Crate ) -> clean:: Crate > {
122- match self {
123- Pass :: LatePass { pass, .. } => Some ( pass) ,
124- _ => None ,
125- }
126- }
52+ pub struct Pass {
53+ pub name : & ' static str ,
54+ pub pass : fn ( clean:: Crate , & DocContext < ' _ , ' _ , ' _ > ) -> clean:: Crate ,
55+ pub description : & ' static str ,
12756}
12857
12958/// The full list of passes.
@@ -184,8 +113,8 @@ pub fn defaults(default_set: DefaultPassOption) -> &'static [&'static str] {
184113}
185114
186115/// If the given name matches a known pass, returns its information.
187- pub fn find_pass ( pass_name : & str ) -> Option < Pass > {
188- PASSES . iter ( ) . find ( |p| p. name ( ) == pass_name) . cloned ( )
116+ pub fn find_pass ( pass_name : & str ) -> Option < & ' static Pass > {
117+ PASSES . iter ( ) . find ( |p| p. name == pass_name)
189118}
190119
191120struct Stripper < ' a > {
0 commit comments