[−][src]Struct c2rust_refactor::transform::statics::Localize
static_to_local_ref
Command
Usage: static_to_local_ref
Marks: target
, user
For each function marked user
, replace uses of statics marked target
with
uses of newly-introduced reference arguments. Afterward, no user
function
directly accesses any target
static. At call sites of user
functions, a
reference to the original static is passed in for each new argument if the
caller is not itself a user
function; otherwise, the caller's own reference
argument is passed through. Note this sometimes results in functions gaining
arguments corresponding to statics that the function itself does not use, but
that its callees do.
Example:
static mut FOO: i32 = 100; // FOO: target unsafe fn f() -> i32 { // f: user FOO } unsafe fn g() -> i32 { // g: user f() } unsafe fn h() -> i32 { g() }
After running static_to_local_ref
:
static mut FOO: i32 = 100; // `f` is a `user` that references `FOO`, so it // gains a new argument `FOO_`. unsafe fn f(FOO_: &mut i32) -> i32 { // References to `FOO` are replaced with `*FOO_` *FOO_ } // `g` is a `user` that references `FOO` indirectly, // via fellow `user` `f`. unsafe fn g(FOO_: &mut i32) -> i32 { // `g` passes through its own `FOO_` reference // when calling `f`. f(FOO_) } // `h` is not a `user`, so its signature is unchanged. unsafe fn h() -> i32 { // `h` passes in a reference to the original // static `FOO`. g(&mut FOO) }
Trait Implementations
impl Transform for Localize
[src]
fn transform(&self, krate: &mut Crate, st: &CommandState, cx: &RefactorCtxt)
[src]
fn min_phase(&self) -> Phase
[src]
Return the minimum phase at which this transform can operate. See the Phase
docs for details. The default is Phase2
. Read more
Auto Trait Implementations
Blanket Implementations
impl<T> Lone for T
[src]
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<E> SpecializationError for E
[src]
default fn not_found<S, T>(
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
[src]
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
impl<T> Erased for T
[src]
impl<T> Send for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Sync for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Same for T
type Output = T
Should always be Self
impl<T> MaybeResult for T
[src]
impl<'a, T> Captures for T where
T: ?Sized,
[src]
T: ?Sized,