Skip to content

Why fmt must use internet to fmt code? #3811

Closed
@driftluo

Description

@driftluo

rustfmt use cargo-metadata to get all kinds of metadata, but default use online mode and can not change to offline.

But it is well known that because of various network problems, cargo added the --offline option, metadata also supports this option, but fmt does not support.

I strongly recommend that fmt also have the offline parameter or default with offline.

fn get_cargo_metadata(
manifest_path: Option<&Path>,
include_deps: bool,
) -> Result<cargo_metadata::Metadata, io::Error> {
let mut cmd = cargo_metadata::MetadataCommand::new();
if !include_deps {
cmd.no_deps();
}
if let Some(manifest_path) = manifest_path {
cmd.manifest_path(manifest_path);
}
match cmd.exec() {
Ok(metadata) => Ok(metadata),
Err(error) => Err(io::Error::new(io::ErrorKind::Other, error.to_string())),
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions