Skip to content

Inline asm: *const [type error] does not implement the Copy trait #113788

Closed
@Kyuuhachi

Description

@Kyuuhachi

Code

fn main() {
	let peb: *const PEB;
	unsafe { std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb); }
}

Current output

error[E0412]: cannot find type `PEB` in this scope
 --> src/main.rs:2:18
  |
2 |     let peb: *const PEB;
  |                     ^^^ not found in this scope

error: arguments for inline assembly must be copyable
 --> src/main.rs:3:49
  |
3 |     std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb);
  |                                                    ^^^
  |
  = note: `*const [type error]` does not implement the Copy trait

For more information about this error, try `rustc --explain E0412`.

Desired output

Probably just omit the second error; no `Copy` error is given when moving an unknown type normally.

Rationale and extra context

No response

Other cases

No response

Anything else?

Happens on 1.73.0-nightly (2023-07-16 0e8e857b11f60a785aea), as well as several earlier versions.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-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