script bindings: Fix warning about unused span. (#42850)

The span needs to be assigned to a variable, so that it drops at the end
of scope.
This was introduced in #42715. 
Additionally also switch tho the profile_traits macro to simplify the
statement.

Testing: Manually verified the warning is fixed.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender
2026-02-25 19:30:40 +01:00
committed by GitHub
parent 60c5977291
commit 4b2e8c38d1
3 changed files with 4 additions and 8 deletions

1
Cargo.lock generated
View File

@@ -8053,6 +8053,7 @@ dependencies = [
"phf",
"phf_codegen",
"phf_shared",
"profile_traits",
"regex",
"serde_json",
"servo_arc",

View File

@@ -34,6 +34,7 @@ malloc_size_of_derive = { workspace = true }
num-traits = { workspace = true }
parking_lot = { workspace = true }
phf = "0.13"
profile_traits = { workspace = true }
regex = { workspace = true }
servo_arc = { workspace = true }
servo_config = { path = "../config" }

View File

@@ -32,20 +32,14 @@ pub struct StackEntry<D: DomTypes> {
/// <https://html.spec.whatwg.org/multipage/#clean-up-after-running-script>
pub fn run_a_script<D: DomTypes, R>(global: &D::GlobalScope, f: impl FnOnce() -> R) -> R {
let settings_stack = <D as DomHelpers<D>>::settings_stack();
settings_stack.with(|stack| {
let _span = settings_stack.with(|stack| {
trace!("Prepare to run script with {:p}", global);
let mut stack = stack.borrow_mut();
stack.push(StackEntry {
global: Dom::from_ref(global),
kind: StackEntryKind::Entry,
});
#[cfg(feature = "tracing")]
tracing::info_span!(
"ScriptEvaluate",
servo_profiling = true,
url = global.get_url().to_string(),
)
.entered()
profile_traits::info_span!("ScriptEvaluate", url = global.get_url().to_string()).entered()
});
let r = f();
let stack_is_empty = settings_stack.with(|stack| {