Skip to content

Commit

Permalink
feat: remove license_template_path config option
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed May 30, 2022
1 parent 5e42967 commit 79515f1
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 391 deletions.
20 changes: 0 additions & 20 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1473,26 +1473,6 @@ use core::slice;
#[cfg(feature = "alloc")] use core::slice;
```

## `license_template_path`

Check whether beginnings of files match a license template.

- **Default value**: `""`
- **Possible values**: path to a license template file
- **Stable**: No (tracking issue: [#3352](https://github.com/rust-lang/rustfmt/issues/3352))

A license template is a plain text file which is matched literally against the
beginning of each source file, except for `{}`-delimited blocks, which are
matched as regular expressions. The following license template therefore
matches strings like `// Copyright 2017 The Rust Project Developers.`, `//
Copyright 2018 The Rust Project Developers.`, etc.:

```
// Copyright {\d+} The Rust Project Developers.
```

`\{`, `\}` and `\\` match literal braces / backslashes.

## `match_arm_blocks`

Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator.
Expand Down
22 changes: 0 additions & 22 deletions src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ macro_rules! create_config {
#[derive(Clone)]
#[allow(unreachable_pub)]
pub struct Config {
// if a license_template_path has been specified, successfully read, parsed and compiled
// into a regex, it will be stored here
pub license_template: Option<Regex>,
// For each config item, we store a bool indicating whether it has
// been accessed and the value, and a bool whether the option was
// manually initialised, or taken from the default,
Expand Down Expand Up @@ -104,7 +101,6 @@ macro_rules! create_config {
| "struct_variant_width"
| "array_width"
| "chain_width" => self.0.set_heuristics(),
"license_template_path" => self.0.set_license_template(),
"merge_imports" => self.0.set_merge_imports(),
&_ => (),
}
Expand Down Expand Up @@ -163,7 +159,6 @@ macro_rules! create_config {
}
)+
self.set_heuristics();
self.set_license_template();
self.set_ignore(dir);
self.set_merge_imports();
self
Expand Down Expand Up @@ -247,7 +242,6 @@ macro_rules! create_config {
| "struct_variant_width"
| "array_width"
| "chain_width" => self.set_heuristics(),
"license_template_path" => self.set_license_template(),
"merge_imports" => self.set_merge_imports(),
&_ => (),
}
Expand Down Expand Up @@ -386,21 +380,6 @@ macro_rules! create_config {
};
}

fn set_license_template(&mut self) {
if self.was_set().license_template_path() {
let lt_path = self.license_template_path();
if lt_path.len() > 0 {
match license::load_and_compile_template(&lt_path) {
Ok(re) => self.license_template = Some(re),
Err(msg) => eprintln!("Warning for license template file {:?}: {}",
lt_path, msg),
}
} else {
self.license_template = None;
}
}
}

fn set_ignore(&mut self, dir: &Path) {
self.ignore.2.add_prefix(dir);
}
Expand Down Expand Up @@ -437,7 +416,6 @@ macro_rules! create_config {
impl Default for Config {
fn default() -> Config {
Config {
license_template: None,
$(
$i: (Cell::new(false), false, $def, $stb),
)+
Expand Down
265 changes: 0 additions & 265 deletions src/config/license.rs

This file was deleted.

Loading

0 comments on commit 79515f1

Please sign in to comment.