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

Validate NIF attributes #279

Merged
merged 1 commit into from
Nov 12, 2019
Merged

Conversation

evnu
Copy link
Member

@evnu evnu commented Nov 12, 2019

An unknown NIF attribute should result in an error instead of being ignored. Example:

#[rustler::nif(schedul = "DirtyIo")]
pub fn dirty_io() -> Atom {
    let duration = Duration::from_millis(100);
    std::thread::sleep(duration);

    atoms::ok()
}

Resulting error:

error: custom attribute panicked
  --> rustler_tests/native/rustler_test/src/test_dirty.rs:18:1
   |
18 | #[rustler::nif(schedul = "DirtyIo")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: message: Unknown attribute 'schedul'. Allowed attributes: ["schedule", "name"]

@evnu evnu requested a review from scrogson November 12, 2019 20:49
Copy link
Member

@scrogson scrogson left a comment

Choose a reason for hiding this comment

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

👍

@scrogson
Copy link
Member

scrogson commented Nov 12, 2019

We should also look into proc-macro-error until diagnostics become stable.

@scrogson scrogson merged commit 5da9019 into rusterlium:master Nov 12, 2019
@evnu evnu deleted the error-on-unknown-attribute branch February 20, 2020 22:08
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.

2 participants