Skip to content

Commit

Permalink
Appease clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Nov 22, 2019
1 parent 24b92f0 commit bad18d3
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::path::PathBuf;
use structopt::clap::AppSettings;
use structopt::StructOpt;

const VERSION: &'static str = env!("CARGO_PKG_VERSION");
const VERSION: &str = env!("CARGO_PKG_VERSION");

#[derive(StructOpt, Debug)]
#[structopt(global_settings = &[AppSettings::ColoredHelp, AppSettings::VersionlessSubcommands])]
Expand Down
4 changes: 2 additions & 2 deletions src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn hello_world_test() {{
)
}

const APACHE_2: &'static str = r#" Apache License
const APACHE_2: &str = r#" Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -419,7 +419,7 @@ const APACHE_2: &'static str = r#" Apache Licens
"#;

const GITIGNORE: &'static str = "*.beam
const GITIGNORE: &str = "*.beam
*.iml
*.o
*.plt
Expand Down
6 changes: 3 additions & 3 deletions src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ fn fits(mut limit: isize, mut docs: Vector<(isize, Mode, Document)>) -> bool {

Document::Group(doc) => docs.push_front((indent, Mode::Unbroken, *doc)),

Document::Text(s) => limit = limit - s.len() as isize,
Document::Text(s) => limit -= s.len() as isize,

Document::Break { unbroken, .. } => match mode {
Mode::Broken => return true,
Mode::Unbroken => limit = limit - unbroken.len() as isize,
Mode::Unbroken => limit -= unbroken.len() as isize,
},

Document::Cons(left, right) => {
Expand Down Expand Up @@ -175,7 +175,7 @@ fn fmt(b: &mut String, limit: isize, mut width: isize, mut docs: Vector<(isize,
}

Document::Text(s) => {
width = width + s.len() as isize;
width += s.len() as isize;
b.push_str(s.as_str());
}

Expand Down
100 changes: 38 additions & 62 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,23 @@ Second: {}",
label: did_you_mean(label, &mut options, "Unexpected label"),
};
write(buffer, diagnostic);
if options.len() > 0 {
if options.is_empty() {
write!(
buffer,
"
This constructor does not accept the label `{}`.
Expected one of `{}`.
",
label,
options.iter().join("`, `")
"\n This constructor does not accept any labelled arguments.\n "
)
.unwrap();
} else {
write!(
writeln!(
buffer,
"\n This constructor does not accept any labelled arguments.\n "
"
This constructor does not accept the label `{}`.
Expected one of `{}`.",
label,
options.iter().join("`, `")
)
.unwrap();
}

if options.len() > 0 {}
}

UnexpectedLabelledArg { meta, label } => {
Expand All @@ -193,12 +190,11 @@ Expected one of `{}`.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
This argument has been given a label but the constructor does not expect any.
Please remove the label `{}`.
",
Please remove the label `{}`.",
label
)
.unwrap();
Expand All @@ -213,13 +209,12 @@ Please remove the label `{}`.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
This unlablled argument has been supplied after a labelled argument.
Once a labelled argument has been supplied all following arguments must
also be labelled.
",
also be labelled.",
)
.unwrap();
}
Expand All @@ -233,12 +228,11 @@ also be labelled.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
A function has already been defined with the name
`{}` in this module.
",
`{}` in this module.",
fun
)
.unwrap();
Expand All @@ -253,11 +247,10 @@ A function has already been defined with the name
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
The field `{}` has already been defined. Rename this field.
",
The field `{}` has already been defined. Rename this field.",
label
)
.unwrap();
Expand All @@ -272,11 +265,9 @@ The field `{}` has already been defined. Rename this field.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
The labelled argument `{}` has already been supplied.
",
"\nThe labelled argument `{}` has already been supplied.",
label
)
.unwrap();
Expand All @@ -303,13 +294,12 @@ The labelled argument `{}` has already been supplied.
};
write(buffer, diagnostic);

write!(
writeln!(
buffer,
"
This value is being called as a function but its type is:
{}
",
{}",
typ.pretty_print(4)
)
.unwrap();
Expand All @@ -325,14 +315,13 @@ This value is being called as a function but its type is:
};
write(buffer, diagnostic);

write!(
writeln!(
buffer,
"
Fields can only be accessed on modules. This is not a module, it is
a value with this type:
{}
",
{}",
typ.pretty_print(4)
)
.unwrap();
Expand All @@ -352,7 +341,7 @@ a value with this type:
};
write(buffer, diagnostic);

write!(
writeln!(
buffer,
"
Expected type:
Expand All @@ -361,8 +350,7 @@ Expected type:
Found type:
{}
",
{}",
expected.pretty_print(4),
given.pretty_print(4)
)
Expand Down Expand Up @@ -409,11 +397,10 @@ Found type:
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
The type `{}` is not defined or imported in this module.
",
The type `{}` is not defined or imported in this module.",
name
)
.unwrap();
Expand All @@ -433,14 +420,7 @@ The type `{}` is not defined or imported in this module.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
buffer,
"
The name `{}` is not in scope here.
",
name
)
.unwrap();
writeln!(buffer, "\nThe name `{}` is not in scope here.", name).unwrap();
}

PrivateTypeLeak { meta, leaked } => {
Expand All @@ -458,15 +438,14 @@ The name `{}` is not in scope here.
// - is taken as an argument by this public function
// - is taken as an argument by this public enum constructor
// etc
write!(
writeln!(
buffer,
"
The following type is private, but is being used by this public export.
{}
Private types can only be used within the module that defines them.
",
Private types can only be used within the module that defines them.",
leaked.pretty_print(4),
)
.unwrap();
Expand All @@ -486,11 +465,9 @@ Private types can only be used within the module that defines them.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
No module has been imported with the name `{}`.
",
"\nNo module has been imported with the name `{}`.",
name
)
.unwrap();
Expand All @@ -511,7 +488,7 @@ No module has been imported with the name `{}`.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"\nThe module `{}` does not have a `{}` type.\n",
module_name.join("/"),
Expand All @@ -535,7 +512,7 @@ No module has been imported with the name `{}`.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"\nThe module `{}` does not have a `{}` value.\n",
module_name.join("/"),
Expand Down Expand Up @@ -563,7 +540,7 @@ No module has been imported with the name `{}`.
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"\nThe module `{}` does not have a `{}` field.\n",
module_name.join("/"),
Expand Down Expand Up @@ -622,7 +599,7 @@ No module has been imported with the name `{}`.
},
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"\nI don't know what this character means. Is it a typo?\n"
)
Expand Down Expand Up @@ -684,12 +661,11 @@ but this one uses {}. Rewrite this using the fn({}) {{ ... }} syntax.",
meta: meta.clone(),
};
write(buffer, diagnostic);
write!(
writeln!(
buffer,
"
The module `{}` is trying to import the module `{}`,
but it cannot be found.
",
but it cannot be found.",
module, import
)
.expect("error pretty buffer write");
Expand Down Expand Up @@ -799,7 +775,7 @@ pub fn compile(srcs: Vec<Input>) -> Result<Vec<Compiled>, Error> {
});
}

module.name = name.split("/").map(|s| s.to_string()).collect();
module.name = name.split('/').map(|s| s.to_string()).collect();

let index = deps_graph.add_node(name.clone());
indexes.insert(name.clone(), index);
Expand Down
Loading

0 comments on commit bad18d3

Please sign in to comment.