Skip to content
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

Work around needless_return rust-analyzer bug in bail macro #355

Closed
wants to merge 1 commit into from
Closed
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
Work around needless_return rust-analyzer bug in bail macro
  • Loading branch information
dtolnay committed Mar 12, 2024
commit 6d1faba582c74e1c72ef71e899b3cec04726d1fa
15 changes: 9 additions & 6 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@
/// ```
#[macro_export]
macro_rules! bail {
($msg:literal $(,)?) => {
($msg:literal $(,)?) => {{
#[allow(clippy::needless_return)]
return $crate::__private::Err($crate::__anyhow!($msg))
};
($err:expr $(,)?) => {
}};
($err:expr $(,)?) => {{
#[allow(clippy::needless_return)]
return $crate::__private::Err($crate::__anyhow!($err))
};
($fmt:expr, $($arg:tt)*) => {
}};
($fmt:expr, $($arg:tt)*) => {{
#[allow(clippy::needless_return)]
return $crate::__private::Err($crate::__anyhow!($fmt, $($arg)*))
};
}};
}

/// Return early with an error if a condition is not satisfied.
Expand Down
Loading