machine-check-machine 0.7.1

Utility crate for the formal verification tool machine-check
Documentation
use syn::visit::Visit;

use crate::into_wir::{Error, Errors};

pub struct AttributeDisallower {
    errors: Vec<Error>,
}

impl AttributeDisallower {
    pub fn new() -> Self {
        Self { errors: Vec::new() }
    }

    pub fn into_result(self) -> Result<(), Errors> {
        Errors::iter_to_result(self.errors)
    }
}

impl Visit<'_> for AttributeDisallower {
    fn visit_attribute(&mut self, attribute: &syn::Attribute) {
        if let syn::Meta::NameValue(meta) = &attribute.meta {
            if meta.path.is_ident("doc") {
                // doc comments are allowed everywhere
                return;
            }
        }

        self.errors.push(Error::unsupported_syn_construct(
            "Attribute here",
            &attribute,
        ));
    }
}