rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Handle no return attributes

Open pvdrz opened this issue 3 years ago • 5 comments

Partially fixes https://github.com/rust-lang/rust-bindgen/issues/2094

pvdrz avatar Aug 31 '22 19:08 pvdrz

So it looks reasonable, but it's fairly unfortunate that we can't handle neither [[noreturn]] nor __attribute__((noreturn)) which I think are more common ways to deal with this.

emilio avatar Sep 01 '22 17:09 emilio

So it looks reasonable, but it's fairly unfortunate that we can't handle neither [[noreturn]] nor __attribute__((noreturn)) which I think are more common ways to deal with this.

I can try and handle __attribute_((noreturn)) at least in a future PR. I just need to dig more into clang to figure out how to detect them.

pvdrz avatar Sep 01 '22 17:09 pvdrz

Weird, both test that failed pass on local (but I have a pretty recent clang version so that might be it). I'll try to bring back the UnexposedAttribute logic to check if that works.

pvdrz avatar Sep 01 '22 17:09 pvdrz

Fixed :tada:

pvdrz avatar Sep 01 '22 17:09 pvdrz

@emilio now this supports all 3 options :)

pvdrz avatar Sep 01 '22 21:09 pvdrz

Any chance a new Bindgen release will pick this up anytime soon? I'm excited to use this :)

EDIT: Never mind! This is already out, and I just don't know how to fetch tags :p

oconnor663 avatar Oct 27 '22 21:10 oconnor663

I'm experiencing an issue that this PR should have dealt with. I'm thinking the reason could be that this was done for C++ and not for C. Is that restriction here?

CGMossa avatar Mar 19 '24 18:03 CGMossa

Without more information I'm unable to say. However, this feature works on c:

// hello.h
__attribute__((noreturn)) void g(void);

Then you run bindgen hello.h and get

/* automatically generated by rust-bindgen 0.69.4 */

extern "C" {
    pub fn g() -> !;
}

pvdrz avatar Mar 19 '24 18:03 pvdrz

I'm still seeing an issue on our end. Let me make a dedicated issue.

CGMossa avatar Mar 20 '24 10:03 CGMossa