mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
More track_caller
annotations
This commit is contained in:
parent
43ef60c09c
commit
9d962c5c40
@ -216,6 +216,7 @@ fn convert_json(value: serde_json::Value) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Format the user-facing JSON error message.
|
/// Format the user-facing JSON error message.
|
||||||
|
#[track_caller]
|
||||||
fn format_json_error(error: serde_json::Error) -> String {
|
fn format_json_error(error: serde_json::Error) -> String {
|
||||||
assert!(error.is_syntax() || error.is_eof());
|
assert!(error.is_syntax() || error.is_eof());
|
||||||
format!("failed to parse json file: syntax error in line {}", error.line())
|
format!("failed to parse json file: syntax error in line {}", error.line())
|
||||||
|
@ -83,6 +83,7 @@ impl Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Bind a value to a name.
|
/// Bind a value to a name.
|
||||||
|
#[track_caller]
|
||||||
pub fn define(&mut self, name: impl Into<EcoString>, value: impl Into<Value>) {
|
pub fn define(&mut self, name: impl Into<EcoString>, value: impl Into<Value>) {
|
||||||
let name = name.into();
|
let name = name.into();
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ impl Shorthand {
|
|||||||
"|->" => '↦',
|
"|->" => '↦',
|
||||||
"<->" => '↔',
|
"<->" => '↔',
|
||||||
"<=>" => '⇔',
|
"<=>" => '⇔',
|
||||||
_ => panic!("shorthand is invalid"),
|
_ => char::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,7 +879,7 @@ impl Numeric {
|
|||||||
"em" => Unit::Em,
|
"em" => Unit::Em,
|
||||||
"fr" => Unit::Fr,
|
"fr" => Unit::Fr,
|
||||||
"%" => Unit::Percent,
|
"%" => Unit::Percent,
|
||||||
_ => panic!("number has invalid suffix"),
|
_ => Unit::Percent,
|
||||||
};
|
};
|
||||||
|
|
||||||
(value, unit)
|
(value, unit)
|
||||||
|
@ -1025,6 +1025,7 @@ impl<'s> Parser<'s> {
|
|||||||
self.current == kind
|
self.current == kind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
fn assert(&mut self, kind: SyntaxKind) {
|
fn assert(&mut self, kind: SyntaxKind) {
|
||||||
assert_eq!(self.current, kind);
|
assert_eq!(self.current, kind);
|
||||||
self.eat();
|
self.eat();
|
||||||
|
@ -38,6 +38,7 @@ impl Span {
|
|||||||
/// Create a new span from a source id and a unique number.
|
/// Create a new span from a source id and a unique number.
|
||||||
///
|
///
|
||||||
/// Panics if the `number` is not contained in `FULL`.
|
/// Panics if the `number` is not contained in `FULL`.
|
||||||
|
#[track_caller]
|
||||||
pub const fn new(id: SourceId, number: u64) -> Self {
|
pub const fn new(id: SourceId, number: u64) -> Self {
|
||||||
assert!(
|
assert!(
|
||||||
Self::FULL.start <= number && number < Self::FULL.end,
|
Self::FULL.start <= number && number < Self::FULL.end,
|
||||||
@ -53,6 +54,7 @@ impl Span {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pack the components into a span.
|
/// Pack the components into a span.
|
||||||
|
#[track_caller]
|
||||||
const fn pack(id: SourceId, number: u64) -> Span {
|
const fn pack(id: SourceId, number: u64) -> Span {
|
||||||
let bits = ((id.into_u16() as u64) << Self::BITS) | number;
|
let bits = ((id.into_u16() as u64) << Self::BITS) | number;
|
||||||
match NonZeroU64::new(bits) {
|
match NonZeroU64::new(bits) {
|
||||||
|
@ -14,6 +14,7 @@ use std::mem;
|
|||||||
/// Must only be called when `T` is a `dyn Trait`. The data address must point
|
/// Must only be called when `T` is a `dyn Trait`. The data address must point
|
||||||
/// to a value whose type implements the trait of `T` and the `vtable` must have
|
/// to a value whose type implements the trait of `T` and the `vtable` must have
|
||||||
/// been extracted with [`vtable`].
|
/// been extracted with [`vtable`].
|
||||||
|
#[track_caller]
|
||||||
pub unsafe fn from_raw_parts<T: ?Sized>(data: *const (), vtable: *const ()) -> *const T {
|
pub unsafe fn from_raw_parts<T: ?Sized>(data: *const (), vtable: *const ()) -> *const T {
|
||||||
let fat = FatPointer { data, vtable };
|
let fat = FatPointer { data, vtable };
|
||||||
debug_assert_eq!(Layout::new::<*const T>(), Layout::new::<FatPointer>());
|
debug_assert_eq!(Layout::new::<*const T>(), Layout::new::<FatPointer>());
|
||||||
@ -26,6 +27,7 @@ pub unsafe fn from_raw_parts<T: ?Sized>(data: *const (), vtable: *const ()) -> *
|
|||||||
/// Must only be called when `T` is a `dyn Trait`. The data address must point
|
/// Must only be called when `T` is a `dyn Trait`. The data address must point
|
||||||
/// to a value whose type implements the trait of `T` and the `vtable` must have
|
/// to a value whose type implements the trait of `T` and the `vtable` must have
|
||||||
/// been extracted with [`vtable`].
|
/// been extracted with [`vtable`].
|
||||||
|
#[track_caller]
|
||||||
pub unsafe fn from_raw_parts_mut<T: ?Sized>(data: *mut (), vtable: *const ()) -> *mut T {
|
pub unsafe fn from_raw_parts_mut<T: ?Sized>(data: *mut (), vtable: *const ()) -> *mut T {
|
||||||
let fat = FatPointer { data, vtable };
|
let fat = FatPointer { data, vtable };
|
||||||
debug_assert_eq!(Layout::new::<*mut T>(), Layout::new::<FatPointer>());
|
debug_assert_eq!(Layout::new::<*mut T>(), Layout::new::<FatPointer>());
|
||||||
@ -36,6 +38,7 @@ pub unsafe fn from_raw_parts_mut<T: ?Sized>(data: *mut (), vtable: *const ()) ->
|
|||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Must only be called when `T` is a `dyn Trait`.
|
/// Must only be called when `T` is a `dyn Trait`.
|
||||||
|
#[track_caller]
|
||||||
pub unsafe fn vtable<T: ?Sized>(ptr: *const T) -> *const () {
|
pub unsafe fn vtable<T: ?Sized>(ptr: *const T) -> *const () {
|
||||||
debug_assert_eq!(Layout::new::<*const T>(), Layout::new::<FatPointer>());
|
debug_assert_eq!(Layout::new::<*const T>(), Layout::new::<FatPointer>());
|
||||||
mem::transmute_copy::<*const T, FatPointer>(&ptr).vtable
|
mem::transmute_copy::<*const T, FatPointer>(&ptr).vtable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user