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

Use type based qualification for unions #90373

Merged
merged 1 commit into from
Oct 29, 2021

Commits on Oct 28, 2021

  1. Use type based qualification for unions

    Union field access is currently qualified based on the qualification of
    a value previously assigned to the union. At the same time, every union
    access transmutes the content of the union, which might result in a
    different qualification.
    
    For example, consider constants A and B as defined below, under the
    current rules neither contains interior mutability, since a value used
    in the initial assignment did not contain `UnsafeCell` constructor.
    
    ```rust
    #![feature(untagged_unions)]
    
    union U { i: u32, c: std::cell::Cell<u32> }
    const A: U = U { i: 0 };
    const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
    ```
    
    To avoid the issue, the changes here propose to consider the content of
    a union as opaque and use type based qualification for union types.
    tmiasko committed Oct 28, 2021
    Configuration menu
    Copy the full SHA
    3f778f3 View commit details
    Browse the repository at this point in the history