Skip to content

Ignore license_template_path if it is the empty string #3802

@bolinfest

Description

@bolinfest

See here:

pub(crate) fn load_and_compile_template(path: &str) -> Result<Regex, LicenseError> {
let mut lt_file = File::open(&path)?;
let mut lt_str = String::new();
lt_file.read_to_string(&mut lt_str)?;
let lt_parsed = TemplateParser::parse(&lt_str)?;
Ok(Regex::new(&lt_parsed)?)
}

Nothing upstream of this function aborts if license_template_path is the empty string.

One might wonder why anyone would set license_template_path to "". Well, rls does it when it creates a rustfmt Config using Default::default(), serializes it to file, and passes it as an argument via --config-path. This inevitably results in:

Warning for license template file "": No such file or directory (os error 2)

It would be nice to avoid this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues up for grabs, also good candidates for new rustfmt contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions