Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Feb 12, 2025
1 parent 440884c commit dea9f1e
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 39 deletions.
6 changes: 3 additions & 3 deletions collector/src/artifact_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ impl ArtifactStats {
/// Normalizes the following things, in the following order:
/// - Demangles the symbol.
/// - Removes `.cold` and `.warm` from the end of the symbol, to merge cold and hot parts of a function
/// into the same symbol.
/// into the same symbol.
/// - Removes rustc hashes from the symbol, e.g. `foo::[abcdef]` -> `foo::[]` or
/// `foo::abcd` -> `foo`.
/// `foo::abcd` -> `foo`.
/// - Removes suffixes after a dot from the symbol, e.g. `anon.abcdef.123` -> `anon` or
/// `foo.llvm.123` -> `foo`.
/// `foo.llvm.123` -> `foo`.
///
/// These modifications should remove things added by LLVM in the LTO/PGO phase.
/// See more information here: https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html#vendor-specific-suffix
Expand Down
10 changes: 2 additions & 8 deletions collector/src/bin/rustc-fake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ fn main() {

let prof_out_dir = create_self_profile_dir();
if wrapper == "PerfStatSelfProfile" {
cmd.arg(&format!(
"-Zself-profile={}",
prof_out_dir.to_str().unwrap()
));
cmd.arg(format!("-Zself-profile={}", prof_out_dir.to_str().unwrap()));
let _ = fs::remove_dir_all(&prof_out_dir);
let _ = fs::create_dir_all(&prof_out_dir);
}
Expand Down Expand Up @@ -189,10 +186,7 @@ fn main() {

let prof_out_dir = create_self_profile_dir();
if wrapper == "XperfStatSelfProfile" {
tool.arg(&format!(
"-Zself-profile={}",
prof_out_dir.to_str().unwrap()
));
tool.arg(format!("-Zself-profile={}", prof_out_dir.to_str().unwrap()));
let _ = fs::remove_dir_all(&prof_out_dir);
let _ = fs::create_dir_all(&prof_out_dir);
}
Expand Down
4 changes: 2 additions & 2 deletions collector/src/compile/execute/bencher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl<'a> BenchProcessor<'a> {
}
}

impl<'a> Processor for BenchProcessor<'a> {
impl Processor for BenchProcessor<'_> {
fn perf_tool(&self) -> PerfTool {
if self.is_first_collection && self.is_self_profile {
if cfg!(unix) {
Expand Down Expand Up @@ -309,7 +309,7 @@ impl SelfProfileS3Upload {
.arg("INTELLIGENT_TIERING")
.arg("--only-show-errors")
.arg(upload.path())
.arg(&format!(
.arg(format!(
"s3://rustc-perf/{}",
&prefix.join(filename).to_str().unwrap()
))
Expand Down
14 changes: 6 additions & 8 deletions collector/src/compile/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,7 @@ fn process_stat_output(
// In any case it's better than crashing the collector and looping indefinitely trying
// to to complete a run -- which happens if we propagate `parse_self_profile`'s errors
// up to the caller.
if let Ok(self_profile_data) = parse_self_profile(dir, krate) {
self_profile_data
} else {
(None, None)
}
parse_self_profile(dir, krate).unwrap_or_default()
}
_ => (None, None),
};
Expand Down Expand Up @@ -640,9 +636,11 @@ fn parse_self_profile(
// `perf` pid. So just blindly look in the directory to hopefully find it.
for entry in fs::read_dir(dir)? {
let entry = entry?;
if entry.file_name().to_str().map_or(false, |s| {
s.starts_with(&crate_name) && s.ends_with("mm_profdata")
}) {
if entry
.file_name()
.to_str()
.is_some_and(|s| s.starts_with(&crate_name) && s.ends_with("mm_profdata"))
{
full_path = Some(entry.path());
break;
}
Expand Down
2 changes: 1 addition & 1 deletion collector/src/compile/execute/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'a> ProfileProcessor<'a> {
}
}

impl<'a> Processor for ProfileProcessor<'a> {
impl Processor for ProfileProcessor<'_> {
fn perf_tool(&self) -> PerfTool {
PerfTool::ProfileTool(self.profiler)
}
Expand Down
4 changes: 2 additions & 2 deletions collector/src/compile/execute/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ async fn record(
.arg("--set")
.arg("rust.deny-warnings=false")
.arg("--set")
.arg(&format!("build.rustc={}", fake_rustc.to_str().unwrap()))
.arg(format!("build.rustc={}", fake_rustc.to_str().unwrap()))
.env("RUSTC_PERF_REAL_RUSTC", &toolchain.components.rustc)
.arg("--set")
.arg(&format!(
.arg(format!(
"build.cargo={}",
toolchain.components.cargo.to_str().unwrap()
))
Expand Down
2 changes: 1 addition & 1 deletion collector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'de> Deserialize<'de> for Bound {
{
struct BoundVisitor;

impl<'de> serde::de::Visitor<'de> for BoundVisitor {
impl serde::de::Visitor<'_> for BoundVisitor {
type Value = Bound;

fn visit_str<E>(self, value: &str) -> ::std::result::Result<Bound, E>
Expand Down
2 changes: 1 addition & 1 deletion database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<'de> Deserialize<'de> for Date {
{
struct DateVisitor;

impl<'de> serde::de::Visitor<'de> for DateVisitor {
impl serde::de::Visitor<'_> for DateVisitor {
type Value = Date;

fn visit_str<E>(self, value: &str) -> ::std::result::Result<Date, E>
Expand Down
2 changes: 1 addition & 1 deletion database/src/pool/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl ConnectionManager for Postgres {
}

#[async_trait::async_trait]
impl<'a> Transaction for PostgresTransaction<'a> {
impl Transaction for PostgresTransaction<'_> {
async fn commit(self: Box<Self>) -> Result<(), anyhow::Error> {
Ok(self.conn.commit().await?)
}
Expand Down
2 changes: 1 addition & 1 deletion database/src/pool/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct SqliteTransaction<'a> {
}

#[async_trait::async_trait]
impl<'a> Transaction for SqliteTransaction<'a> {
impl Transaction for SqliteTransaction<'_> {
async fn commit(mut self: Box<Self>) -> Result<(), anyhow::Error> {
self.finished = true;
Ok(self.conn.raw().execute_batch("COMMIT")?)
Expand Down
2 changes: 1 addition & 1 deletion site/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ where
{
struct CommaSeparatedVisitor<T>(PhantomData<T>);

impl<'de, T: DeserializeOwned> serde::de::Visitor<'de> for CommaSeparatedVisitor<T> {
impl<T: DeserializeOwned> serde::de::Visitor<'_> for CommaSeparatedVisitor<T> {
type Value = Vec<T>;

fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion site/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ impl ArtifactComparison {
if let Some(b) = master_commits.iter().find(|c| c.sha == b.sha) {
b.parent_sha == a.sha
} else {
conn.parent_of(&b.sha).await.map_or(false, |p| p == a.sha)
conn.parent_of(&b.sha).await.as_ref() == Some(&a.sha)
}
}
_ => false,
Expand Down
5 changes: 2 additions & 3 deletions site/src/request_handlers/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ pub async fn handle_graphs(
};

if is_default_query {
match &**ctxt.landing_page.load() {
Some(resp) => return Ok(resp.clone()),
None => {}
if let Some(resp) = &**ctxt.landing_page.load() {
return Ok(resp.clone());
}
}

Expand Down
4 changes: 2 additions & 2 deletions site/src/self_profile/codegen_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn by_thread(self_profile_data: Vec<u8>) -> anyhow::Result<(u64, HashMap<u32, Ve
let mut start = None;
for event in data
.iter()
.filter(|e| e.timestamp().map_or(false, |t| !t.is_instant()))
.filter(|e| e.timestamp().is_some_and(|t| !t.is_instant()))
{
let full_event = data.to_full_event(&event);
if is_interesting(&full_event.label) {
Expand All @@ -43,7 +43,7 @@ fn by_thread(self_profile_data: Vec<u8>) -> anyhow::Result<(u64, HashMap<u32, Ve
let mut by_thread = HashMap::new();
for event in data
.iter()
.filter(|e| e.timestamp().map_or(false, |t| !t.is_instant()))
.filter(|e| e.timestamp().is_some_and(|t| !t.is_instant()))
{
let full_event = data.to_full_event(&event);

Expand Down
2 changes: 1 addition & 1 deletion site/src/self_profile/crox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn generate(self_profile_data: Vec<u8>, opt: Opt) -> anyhow::Result<Vec<u8>>
// only handle Interval events for now
for event in data
.iter()
.filter(|e| e.timestamp().map_or(false, |t| !t.is_instant()))
.filter(|e| e.timestamp().is_some_and(|t| !t.is_instant()))
{
let duration = event.duration().unwrap();
if let Some(minimum_duration) = opt.minimum_duration {
Expand Down
4 changes: 1 addition & 3 deletions site/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,7 @@ async fn serve_req(server: Server, req: Request) -> Result<Response, ServerError
.headers()
.get(hyper::header::ACCEPT_ENCODING)
.and_then(|e| e.to_str().ok())
.map_or(false, |s| {
s.split(',').any(|part| part.trim().starts_with("br"))
});
.is_some_and(|s| s.split(',').any(|part| part.trim().starts_with("br")));

let compression = if allow_compression {
// In tests on /perf/graphs and /perf/get, quality = 2 reduces size by 20-40% compared to 0,
Expand Down

0 comments on commit dea9f1e

Please sign in to comment.