Skip to content

Commit 79515f1

Browse files
committedMay 30, 2022
feat: remove license_template_path config option
1 parent 5e42967 commit 79515f1

File tree

13 files changed

+3
-391
lines changed

13 files changed

+3
-391
lines changed
 

‎Configurations.md

-20
Original file line numberDiff line numberDiff line change
@@ -1473,26 +1473,6 @@ use core::slice;
14731473
#[cfg(feature = "alloc")] use core::slice;
14741474
```
14751475

1476-
## `license_template_path`
1477-
1478-
Check whether beginnings of files match a license template.
1479-
1480-
- **Default value**: `""`
1481-
- **Possible values**: path to a license template file
1482-
- **Stable**: No (tracking issue: [#3352](https://github.com/rust-lang/rustfmt/issues/3352))
1483-
1484-
A license template is a plain text file which is matched literally against the
1485-
beginning of each source file, except for `{}`-delimited blocks, which are
1486-
matched as regular expressions. The following license template therefore
1487-
matches strings like `// Copyright 2017 The Rust Project Developers.`, `//
1488-
Copyright 2018 The Rust Project Developers.`, etc.:
1489-
1490-
```
1491-
// Copyright {\d+} The Rust Project Developers.
1492-
```
1493-
1494-
`\{`, `\}` and `\\` match literal braces / backslashes.
1495-
14961476
## `match_arm_blocks`
14971477

14981478
Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator.

‎src/config/config_type.rs

-22
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ macro_rules! create_config {
6161
#[derive(Clone)]
6262
#[allow(unreachable_pub)]
6363
pub struct Config {
64-
// if a license_template_path has been specified, successfully read, parsed and compiled
65-
// into a regex, it will be stored here
66-
pub license_template: Option<Regex>,
6764
// For each config item, we store a bool indicating whether it has
6865
// been accessed and the value, and a bool whether the option was
6966
// manually initialised, or taken from the default,
@@ -104,7 +101,6 @@ macro_rules! create_config {
104101
| "struct_variant_width"
105102
| "array_width"
106103
| "chain_width" => self.0.set_heuristics(),
107-
"license_template_path" => self.0.set_license_template(),
108104
"merge_imports" => self.0.set_merge_imports(),
109105
&_ => (),
110106
}
@@ -163,7 +159,6 @@ macro_rules! create_config {
163159
}
164160
)+
165161
self.set_heuristics();
166-
self.set_license_template();
167162
self.set_ignore(dir);
168163
self.set_merge_imports();
169164
self
@@ -247,7 +242,6 @@ macro_rules! create_config {
247242
| "struct_variant_width"
248243
| "array_width"
249244
| "chain_width" => self.set_heuristics(),
250-
"license_template_path" => self.set_license_template(),
251245
"merge_imports" => self.set_merge_imports(),
252246
&_ => (),
253247
}
@@ -386,21 +380,6 @@ macro_rules! create_config {
386380
};
387381
}
388382

389-
fn set_license_template(&mut self) {
390-
if self.was_set().license_template_path() {
391-
let lt_path = self.license_template_path();
392-
if lt_path.len() > 0 {
393-
match license::load_and_compile_template(&lt_path) {
394-
Ok(re) => self.license_template = Some(re),
395-
Err(msg) => eprintln!("Warning for license template file {:?}: {}",
396-
lt_path, msg),
397-
}
398-
} else {
399-
self.license_template = None;
400-
}
401-
}
402-
}
403-
404383
fn set_ignore(&mut self, dir: &Path) {
405384
self.ignore.2.add_prefix(dir);
406385
}
@@ -437,7 +416,6 @@ macro_rules! create_config {
437416
impl Default for Config {
438417
fn default() -> Config {
439418
Config {
440-
license_template: None,
441419
$(
442420
$i: (Cell::new(false), false, $def, $stb),
443421
)+

‎src/config/license.rs

-265
This file was deleted.

0 commit comments

Comments
 (0)