提交 6766abbf 编写于 作者: M Mark Simulacrum

Clippy lints

上级 802b6db0
...@@ -99,6 +99,6 @@ pub fn version(&self, build: &Build, num: &str) -> String { ...@@ -99,6 +99,6 @@ pub fn version(&self, build: &Build, num: &str) -> String {
version.push_str(&inner.commit_date); version.push_str(&inner.commit_date);
version.push_str(")"); version.push_str(")");
} }
return version version
} }
} }
...@@ -559,23 +559,24 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) { ...@@ -559,23 +559,24 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) {
// If this was an output file in the "host dir" we don't actually // If this was an output file in the "host dir" we don't actually
// worry about it, it's not relevant for us. // worry about it, it's not relevant for us.
if filename.starts_with(&host_root_dir) { if filename.starts_with(&host_root_dir) {
continue continue;
}
// If this was output in the `deps` dir then this is a precise file // If this was output in the `deps` dir then this is a precise file
// name (hash included) so we start tracking it. // name (hash included) so we start tracking it.
} else if filename.starts_with(&target_deps_dir) { if filename.starts_with(&target_deps_dir) {
deps.push(filename.to_path_buf()); deps.push(filename.to_path_buf());
continue;
}
// Otherwise this was a "top level artifact" which right now doesn't // Otherwise this was a "top level artifact" which right now doesn't
// have a hash in the name, but there's a version of this file in // have a hash in the name, but there's a version of this file in
// the `deps` folder which *does* have a hash in the name. That's // the `deps` folder which *does* have a hash in the name. That's
// the one we'll want to we'll probe for it later. // the one we'll want to we'll probe for it later.
} else { toplevel.push((filename.file_stem().unwrap()
toplevel.push((filename.file_stem().unwrap() .to_str().unwrap().to_string(),
.to_str().unwrap().to_string(), filename.extension().unwrap().to_owned()
filename.extension().unwrap().to_owned() .to_str().unwrap().to_string()));
.to_str().unwrap().to_string()));
}
} }
} }
......
...@@ -417,7 +417,7 @@ pub fn parse(build: &str, file: Option<PathBuf>) -> Config { ...@@ -417,7 +417,7 @@ pub fn parse(build: &str, file: Option<PathBuf>) -> Config {
config.update_with_config_mk(); config.update_with_config_mk();
} }
return config config
} }
/// "Temporary" routine to parse `config.mk` into this configuration. /// "Temporary" routine to parse `config.mk` into this configuration.
......
...@@ -488,12 +488,11 @@ fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool { ...@@ -488,12 +488,11 @@ fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
if spath.ends_with("~") || spath.ends_with(".pyc") { if spath.ends_with("~") || spath.ends_with(".pyc") {
return false return false
} }
if spath.contains("llvm/test") || spath.contains("llvm\\test") { if (spath.contains("llvm/test") || spath.contains("llvm\\test")) &&
if spath.ends_with(".ll") || (spath.ends_with(".ll") ||
spath.ends_with(".td") || spath.ends_with(".td") ||
spath.ends_with(".s") { spath.ends_with(".s")) {
return false return false
}
} }
let full_path = Path::new(dir).join(path); let full_path = Path::new(dir).join(path);
......
...@@ -315,10 +315,8 @@ pub fn parse(args: &[String]) -> Flags { ...@@ -315,10 +315,8 @@ pub fn parse(args: &[String]) -> Flags {
let mut stage = matches.opt_str("stage").map(|j| j.parse().unwrap()); let mut stage = matches.opt_str("stage").map(|j| j.parse().unwrap());
if matches.opt_present("incremental") { if matches.opt_present("incremental") && stage.is_none() {
if stage.is_none() { stage = Some(1);
stage = Some(1);
}
} }
Flags { Flags {
......
...@@ -146,5 +146,5 @@ fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf { ...@@ -146,5 +146,5 @@ fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
_ => {} _ => {}
} }
} }
return ret ret
} }
...@@ -496,7 +496,7 @@ fn cargo(&self, ...@@ -496,7 +496,7 @@ fn cargo(&self,
self.ci_env.force_coloring_in_ci(&mut cargo); self.ci_env.force_coloring_in_ci(&mut cargo);
return cargo cargo
} }
/// Get a path to the compiler specified. /// Get a path to the compiler specified.
...@@ -519,7 +519,7 @@ fn rustdoc(&self, compiler: &Compiler) -> PathBuf { ...@@ -519,7 +519,7 @@ fn rustdoc(&self, compiler: &Compiler) -> PathBuf {
let mut rustdoc = self.compiler_path(compiler); let mut rustdoc = self.compiler_path(compiler);
rustdoc.pop(); rustdoc.pop();
rustdoc.push(exe("rustdoc", compiler.host)); rustdoc.push(exe("rustdoc", compiler.host));
return rustdoc rustdoc
} }
/// Get a `Command` which is ready to run `tool` in `stage` built for /// Get a `Command` which is ready to run `tool` in `stage` built for
...@@ -527,7 +527,7 @@ fn rustdoc(&self, compiler: &Compiler) -> PathBuf { ...@@ -527,7 +527,7 @@ fn rustdoc(&self, compiler: &Compiler) -> PathBuf {
fn tool_cmd(&self, compiler: &Compiler, tool: &str) -> Command { fn tool_cmd(&self, compiler: &Compiler, tool: &str) -> Command {
let mut cmd = Command::new(self.tool(&compiler, tool)); let mut cmd = Command::new(self.tool(&compiler, tool));
self.prepare_tool_cmd(compiler, &mut cmd); self.prepare_tool_cmd(compiler, &mut cmd);
return cmd cmd
} }
/// Prepares the `cmd` provided to be able to run the `compiler` provided. /// Prepares the `cmd` provided to be able to run the `compiler` provided.
...@@ -578,7 +578,7 @@ fn std_features(&self) -> String { ...@@ -578,7 +578,7 @@ fn std_features(&self) -> String {
if self.config.profiler { if self.config.profiler {
features.push_str(" profiler"); features.push_str(" profiler");
} }
return features features
} }
/// Get the space-separated set of activated features for the compiler. /// Get the space-separated set of activated features for the compiler.
...@@ -587,7 +587,7 @@ fn rustc_features(&self) -> String { ...@@ -587,7 +587,7 @@ fn rustc_features(&self) -> String {
if self.config.use_jemalloc { if self.config.use_jemalloc {
features.push_str(" jemalloc"); features.push_str(" jemalloc");
} }
return features features
} }
/// Component directory that Cargo will produce output into (e.g. /// Component directory that Cargo will produce output into (e.g.
...@@ -834,7 +834,7 @@ fn cflags(&self, target: &str) -> Vec<String> { ...@@ -834,7 +834,7 @@ fn cflags(&self, target: &str) -> Vec<String> {
if target == "i686-pc-windows-gnu" { if target == "i686-pc-windows-gnu" {
base.push("-fno-omit-frame-pointer".into()); base.push("-fno-omit-frame-pointer".into());
} }
return base base
} }
/// Returns the path to the `ar` archive utility for the target specified. /// Returns the path to the `ar` archive utility for the target specified.
...@@ -866,7 +866,7 @@ fn rustc_flags(&self, target: &str) -> Vec<String> { ...@@ -866,7 +866,7 @@ fn rustc_flags(&self, target: &str) -> Vec<String> {
!target.contains("emscripten") { !target.contains("emscripten") {
base.push(format!("-Clinker={}", self.cc(target).display())); base.push(format!("-Clinker={}", self.cc(target).display()));
} }
return base base
} }
/// Returns the "musl root" for this `target`, if defined /// Returns the "musl root" for this `target`, if defined
......
...@@ -56,7 +56,7 @@ fn maybe_have<S: AsRef<OsStr>>(&mut self, cmd: S) -> Option<PathBuf> { ...@@ -56,7 +56,7 @@ fn maybe_have<S: AsRef<OsStr>>(&mut self, cmd: S) -> Option<PathBuf> {
return Some(target); return Some(target);
} }
} }
return None; None
}).clone() }).clone()
} }
...@@ -73,10 +73,8 @@ pub fn check(build: &mut Build) { ...@@ -73,10 +73,8 @@ pub fn check(build: &mut Build) {
// one is present as part of the PATH then that can lead to the system // one is present as part of the PATH then that can lead to the system
// being unable to identify the files properly. See // being unable to identify the files properly. See
// https://github.com/rust-lang/rust/issues/34959 for more details. // https://github.com/rust-lang/rust/issues/34959 for more details.
if cfg!(windows) { if cfg!(windows) && path.to_string_lossy().contains("\"") {
if path.to_string_lossy().contains("\"") { panic!("PATH contains invalid character '\"'");
panic!("PATH contains invalid character '\"'");
}
} }
let mut cmd_finder = Finder::new(); let mut cmd_finder = Finder::new();
...@@ -95,12 +93,10 @@ pub fn check(build: &mut Build) { ...@@ -95,12 +93,10 @@ pub fn check(build: &mut Build) {
} }
// Ninja is currently only used for LLVM itself. // Ninja is currently only used for LLVM itself.
if building_llvm && build.config.ninja { // Some Linux distros rename `ninja` to `ninja-build`.
// Some Linux distros rename `ninja` to `ninja-build`. // CMake can work with either binary name.
// CMake can work with either binary name. if building_llvm && build.config.ninja && cmd_finder.maybe_have("ninja-build").is_none() {
if cmd_finder.maybe_have("ninja-build").is_none() { cmd_finder.must_have("ninja");
cmd_finder.must_have("ninja");
}
} }
build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p)) build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p))
......
...@@ -148,7 +148,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { ...@@ -148,7 +148,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
} }
} }
} }
return ret ret
}; };
// ======================================================================== // ========================================================================
...@@ -237,7 +237,7 @@ fn crate_rule<'a, 'b>(build: &'a Build, ...@@ -237,7 +237,7 @@ fn crate_rule<'a, 'b>(build: &'a Build,
s.target) s.target)
} }
}); });
return rule rule
} }
// Similar to the `libstd`, `libtest`, and `librustc` rules above, except // Similar to the `libstd`, `libtest`, and `librustc` rules above, except
...@@ -1326,7 +1326,7 @@ fn expand(&self, steps: &[Step<'a>]) -> Vec<Step<'a>> { ...@@ -1326,7 +1326,7 @@ fn expand(&self, steps: &[Step<'a>]) -> Vec<Step<'a>> {
for idx in 0..nodes.len() { for idx in 0..nodes.len() {
self.topo_sort(idx, &idx_to_node, &edges, &mut visited, &mut order); self.topo_sort(idx, &idx_to_node, &edges, &mut visited, &mut order);
} }
return order order
} }
/// Builds the dependency graph rooted at `step`. /// Builds the dependency graph rooted at `step`.
...@@ -1365,7 +1365,7 @@ fn build_graph(&self, ...@@ -1365,7 +1365,7 @@ fn build_graph(&self,
} }
edges.entry(idx).or_insert(HashSet::new()).extend(deps); edges.entry(idx).or_insert(HashSet::new()).extend(deps);
return idx idx
} }
/// Given a dependency graph with a finished list of `nodes`, fill out more /// Given a dependency graph with a finished list of `nodes`, fill out more
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册