Skip to content

Tracking issue for the cast method of raw pointers #60602

Closed

Description

@SimonSapin

#60601 adds:

impl<T: ?Sized> *mut T {
    /// Cast to a pointer to a different type
    #[inline]
    pub const fn cast<U>(self) -> *mut U {
        self as _
    }
}

impl<T: ?Sized> *const T {
    /// Cast to a pointer to a different type
    #[inline]
    pub const fn cast<U>(self) -> *const U {
        self as _
    }
}

Like with NonNull::cast, the input pointed type does not need to be Sized but the output pointed type does, because we wouldn’t know what appropriate pointer metadata (slice length, trait object vtable, …) to insert. The actual requirement is that the pointer is thin, but Sized is the closest approximation we have (until we add something like T: ptr::Pointee<Metadata=()>).

Activity

  1. added
    T-libs-api[DEPRECATED; DO NOT USE]
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on May 7, 2019
  2. SimonSapin commented on Jul 3, 2019

    @SimonSapin
    ContributorAuthor

    Let’s?

    @rfcbot fcp merge

  3. rfcbot commented on Jul 3, 2019

    @rfcbot

    Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members:

    No concerns currently listed.

    Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

    See this document for info about what commands tagged team members can give me.

  4. added
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Jul 3, 2019
  5. rfcbot commented on Jul 3, 2019

    @rfcbot

    🔔 This is now entering its final comment period, as per the review above. 🔔

  6. removed
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Jul 3, 2019
  7. added and removed
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Jul 13, 2019
  8. rfcbot commented on Jul 13, 2019

    @rfcbot

    The final comment period, with a disposition to merge, as per the review above, is now complete.

    As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

    The RFC will be merged soon.

  9. added a commit that references this issue on Jul 22, 2019
    2567af6
  10. jpryne commented on Mar 3, 2020

    @jpryne

    Getting this issue when executing:
    cargo install cargo-generate

    More detail:

       Compiling backtrace v0.3.44
    error[E0658]: use of unstable library feature 'ptr_cast'
       --> C:\Users\jack_\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.44\src\backtrace\dbghelp.rs:110:74
        |
    110 |                 RtlLookupFunctionEntry(addr, &mut base, ptr::null_mut()).cast()
        |                                                                          ^^^^
        |
        = note: for more information, see https://github.com/rust-lang/rust/issues/60602
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0658`.
    error: Could not compile `backtrace`.
    warning: build failed, waiting for other jobs to finish...
    error: failed to compile `cargo-generate v0.5.0`, intermediate artifacts can be found at `C:\Users\jack_\AppData\Local\Temp\cargo-installM3JL39`
    
    Caused by:
      build failed
    
  11. sfackler commented on Mar 3, 2020

    @sfackler
    Member

    Your Rust installation is out of date.

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

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions