Skip to content

The warning diagnostics of the usage of std::intrinsics::copy_nonoverlapping is misleading #139505

Closed

Description

@OscarTHZhang

Code

fn main() {
    let a = 10;
    let mut b;
    unsafe {
        std::ptr::copy_nonoverlapping(a.as_ptr(), b.as_mut_ptr(), std::mem::sizeof::<i32>());
    }
}

Current output

use of deprecated module `std::intrinsics`: import this function via `std::mem` instead

Desired output

Either

use of deprecated module `std::intrinsics`: import this function via `std::ptr` instead

or
this function should be added into std::mem module.

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.86.0 (872aa6e349 2025-04-01)
binary: rustc
commit-hash: 872aa6e34902620b5f406a0cbef652085a3c54b1
commit-date: 2025-04-01
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7

Anything else?

No response

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Apr 8, 2025
  2. changed the title [-]The warning diagnostics of the usage of `std::intrinsics::copy_nonoverlapping` in 1.86 is misleading[/-] [+]The warning diagnostics of the usage of `std::intrinsics::copy_nonoverlapping` is misleading[/+] on Apr 8, 2025
  3. smanilov commented on Apr 8, 2025

    @smanilov
    Contributor

    Looks like an easy fix, taking this on as a first issue.

  4. RalfJung commented on Apr 8, 2025

    @RalfJung
    Member

    @OscarTHZhang your code example does not compile. And it uses std::ptr so even if it compiled it would not show a deprecation warning. Could you fix the issue description? :)

  5. added a commit that references this issue on Apr 8, 2025
    51bc376
  6. added a commit that references this issue on Apr 9, 2025
    32da310
  7. added a commit that references this issue on Apr 19, 2025
    ff64fc4
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

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions