chores: run cargo +1.40.0 fmt

Apparently fmt from 1.40.0 is a bit more strict in some places

Let me know if this is worthwhile merging :)
This commit is contained in:
ReggaeMuffin 2021-04-02 10:56:49 +01:00
parent de6aa69259
commit 2eb32d845e
No known key found for this signature in database
GPG key ID: B7A56D7FE881B7C5
13 changed files with 94 additions and 95 deletions

2
Cargo.lock generated
View file

@ -2181,7 +2181,7 @@ dependencies = [
name = "uu_relpath"
version = "0.0.4"
dependencies = [
"getopts",
"clap",
"uucore",
"uucore_procs",
]

View file

@ -44,10 +44,10 @@ pub fn main() {
mf.write_all(
"type UtilityMap<T> = HashMap<&'static str, fn(T) -> i32>;\n\
\n\
fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n\
\tlet mut map = UtilityMap::new();\n\
"
\n\
fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n\
\tlet mut map = UtilityMap::new();\n\
"
.as_bytes(),
)
.unwrap();
@ -97,21 +97,21 @@ pub fn main() {
mf.write_all(
format!(
"\
\tmap.insert(\"{krate}\", {krate}::uumain);\n\
\t\tmap.insert(\"md5sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha1sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha224sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha256sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha384sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha512sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-224sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-256sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-384sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-512sum\", {krate}::uumain);\n\
\t\tmap.insert(\"shake128sum\", {krate}::uumain);\n\
\t\tmap.insert(\"shake256sum\", {krate}::uumain);\n\
",
\tmap.insert(\"{krate}\", {krate}::uumain);\n\
\t\tmap.insert(\"md5sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha1sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha224sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha256sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha384sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha512sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-224sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-256sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-384sum\", {krate}::uumain);\n\
\t\tmap.insert(\"sha3-512sum\", {krate}::uumain);\n\
\t\tmap.insert(\"shake128sum\", {krate}::uumain);\n\
\t\tmap.insert(\"shake256sum\", {krate}::uumain);\n\
",
krate = krate
)
.as_bytes(),

View file

@ -65,8 +65,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(options::USERSPEC)
.help(
"Colon-separated user and group to switch to. \
Same as -u USER -g GROUP. \
Userspec has higher preference than -u and/or -g",
Same as -u USER -g GROUP. \
Userspec has higher preference than -u and/or -g",
)
.value_name("USER:GROUP"),
)

View file

@ -10,13 +10,13 @@ const BUF_SIZE: usize = 65536;
const VERSION: &str = env!("CARGO_PKG_VERSION");
const ABOUT: &str = "\
Print the first 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
Mandatory arguments to long flags are mandatory for short flags too.\
";
Print the first 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
Mandatory arguments to long flags are mandatory for short flags too.\
";
const USAGE: &str = "head [FLAG]... [FILE]...";
mod options {
@ -43,10 +43,10 @@ fn app<'a>() -> App<'a, 'a> {
.takes_value(true)
.help(
"\
print the first NUM bytes of each file;\n\
with the leading '-', print all but the last\n\
NUM bytes of each file\
",
print the first NUM bytes of each file;\n\
with the leading '-', print all but the last\n\
NUM bytes of each file\
",
)
.overrides_with_all(&[options::BYTES_NAME, options::LINES_NAME])
.allow_hyphen_values(true),
@ -59,10 +59,10 @@ fn app<'a>() -> App<'a, 'a> {
.takes_value(true)
.help(
"\
print the first NUM lines instead of the first 10;\n\
with the leading '-', print all but the last\n\
NUM lines of each file\
",
print the first NUM lines instead of the first 10;\n\
with the leading '-', print all but the last\n\
NUM lines of each file\
",
)
.overrides_with_all(&[options::LINES_NAME, options::BYTES_NAME])
.allow_hyphen_values(true),

View file

@ -78,7 +78,7 @@ fn execute(args: impl uucore::Args) -> i32 {
)
.arg(Arg::with_name(OPT_SHORT).short("s").long("short").help(
"Display the short hostname (the portion before the first dot) if \
possible",
possible",
))
.arg(Arg::with_name(OPT_HOST))
.get_matches_from(args);

View file

@ -111,7 +111,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_BACKUP)
.help(
"make a backup of each file that would otherwise be overwritten \
or removed",
or removed",
)
.takes_value(true)
.possible_value("simple")
@ -145,7 +145,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_NO_DEREFERENCE)
.help(
"treat LINK_executable!() as a normal file if it is a \
symbolic link to a directory",
symbolic link to a directory",
),
)
// TODO: opts.arg(

View file

@ -71,7 +71,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_SUFFIX)
.help(
"append SUFF to TEMPLATE; SUFF must not contain a path separator. \
This option is implied if TEMPLATE does not end with X.",
This option is implied if TEMPLATE does not end with X.",
)
.value_name("SUFF"),
)
@ -81,15 +81,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_TMPDIR)
.help(
"interpret TEMPLATE relative to DIR; if DIR is not specified, use \
$TMPDIR if set, else /tmp. With this option, TEMPLATE must not \
be an absolute name; unlike with -t, TEMPLATE may contain \
slashes, but mktemp creates only the final component",
$TMPDIR if set, else /tmp. With this option, TEMPLATE must not \
be an absolute name; unlike with -t, TEMPLATE may contain \
slashes, but mktemp creates only the final component",
)
.value_name("DIR"),
)
.arg(Arg::with_name(OPT_T).short(OPT_T).help(
"Generate a template (using the supplied prefix and TMPDIR if set) \
to create a filename template [deprecated]",
to create a filename template [deprecated]",
))
.arg(
Arg::with_name(ARG_TEMPLATE)

View file

@ -187,9 +187,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(options::PADDING)
.help(
"pad the output to N characters; positive N will \
right-align; negative N will left-align; padding is \
ignored if the output is wider than N; the default is \
to automatically pad if a whitespace is found",
right-align; negative N will left-align; padding is \
ignored if the output is wider than N; the default is \
to automatically pad if a whitespace is found",
)
.value_name("N"),
)
@ -198,7 +198,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(options::HEADER)
.help(
"print (without converting) the first N header lines; \
N defaults to 1 if not specified",
N defaults to 1 if not specified",
)
.value_name("N")
.default_value(options::HEADER_DEFAULT)

View file

@ -46,7 +46,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_CANONICALIZE)
.help(
"canonicalize by following every symlink in every component of the \
given name recursively; all but the last component must exist",
given name recursively; all but the last component must exist",
),
)
.arg(
@ -55,7 +55,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long("canonicalize-existing")
.help(
"canonicalize by following every symlink in every component of the \
given name recursively, all components must exist",
given name recursively, all components must exist",
),
)
.arg(
@ -64,7 +64,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_CANONICALIZE_MISSING)
.help(
"canonicalize by following every symlink in every component of the \
given name recursively, without requirements on components existence",
given name recursively, without requirements on components existence",
),
)
.arg(

View file

@ -223,40 +223,40 @@ fn get_usage() -> String {
static AFTER_HELP: &str =
"Delete FILE(s) if --remove (-u) is specified. The default is not to remove\n\
the files because it is common to operate on device files like /dev/hda,\n\
and those files usually should not be removed.\n\
\n\
CAUTION: Note that shred relies on a very important assumption:\n\
that the file system overwrites data in place. This is the traditional\n\
way to do things, but many modern file system designs do not satisfy this\n\
assumption. The following are examples of file systems on which shred is\n\
not effective, or is not guaranteed to be effective in all file system modes:\n\
\n\
* log-structured or journaled file systems, such as those supplied with\n\
AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)\n\
\n\
* file systems that write redundant data and carry on even if some writes\n\
fail, such as RAID-based file systems\n\
\n\
* file systems that make snapshots, such as Network Appliance's NFS server\n\
\n\
* file systems that cache in temporary locations, such as NFS\n\
version 3 clients\n\
\n\
* compressed file systems\n\
\n\
In the case of ext3 file systems, the above disclaimer applies\n\
and shred is thus of limited effectiveness) only in data=journal mode,\n\
which journals file data in addition to just metadata. In both the\n\
data=ordered (default) and data=writeback modes, shred works as usual.\n\
Ext3 journaling modes can be changed by adding the data=something option\n\
to the mount options for a particular file system in the /etc/fstab file,\n\
as documented in the mount man page (man mount).\n\
\n\
In addition, file system backups and remote mirrors may contain copies\n\
of the file that cannot be removed, and that will allow a shredded file\n\
to be recovered later.\n\
";
the files because it is common to operate on device files like /dev/hda,\n\
and those files usually should not be removed.\n\
\n\
CAUTION: Note that shred relies on a very important assumption:\n\
that the file system overwrites data in place. This is the traditional\n\
way to do things, but many modern file system designs do not satisfy this\n\
assumption. The following are examples of file systems on which shred is\n\
not effective, or is not guaranteed to be effective in all file system modes:\n\
\n\
* log-structured or journaled file systems, such as those supplied with\n\
AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)\n\
\n\
* file systems that write redundant data and carry on even if some writes\n\
fail, such as RAID-based file systems\n\
\n\
* file systems that make snapshots, such as Network Appliance's NFS server\n\
\n\
* file systems that cache in temporary locations, such as NFS\n\
version 3 clients\n\
\n\
* compressed file systems\n\
\n\
In the case of ext3 file systems, the above disclaimer applies\n\
and shred is thus of limited effectiveness) only in data=journal mode,\n\
which journals file data in addition to just metadata. In both the\n\
data=ordered (default) and data=writeback modes, shred works as usual.\n\
Ext3 journaling modes can be changed by adding the data=something option\n\
to the mount options for a particular file system in the /etc/fstab file,\n\
as documented in the mount man page (man mount).\n\
\n\
In addition, file system backups and remote mirrors may contain copies\n\
of the file that cannot be removed, and that will allow a shredded file\n\
to be recovered later.\n\
";
pub mod options {
pub const FILE: &str = "file";
@ -312,7 +312,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.short("x")
.help(
"do not round file sizes up to the next full block;\n\
this is the default for non-regular files",
this is the default for non-regular files",
),
)
.arg(

View file

@ -80,7 +80,8 @@ fn print_version() {
fn print_usage(opts: &Options) {
let brief = "Run COMMAND, with modified buffering operations for its standard streams\n \
Mandatory arguments to long options are mandatory for short options too.";
let explanation = "If MODE is 'L' the corresponding stream will be line buffered.\n \
let explanation =
"If MODE is 'L' the corresponding stream will be line buffered.\n \
This option is invalid with standard input.\n\n \
If MODE is '0' the corresponding stream will be unbuffered.\n\n \
Otherwise MODE is a number which may be followed by one of the following:\n\n \

View file

@ -19,8 +19,8 @@ use uucore::libc::time_t;
static VERSION: &str = env!("CARGO_PKG_VERSION");
static ABOUT: &str = "Display the current time, the length of time the system has been up,\n\
the number of users on the system, and the average number of jobs\n\
in the run queue over the last 1, 5 and 15 minutes.";
the number of users on the system, and the average number of jobs\n\
in the run queue over the last 1, 5 and 15 minutes.";
pub mod options {
pub static SINCE: &str = "since";
}

View file

@ -29,8 +29,8 @@ static TESTS_DIR: &str = "tests";
static FIXTURES_DIR: &str = "fixtures";
static ALREADY_RUN: &str = " you have already run this UCommand, if you want to run \
another command in the same test, use TestScenario::new instead of \
testing();";
another command in the same test, use TestScenario::new instead of \
testing();";
static MULTIPLE_STDIN_MEANINGLESS: &str = "Ucommand is designed around a typical use case of: provide args and input stream -> spawn process -> block until completion -> return output streams. For verifying that a particular section of the input stream is what causes a particular behavior, use the Command type directly.";
/// Test if the program is running under CI
@ -135,9 +135,7 @@ impl CmdResult {
pub fn tmpd(&self) -> Rc<TempDir> {
match &self.tmpd {
Some(ptr) => ptr.clone(),
None => {
panic!("Command not associated with a TempDir")
}
None => panic!("Command not associated with a TempDir"),
}
}