Minor manual cleanu

* use default derive
* use `strip_prefix` where possible to avoid dup work
This commit is contained in:
Yuri Astrakhan 2022-12-23 03:07:42 -05:00
parent f1785f7a21
commit ec55dd1d7b
4 changed files with 9 additions and 24 deletions

View File

@ -85,16 +85,13 @@ fn main() {
let mut artifact_path = None; let mut artifact_path = None;
for message in Message::parse_stream(output.stdout.as_slice()) { for message in Message::parse_stream(output.stdout.as_slice()) {
match message.unwrap() { if let Message::CompilerArtifact(artifact) = message.unwrap() {
Message::CompilerArtifact(artifact) => { if artifact.target.kind.contains(&"proc-macro".to_string()) {
if artifact.target.kind.contains(&"proc-macro".to_string()) { let repr = format!("{} {}", name, version);
let repr = format!("{} {}", name, version); if artifact.package_id.repr.starts_with(&repr) {
if artifact.package_id.repr.starts_with(&repr) { artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
}
} }
} }
_ => (), // Unknown message
} }
} }

View File

@ -140,16 +140,11 @@ impl FileSetConfig {
} }
/// Builder for [`FileSetConfig`]. /// Builder for [`FileSetConfig`].
#[derive(Default)]
pub struct FileSetConfigBuilder { pub struct FileSetConfigBuilder {
roots: Vec<Vec<VfsPath>>, roots: Vec<Vec<VfsPath>>,
} }
impl Default for FileSetConfigBuilder {
fn default() -> Self {
FileSetConfigBuilder { roots: Vec::new() }
}
}
impl FileSetConfigBuilder { impl FileSetConfigBuilder {
/// Returns the number of sets currently held. /// Returns the number of sets currently held.
pub fn len(&self) -> usize { pub fn len(&self) -> usize {

View File

@ -9,16 +9,11 @@ use rustc_hash::FxHasher;
use crate::{FileId, VfsPath}; use crate::{FileId, VfsPath};
/// Structure to map between [`VfsPath`] and [`FileId`]. /// Structure to map between [`VfsPath`] and [`FileId`].
#[derive(Default)]
pub(crate) struct PathInterner { pub(crate) struct PathInterner {
map: IndexSet<VfsPath, BuildHasherDefault<FxHasher>>, map: IndexSet<VfsPath, BuildHasherDefault<FxHasher>>,
} }
impl Default for PathInterner {
fn default() -> Self {
Self { map: IndexSet::default() }
}
}
impl PathInterner { impl PathInterner {
/// Get the id corresponding to `path`. /// Get the id corresponding to `path`.
/// ///

View File

@ -113,11 +113,9 @@ fn unescape(s: &str) -> String {
fn parse_pr_number(s: &str) -> Option<u32> { fn parse_pr_number(s: &str) -> Option<u32> {
const BORS_PREFIX: &str = "Merge #"; const BORS_PREFIX: &str = "Merge #";
const HOMU_PREFIX: &str = "Auto merge of #"; const HOMU_PREFIX: &str = "Auto merge of #";
if s.starts_with(BORS_PREFIX) { if let Some(s) = s.strip_prefix(BORS_PREFIX) {
let s = &s[BORS_PREFIX.len()..];
s.parse().ok() s.parse().ok()
} else if s.starts_with(HOMU_PREFIX) { } else if let Some(s) = s.strip_prefix(HOMU_PREFIX) {
let s = &s[HOMU_PREFIX.len()..];
if let Some(space) = s.find(' ') { if let Some(space) = s.find(' ') {
s[..space].parse().ok() s[..space].parse().ok()
} else { } else {