about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-07-30 01:53:29 +0000
committerMichael Goulet <michael@errs.io>2022-08-07 16:28:24 -0700
commit6b2eab231056da3734e90bd35f11e257dc0bc138 (patch)
tree3561fe9589b7f1961890b69e5f986d25c10c1a0b
parentd394408fb38c4de61f765a3ed5189d2731a1da91 (diff)
downloadrust-6b2eab231056da3734e90bd35f11e257dc0bc138.tar.gz
rust-6b2eab231056da3734e90bd35f11e257dc0bc138.zip
Add Tuple marker trait
-rw-r--r--compiler/rustc_hir/src/lang_items.rs2
-rw-r--r--compiler/rustc_span/src/symbol.rs1
-rw-r--r--library/core/src/marker.rs9
3 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs
index c337be12ae4..03e204eb7d8 100644
--- a/compiler/rustc_hir/src/lang_items.rs
+++ b/compiler/rustc_hir/src/lang_items.rs
@@ -290,6 +290,8 @@ language_item_table! {
 
     Try,                     sym::Try,                 try_trait,                  Target::Trait,          GenericRequirement::None;
 
+    Tuple,                   sym::tuple_trait,         tuple_trait,                Target::Trait,          GenericRequirement::Exact(0);
+
     SliceLen,                sym::slice_len_fn,        slice_len_fn,               Target::Method(MethodKind::Inherent), GenericRequirement::None;
 
     // Language items from AST lowering
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index f81a69c1cce..4120717a681 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -1481,6 +1481,7 @@ symbols! {
         tuple,
         tuple_from_req,
         tuple_indexing,
+        tuple_trait,
         two_phase,
         ty,
         type_alias_enum_variants,
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index 2c57897956f..63096bf14d7 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -800,6 +800,15 @@ impl<T: ?Sized> Unpin for *mut T {}
 #[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
 pub trait Destruct {}
 
+/// A marker for tuple types.
+///
+/// The implementation of this trait is built-in and cannot be implemented
+/// for any user type.
+#[unstable(feature = "tuple_trait", issue = "none")]
+#[cfg_attr(not(bootstrap), lang = "tuple_trait")]
+#[rustc_on_unimplemented(message = "`{Self}` is not a tuple")]
+pub trait Tuple {}
+
 /// Implementations of `Copy` for primitive types.
 ///
 /// Implementations that cannot be described in Rust