about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuri Astrakhan <YuriAstrakhan@gmail.com>2022-12-23 03:07:42 -0500
committerYuri Astrakhan <YuriAstrakhan@gmail.com>2022-12-23 03:11:53 -0500
commitec55dd1d7b766bb2cf5cb91f77fbb175c20e128f (patch)
tree120145d856703b96a7d6dfeff56b45e2967afd16
parentf1785f7a21f25ecad44b6a545ff14570d4754607 (diff)
downloadrust-ec55dd1d7b766bb2cf5cb91f77fbb175c20e128f.tar.gz
rust-ec55dd1d7b766bb2cf5cb91f77fbb175c20e128f.zip
Minor manual cleanu
* use default derive
* use `strip_prefix` where possible to avoid dup work
-rw-r--r--crates/proc-macro-test/build.rs13
-rw-r--r--crates/vfs/src/file_set.rs7
-rw-r--r--crates/vfs/src/path_interner.rs7
-rw-r--r--xtask/src/release/changelog.rs6
4 files changed, 9 insertions, 24 deletions
diff --git a/crates/proc-macro-test/build.rs b/crates/proc-macro-test/build.rs
index a80c962617b..dd6203e2eeb 100644
--- a/crates/proc-macro-test/build.rs
+++ b/crates/proc-macro-test/build.rs
@@ -85,16 +85,13 @@ fn main() {
 
     let mut artifact_path = None;
     for message in Message::parse_stream(output.stdout.as_slice()) {
-        match message.unwrap() {
-            Message::CompilerArtifact(artifact) => {
-                if artifact.target.kind.contains(&"proc-macro".to_string()) {
-                    let repr = format!("{} {}", name, version);
-                    if artifact.package_id.repr.starts_with(&repr) {
-                        artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
-                    }
+        if let Message::CompilerArtifact(artifact) = message.unwrap() {
+            if artifact.target.kind.contains(&"proc-macro".to_string()) {
+                let repr = format!("{} {}", name, version);
+                if artifact.package_id.repr.starts_with(&repr) {
+                    artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
                 }
             }
-            _ => (), // Unknown message
         }
     }
 
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs
index e0ef737b3fc..700aebe0b34 100644
--- a/crates/vfs/src/file_set.rs
+++ b/crates/vfs/src/file_set.rs
@@ -140,16 +140,11 @@ impl FileSetConfig {
 }
 
 /// Builder for [`FileSetConfig`].
+#[derive(Default)]
 pub struct FileSetConfigBuilder {
     roots: Vec<Vec<VfsPath>>,
 }
 
-impl Default for FileSetConfigBuilder {
-    fn default() -> Self {
-        FileSetConfigBuilder { roots: Vec::new() }
-    }
-}
-
 impl FileSetConfigBuilder {
     /// Returns the number of sets currently held.
     pub fn len(&self) -> usize {
diff --git a/crates/vfs/src/path_interner.rs b/crates/vfs/src/path_interner.rs
index 6e049f0d40f..64f51976053 100644
--- a/crates/vfs/src/path_interner.rs
+++ b/crates/vfs/src/path_interner.rs
@@ -9,16 +9,11 @@ use rustc_hash::FxHasher;
 use crate::{FileId, VfsPath};
 
 /// Structure to map between [`VfsPath`] and [`FileId`].
+#[derive(Default)]
 pub(crate) struct PathInterner {
     map: IndexSet<VfsPath, BuildHasherDefault<FxHasher>>,
 }
 
-impl Default for PathInterner {
-    fn default() -> Self {
-        Self { map: IndexSet::default() }
-    }
-}
-
 impl PathInterner {
     /// Get the id corresponding to `path`.
     ///
diff --git a/xtask/src/release/changelog.rs b/xtask/src/release/changelog.rs
index cbf79b657c0..7df8f89dbe2 100644
--- a/xtask/src/release/changelog.rs
+++ b/xtask/src/release/changelog.rs
@@ -113,11 +113,9 @@ fn unescape(s: &str) -> String {
 fn parse_pr_number(s: &str) -> Option<u32> {
     const BORS_PREFIX: &str = "Merge #";
     const HOMU_PREFIX: &str = "Auto merge of #";
-    if s.starts_with(BORS_PREFIX) {
-        let s = &s[BORS_PREFIX.len()..];
+    if let Some(s) = s.strip_prefix(BORS_PREFIX) {
         s.parse().ok()
-    } else if s.starts_with(HOMU_PREFIX) {
-        let s = &s[HOMU_PREFIX.len()..];
+    } else if let Some(s) = s.strip_prefix(HOMU_PREFIX) {
         if let Some(space) = s.find(' ') {
             s[..space].parse().ok()
         } else {