]> git.lizzy.rs Git - rust.git/commitdiff
bootstrap: clippy fixes
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 30 Dec 2020 21:52:04 +0000 (22:52 +0100)
committerMatthias Krüger <matthias.krueger@famsik.de>
Wed, 30 Dec 2020 23:58:52 +0000 (00:58 +0100)
addresses:

clippy::or_fun_call
clippy::single_char_add_str
clippy::comparison_to_empty
clippy::or_fun_call

src/bootstrap/builder.rs
src/bootstrap/channel.rs
src/bootstrap/config.rs
src/bootstrap/dist.rs
src/bootstrap/lib.rs
src/bootstrap/sanity.rs
src/bootstrap/setup.rs
src/bootstrap/test.rs

index c2abb01fa8c95f5723a16ef6ca3ba2456378c330..ec9ce4c820c69f18b72823735b47710b86d84f43 100644 (file)
@@ -1534,7 +1534,7 @@ fn env(&mut self, env: &str) {
     fn arg(&mut self, arg: &str) -> &mut Self {
         assert_eq!(arg.split(' ').count(), 1);
         if !self.0.is_empty() {
-            self.0.push_str(" ");
+            self.0.push(' ');
         }
         self.0.push_str(arg);
         self
index 2b82f6c30b27364aa4f56ab0d44ffa0aad9d0428..6e65be93fecc8a19365acbb80f1e5483c2e0d78f 100644 (file)
@@ -74,9 +74,9 @@ pub fn version(&self, build: &Build, num: &str) -> String {
         if let Some(ref inner) = self.inner {
             version.push_str(" (");
             version.push_str(&inner.short_sha);
-            version.push_str(" ");
+            version.push(' ');
             version.push_str(&inner.commit_date);
-            version.push_str(")");
+            version.push(')');
         }
         version
     }
index def8f21543626ad442b68a2abcfeafaab356e22d..a8b1082edebd059ebda49662634b8379c44eef08 100644 (file)
@@ -334,7 +334,7 @@ fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>) {
                     *x = Some(new);
                 }
             }
-        };
+        }
         do_merge(&mut self.build, build);
         do_merge(&mut self.install, install);
         do_merge(&mut self.llvm, llvm);
index 0a79d09b27fed29598f66cbe41e7ac28a0b215c0..dff9e12ee1167fa16ea44e3249f6241bcc6ee411 100644 (file)
@@ -1326,17 +1326,17 @@ fn run(self, builder: &Builder<'_>) {
         license += &builder.read(&builder.src.join("COPYRIGHT"));
         license += &builder.read(&builder.src.join("LICENSE-APACHE"));
         license += &builder.read(&builder.src.join("LICENSE-MIT"));
-        license.push_str("\n");
-        license.push_str("\n");
+        license.push('\n');
+        license.push('\n');
 
         let rtf = r"{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}\nowwrap\fs18";
         let mut rtf = rtf.to_string();
-        rtf.push_str("\n");
+        rtf.push('\n');
         for line in license.lines() {
             rtf.push_str(line);
             rtf.push_str("\\line ");
         }
-        rtf.push_str("}");
+        rtf.push('}');
 
         fn filter(contents: &str, marker: &str) -> String {
             let start = format!("tool-{}-start", marker);
index a47ddfbcc1f180c13deeb18bef9c449efd1d5dad..88fdcfa2d43cd14e55c0255cd2a1c01656a2e59b 100644 (file)
@@ -1083,7 +1083,7 @@ fn rust_version(&self) -> String {
         if let Some(ref s) = self.config.description {
             version.push_str(" (");
             version.push_str(s);
-            version.push_str(")");
+            version.push(')');
         }
         version
     }
@@ -1144,7 +1144,7 @@ fn in_tree_crates(&self, root: &str, target: Option<TargetSelection>) -> Vec<&Cr
                     && (dep != "profiler_builtins"
                         || target
                             .map(|t| self.config.profiler_enabled(t))
-                            .unwrap_or(self.config.any_profiler_enabled()))
+                            .unwrap_or_else(|| self.config.any_profiler_enabled()))
                     && (dep != "rustc_codegen_llvm" || self.config.llvm_enabled())
                 {
                     list.push(*dep);
index acb941d95407ed42856a2c395a308d3938132808..08acc3d671fac8b836e20cd5bd981d7f86c915c0 100644 (file)
@@ -163,7 +163,11 @@ pub fn check(build: &mut Build) {
             panic!("the iOS target is only supported on macOS");
         }
 
-        build.config.target_config.entry(*target).or_insert(Target::from_triple(&target.triple));
+        build
+            .config
+            .target_config
+            .entry(*target)
+            .or_insert_with(|| Target::from_triple(&target.triple));
 
         if target.contains("-none-") || target.contains("nvptx") {
             if build.no_std(*target) == Some(false) {
index 2d4484c562c40db77f9a715800d9fc31de0f9690..725147767dbd1eac034694216549253bdb892dfb 100644 (file)
@@ -89,7 +89,7 @@ pub fn setup(src_path: &Path, profile: Profile) {
         std::process::exit(1);
     }
 
-    let path = cfg_file.unwrap_or("config.toml".into());
+    let path = cfg_file.unwrap_or_else(|| "config.toml".into());
     let settings = format!(
         "# Includes one of the default files in src/bootstrap/defaults\n\
     profile = \"{}\"\n\
@@ -156,7 +156,7 @@ fn parse_with_abbrev(input: &str) -> Result<Profile, String> {
         io::stdout().flush()?;
         let mut input = String::new();
         io::stdin().read_line(&mut input)?;
-        if input == "" {
+        if input.is_empty() {
             eprintln!("EOF on stdin, when expecting answer to question.  Giving up.");
             std::process::exit(1);
         }
index 859236804d3c55e86b4b68ecf0b63e994143d6e2..66a18dfbeaa7dd0657b337d4364a55064b24ace6 100644 (file)
@@ -1135,7 +1135,7 @@ fn run(self, builder: &Builder<'_>) {
                 // flag is respected, so providing an empty --test-args conflicts with
                 // any following it.
                 match p.strip_prefix(suite_path).ok().and_then(|p| p.to_str()) {
-                    Some(s) if s != "" => Some(s),
+                    Some(s) if !s.is_empty() => Some(s),
                     _ => None,
                 }
             })