17
17
//! * No trailing whitespace
18
18
//! * No CR characters
19
19
//! * No `TODO` or `XXX` directives
20
- //! * A valid license header is at the top
21
20
//! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests
22
21
//!
23
22
//! A number of these checks can be opted-out of with various directives like
@@ -28,16 +27,6 @@ use std::io::prelude::*;
28
27
use std:: path:: Path ;
29
28
30
29
const COLS : usize = 100 ;
31
- const LICENSE : & ' static str = "\
32
- Copyright <year> The Rust Project Developers. See the COPYRIGHT
33
- file at the top-level directory of this distribution and at
34
- http://rust-lang.org/COPYRIGHT.
35
-
36
- Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
37
- http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
38
- <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
39
- option. This file may not be copied, modified, or distributed
40
- except according to those terms." ;
41
30
42
31
const UNEXPLAINED_IGNORE_DOCTEST_INFO : & str = r#"unexplained "```ignore" doctest; try one:
43
32
@@ -168,52 +157,10 @@ pub fn check(path: &Path, bad: &mut bool) {
168
157
trailing_new_lines = 0 ;
169
158
}
170
159
}
171
- if !licenseck ( file, & contents) {
172
- tidy_error ! ( bad, "{}: incorrect license" , file. display( ) ) ;
173
- }
174
160
match trailing_new_lines {
175
161
0 => tidy_error ! ( bad, "{}: missing trailing newline" , file. display( ) ) ,
176
162
1 | 2 => { }
177
163
n => tidy_error ! ( bad, "{}: too many trailing newlines ({})" , file. display( ) , n) ,
178
164
} ;
179
165
} )
180
166
}
181
-
182
- fn licenseck ( file : & Path , contents : & str ) -> bool {
183
- if contents. contains ( "ignore-license" ) {
184
- return true
185
- }
186
- let exceptions = [
187
- "libstd/sync/mpsc/mpsc_queue.rs" ,
188
- "libstd/sync/mpsc/spsc_queue.rs" ,
189
- ] ;
190
- if exceptions. iter ( ) . any ( |f| file. ends_with ( f) ) {
191
- return true
192
- }
193
-
194
- // Skip the BOM if it's there
195
- let bom = "\u{feff} " ;
196
- let contents = if contents. starts_with ( bom) { & contents[ 3 ..] } else { contents} ;
197
-
198
- // See if the license shows up in the first 100 lines
199
- let lines = contents. lines ( ) . take ( 100 ) . collect :: < Vec < _ > > ( ) ;
200
- lines. windows ( LICENSE . lines ( ) . count ( ) ) . any ( |window| {
201
- let offset = if window. iter ( ) . all ( |w| w. starts_with ( "//" ) ) {
202
- 2
203
- } else if window. iter ( ) . all ( |w| w. starts_with ( '#' ) ) {
204
- 1
205
- } else if window. iter ( ) . all ( |w| w. starts_with ( " *" ) ) {
206
- 2
207
- } else {
208
- return false
209
- } ;
210
- window. iter ( ) . map ( |a| a[ offset..] . trim ( ) )
211
- . zip ( LICENSE . lines ( ) ) . all ( |( a, b) | {
212
- a == b || match b. find ( "<year>" ) {
213
- Some ( i) => a. starts_with ( & b[ ..i] ) && a. ends_with ( & b[ i+6 ..] ) ,
214
- None => false ,
215
- }
216
- } )
217
- } )
218
-
219
- }
0 commit comments