Skip to content

Commit de0bebc

Browse files
committed
chore: rm &PathBuf
1 parent 49b65bf commit de0bebc

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ manual-string-new = "warn"
2222
uninlined-format-args = "warn"
2323
use-self = "warn"
2424
redundant-clone = "warn"
25-
# until <https://github.com/rust-lang/rust-clippy/issues/13885> is fixed
26-
literal-string-with-formatting-args = "allow"
25+
26+
result-large-err = "allow"
27+
large-enum-variant = "allow"
2728

2829
[workspace.lints.rust]
2930
rust-2018-idioms = "warn"

crates/compilers/src/flatten.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl Flattener {
212212
let sources = Source::read_all_files(vec![target.to_path_buf()])?;
213213
let graph = Graph::<C::ParsedSource>::resolve_sources(&project.paths, sources)?;
214214

215-
let ordered_sources = collect_ordered_deps(&target.to_path_buf(), &project.paths, &graph)?;
215+
let ordered_sources = collect_ordered_deps(target, &project.paths, &graph)?;
216216

217217
#[cfg(windows)]
218218
let ordered_sources = {
@@ -244,7 +244,7 @@ impl Flattener {
244244
sources,
245245
asts,
246246
ordered_sources,
247-
project_root: project.root().clone(),
247+
project_root: project.root().to_path_buf(),
248248
})
249249
}
250250

@@ -795,12 +795,12 @@ impl Flattener {
795795

796796
/// Performs DFS to collect all dependencies of a target
797797
fn collect_deps<D: ParsedSource + MaybeSolData>(
798-
path: &PathBuf,
798+
path: &Path,
799799
paths: &ProjectPathsConfig<D::Language>,
800800
graph: &Graph<D>,
801801
deps: &mut HashSet<PathBuf>,
802802
) -> Result<()> {
803-
if deps.insert(path.clone()) {
803+
if deps.insert(path.to_path_buf()) {
804804
let target_dir = path.parent().ok_or_else(|| {
805805
SolcError::msg(format!("failed to get parent directory for \"{}\"", path.display()))
806806
})?;
@@ -831,7 +831,7 @@ fn collect_deps<D: ParsedSource + MaybeSolData>(
831831
/// order. If files have the same number of dependencies, we sort them alphabetically.
832832
/// Target file is always placed last.
833833
pub fn collect_ordered_deps<D: ParsedSource + MaybeSolData>(
834-
path: &PathBuf,
834+
path: &Path,
835835
paths: &ProjectPathsConfig<D::Language>,
836836
graph: &Graph<D>,
837837
) -> Result<Vec<PathBuf>> {
@@ -871,7 +871,7 @@ pub fn collect_ordered_deps<D: ParsedSource + MaybeSolData>(
871871
let mut ordered_deps =
872872
paths_with_deps_count.into_iter().map(|(_, path)| path).collect::<Vec<_>>();
873873

874-
ordered_deps.push(path.clone());
874+
ordered_deps.push(path.to_path_buf());
875875

876876
Ok(ordered_deps)
877877
}

crates/compilers/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,27 +213,27 @@ where
213213

214214
impl<T: ArtifactOutput<CompilerContract = C::CompilerContract>, C: Compiler> Project<C, T> {
215215
/// Returns the path to the artifacts directory
216-
pub fn artifacts_path(&self) -> &PathBuf {
216+
pub fn artifacts_path(&self) -> &Path {
217217
&self.paths.artifacts
218218
}
219219

220220
/// Returns the path to the sources directory
221-
pub fn sources_path(&self) -> &PathBuf {
221+
pub fn sources_path(&self) -> &Path {
222222
&self.paths.sources
223223
}
224224

225225
/// Returns the path to the cache file
226-
pub fn cache_path(&self) -> &PathBuf {
226+
pub fn cache_path(&self) -> &Path {
227227
&self.paths.cache
228228
}
229229

230230
/// Returns the path to the `build-info` directory nested in the artifacts dir
231-
pub fn build_info_path(&self) -> &PathBuf {
231+
pub fn build_info_path(&self) -> &Path {
232232
&self.paths.build_infos
233233
}
234234

235235
/// Returns the root directory of the project
236-
pub fn root(&self) -> &PathBuf {
236+
pub fn root(&self) -> &Path {
237237
&self.paths.root
238238
}
239239

@@ -349,7 +349,7 @@ impl<T: ArtifactOutput<CompilerContract = C::CompilerContract>, C: Compiler> Pro
349349
std::fs::remove_file(self.cache_path())
350350
.map_err(|err| SolcIoError::new(err, self.cache_path()))?;
351351
if let Some(cache_folder) =
352-
self.cache_path().parent().filter(|cache_folder| self.root() != cache_folder)
352+
self.cache_path().parent().filter(|cache_folder| self.root() != *cache_folder)
353353
{
354354
// remove the cache folder if the cache file was the only file
355355
if cache_folder
@@ -368,14 +368,14 @@ impl<T: ArtifactOutput<CompilerContract = C::CompilerContract>, C: Compiler> Pro
368368
// clean the artifacts dir
369369
if self.artifacts_path().exists() && self.root() != self.artifacts_path() {
370370
std::fs::remove_dir_all(self.artifacts_path())
371-
.map_err(|err| SolcIoError::new(err, self.artifacts_path().clone()))?;
371+
.map_err(|err| SolcIoError::new(err, self.artifacts_path()))?;
372372
trace!("removed artifacts dir \"{}\"", self.artifacts_path().display());
373373
}
374374

375375
// also clean the build-info dir, in case it's not nested in the artifacts dir
376376
if self.build_info_path().exists() && self.root() != self.build_info_path() {
377377
std::fs::remove_dir_all(self.build_info_path())
378-
.map_err(|err| SolcIoError::new(err, self.build_info_path().clone()))?;
378+
.map_err(|err| SolcIoError::new(err, self.build_info_path()))?;
379379
tracing::trace!("removed build-info dir \"{}\"", self.build_info_path().display());
380380
}
381381

crates/compilers/src/preprocessor/deps.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl PreprocessorDependencies {
2828
sess: &Session,
2929
hir: &Hir<'_>,
3030
paths: &[PathBuf],
31-
src_dir: &PathBuf,
31+
src_dir: &Path,
3232
root_dir: &Path,
3333
mocks: &mut HashSet<PathBuf>,
3434
) -> Self {
@@ -128,7 +128,7 @@ struct BytecodeDependencyCollector<'hir> {
128128
/// Source content of current contract.
129129
src: &'hir str,
130130
/// Project source dir, used to determine if referenced contract is a source contract.
131-
src_dir: &'hir PathBuf,
131+
src_dir: &'hir Path,
132132
/// Dependencies collected for current contract.
133133
dependencies: Vec<BytecodeDependency>,
134134
/// Unique HIR ids of contracts referenced from current contract.
@@ -140,7 +140,7 @@ impl<'hir> BytecodeDependencyCollector<'hir> {
140140
source_map: &'hir SourceMap,
141141
hir: &'hir Hir<'hir>,
142142
src: &'hir str,
143-
src_dir: &'hir PathBuf,
143+
src_dir: &'hir Path,
144144
) -> Self {
145145
Self {
146146
source_map,

0 commit comments

Comments
 (0)