Skip to content

Commit 6b2eab2

Browse files
Add Tuple marker trait
1 parent d394408 commit 6b2eab2

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

compiler/rustc_hir/src/lang_items.rs

+2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ language_item_table! {
290290

291291
Try, sym::Try, try_trait, Target::Trait, GenericRequirement::None;
292292

293+
Tuple, sym::tuple_trait, tuple_trait, Target::Trait, GenericRequirement::Exact(0);
294+
293295
SliceLen, sym::slice_len_fn, slice_len_fn, Target::Method(MethodKind::Inherent), GenericRequirement::None;
294296

295297
// Language items from AST lowering

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,7 @@ symbols! {
14811481
tuple,
14821482
tuple_from_req,
14831483
tuple_indexing,
1484+
tuple_trait,
14841485
two_phase,
14851486
ty,
14861487
type_alias_enum_variants,

library/core/src/marker.rs

+9
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,15 @@ impl<T: ?Sized> Unpin for *mut T {}
800800
#[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
801801
pub trait Destruct {}
802802

803+
/// A marker for tuple types.
804+
///
805+
/// The implementation of this trait is built-in and cannot be implemented
806+
/// for any user type.
807+
#[unstable(feature = "tuple_trait", issue = "none")]
808+
#[cfg_attr(not(bootstrap), lang = "tuple_trait")]
809+
#[rustc_on_unimplemented(message = "`{Self}` is not a tuple")]
810+
pub trait Tuple {}
811+
803812
/// Implementations of `Copy` for primitive types.
804813
///
805814
/// Implementations that cannot be described in Rust

0 commit comments

Comments
 (0)