Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer Option<Vc<IssueSource>> over Vc<OptionIssueSource> #6229

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/turbopack-cli-utils/src/runtime_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{
chunk::{EvaluatableAsset, EvaluatableAssetExt, EvaluatableAssets},
context::AssetContext,
issue::{IssueSeverity, OptionIssueSource},
issue::IssueSeverity,
module::Module,
resolve::{origin::PlainResolveOrigin, parse::Request},
source::Source,
Expand Down Expand Up @@ -36,7 +36,7 @@ impl RuntimeEntry {
let modules = cjs_resolve(
Vc::upcast(PlainResolveOrigin::new(asset_context, path)),
request,
OptionIssueSource::none(),
None,
IssueSeverity::Error.cell(),
)
.primary_modules()
Expand Down
15 changes: 1 addition & 14 deletions crates/turbopack-core/src/issue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub trait Issue {
/// should point at the offending character. Displayed to the user alongside
/// the title/description.
fn source(self: Vc<Self>) -> Vc<OptionIssueSource> {
OptionIssueSource::none()
Vc::cell(None)
}

fn sub_issues(self: Vc<Self>) -> Vc<Issues> {
Expand Down Expand Up @@ -449,19 +449,6 @@ impl IssueSource {
#[turbo_tasks::value(transparent)]
pub struct OptionIssueSource(Option<Vc<IssueSource>>);

#[turbo_tasks::value_impl]
impl OptionIssueSource {
#[turbo_tasks::function]
pub fn some(source: Vc<IssueSource>) -> Vc<Self> {
Vc::cell(Some(source))
}

#[turbo_tasks::function]
pub fn none() -> Vc<Self> {
Vc::cell(None)
}
}

#[turbo_tasks::value(serialization = "none")]
#[derive(Clone, Debug)]
pub struct PlainIssue {
Expand Down
8 changes: 4 additions & 4 deletions crates/turbopack-core/src/issue/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use anyhow::Result;
use turbo_tasks::{ValueToString, Vc};
use turbo_tasks_fs::FileSystemPath;

use super::Issue;
use super::{Issue, OptionIssueSource};
use crate::{
error::PrettyPrintError,
issue::{IssueSeverity, OptionIssueSource},
issue::{IssueSeverity, IssueSource},
resolve::{options::ResolveOptions, parse::Request},
};

Expand All @@ -19,7 +19,7 @@ pub struct ResolvingIssue {
pub file_path: Vc<FileSystemPath>,
pub resolve_options: Vc<ResolveOptions>,
pub error_message: Option<String>,
pub source: Vc<OptionIssueSource>,
pub source: Option<Vc<IssueSource>>,
}

#[turbo_tasks::value_impl]
Expand Down Expand Up @@ -102,7 +102,7 @@ impl Issue for ResolvingIssue {

#[turbo_tasks::function]
fn source(&self) -> Vc<OptionIssueSource> {
self.source
Vc::cell(self.source)
}

// TODO add sub_issue for a description of resolve_options
Expand Down
14 changes: 7 additions & 7 deletions crates/turbopack-core/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use alias_map::{
};
pub use remap::{ResolveAliasMap, SubpathValue};

use crate::issue::{IssueSeverity, OptionIssueSource};
use crate::issue::{IssueSeverity, IssueSource};

#[turbo_tasks::value(shared)]
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -1209,7 +1209,7 @@ async fn resolve_internal(
relative to the file you are importing from."
.to_string(),
),
source: OptionIssueSource::none(),
source: None,
}
.cell()
.emit();
Expand All @@ -1228,7 +1228,7 @@ async fn resolve_internal(
file_path: lookup_path,
resolve_options: options,
error_message: Some("windows imports are not implemented yet".to_string()),
source: OptionIssueSource::none(),
source: None,
}
.cell()
.emit();
Expand Down Expand Up @@ -1275,7 +1275,7 @@ async fn resolve_internal(
file_path: lookup_path,
resolve_options: options,
error_message: None,
source: OptionIssueSource::none(),
source: None,
}
.cell()
.emit();
Expand Down Expand Up @@ -1620,7 +1620,7 @@ async fn resolve_alias_field_result(
request: Request::parse(Value::new(Pattern::Constant(issue_request.to_string()))),
resolve_options,
error_message: Some(format!("invalid alias field value: {}", result)),
source: OptionIssueSource::none(),
source: None,
}
.cell()
.emit();
Expand Down Expand Up @@ -1791,7 +1791,7 @@ async fn resolve_package_internal_with_imports_field(
request,
resolve_options,
error_message: None,
source: OptionIssueSource::none(),
source: None,
}
.cell()
.emit();
Expand Down Expand Up @@ -1855,7 +1855,7 @@ pub async fn handle_resolve_error(
origin_path: Vc<FileSystemPath>,
request: Vc<Request>,
resolve_options: Vc<ResolveOptions>,
source: Vc<OptionIssueSource>,
source: Option<Vc<IssueSource>>,
severity: Vc<IssueSeverity>,
) -> Result<Vc<ModuleResolveResult>> {
Ok(match result.is_unresolveable().await {
Expand Down
3 changes: 1 addition & 2 deletions crates/turbopack-css/src/references/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use anyhow::Result;
use turbo_tasks::{Value, ValueToString, Vc};
use turbopack_core::{
chunk::ChunkableModuleReference,
issue::OptionIssueSource,
reference::ModuleReference,
reference_type::CssReferenceSubType,
resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult},
Expand Down Expand Up @@ -38,7 +37,7 @@ impl ModuleReference for CssModuleComposeReference {
// TODO: add real issue source, currently impossible because `CssClassName` doesn't
// contain the source span
// https://docs.rs/swc_css_modules/0.21.16/swc_css_modules/enum.CssClassName.html
OptionIssueSource::none(),
None,
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-css/src/references/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use swc_core::{
use turbo_tasks::{Value, ValueToString, Vc};
use turbopack_core::{
chunk::{ChunkableModuleReference, ChunkingContext},
issue::{IssueSource, OptionIssueSource},
issue::IssueSource,
reference::ModuleReference,
reference_type::CssReferenceSubType,
resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult},
Expand Down Expand Up @@ -218,7 +218,7 @@ impl ModuleReference for ImportAssetReference {
self.origin,
self.request,
Value::new(CssReferenceSubType::AtImport),
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-css/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use swc_core::{
};
use turbo_tasks::{Value, Vc};
use turbopack_core::{
issue::{IssueSeverity, IssueSource, OptionIssueSource},
issue::{IssueSeverity, IssueSource},
reference::{ModuleReference, ModuleReferences},
reference_type::{CssReferenceSubType, ReferenceType},
resolve::{
Expand Down Expand Up @@ -177,7 +177,7 @@ pub async fn css_resolve(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
ty: Value<CssReferenceSubType>,
issue_source: Vc<OptionIssueSource>,
issue_source: Option<Vc<IssueSource>>,
) -> Result<Vc<ModuleResolveResult>> {
let ty = Value::new(ReferenceType::Css(ty.into_value()));
let options = origin.resolve_options(ty.clone());
Expand Down
6 changes: 3 additions & 3 deletions crates/turbopack-ecmascript/src/references/amd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use turbo_tasks::{
};
use turbopack_core::{
chunk::ChunkableModuleReference,
issue::{IssueSource, OptionIssueSource},
issue::IssueSource,
reference::ModuleReference,
resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult},
};
Expand Down Expand Up @@ -63,7 +63,7 @@ impl ModuleReference for AmdDefineAssetReference {
cjs_resolve(
self.origin,
self.request,
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
)
}
Expand Down Expand Up @@ -156,7 +156,7 @@ impl CodeGenerateable for AmdDefineWithDependenciesCodeGen {
cjs_resolve(
self.origin,
*request,
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
),
Value::new(Cjs),
Expand Down
12 changes: 6 additions & 6 deletions crates/turbopack-ecmascript/src/references/cjs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use swc_core::{
use turbo_tasks::{Value, ValueToString, Vc};
use turbopack_core::{
chunk::ChunkableModuleReference,
issue::{IssueSource, OptionIssueSource},
issue::IssueSource,
reference::ModuleReference,
resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult},
};
Expand Down Expand Up @@ -54,7 +54,7 @@ impl ModuleReference for CjsAssetReference {
cjs_resolve(
self.origin,
self.request,
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ impl ModuleReference for CjsRequireAssetReference {
cjs_resolve(
self.origin,
self.request,
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
)
}
Expand Down Expand Up @@ -145,7 +145,7 @@ impl CodeGenerateable for CjsRequireAssetReference {
cjs_resolve(
self.origin,
self.request,
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
),
Value::new(Cjs),
Expand Down Expand Up @@ -235,7 +235,7 @@ impl ModuleReference for CjsRequireResolveAssetReference {
cjs_resolve(
self.origin,
self.request,
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
)
}
Expand Down Expand Up @@ -269,7 +269,7 @@ impl CodeGenerateable for CjsRequireResolveAssetReference {
cjs_resolve(
self.origin,
self.request,
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
),
Value::new(Cjs),
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-ecmascript/src/references/esm/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use turbopack_core::{
ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType,
ChunkingTypeOption, ModuleId,
},
issue::{IssueSeverity, OptionIssueSource},
issue::IssueSeverity,
module::Module,
reference::ModuleReference,
reference_type::EcmaScriptModulesReferenceSubType,
Expand Down Expand Up @@ -162,7 +162,7 @@ impl ModuleReference for EsmAssetReference {
self.get_origin().resolve().await?,
self.request,
ty,
OptionIssueSource::none(),
None,
IssueSeverity::Error.cell(),
))
}
Expand Down
6 changes: 3 additions & 3 deletions crates/turbopack-ecmascript/src/references/esm/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use swc_core::{
use turbo_tasks::{Value, ValueToString, Vc};
use turbopack_core::{
chunk::{ChunkableModuleReference, ChunkingType, ChunkingTypeOption},
issue::{IssueSource, OptionIssueSource},
issue::IssueSource,
reference::ModuleReference,
reference_type::EcmaScriptModulesReferenceSubType,
resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult},
Expand Down Expand Up @@ -59,7 +59,7 @@ impl ModuleReference for EsmAsyncAssetReference {
self.origin,
self.request,
Default::default(),
OptionIssueSource::some(self.issue_source),
Some(self.issue_source),
try_to_severity(self.in_try),
)
}
Expand Down Expand Up @@ -99,7 +99,7 @@ impl CodeGenerateable for EsmAsyncAssetReference {
self.origin,
self.request,
Value::new(EcmaScriptModulesReferenceSubType::Undefined),
OptionIssueSource::some(self.issue_source).resolve().await?,
Some(self.issue_source),
try_to_severity(self.in_try),
),
Value::new(EsmAsync),
Expand Down
13 changes: 4 additions & 9 deletions crates/turbopack-ecmascript/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use turbo_tasks_fs::{FileJsonContent, FileSystemPath};
use turbopack_core::{
compile_time_info::{CompileTimeInfo, FreeVarReference},
error::PrettyPrintError,
issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource, OptionIssueSource},
issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource},
module::Module,
reference::{ModuleReference, ModuleReferences, SourceMapReference},
reference_type::{CommonJsReferenceSubType, ReferenceType},
Expand Down Expand Up @@ -1190,7 +1190,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
options.include_subdirs,
Vc::cell(options.filter),
Vc::cell(ast_path.to_vec()),
OptionIssueSource::some(issue_source(source, span)),
Some(issue_source(source, span)),
in_try,
));
}
Expand Down Expand Up @@ -2100,12 +2100,7 @@ async fn require_resolve_visitor(
Ok(if args.len() == 1 {
let pat = js_value_to_pattern(&args[0]);
let request = Request::parse(Value::new(pat.clone()));
let resolved = cjs_resolve(
origin,
request,
OptionIssueSource::none(),
try_to_severity(in_try),
);
let resolved = cjs_resolve(origin, request, None, try_to_severity(in_try));
let mut values = resolved
.primary_modules()
.await?
Expand Down Expand Up @@ -2167,7 +2162,7 @@ async fn require_context_visitor(
dir,
options.include_subdirs,
Vc::cell(options.filter),
OptionIssueSource::none(),
None,
try_to_severity(in_try),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use turbopack_core::{
ChunkingContext,
},
ident::AssetIdent,
issue::{IssueSeverity, OptionIssueSource},
issue::{IssueSeverity, IssueSource},
module::Module,
reference::{ModuleReference, ModuleReferences},
resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult},
Expand Down Expand Up @@ -165,7 +165,7 @@ impl RequireContextMap {
dir: Vc<FileSystemPath>,
recursive: bool,
filter: Vc<Regex>,
issue_source: Vc<OptionIssueSource>,
issue_source: Option<Vc<IssueSource>>,
issue_severity: Vc<IssueSeverity>,
) -> Result<Vc<Self>> {
let origin_path = &*origin.origin_path().parent().await?;
Expand Down Expand Up @@ -206,7 +206,7 @@ pub struct RequireContextAssetReference {
pub include_subdirs: bool,

pub path: Vc<AstPath>,
pub issue_source: Vc<OptionIssueSource>,
pub issue_source: Option<Vc<IssueSource>>,
pub in_try: bool,
}

Expand All @@ -220,7 +220,7 @@ impl RequireContextAssetReference {
include_subdirs: bool,
filter: Vc<Regex>,
path: Vc<AstPath>,
issue_source: Vc<OptionIssueSource>,
issue_source: Option<Vc<IssueSource>>,
in_try: bool,
) -> Vc<Self> {
let map = RequireContextMap::generate(
Expand Down
Loading
Loading