Kickstart the inner usage of macro_metavar_expr
This commit is contained in:
parent
f565016edd
commit
3191d27f48
4 changed files with 28 additions and 120 deletions
|
@ -83,9 +83,7 @@ macro_rules! ast_fragments {
|
||||||
}
|
}
|
||||||
match self {
|
match self {
|
||||||
$($(AstFragment::$Kind(ast) => ast.extend(placeholders.iter().flat_map(|id| {
|
$($(AstFragment::$Kind(ast) => ast.extend(placeholders.iter().flat_map(|id| {
|
||||||
// We are repeating through arguments with `many`, to do that we have to
|
${ignore(flat_map_ast_elt)}
|
||||||
// mention some macro variable from those arguments even if it's not used.
|
|
||||||
macro _repeating($flat_map_ast_elt) {}
|
|
||||||
placeholder(AstFragmentKind::$Kind, *id, None).$make_ast()
|
placeholder(AstFragmentKind::$Kind, *id, None).$make_ast()
|
||||||
})),)?)*
|
})),)?)*
|
||||||
_ => panic!("unexpected AST fragment kind")
|
_ => panic!("unexpected AST fragment kind")
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(rustc::potential_query_instability)]
|
||||||
#![feature(associated_type_bounds)]
|
#![feature(associated_type_bounds)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
|
@ -5,12 +6,12 @@
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(let_else)]
|
#![feature(let_else)]
|
||||||
|
#![feature(macro_metavar_expr)]
|
||||||
#![feature(proc_macro_diagnostic)]
|
#![feature(proc_macro_diagnostic)]
|
||||||
#![feature(proc_macro_internals)]
|
#![feature(proc_macro_internals)]
|
||||||
#![feature(proc_macro_span)]
|
#![feature(proc_macro_span)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![allow(rustc::potential_query_instability)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_macros;
|
extern crate rustc_macros;
|
||||||
|
|
|
@ -181,6 +181,7 @@
|
||||||
#![feature(intrinsics)]
|
#![feature(intrinsics)]
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(link_llvm_intrinsics)]
|
#![feature(link_llvm_intrinsics)]
|
||||||
|
#![feature(macro_metavar_expr)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(mixed_integer_ops)]
|
#![feature(mixed_integer_ops)]
|
||||||
#![feature(must_not_suspend)]
|
#![feature(must_not_suspend)]
|
||||||
|
|
|
@ -5,21 +5,17 @@ use crate::cmp::*;
|
||||||
|
|
||||||
// macro for implementing n-ary tuple functions and operations
|
// macro for implementing n-ary tuple functions and operations
|
||||||
macro_rules! tuple_impls {
|
macro_rules! tuple_impls {
|
||||||
($(
|
( $( $Tuple:ident( $( $T:ident )+ ) )+ ) => {
|
||||||
$Tuple:ident {
|
|
||||||
$(($idx:tt) -> $T:ident)+
|
|
||||||
}
|
|
||||||
)+) => {
|
|
||||||
$(
|
$(
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<$($T:PartialEq),+> PartialEq for ($($T,)+) where last_type!($($T,)+): ?Sized {
|
impl<$($T:PartialEq),+> PartialEq for ($($T,)+) where last_type!($($T,)+): ?Sized {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &($($T,)+)) -> bool {
|
fn eq(&self, other: &($($T,)+)) -> bool {
|
||||||
$(self.$idx == other.$idx)&&+
|
$( ${ignore(T)} self.${index()} == other.${index()} )&&+
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ne(&self, other: &($($T,)+)) -> bool {
|
fn ne(&self, other: &($($T,)+)) -> bool {
|
||||||
$(self.$idx != other.$idx)||+
|
$( ${ignore(T)} self.${index()} != other.${index()} )||+
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,26 +24,28 @@ macro_rules! tuple_impls {
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+)
|
impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+)
|
||||||
where last_type!($($T,)+): ?Sized {
|
where
|
||||||
|
last_type!($($T,)+): ?Sized
|
||||||
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
|
||||||
lexical_partial_cmp!($(self.$idx, other.$idx),+)
|
lexical_partial_cmp!($( ${ignore(T)} self.${index()}, other.${index()} ),+)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn lt(&self, other: &($($T,)+)) -> bool {
|
fn lt(&self, other: &($($T,)+)) -> bool {
|
||||||
lexical_ord!(lt, $(self.$idx, other.$idx),+)
|
lexical_ord!(lt, $( ${ignore(T)} self.${index()}, other.${index()} ),+)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn le(&self, other: &($($T,)+)) -> bool {
|
fn le(&self, other: &($($T,)+)) -> bool {
|
||||||
lexical_ord!(le, $(self.$idx, other.$idx),+)
|
lexical_ord!(le, $( ${ignore(T)} self.${index()}, other.${index()} ),+)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ge(&self, other: &($($T,)+)) -> bool {
|
fn ge(&self, other: &($($T,)+)) -> bool {
|
||||||
lexical_ord!(ge, $(self.$idx, other.$idx),+)
|
lexical_ord!(ge, $( ${ignore(T)} self.${index()}, other.${index()} ),+)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn gt(&self, other: &($($T,)+)) -> bool {
|
fn gt(&self, other: &($($T,)+)) -> bool {
|
||||||
lexical_ord!(gt, $(self.$idx, other.$idx),+)
|
lexical_ord!(gt, $( ${ignore(T)} self.${index()}, other.${index()} ),+)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ macro_rules! tuple_impls {
|
||||||
impl<$($T:Ord),+> Ord for ($($T,)+) where last_type!($($T,)+): ?Sized {
|
impl<$($T:Ord),+> Ord for ($($T,)+) where last_type!($($T,)+): ?Sized {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &($($T,)+)) -> Ordering {
|
fn cmp(&self, other: &($($T,)+)) -> Ordering {
|
||||||
lexical_cmp!($(self.$idx, other.$idx),+)
|
lexical_cmp!($( ${ignore(T)} self.${index()}, other.${index()} ),+)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,106 +106,16 @@ macro_rules! last_type {
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple_impls! {
|
tuple_impls! {
|
||||||
Tuple1 {
|
Tuple1(A)
|
||||||
(0) -> A
|
Tuple2(A B)
|
||||||
}
|
Tuple3(A B C)
|
||||||
Tuple2 {
|
Tuple4(A B C D)
|
||||||
(0) -> A
|
Tuple5(A B C D E)
|
||||||
(1) -> B
|
Tuple6(A B C D E F)
|
||||||
}
|
Tuple7(A B C D E F G)
|
||||||
Tuple3 {
|
Tuple8(A B C D E F G H)
|
||||||
(0) -> A
|
Tuple9(A B C D E F G H I)
|
||||||
(1) -> B
|
Tuple10(A B C D E F G H I J)
|
||||||
(2) -> C
|
Tuple11(A B C D E F G H I J K)
|
||||||
}
|
Tuple12(A B C D E F G H I J K L)
|
||||||
Tuple4 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
}
|
|
||||||
Tuple5 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
}
|
|
||||||
Tuple6 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
(5) -> F
|
|
||||||
}
|
|
||||||
Tuple7 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
(5) -> F
|
|
||||||
(6) -> G
|
|
||||||
}
|
|
||||||
Tuple8 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
(5) -> F
|
|
||||||
(6) -> G
|
|
||||||
(7) -> H
|
|
||||||
}
|
|
||||||
Tuple9 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
(5) -> F
|
|
||||||
(6) -> G
|
|
||||||
(7) -> H
|
|
||||||
(8) -> I
|
|
||||||
}
|
|
||||||
Tuple10 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
(5) -> F
|
|
||||||
(6) -> G
|
|
||||||
(7) -> H
|
|
||||||
(8) -> I
|
|
||||||
(9) -> J
|
|
||||||
}
|
|
||||||
Tuple11 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
(5) -> F
|
|
||||||
(6) -> G
|
|
||||||
(7) -> H
|
|
||||||
(8) -> I
|
|
||||||
(9) -> J
|
|
||||||
(10) -> K
|
|
||||||
}
|
|
||||||
Tuple12 {
|
|
||||||
(0) -> A
|
|
||||||
(1) -> B
|
|
||||||
(2) -> C
|
|
||||||
(3) -> D
|
|
||||||
(4) -> E
|
|
||||||
(5) -> F
|
|
||||||
(6) -> G
|
|
||||||
(7) -> H
|
|
||||||
(8) -> I
|
|
||||||
(9) -> J
|
|
||||||
(10) -> K
|
|
||||||
(11) -> L
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue