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.
FN_ONCE,
FN_ONCE_OUTPUT,
+ // markers
+ COPY,
+ CLONE,
+ SIZED,
+
+ // delimiter
UNKNOWN,
};
{
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;
}
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>";
--- /dev/null
+#[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
+ }
+ }
+}