+
Skip to content

feat: Log failed debug assertions in all configurations #6996

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

Merged
merged 1 commit into from
Jul 12, 2025

Conversation

iequidoo
Copy link
Collaborator

Add logged_debug_assert macro logging a warning if a condition is not satisfied, before invoking debug_assert!, and use this macro where Context is accessible (i.e. don't change function signatures for now).
Follow-up to 0359481.

Add `logged_debug_assert` macro logging a warning if a condition is not satisfied, before invoking
`debug_assert!`, and use this macro where `Context` is accessible (i.e. don't change function
signatures for now).
Follow-up to 0359481.
@iequidoo iequidoo requested review from link2xt and Hocuri July 11, 2025 21:16
Copy link
Collaborator

@Hocuri Hocuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@iequidoo iequidoo merged commit 58b99f5 into main Jul 12, 2025
29 checks passed
@iequidoo iequidoo deleted the iequidoo/logged_debug_assert branch July 12, 2025 10:27
#[macro_export]
macro_rules! logged_debug_assert {
($ctx:expr, $cond:expr, $($arg:tt)*) => {
if !$cond {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to assign $cond to a local variable to avoid evaluating the expression twice. Same for other macros.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only other one is ensure_and_debug_assert. But i wanted to pass $cond to debug_assert as is so that it prints a nicer assertion failed: <stringified expr> line. Maybe it's not that important and we indeed should assign the value to a local var. Anyway one needs to look into the source code usually to debug it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #7004. It prints informative messages also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载