Unverified Commit 0e0fc718 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

chore(turbopack): Delete dead code in next_core::{app,pages}_structure (#69387)

These functions were either public and/or mutually recursive, preventing
rustc's dead code analysis from finding them.

```
cargo check
cargo check --tests
```
parent 46c67764
......@@ -10,8 +10,8 @@ use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use tracing::Instrument;
use turbo_tasks::{
debug::ValueDebugFormat, trace::TraceRawVcs, Completion, Completions, RcStr, TaskInput,
TryJoinIterExt, ValueToString, Vc,
debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, TaskInput, TryJoinIterExt, ValueToString,
Vc,
};
use turbo_tasks_fs::{DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath};
use turbopack_core::issue::{
......@@ -26,7 +26,6 @@ use crate::{
},
AppPage, AppPath, PageSegment, PageType,
},
next_config::NextConfig,
next_import_map::get_next_package,
};
......@@ -218,18 +217,6 @@ struct PlainDirectoryTree {
#[turbo_tasks::value_impl]
impl DirectoryTree {
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(&self) -> Result<Vc<Completion>> {
let mut children = Vec::new();
children.push(Completion::new());
for child in self.subdirectories.values() {
children.push(child.routes_changed());
}
Ok(Vc::<Completions>::cell(children).completed())
}
#[turbo_tasks::function]
pub async fn into_plain(&self) -> Result<Vc<PlainDirectoryTree>> {
let mut subdirectories = BTreeMap::new();
......@@ -249,23 +236,6 @@ impl DirectoryTree {
#[turbo_tasks::value(transparent)]
pub struct OptionAppDir(Option<Vc<FileSystemPath>>);
#[turbo_tasks::value_impl]
impl OptionAppDir {
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(
self: Vc<Self>,
next_config: Vc<NextConfig>,
) -> Result<Vc<Completion>> {
if let Some(app_dir) = *self.await? {
let directory_tree = get_directory_tree(app_dir, next_config.page_extensions());
directory_tree.routes_changed().await?;
}
Ok(Completion::new())
}
}
/// Finds and returns the [DirectoryTree] of the app directory if existing.
#[turbo_tasks::function]
pub async fn find_app_dir(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionAppDir>> {
......@@ -284,13 +254,6 @@ pub async fn find_app_dir(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionA
Ok(Vc::cell(Some(app_dir)))
}
/// Finds and returns the [DirectoryTree] of the app directory if enabled and
/// existing.
#[turbo_tasks::function]
pub async fn find_app_dir_if_enabled(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionAppDir>> {
Ok(find_app_dir(project_path))
}
#[turbo_tasks::function]
async fn get_directory_tree(
dir: Vc<FileSystemPath>,
......
use anyhow::Result;
use tracing::Instrument;
use turbo_tasks::{Completion, RcStr, ValueToString, Vc};
use turbo_tasks::{RcStr, ValueToString, Vc};
use turbo_tasks_fs::{
DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath, FileSystemPathOption,
};
......@@ -58,15 +58,6 @@ impl PagesStructureItem {
Ok(self.base_path)
}
}
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(self: Vc<Self>) -> Result<Vc<Completion>> {
let this = self.await?;
this.next_router_path.await?;
Ok(Completion::new())
}
}
/// A (sub)directory in the pages directory with all analyzed routes and
......@@ -82,29 +73,6 @@ pub struct PagesStructure {
#[turbo_tasks::value_impl]
impl PagesStructure {
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(self: Vc<Self>) -> Result<Vc<Completion>> {
let PagesStructure {
ref app,
ref document,
ref error,
ref api,
ref pages,
} = &*self.await?;
app.routes_changed().await?;
document.routes_changed().await?;
error.routes_changed().await?;
if let Some(api) = api {
api.routes_changed().await?;
}
if let Some(pages) = pages {
pages.routes_changed().await?;
}
Ok(Completion::new())
}
#[turbo_tasks::function]
pub fn app(&self) -> Vc<PagesStructureItem> {
self.app
......@@ -131,31 +99,12 @@ pub struct PagesDirectoryStructure {
#[turbo_tasks::value_impl]
impl PagesDirectoryStructure {
/// Returns the router path of this directory.
#[turbo_tasks::function]
pub async fn next_router_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
Ok(self.await?.next_router_path)
}
/// Returns the path to the directory of this structure in the project file
/// system.
#[turbo_tasks::function]
pub async fn project_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
Ok(self.await?.project_path)
}
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(self: Vc<Self>) -> Result<Vc<Completion>> {
for item in self.await?.items.iter() {
item.routes_changed().await?;
}
for child in self.await?.children.iter() {
child.routes_changed().await?;
}
Ok(Completion::new())
}
}
/// Finds and returns the [PagesStructure] of the pages directory if existing.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment