Repository: vercel/next.js
Pull request: Turbopack: remove a few clones

Showed up in an ast-grep search for `&$$$.clone()`

Closes PACK-5197

Changed files:
filename: crates/napi/src/react_compiler.rs
patch: @@ -23,7 +23,7 @@ impl Task for CheckTask {
         GLOBALS.set(&Default::default(), || {
             //
             let cm = Arc::new(SourceMap::default());
-            let Ok(fm) = cm.load_file(&self.filename.clone()) else {
+            let Ok(fm) = cm.load_file(&self.filename) else {
                 return Ok(false);
             };
             let mut errors = vec![];

filename: turbopack/crates/turbopack-core/src/resolve/mod.rs
patch: @@ -1392,7 +1392,7 @@ async fn find_package(
                     for name in names.iter() {
                         let fs_path = lookup_path.join(name)?;
                         if let Some(fs_path) = dir_exists(fs_path, &mut affecting_sources).await? {
-                            let fs_path = fs_path.join(&package_name.clone())?;
+                            let fs_path = fs_path.join(&package_name)?;
                             if let Some(fs_path) =
                                 dir_exists(fs_path.clone(), &mut affecting_sources).await?
                             {
@@ -1431,7 +1431,7 @@ async fn find_package(
                     if excluded_extensions.contains(extension) {
                         continue;
                     }
-                    let package_file = package_dir.append(&extension.clone())?;
+                    let package_file = package_dir.append(extension)?;
                     if let Some(package_file) = exists(package_file, &mut affecting_sources).await?
                     {
                         packages.push(FindPackageItem::PackageFile(package_file));

filename: turbopack/crates/turbopack-core/src/resolve/pattern.rs
patch: @@ -1631,7 +1631,7 @@ pub async fn read_matches(
                                     prefix.pop();
                                 }
                                 if let Some(pos) = pat.match_position(&prefix) {
-                                    let fs_path = lookup_dir.join(&key.clone())?;
+                                    let fs_path = lookup_dir.join(key)?;
                                     if let LinkContent::Link { link_type, .. } =
                                         &*fs_path.read_link().await?
                                     {
@@ -1653,7 +1653,7 @@ pub async fn read_matches(
                                 }
                                 prefix.push('/');
                                 if let Some(pos) = pat.match_position(&prefix) {
-                                    let fs_path = lookup_dir.join(&key.clone())?;
+                                    let fs_path = lookup_dir.join(key)?;
                                     if let LinkContent::Link { link_type, .. } =
                                         &*fs_path.read_link().await?
                                         && link_type.contains(LinkType::DIRECTORY)
@@ -1665,7 +1665,7 @@ pub async fn read_matches(
                                     }
                                 }
                                 if let Some(pos) = pat.could_match_position(&prefix) {
-                                    let fs_path = lookup_dir.join(&key.clone())?;
+                                    let fs_path = lookup_dir.join(key)?;
                                     if let LinkContent::Link { link_type, .. } =
                                         &*fs_path.read_link().await?
                                         && link_type.contains(LinkType::DIRECTORY)

filename: turbopack/crates/turbopack-node/src/render/node_api_source.rs
patch: @@ -127,7 +127,7 @@ impl GetContentSourceContent for NodeApiContentSource {
         Ok(ContentSourceContent::HttpProxy(render_proxy_operation(
             self.cwd.clone(),
             self.env,
-            self.server_root.join(&path.clone())?,
+            self.server_root.join(&path)?,
             ResolvedVc::upcast(entry.module),
             entry.runtime_entries,
             entry.chunking_context,

filename: turbopack/crates/turbopack-tests/tests/execution.rs
patch: @@ -291,8 +291,8 @@ async fn prepare_test(resource: RcStr) -> Result<Vc<PreparedTest>> {
         resource_path.display()
     ))?;
     let relative_path: RcStr = sys_to_unix(relative_path.to_str().unwrap()).into();
-    let path = root_fs.root().await?.join(&relative_path.clone())?;
-    let project_path = project_root.join(&relative_path.clone())?;
+    let path = root_fs.root().await?.join(&relative_path)?;
+    let project_path = project_root.join(&relative_path)?;
     let tests_path = project_fs
         .root()
         .await?