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

Fixed handling of trait methods containing the unsafe attribute #1053

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PuffyWithEyes
Copy link

Currently, the application is throwing an error:

WARN: couldn't parse unsafe() attribute
WARN: Skipping dummy::DummyStruct::dummy - (not `no_mangle`, and has no `export_name` attribute)

In the following example:

struct DummyStruct {
    dummy: i32,
}

impl DummyStruct {
    #[unsafe(export_name = "new")]
    pub extern "C" dummy() -> Self {
        Self {
            dummy: 0,
        }
    }
}

Accordingly, the function new will not be generated in the header file. My solution fixes this error. Now, similar methods will not encounter this issue.

Copy link
Collaborator

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Could you add a test please?

@PuffyWithEyes
Copy link
Author

@emilio yes, I can write

@PuffyWithEyes
Copy link
Author

@emilio done. I hope I did everything right :)

@PuffyWithEyes PuffyWithEyes requested a review from emilio February 16, 2025 12:59
@emilio
Copy link
Collaborator

emilio commented Feb 16, 2025

Thank you!

@lpraneis
Copy link

Is there anything blocking this merge? I believe this will be required for Rust 2024 Edition updates since unsafe(no_mangle) is now required

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.

3 participants