Skip to content

Commit e532684

Browse files
authored
Turbopack: remove a few clones (#82435)
Showed up in an ast-grep search for `&$$$.clone()`
1 parent 4dd7c7f commit e532684

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

crates/napi/src/react_compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Task for CheckTask {
2323
GLOBALS.set(&Default::default(), || {
2424
//
2525
let cm = Arc::new(SourceMap::default());
26-
let Ok(fm) = cm.load_file(&self.filename.clone()) else {
26+
let Ok(fm) = cm.load_file(&self.filename) else {
2727
return Ok(false);
2828
};
2929
let mut errors = vec![];

turbopack/crates/turbopack-core/src/resolve/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ async fn find_package(
13921392
for name in names.iter() {
13931393
let fs_path = lookup_path.join(name)?;
13941394
if let Some(fs_path) = dir_exists(fs_path, &mut affecting_sources).await? {
1395-
let fs_path = fs_path.join(&package_name.clone())?;
1395+
let fs_path = fs_path.join(&package_name)?;
13961396
if let Some(fs_path) =
13971397
dir_exists(fs_path.clone(), &mut affecting_sources).await?
13981398
{
@@ -1431,7 +1431,7 @@ async fn find_package(
14311431
if excluded_extensions.contains(extension) {
14321432
continue;
14331433
}
1434-
let package_file = package_dir.append(&extension.clone())?;
1434+
let package_file = package_dir.append(extension)?;
14351435
if let Some(package_file) = exists(package_file, &mut affecting_sources).await?
14361436
{
14371437
packages.push(FindPackageItem::PackageFile(package_file));

turbopack/crates/turbopack-core/src/resolve/pattern.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ pub async fn read_matches(
16311631
prefix.pop();
16321632
}
16331633
if let Some(pos) = pat.match_position(&prefix) {
1634-
let fs_path = lookup_dir.join(&key.clone())?;
1634+
let fs_path = lookup_dir.join(key)?;
16351635
if let LinkContent::Link { link_type, .. } =
16361636
&*fs_path.read_link().await?
16371637
{
@@ -1653,7 +1653,7 @@ pub async fn read_matches(
16531653
}
16541654
prefix.push('/');
16551655
if let Some(pos) = pat.match_position(&prefix) {
1656-
let fs_path = lookup_dir.join(&key.clone())?;
1656+
let fs_path = lookup_dir.join(key)?;
16571657
if let LinkContent::Link { link_type, .. } =
16581658
&*fs_path.read_link().await?
16591659
&& link_type.contains(LinkType::DIRECTORY)
@@ -1665,7 +1665,7 @@ pub async fn read_matches(
16651665
}
16661666
}
16671667
if let Some(pos) = pat.could_match_position(&prefix) {
1668-
let fs_path = lookup_dir.join(&key.clone())?;
1668+
let fs_path = lookup_dir.join(key)?;
16691669
if let LinkContent::Link { link_type, .. } =
16701670
&*fs_path.read_link().await?
16711671
&& link_type.contains(LinkType::DIRECTORY)

turbopack/crates/turbopack-node/src/render/node_api_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl GetContentSourceContent for NodeApiContentSource {
127127
Ok(ContentSourceContent::HttpProxy(render_proxy_operation(
128128
self.cwd.clone(),
129129
self.env,
130-
self.server_root.join(&path.clone())?,
130+
self.server_root.join(&path)?,
131131
ResolvedVc::upcast(entry.module),
132132
entry.runtime_entries,
133133
entry.chunking_context,

turbopack/crates/turbopack-tests/tests/execution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ async fn prepare_test(resource: RcStr) -> Result<Vc<PreparedTest>> {
291291
resource_path.display()
292292
))?;
293293
let relative_path: RcStr = sys_to_unix(relative_path.to_str().unwrap()).into();
294-
let path = root_fs.root().await?.join(&relative_path.clone())?;
295-
let project_path = project_root.join(&relative_path.clone())?;
294+
let path = root_fs.root().await?.join(&relative_path)?;
295+
let project_path = project_root.join(&relative_path)?;
296296
let tests_path = project_fs
297297
.root()
298298
.await?

0 commit comments

Comments
 (0)