Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Kyuuhachi opened this issue Jul 17, 2023 · 7 comments · Fixed by #114752
Closed

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

Kyuuhachi opened this issue Jul 17, 2023 · 7 comments · Fixed by #114752
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Kyuuhachi
Copy link
Contributor

Kyuuhachi commented Jul 17, 2023

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.

@Kyuuhachi Kyuuhachi added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 17, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 17, 2023
@compiler-errors
Copy link
Member

compiler-errors commented Jul 17, 2023

Just needs someone to suppress this error if the type references_error, I think.

@compiler-errors compiler-errors added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. D-papercut Diagnostics: An error or lint that needs small tweaks. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 17, 2023
@RickleAndMortimer
Copy link
Contributor

@rustbot assign

@rustbot
Copy link
Collaborator

rustbot commented Jul 17, 2023

Error: Parsing assign command in comment failed: ...' assign' | error: specify user to assign to at >| ''...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@RickleAndMortimer
Copy link
Contributor

@rustbot claim

@ameya-deshmukh
Copy link

@rustbot claim

@Rajveer100
Copy link
Contributor

Rajveer100 commented Aug 11, 2023

@Kyuuhachi @compiler-errors
Hi! I have given a brief introduction of myself in the new members zulip channel.

With that said, I have potentially setup the necessary pre-requisites and compiler infrastructure in my local machine, also re confirmed by using the ./x check and other build commands which seem to work. As per the docs, I have the all the toolchains command executed (for stages [0-2]).

Like any other contribution, I figured that in rust-lang repo, good-first-issues are tagged as E-Easy for new-comers, and to start, I have chosen this issue.

Until now, I have found the following snippet which I presume is targeting the output:

// Check that the type implements Copy. The only case where this can
// possibly fail is for SIMD types which don't #[derive(Copy)].
if !ty.is_copy_modulo_regions(self.tcx, self.param_env) {
    let msg = "arguments for inline assembly must be copyable";
    let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
    err.note(format!("`{ty}` does not implement the Copy trait"));
    err.emit();
}

Would be great if one could point out any points I may have missed out!
A head start would be great!

@RickleAndMortimer
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants