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

msg_send without explicit return types will break if/when ! is stabilized. #2939

Closed
mtak- opened this issue Aug 2, 2019 · 1 comment · Fixed by #2943
Closed

msg_send without explicit return types will break if/when ! is stabilized. #2939

mtak- opened this issue Aug 2, 2019 · 1 comment · Fixed by #2943

Comments

@mtak-
Copy link
Contributor

mtak- commented Aug 2, 2019

Code like this has an unconstrained return type.

msg_send![view, retain];

This presently will fall back to deducing () as the return type. Previous attempts to stabilize the ! type have involved unconstrained return types deducing to !. This has directly caused UB in winit rust-windowing/winit#428 during both attempts to stabilize the never type.
rust-lang/rust#48950 (comment)

One recommended fix is to change the code to explicitly deduce the return type as () where appropriate.

let () = msg_send![layer, setBounds: bounds];

The first example is already UB because the return type of retain is *mut c_void but is currently being deduced as ().

So that should be changed to:

let _: *mut std::raw::c_void = msg_send![view, retain];
@kvark
Copy link
Member

kvark commented Aug 2, 2019

I recall us hitting this problem on Nightly at some point. Guess there is no way around it.
Also related to #1972

bors bot added a commit that referenced this issue Aug 7, 2019
2943: [mtl] add explicit return types for `msg_send!` calls r=kvark a=aleksijuvani

Fixes #2939
PR checklist:
- [x] `make` succeeds (on *nix)
- [x] `make reftests` succeeds
- [x] tested examples with the following backends: mtl
- [ ] `rustfmt` run on changed code

Co-authored-by: Aleksi Juvani <[email protected]>
@bors bors bot closed this as completed in #2943 Aug 7, 2019
bors bot added a commit to gfx-rs/metal-rs that referenced this issue Aug 7, 2019
91: Add explicit return types for `msg_send!` calls r=kvark a=aleksijuvani

See gfx-rs/gfx#2939.

Co-authored-by: Aleksi Juvani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants