Skip to content

Commit 376b51e

Browse files
eminencesharkdp
authored andcommitted
Add #[track_caller] annotation to some panicy VM functions
This improves the error messages a bit if the the panics are triggered in these functions
1 parent 195e22a commit 376b51e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

numbat/src/vm.rs

+5
Original file line numberDiff line numberDiff line change
@@ -515,31 +515,36 @@ impl Vm {
515515
self.stack.push(value);
516516
}
517517

518+
#[track_caller]
518519
fn pop_quantity(&mut self) -> Quantity {
519520
match self.pop() {
520521
Value::Quantity(q) => q,
521522
_ => panic!("Expected quantity to be on the top of the stack"),
522523
}
523524
}
524525

526+
#[track_caller]
525527
fn pop_bool(&mut self) -> bool {
526528
self.pop().unsafe_as_bool()
527529
}
528530

531+
#[track_caller]
529532
fn pop_datetime(&mut self) -> chrono::DateTime<chrono::Utc> {
530533
match self.pop() {
531534
Value::DateTime(q, _) => q,
532535
_ => panic!("Expected datetime to be on the top of the stack"),
533536
}
534537
}
535538

539+
#[track_caller]
536540
fn pop_string(&mut self) -> String {
537541
match self.pop() {
538542
Value::String(s) => s,
539543
_ => panic!("Expected string to be on the top of the stack"),
540544
}
541545
}
542546

547+
#[track_caller]
543548
fn pop(&mut self) -> Value {
544549
self.stack.pop().expect("stack should not be empty")
545550
}

0 commit comments

Comments
 (0)