Skip to content

Commit

Permalink
Minor manual cleanu
Browse files Browse the repository at this point in the history
* use default derive
* use `strip_prefix` where possible to avoid dup work
  • Loading branch information
nyurik committed Dec 23, 2022
1 parent f1785f7 commit ec55dd1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
13 changes: 5 additions & 8 deletions crates/proc-macro-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
7 changes: 1 addition & 6 deletions crates/vfs/src/file_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions crates/vfs/src/path_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
///
Expand Down
6 changes: 2 additions & 4 deletions xtask/src/release/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ec55dd1

Please sign in to comment.