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

Implement unsafe trait support (continued) #155

Merged
merged 11 commits into from
Nov 12, 2023
12 changes: 12 additions & 0 deletions crates/formality-prove/src/decls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt;

use formality_core::{set, Set, Upcast};
use formality_macros::term;
use formality_types::grammar::{
Expand Down Expand Up @@ -141,13 +143,23 @@ pub struct NegImplDeclBoundData {
}

#[term]
#[customize(debug)]
#[derive(Default)]
pub enum Safety {
#[default]
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know you could do this, nifty.

Safe,
Unsafe,
}

impl fmt::Debug for Safety {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this the default behavior that #[term] would generate?

Copy link
Member Author

@lqd lqd Nov 12, 2023

Choose a reason for hiding this comment

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

Oh I didn't know this, or test that it would. I'll try, and open a PR to clean this up.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've fixed this in #156

fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Safety::Safe => write!(f, "safe"),
Safety::Unsafe => write!(f, "unsafe"),
}
}
}

/// A "trait declaration" declares a trait that exists, its generics, and its where-clauses.
/// It doesn't capture the trait items, which will be transformed into other sorts of rules.
///
Expand Down