public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] gccrs: Add missing Sized, Copy and Clone lang item mappings Date: Tue, 7 Feb 2023 17:56:21 +0000 (GMT) [thread overview] Message-ID: <20230207175621.6D21E3858D33@sourceware.org> (raw) https://gcc.gnu.org/g:d4e6b64e7f9e23aeb5d3c40665f18091575921ed commit d4e6b64e7f9e23aeb5d3c40665f18091575921ed Author: Philip Herron <herron.philip@googlemail.com> Date: Tue Jan 31 14:39:29 2023 +0000 gccrs: Add missing Sized, Copy and Clone lang item mappings We need these lang items to be defined and later down the line the mappings will be used to implement proper copy and clone logic. Fixes #1786 Signed-off-by: Philip Herron <herron.philip@googlemail.com> gcc/rust/ChangeLog: * util/rust-lang-item.h: gcc/testsuite/ChangeLog: * rust/compile/issue-1786.rs: New test. Diff: --- gcc/rust/util/rust-lang-item.h | 24 ++++++++++++++++++++++++ gcc/testsuite/rust/compile/issue-1786.rs | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h index 52f53fa3f93..5bad08ae7c1 100644 --- a/gcc/rust/util/rust-lang-item.h +++ b/gcc/rust/util/rust-lang-item.h @@ -80,6 +80,12 @@ public: FN_ONCE, FN_ONCE_OUTPUT, + // markers + COPY, + CLONE, + SIZED, + + // delimiter UNKNOWN, }; @@ -237,6 +243,18 @@ public: { return ItemType::FN_ONCE_OUTPUT; } + else if (item.compare ("copy") == 0) + { + return ItemType::COPY; + } + else if (item.compare ("clone") == 0) + { + return ItemType::CLONE; + } + else if (item.compare ("sized") == 0) + { + return ItemType::SIZED; + } return ItemType::UNKNOWN; } @@ -321,6 +339,12 @@ public: return "fn_once"; case FN_ONCE_OUTPUT: return "fn_once_output"; + case COPY: + return "copy"; + case CLONE: + return "clone"; + case SIZED: + return "sized"; case UNKNOWN: return "<UNKNOWN>"; diff --git a/gcc/testsuite/rust/compile/issue-1786.rs b/gcc/testsuite/rust/compile/issue-1786.rs new file mode 100644 index 00000000000..f73b63d0cb6 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-1786.rs @@ -0,0 +1,23 @@ +#[lang = "clone"] +trait Clone { + fn clone(&self) -> Self; + + fn clone_from(&mut self, source: &Self) { + *self = source.clone() + } +} + +#[lang = "copy"] +pub trait Copy: Clone { + // Empty. +} + +mod impls { + use super::Clone; + + impl Clone for char { + fn clone(&self) -> Self { + *self + } + } +}
reply other threads:[~2023-02-07 17:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230207175621.6D21E3858D33@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).