Skip to content

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

@mtak-

Description

@mtak-

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];

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions