Skip to content

Commit cf90fd0

Browse files
committed
Rollup merge of rust-lang#53617 - joshtriplett:tidy-no-license-header, r=Mark-Simulacrum
tidy: Stop requiring a license header Previously approved in rust-lang#43498 ; update tidy to match.
2 parents ff4500c + a15b617 commit cf90fd0

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

src/tools/tidy/src/style.rs

-53
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
//! * No trailing whitespace
1818
//! * No CR characters
1919
//! * No `TODO` or `XXX` directives
20-
//! * A valid license header is at the top
2120
//! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests
2221
//!
2322
//! A number of these checks can be opted-out of with various directives like
@@ -28,16 +27,6 @@ use std::io::prelude::*;
2827
use std::path::Path;
2928

3029
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.";
4130

4231
const UNEXPLAINED_IGNORE_DOCTEST_INFO: &str = r#"unexplained "```ignore" doctest; try one:
4332
@@ -168,52 +157,10 @@ pub fn check(path: &Path, bad: &mut bool) {
168157
trailing_new_lines = 0;
169158
}
170159
}
171-
if !licenseck(file, &contents) {
172-
tidy_error!(bad, "{}: incorrect license", file.display());
173-
}
174160
match trailing_new_lines {
175161
0 => tidy_error!(bad, "{}: missing trailing newline", file.display()),
176162
1 | 2 => {}
177163
n => tidy_error!(bad, "{}: too many trailing newlines ({})", file.display(), n),
178164
};
179165
})
180166
}
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

Comments
 (0)