Skip to content
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
22 changes: 5 additions & 17 deletions nova_cli/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,12 @@ static START_TIME: LazyLock<std::time::Instant> = LazyLock::new(std::time::Insta

use nova_vm::{
ecmascript::{
builtins::{
ArgumentsList, Behaviour, BuiltinFunctionArgs, RegularFn, SharedArrayBuffer,
create_builtin_function,
},
execution::{
Agent, JsResult,
agent::{ExceptionType, GcAgent, HostHooks, Job, Options, unwrap_try},
},
scripts_and_modules::script::{parse_script, script_evaluation},
types::{
BigInt, Function, InternalMethods, Number, Object, OrdinaryObject, PropertyDescriptor,
PropertyKey, String, Value,
},
},
engine::{
context::{Bindable, GcScope, NoGcScope},
rootable::Scopable,
Agent, ArgumentsList, Behaviour, BigInt, BuiltinFunctionArgs, ExceptionType, Function,
GcAgent, HostHooks, InternalMethods, Job, JsResult, Number, Object, Options,
OrdinaryObject, PropertyDescriptor, PropertyKey, RegularFn, SharedArrayBuffer, String,
Value, create_builtin_function, parse_script, script_evaluation, unwrap_try,
},
engine::{Bindable, GcScope, NoGcScope, Scopable},
};
use oxc_diagnostics::OxcDiagnostic;

Expand Down
23 changes: 5 additions & 18 deletions nova_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,12 @@ use helper::{
};
use nova_vm::{
ecmascript::{
execution::{
Agent, JsResult,
agent::{ExceptionType, GcAgent, HostHooks, Job, Options},
},
scripts_and_modules::{
module::module_semantics::{
ModuleRequest, Referrer, abstract_module_records::AbstractModule,
cyclic_module_records::GraphLoadingStateRecord, finish_loading_imported_module,
source_text_module_records::parse_module,
},
script::{HostDefined, parse_script, script_evaluation},
},
types::{Object, SharedDataBlock, String as JsString, Value},
},
engine::{
Global,
context::{Bindable, GcScope, NoGcScope},
rootable::Scopable,
AbstractModule, Agent, ExceptionType, GcAgent, GraphLoadingStateRecord, HostDefined,
HostHooks, Job, JsResult, ModuleRequest, Object, Options, Referrer, SharedDataBlock,
String as JsString, Value, finish_loading_imported_module, parse_module, parse_script,
script_evaluation,
},
engine::{Bindable, GcScope, Global, NoGcScope, Scopable},
register_probes,
};
use oxc_parser::Parser;
Expand Down
12 changes: 6 additions & 6 deletions nova_lint/src/agent_comes_first.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clippy_utils::{diagnostics::span_lint_and_help, is_self};
use rustc_hir::{Body, FnDecl, def_id::LocalDefId, intravisit::FnKind};
use rustc_hir::{def_id::LocalDefId, intravisit::FnKind, Body, FnDecl};
use rustc_lint::{LateContext, LateLintPass};
use rustc_span::Span;

Expand All @@ -8,11 +8,11 @@ use crate::{is_agent_ty, is_param_ty};
dylint_linting::declare_late_lint! {
/// ### What it does
///
/// Checks that the `nova_vm::ecmascript::execution::agent::Agent` is the first parameter of a function.
/// Checks that the `nova_vm::ecmascript::Agent` is the first parameter of a function.
///
/// ### Why is this bad?
///
/// The `nova_vm::ecmascript::execution::agent::Agent` is expected to be
/// The `nova_vm::ecmascript::Agent` is expected to be
/// the first parameter of a function according to the Nova engines conventions.
///
/// ### Example
Expand All @@ -28,7 +28,7 @@ dylint_linting::declare_late_lint! {
/// ```
pub AGENT_COMES_FIRST,
Warn,
"the `nova_vm::ecmascript::execution::agent::Agent` should be the first parameter of any function using it"
"the `nova_vm::ecmascript::Agent` should be the first parameter of any function using it"
}

impl<'tcx> LateLintPass<'tcx> for AgentComesFirst {
Expand Down Expand Up @@ -68,9 +68,9 @@ impl<'tcx> LateLintPass<'tcx> for AgentComesFirst {
cx,
AGENT_COMES_FIRST,
param.span,
"the `nova_vm::ecmascript::execution::agent::Agent` should be the first parameter of any function using it",
"the `nova_vm::ecmascript::Agent` should be the first parameter of any function using it",
None,
"consider moving the `nova_vm::ecmascript::execution::agent::Agent` to the first parameter",
"consider moving the `nova_vm::ecmascript::Agent` to the first parameter",
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions nova_lint/ui/agent_comes_first.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(dead_code, unused_variables, clippy::disallowed_names)]

type Agent = nova_vm::ecmascript::execution::agent::Agent;
type Agent = nova_vm::ecmascript::Agent;

fn test_no_params() {
unimplemented!()
Expand All @@ -10,7 +10,7 @@ fn test_one_param(_foo: ()) {
unimplemented!()
}

fn test_owned_qualified_agent_only(agent: nova_vm::ecmascript::execution::Agent) {
fn test_owned_qualified_agent_only(agent: nova_vm::ecmascript::Agent) {
unimplemented!()
}

Expand Down
16 changes: 8 additions & 8 deletions nova_lint/ui/agent_comes_first.stderr
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
warning: the `nova_vm::ecmascript::execution::agent::Agent` should be the first parameter of any function using it
warning: the `nova_vm::ecmascript::Agent` should be the first parameter of any function using it
--> $DIR/agent_comes_first.rs:33:46
|
LL | fn test_something_else_before_agent(foo: (), agent: Agent) {
| ^^^^^^^^^^^^
|
= help: consider moving the `nova_vm::ecmascript::execution::agent::Agent` to the first parameter
= help: consider moving the `nova_vm::ecmascript::Agent` to the first parameter
= note: `#[warn(agent_comes_first)]` on by default

warning: the `nova_vm::ecmascript::execution::agent::Agent` should be the first parameter of any function using it
warning: the `nova_vm::ecmascript::Agent` should be the first parameter of any function using it
--> $DIR/agent_comes_first.rs:37:75
|
LL | fn test_multiple_agents_with_something_in_between(agent1: Agent, foo: (), agent2: Agent) {
| ^^^^^^^^^^^^^
|
= help: consider moving the `nova_vm::ecmascript::execution::agent::Agent` to the first parameter
= help: consider moving the `nova_vm::ecmascript::Agent` to the first parameter

warning: the `nova_vm::ecmascript::execution::agent::Agent` should be the first parameter of any function using it
warning: the `nova_vm::ecmascript::Agent` should be the first parameter of any function using it
--> $DIR/agent_comes_first.rs:64:61
|
LL | fn test_self_and_something_before_agent(&self, foo: (), agent: &Agent) {
| ^^^^^^^^^^^^^
|
= help: consider moving the `nova_vm::ecmascript::execution::agent::Agent` to the first parameter
= help: consider moving the `nova_vm::ecmascript::Agent` to the first parameter

warning: the `nova_vm::ecmascript::execution::agent::Agent` should be the first parameter of any function using it
warning: the `nova_vm::ecmascript::Agent` should be the first parameter of any function using it
--> $DIR/agent_comes_first.rs:68:45
|
LL | fn test_something_before_agent(foo: (), agent: &Agent) {
| ^^^^^^^^^^^^^
|
= help: consider moving the `nova_vm::ecmascript::execution::agent::Agent` to the first parameter
= help: consider moving the `nova_vm::ecmascript::Agent` to the first parameter

warning: 4 warnings emitted

10 changes: 3 additions & 7 deletions nova_lint/ui/can_use_no_gc_scope.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#![allow(dead_code, unused_variables)]

use nova_vm::{
ecmascript::{
builtins::ArgumentsList,
execution::{Agent, JsResult},
types::{Object, Value},
},
engine::context::{GcScope, NoGcScope},
ecmascript::{Agent, ArgumentsList, JsResult, Object, Value},
engine::{GcScope, NoGcScope},
};

fn test_doesnt_need_gc_scope(gc: GcScope<'_, '_>) {
Expand All @@ -17,7 +13,7 @@ fn test_doesnt_need_gc_scope_at_all(gc: GcScope<'_, '_>) {
unimplemented!()
}

fn test_doesnt_need_gc_scope_with_qualified_path(gc: nova_vm::engine::context::GcScope<'_, '_>) {
fn test_doesnt_need_gc_scope_with_qualified_path(gc: nova_vm::engine::GcScope<'_, '_>) {
unimplemented!()
}

Expand Down
12 changes: 6 additions & 6 deletions nova_lint/ui/can_use_no_gc_scope.stderr
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
warning: you can use `NoGcScope` instead of `GcScope` here
--> $DIR/can_use_no_gc_scope.rs:12:34
--> $DIR/can_use_no_gc_scope.rs:8:34
|
LL | fn test_doesnt_need_gc_scope(gc: GcScope<'_, '_>) {
| ^^^^^^^ help: replace with: `NoGcScope`
|
= note: `#[warn(can_use_no_gc_scope)]` on by default

warning: you can use `NoGcScope` instead of `GcScope` here
--> $DIR/can_use_no_gc_scope.rs:16:41
--> $DIR/can_use_no_gc_scope.rs:12:41
|
LL | fn test_doesnt_need_gc_scope_at_all(gc: GcScope<'_, '_>) {
| ^^^^^^^ help: replace with: `NoGcScope`

warning: you can use `NoGcScope` instead of `GcScope` here
--> $DIR/can_use_no_gc_scope.rs:20:80
--> $DIR/can_use_no_gc_scope.rs:16:71
|
LL | fn test_doesnt_need_gc_scope_with_qualified_path(gc: nova_vm::engine::context::GcScope<'_, '_>) {
| ^^^^^^^ help: replace with: `NoGcScope`
LL | fn test_doesnt_need_gc_scope_with_qualified_path(gc: nova_vm::engine::GcScope<'_, '_>) {
| ^^^^^^^ help: replace with: `NoGcScope`

warning: you can use `NoGcScope` instead of `GcScope` here
--> $DIR/can_use_no_gc_scope.rs:44:45
--> $DIR/can_use_no_gc_scope.rs:40:45
|
LL | fn test_doesnt_need_gc_scope(&self, gc: GcScope<'_, '_>) {
| ^^^^^^^ help: replace with: `NoGcScope`
Expand Down
6 changes: 3 additions & 3 deletions nova_lint/ui/gc_scope_comes_last.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
can_use_no_gc_scope
)]

type GcScope<'a, 'b> = nova_vm::engine::context::GcScope<'a, 'b>;
type NoGcScope<'a, 'b> = nova_vm::engine::context::NoGcScope<'a, 'b>;
type GcScope<'a, 'b> = nova_vm::engine::GcScope<'a, 'b>;
type NoGcScope<'a, 'b> = nova_vm::engine::NoGcScope<'a, 'b>;

fn test_no_params() {
unimplemented!()
Expand All @@ -17,7 +17,7 @@ fn test_one_param(_foo: ()) {
unimplemented!()
}

fn test_owned_qualified_gc_scope_only(gc_scope: nova_vm::engine::context::GcScope<'_, '_>) {
fn test_owned_qualified_gc_scope_only(gc_scope: nova_vm::engine::GcScope<'_, '_>) {
unimplemented!()
}

Expand Down
22 changes: 8 additions & 14 deletions nova_lint/ui/gc_scope_is_only_passed_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,50 @@
can_use_no_gc_scope
)]

type GcScope<'a, 'b> = nova_vm::engine::context::GcScope<'a, 'b>;
type NoGcScope<'a, 'b> = nova_vm::engine::context::NoGcScope<'a, 'b>;
type GcScope<'a, 'b> = nova_vm::engine::GcScope<'a, 'b>;
type NoGcScope<'a, 'b> = nova_vm::engine::NoGcScope<'a, 'b>;

fn test_owned_qualified_gc_scope_only(gc_scope: nova_vm::engine::context::GcScope<'_, '_>) {
fn test_owned_qualified_gc_scope_only(gc_scope: nova_vm::engine::GcScope<'_, '_>) {
unimplemented!()
}

fn test_owned_gc_scope_only(gc_scope: GcScope<'_, '_>) {
unimplemented!()
}

fn test_owned_qualified_no_gc_scope_only(gc_scope: nova_vm::engine::context::NoGcScope<'_, '_>) {
fn test_owned_qualified_no_gc_scope_only(gc_scope: nova_vm::engine::NoGcScope<'_, '_>) {
unimplemented!()
}

fn test_owned_no_gc_scope_only(gc_scope: NoGcScope<'_, '_>) {
unimplemented!()
}

fn test_borrowed_qualified_gc_scope_only(gc_scope: &nova_vm::engine::context::GcScope<'_, '_>) {
fn test_borrowed_qualified_gc_scope_only(gc_scope: &nova_vm::engine::GcScope<'_, '_>) {
unimplemented!()
}

fn test_borrowed_gc_scope_only(gc_scope: &GcScope<'_, '_>) {
unimplemented!()
}

fn test_borrowed_qualified_no_gc_scope_only(
gc_scope: &nova_vm::engine::context::NoGcScope<'_, '_>,
) {
fn test_borrowed_qualified_no_gc_scope_only(gc_scope: &nova_vm::engine::NoGcScope<'_, '_>) {
unimplemented!()
}

fn test_borrowed_no_gc_scope_only(gc_scope: &NoGcScope<'_, '_>) {
unimplemented!()
}

fn test_mut_borrowed_qualified_gc_scope_only(
gc_scope: &mut nova_vm::engine::context::GcScope<'_, '_>,
) {
fn test_mut_borrowed_qualified_gc_scope_only(gc_scope: &mut nova_vm::engine::GcScope<'_, '_>) {
unimplemented!()
}

fn test_mut_borrowed_gc_scope_only(gc_scope: &mut GcScope<'_, '_>) {
unimplemented!()
}

fn test_mut_borrowed_qualified_no_gc_scope_only(
gc_scope: &mut nova_vm::engine::context::NoGcScope<'_, '_>,
) {
fn test_mut_borrowed_qualified_no_gc_scope_only(gc_scope: &mut nova_vm::engine::NoGcScope<'_, '_>) {
unimplemented!()
}

Expand Down
28 changes: 14 additions & 14 deletions nova_lint/ui/gc_scope_is_only_passed_by_value.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: gc scope should only be passed by value
--> $DIR/gc_scope_is_only_passed_by_value.rs:28:52
|
LL | fn test_borrowed_qualified_gc_scope_only(gc_scope: &nova_vm::engine::context::GcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn test_borrowed_qualified_gc_scope_only(gc_scope: &nova_vm::engine::GcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove the reference
= note: `#[deny(gc_scope_is_only_passed_by_value)]` on by default
Expand All @@ -16,47 +16,47 @@ LL | fn test_borrowed_gc_scope_only(gc_scope: &GcScope<'_, '_>) {
= help: remove the reference

error: gc scope should only be passed by value
--> $DIR/gc_scope_is_only_passed_by_value.rs:37:15
--> $DIR/gc_scope_is_only_passed_by_value.rs:36:55
|
LL | gc_scope: &nova_vm::engine::context::NoGcScope<'_, '_>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn test_borrowed_qualified_no_gc_scope_only(gc_scope: &nova_vm::engine::NoGcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove the reference

error: gc scope should only be passed by value
--> $DIR/gc_scope_is_only_passed_by_value.rs:42:45
--> $DIR/gc_scope_is_only_passed_by_value.rs:40:45
|
LL | fn test_borrowed_no_gc_scope_only(gc_scope: &NoGcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^
|
= help: remove the reference

error: gc scope should only be passed by value
--> $DIR/gc_scope_is_only_passed_by_value.rs:47:15
--> $DIR/gc_scope_is_only_passed_by_value.rs:44:56
|
LL | gc_scope: &mut nova_vm::engine::context::GcScope<'_, '_>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn test_mut_borrowed_qualified_gc_scope_only(gc_scope: &mut nova_vm::engine::GcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove the reference

error: gc scope should only be passed by value
--> $DIR/gc_scope_is_only_passed_by_value.rs:52:46
--> $DIR/gc_scope_is_only_passed_by_value.rs:48:46
|
LL | fn test_mut_borrowed_gc_scope_only(gc_scope: &mut GcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^^^
|
= help: remove the reference

error: gc scope should only be passed by value
--> $DIR/gc_scope_is_only_passed_by_value.rs:57:15
--> $DIR/gc_scope_is_only_passed_by_value.rs:52:59
|
LL | gc_scope: &mut nova_vm::engine::context::NoGcScope<'_, '_>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn test_mut_borrowed_qualified_no_gc_scope_only(gc_scope: &mut nova_vm::engine::NoGcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove the reference

error: gc scope should only be passed by value
--> $DIR/gc_scope_is_only_passed_by_value.rs:62:49
--> $DIR/gc_scope_is_only_passed_by_value.rs:56:49
|
LL | fn test_mut_borrowed_no_gc_scope_only(gc_scope: &mut NoGcScope<'_, '_>) {
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading