Skip to content

Borrows of unsafe immubtable static items is permitted on constructors #13005

Closed
@flaper87

Description

@flaper87
Contributor

This is currently valid and it shouldn't be.

The issue is in borrowck::gather_loans::mod:: specifically in the gather_loans_for_static_initializer function. This should be fixed by implementing a small Visitor that will walk the passed expr and look for cases like the one in the example below:

struct Wrap<T> { value: T }
static UNSAFE: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
static WRAPPED_UNSAFE: Wrap<&'static Unsafe<int>> = Wrap { value: &UNSAFE };

fn main() {}

cc @nikomatsakis

Activity

self-assigned this
on Mar 18, 2014
added a commit that references this issue on Mar 25, 2014

auto merge of #13083 : FlaPer87/rust/issue-13005-borrow-unsafe-static…

5d5634a
removed their assignment
on Jun 16, 2014
added a commit that references this issue on Sep 6, 2022

Auto merge of rust-lang#13005 - pocket7878:convert-two-arm-bool-match…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @flaper87

      Issue actions

        Borrows of unsafe immubtable static items is permitted on constructors · Issue #13005 · rust-lang/rust