Skip to content

Commit

Permalink
do not use catch_unwind unless panic=unwind
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Dec 11, 2024
1 parent 327e197 commit 358632e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions hydroflow_lang/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Diagnostic {
/// Emit if possible, otherwise return `Err` containing a [`TokenStream`] of a
/// `compile_error!(...)` call.
pub fn try_emit(&self) -> Result<(), TokenStream> {
#[cfg(nightly)]
#[cfg(all(nightly, panic = "unwind"))]
{
if let Ok(()) = std::panic::catch_unwind(|| {
let pm_diag = match self.level {
Expand Down Expand Up @@ -193,7 +193,7 @@ pub struct SerdeSpan {
}
impl From<Span> for SerdeSpan {
fn from(span: Span) -> Self {
#[cfg(nightly)]
#[cfg(all(nightly, panic = "unwind"))]
let path = std::panic::catch_unwind(|| span.unwrap())
.map(|span| span.source_file().path().display().to_string())
.ok();
Expand Down
2 changes: 1 addition & 1 deletion hydroflow_lang/src/graph/hydroflow_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ impl HydroflowGraph {
#[cfg(not(nightly))]
let source_info = Option::<String>::None;

#[cfg(nightly)]
#[cfg(all(nightly, panic = "unwind"))]
let source_info = std::panic::catch_unwind(|| op_span.unwrap())
.map(|op_span| {
format!(
Expand Down
2 changes: 1 addition & 1 deletion hydroflow_lang/src/pretty_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub struct PrettySpan(pub proc_macro2::Span);
impl std::fmt::Display for PrettySpan {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
#[cfg(nightly)]
#[cfg(all(nightly, panic = "unwind"))]
{
if let Ok(span) = std::panic::catch_unwind(|| self.0.unwrap()) {
write!(
Expand Down

0 comments on commit 358632e

Please sign in to comment.