Fix fallout

This commit is contained in:
Corey Richardson 2015-01-05 01:51:03 -05:00
parent 6680c9c5c7
commit e0b4287df6
7 changed files with 181 additions and 183 deletions

View File

@ -161,7 +161,7 @@ instead of `*` to mean "at least one".
# let input_1 = T::SpecialA(0);
# let input_2 = T::SpecialA(0);
macro_rules! early_return {
($inp:expr, [ $($sp:path)|+ ]) => (
($inp:expr, [ $($sp:path),+ ]) => (
match $inp {
$(
$sp(x) => { return x; }
@ -171,7 +171,7 @@ macro_rules! early_return {
)
}
// ...
early_return!(input_1, [T::SpecialA|T::SpecialC|T::SpecialD]);
early_return!(input_1, [T::SpecialA,T::SpecialC,T::SpecialD]);
// ...
early_return!(input_2, [T::SpecialB]);
# return 0;
@ -245,7 +245,7 @@ can solve the problem:
~~~~
macro_rules! biased_match {
// special case: `let (x) = ...` is illegal, so use `let x = ...` instead
( ($e:expr) ~ ($p:pat) else $err:stmt ;
( ($e:expr) -> ($p:pat) else $err:stmt ;
binds $bind_res:ident
) => (
let $bind_res = match $e {
@ -254,7 +254,7 @@ macro_rules! biased_match {
};
);
// more than one name; use a tuple
( ($e:expr) ~ ($p:pat) else $err:stmt ;
( ($e:expr) -> ($p:pat) else $err:stmt ;
binds $( $bind_res:ident ),*
) => (
let ( $( $bind_res ),* ) = match $e {
@ -268,9 +268,9 @@ macro_rules! biased_match {
# struct T2 { body: T3 }
# enum T3 { Good2(uint), Bad2}
# fn f(x: T1) -> uint {
biased_match!((x) ~ (T1::Good1(g1, val)) else { return 0 };
biased_match!((x) -> (T1::Good1(g1, val)) else { return 0 };
binds g1, val );
biased_match!((g1.body) ~ (T3::Good2(result) )
biased_match!((g1.body) -> (T3::Good2(result) )
else { panic!("Didn't get good_2") };
binds result );
// complicated stuff goes here
@ -286,7 +286,7 @@ pattern we want is clear:
~~~~
# fn main() {}
# macro_rules! b {
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
binds $( $bind_res:ident ),*
)
# => (0) }
@ -317,8 +317,8 @@ input patterns:
~~~~
# fn main() {}
# macro_rules! b {
( ($e :expr) ~ ($p :pat) else $err :stmt ;
$( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
( ($e :expr) -> ($p :pat) else $err :stmt ;
$( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
binds $( $bind_res:ident ),*
)
# => (0) }
@ -333,14 +333,14 @@ piece of syntax (the `let`) which we only want to transcribe once.
macro_rules! biased_match_rec {
// Handle the first layer
( ($e :expr) ~ ($p :pat) else $err :stmt ;
$( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
( ($e :expr) -> ($p :pat) else $err :stmt ;
$( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
binds $( $bind_res:ident ),*
) => (
match $e {
$p => {
// Recursively handle the next layer
biased_match_rec!($( ($e_rest) ~ ($p_rest) else $err_rest ; )*
biased_match_rec!($( ($e_rest) -> ($p_rest) else $err_rest ; )*
binds $( $bind_res ),*
)
}
@ -354,20 +354,20 @@ macro_rules! biased_match_rec {
// Wrap the whole thing in a `let`.
macro_rules! biased_match {
// special case: `let (x) = ...` is illegal, so use `let x = ...` instead
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
binds $bind_res:ident
) => (
let $bind_res = biased_match_rec!(
$( ($e) ~ ($p) else $err ; )*
$( ($e) -> ($p) else $err ; )*
binds $bind_res
);
);
// more than one name: use a tuple
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
binds $( $bind_res:ident ),*
) => (
let ( $( $bind_res ),* ) = biased_match_rec!(
$( ($e) ~ ($p) else $err ; )*
$( ($e) -> ($p) else $err ; )*
binds $( $bind_res ),*
);
)
@ -379,8 +379,8 @@ macro_rules! biased_match {
# enum T3 { Good2(uint), Bad2}
# fn f(x: T1) -> uint {
biased_match!(
(x) ~ (T1::Good1(g1, val)) else { return 0 };
(g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get Good2") };
(x) -> (T1::Good1(g1, val)) else { return 0 };
(g1.body) -> (T3::Good2(result) ) else { panic!("Didn't get Good2") };
binds val, result );
// complicated stuff goes here
return result + val;

View File

@ -35,9 +35,8 @@ use slice::{self, SliceExt};
use uint;
macro_rules! delegate_iter {
(exact $te:ty in $ti:ty) => {
delegate_iter!{$te in $ti}
#[stable]
(exact $te:ty : $ti:ty) => {
delegate_iter!{$te : $ti}
impl<'a> ExactSizeIterator for $ti {
#[inline]
fn len(&self) -> uint {
@ -45,7 +44,7 @@ macro_rules! delegate_iter {
}
}
};
($te:ty in $ti:ty) => {
($te:ty : $ti:ty) => {
#[stable]
impl<'a> Iterator for $ti {
type Item = $te;
@ -67,7 +66,7 @@ macro_rules! delegate_iter {
}
}
};
(pattern $te:ty in $ti:ty) => {
(pattern $te:ty : $ti:ty) => {
#[stable]
impl<'a, P: CharEq> Iterator for $ti {
type Item = $te;
@ -89,7 +88,7 @@ macro_rules! delegate_iter {
}
}
};
(pattern forward $te:ty in $ti:ty) => {
(pattern forward $te:ty : $ti:ty) => {
#[stable]
impl<'a, P: CharEq> Iterator for $ti {
type Item = $te;
@ -415,7 +414,7 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> {
#[stable]
#[derive(Clone)]
pub struct Bytes<'a>(Map<&'a u8, u8, slice::Iter<'a, u8>, BytesDeref>);
delegate_iter!{exact u8 in Bytes<'a>}
delegate_iter!{exact u8 : Bytes<'a>}
/// A temporary fn new type that ensures that the `Bytes` iterator
/// is cloneable.
@ -1165,25 +1164,25 @@ impl<'a, S: ?Sized> Str for &'a S where S: Str {
#[derive(Clone)]
#[stable]
pub struct Split<'a, P>(CharSplits<'a, P>);
delegate_iter!{pattern &'a str in Split<'a, P>}
delegate_iter!{pattern &'a str : Split<'a, P>}
/// Return type of `StrExt::split_terminator`
#[derive(Clone)]
#[unstable = "might get removed in favour of a constructor method on Split"]
pub struct SplitTerminator<'a, P>(CharSplits<'a, P>);
delegate_iter!{pattern &'a str in SplitTerminator<'a, P>}
delegate_iter!{pattern &'a str : SplitTerminator<'a, P>}
/// Return type of `StrExt::splitn`
#[derive(Clone)]
#[stable]
pub struct SplitN<'a, P>(CharSplitsN<'a, P>);
delegate_iter!{pattern forward &'a str in SplitN<'a, P>}
delegate_iter!{pattern forward &'a str : SplitN<'a, P>}
/// Return type of `StrExt::rsplitn`
#[derive(Clone)]
#[stable]
pub struct RSplitN<'a, P>(CharSplitsN<'a, P>);
delegate_iter!{pattern forward &'a str in RSplitN<'a, P>}
delegate_iter!{pattern forward &'a str : RSplitN<'a, P>}
/// Methods for string slices
#[allow(missing_docs)]

View File

@ -737,7 +737,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef> {
macro_rules! ifn {
($name:expr fn() -> $ret:expr) => (
($name:expr, fn() -> $ret:expr) => (
if *key == $name {
let f = base::decl_cdecl_fn(
ccx, $name, Type::func(&[], &$ret),
@ -746,7 +746,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
return Some(f);
}
);
($name:expr fn($($arg:expr),*) -> $ret:expr) => (
($name:expr, fn($($arg:expr),*) -> $ret:expr) => (
if *key == $name {
let f = base::decl_cdecl_fn(ccx, $name,
Type::func(&[$($arg),*], &$ret), ty::mk_nil(ccx.tcx()));
@ -769,111 +769,111 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
let t_f32 = Type::f32(ccx);
let t_f64 = Type::f64(ccx);
ifn!("llvm.memcpy.p0i8.p0i8.i32" fn(i8p, i8p, t_i32, t_i32, i1) -> void);
ifn!("llvm.memcpy.p0i8.p0i8.i64" fn(i8p, i8p, t_i64, t_i32, i1) -> void);
ifn!("llvm.memmove.p0i8.p0i8.i32" fn(i8p, i8p, t_i32, t_i32, i1) -> void);
ifn!("llvm.memmove.p0i8.p0i8.i64" fn(i8p, i8p, t_i64, t_i32, i1) -> void);
ifn!("llvm.memset.p0i8.i32" fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
ifn!("llvm.memset.p0i8.i64" fn(i8p, t_i8, t_i64, t_i32, i1) -> void);
ifn!("llvm.memcpy.p0i8.p0i8.i32", fn(i8p, i8p, t_i32, t_i32, i1) -> void);
ifn!("llvm.memcpy.p0i8.p0i8.i64", fn(i8p, i8p, t_i64, t_i32, i1) -> void);
ifn!("llvm.memmove.p0i8.p0i8.i32", fn(i8p, i8p, t_i32, t_i32, i1) -> void);
ifn!("llvm.memmove.p0i8.p0i8.i64", fn(i8p, i8p, t_i64, t_i32, i1) -> void);
ifn!("llvm.memset.p0i8.i32", fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
ifn!("llvm.memset.p0i8.i64", fn(i8p, t_i8, t_i64, t_i32, i1) -> void);
ifn!("llvm.trap" fn() -> void);
ifn!("llvm.debugtrap" fn() -> void);
ifn!("llvm.frameaddress" fn(t_i32) -> i8p);
ifn!("llvm.trap", fn() -> void);
ifn!("llvm.debugtrap", fn() -> void);
ifn!("llvm.frameaddress", fn(t_i32) -> i8p);
ifn!("llvm.powi.f32" fn(t_f32, t_i32) -> t_f32);
ifn!("llvm.powi.f64" fn(t_f64, t_i32) -> t_f64);
ifn!("llvm.pow.f32" fn(t_f32, t_f32) -> t_f32);
ifn!("llvm.pow.f64" fn(t_f64, t_f64) -> t_f64);
ifn!("llvm.powi.f32", fn(t_f32, t_i32) -> t_f32);
ifn!("llvm.powi.f64", fn(t_f64, t_i32) -> t_f64);
ifn!("llvm.pow.f32", fn(t_f32, t_f32) -> t_f32);
ifn!("llvm.pow.f64", fn(t_f64, t_f64) -> t_f64);
ifn!("llvm.sqrt.f32" fn(t_f32) -> t_f32);
ifn!("llvm.sqrt.f64" fn(t_f64) -> t_f64);
ifn!("llvm.sin.f32" fn(t_f32) -> t_f32);
ifn!("llvm.sin.f64" fn(t_f64) -> t_f64);
ifn!("llvm.cos.f32" fn(t_f32) -> t_f32);
ifn!("llvm.cos.f64" fn(t_f64) -> t_f64);
ifn!("llvm.exp.f32" fn(t_f32) -> t_f32);
ifn!("llvm.exp.f64" fn(t_f64) -> t_f64);
ifn!("llvm.exp2.f32" fn(t_f32) -> t_f32);
ifn!("llvm.exp2.f64" fn(t_f64) -> t_f64);
ifn!("llvm.log.f32" fn(t_f32) -> t_f32);
ifn!("llvm.log.f64" fn(t_f64) -> t_f64);
ifn!("llvm.log10.f32" fn(t_f32) -> t_f32);
ifn!("llvm.log10.f64" fn(t_f64) -> t_f64);
ifn!("llvm.log2.f32" fn(t_f32) -> t_f32);
ifn!("llvm.log2.f64" fn(t_f64) -> t_f64);
ifn!("llvm.sqrt.f32", fn(t_f32) -> t_f32);
ifn!("llvm.sqrt.f64", fn(t_f64) -> t_f64);
ifn!("llvm.sin.f32", fn(t_f32) -> t_f32);
ifn!("llvm.sin.f64", fn(t_f64) -> t_f64);
ifn!("llvm.cos.f32", fn(t_f32) -> t_f32);
ifn!("llvm.cos.f64", fn(t_f64) -> t_f64);
ifn!("llvm.exp.f32", fn(t_f32) -> t_f32);
ifn!("llvm.exp.f64", fn(t_f64) -> t_f64);
ifn!("llvm.exp2.f32", fn(t_f32) -> t_f32);
ifn!("llvm.exp2.f64", fn(t_f64) -> t_f64);
ifn!("llvm.log.f32", fn(t_f32) -> t_f32);
ifn!("llvm.log.f64", fn(t_f64) -> t_f64);
ifn!("llvm.log10.f32", fn(t_f32) -> t_f32);
ifn!("llvm.log10.f64", fn(t_f64) -> t_f64);
ifn!("llvm.log2.f32", fn(t_f32) -> t_f32);
ifn!("llvm.log2.f64", fn(t_f64) -> t_f64);
ifn!("llvm.fma.f32" fn(t_f32, t_f32, t_f32) -> t_f32);
ifn!("llvm.fma.f64" fn(t_f64, t_f64, t_f64) -> t_f64);
ifn!("llvm.fma.f32", fn(t_f32, t_f32, t_f32) -> t_f32);
ifn!("llvm.fma.f64", fn(t_f64, t_f64, t_f64) -> t_f64);
ifn!("llvm.fabs.f32" fn(t_f32) -> t_f32);
ifn!("llvm.fabs.f64" fn(t_f64) -> t_f64);
ifn!("llvm.fabs.f32", fn(t_f32) -> t_f32);
ifn!("llvm.fabs.f64", fn(t_f64) -> t_f64);
ifn!("llvm.floor.f32" fn(t_f32) -> t_f32);
ifn!("llvm.floor.f64" fn(t_f64) -> t_f64);
ifn!("llvm.ceil.f32" fn(t_f32) -> t_f32);
ifn!("llvm.ceil.f64" fn(t_f64) -> t_f64);
ifn!("llvm.trunc.f32" fn(t_f32) -> t_f32);
ifn!("llvm.trunc.f64" fn(t_f64) -> t_f64);
ifn!("llvm.floor.f32", fn(t_f32) -> t_f32);
ifn!("llvm.floor.f64", fn(t_f64) -> t_f64);
ifn!("llvm.ceil.f32", fn(t_f32) -> t_f32);
ifn!("llvm.ceil.f64", fn(t_f64) -> t_f64);
ifn!("llvm.trunc.f32", fn(t_f32) -> t_f32);
ifn!("llvm.trunc.f64", fn(t_f64) -> t_f64);
ifn!("llvm.rint.f32" fn(t_f32) -> t_f32);
ifn!("llvm.rint.f64" fn(t_f64) -> t_f64);
ifn!("llvm.nearbyint.f32" fn(t_f32) -> t_f32);
ifn!("llvm.nearbyint.f64" fn(t_f64) -> t_f64);
ifn!("llvm.rint.f32", fn(t_f32) -> t_f32);
ifn!("llvm.rint.f64", fn(t_f64) -> t_f64);
ifn!("llvm.nearbyint.f32", fn(t_f32) -> t_f32);
ifn!("llvm.nearbyint.f64", fn(t_f64) -> t_f64);
ifn!("llvm.ctpop.i8" fn(t_i8) -> t_i8);
ifn!("llvm.ctpop.i16" fn(t_i16) -> t_i16);
ifn!("llvm.ctpop.i32" fn(t_i32) -> t_i32);
ifn!("llvm.ctpop.i64" fn(t_i64) -> t_i64);
ifn!("llvm.ctpop.i8", fn(t_i8) -> t_i8);
ifn!("llvm.ctpop.i16", fn(t_i16) -> t_i16);
ifn!("llvm.ctpop.i32", fn(t_i32) -> t_i32);
ifn!("llvm.ctpop.i64", fn(t_i64) -> t_i64);
ifn!("llvm.ctlz.i8" fn(t_i8 , i1) -> t_i8);
ifn!("llvm.ctlz.i16" fn(t_i16, i1) -> t_i16);
ifn!("llvm.ctlz.i32" fn(t_i32, i1) -> t_i32);
ifn!("llvm.ctlz.i64" fn(t_i64, i1) -> t_i64);
ifn!("llvm.ctlz.i8", fn(t_i8 , i1) -> t_i8);
ifn!("llvm.ctlz.i16", fn(t_i16, i1) -> t_i16);
ifn!("llvm.ctlz.i32", fn(t_i32, i1) -> t_i32);
ifn!("llvm.ctlz.i64", fn(t_i64, i1) -> t_i64);
ifn!("llvm.cttz.i8" fn(t_i8 , i1) -> t_i8);
ifn!("llvm.cttz.i16" fn(t_i16, i1) -> t_i16);
ifn!("llvm.cttz.i32" fn(t_i32, i1) -> t_i32);
ifn!("llvm.cttz.i64" fn(t_i64, i1) -> t_i64);
ifn!("llvm.cttz.i8", fn(t_i8 , i1) -> t_i8);
ifn!("llvm.cttz.i16", fn(t_i16, i1) -> t_i16);
ifn!("llvm.cttz.i32", fn(t_i32, i1) -> t_i32);
ifn!("llvm.cttz.i64", fn(t_i64, i1) -> t_i64);
ifn!("llvm.bswap.i16" fn(t_i16) -> t_i16);
ifn!("llvm.bswap.i32" fn(t_i32) -> t_i32);
ifn!("llvm.bswap.i64" fn(t_i64) -> t_i64);
ifn!("llvm.bswap.i16", fn(t_i16) -> t_i16);
ifn!("llvm.bswap.i32", fn(t_i32) -> t_i32);
ifn!("llvm.bswap.i64", fn(t_i64) -> t_i64);
ifn!("llvm.sadd.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.sadd.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.sadd.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.sadd.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.sadd.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.sadd.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.sadd.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.sadd.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.uadd.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.uadd.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.uadd.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.uadd.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.uadd.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.uadd.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.uadd.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.uadd.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.ssub.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.ssub.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.ssub.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.ssub.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.ssub.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.ssub.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.ssub.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.ssub.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.usub.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.usub.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.usub.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.usub.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.usub.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.usub.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.usub.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.usub.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.smul.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.smul.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.smul.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.smul.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.smul.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.smul.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.smul.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.smul.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.umul.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.umul.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.umul.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.umul.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.umul.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
ifn!("llvm.umul.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
ifn!("llvm.umul.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
ifn!("llvm.umul.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
ifn!("llvm.lifetime.start" fn(t_i64,i8p) -> void);
ifn!("llvm.lifetime.end" fn(t_i64, i8p) -> void);
ifn!("llvm.lifetime.start", fn(t_i64,i8p) -> void);
ifn!("llvm.lifetime.end", fn(t_i64, i8p) -> void);
ifn!("llvm.expect.i1" fn(i1, i1) -> i1);
ifn!("llvm.assume" fn(i1) -> void);
ifn!("llvm.expect.i1", fn(i1, i1) -> i1);
ifn!("llvm.assume", fn(i1) -> void);
// Some intrinsics were introduced in later versions of LLVM, but they have
// fallbacks in libc or libm and such. Currently, all of these intrinsics
@ -882,7 +882,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr) => (
if unsafe { llvm::LLVMVersionMinor() >= 4 } {
// The `if key == $name` is already in ifn!
ifn!($name fn($($arg),*) -> $ret);
ifn!($name, fn($($arg),*) -> $ret);
} else if *key == $name {
let f = base::decl_cdecl_fn(ccx, stringify!($cname),
Type::func(&[$($arg),*], &$ret),
@ -900,8 +900,8 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
if ccx.sess().opts.debuginfo != NoDebugInfo {
ifn!("llvm.dbg.declare" fn(Type::metadata(ccx), Type::metadata(ccx)) -> void);
ifn!("llvm.dbg.value" fn(Type::metadata(ccx), t_i64, Type::metadata(ccx)) -> void);
ifn!("llvm.dbg.declare", fn(Type::metadata(ccx), Type::metadata(ccx)) -> void);
ifn!("llvm.dbg.value", fn(Type::metadata(ccx), t_i64, Type::metadata(ccx)) -> void);
}
return None;
}

View File

@ -88,7 +88,7 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
while rest.len() > 0 {
if rest.starts_with("$") {
macro_rules! demangle {
($($pat:expr => $demangled:expr),*) => ({
($($pat:expr, => $demangled:expr),*) => ({
$(if rest.starts_with($pat) {
try!(writer.write_str($demangled));
rest = rest.slice_from($pat.len());
@ -103,22 +103,22 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
// see src/librustc/back/link.rs for these mappings
demangle! (
"$SP$" => "@",
"$UP$" => "Box",
"$RP$" => "*",
"$BP$" => "&",
"$LT$" => "<",
"$GT$" => ">",
"$LP$" => "(",
"$RP$" => ")",
"$C$" => ",",
"$SP$", => "@",
"$UP$", => "Box",
"$RP$", => "*",
"$BP$", => "&",
"$LT$", => "<",
"$GT$", => ">",
"$LP$", => "(",
"$RP$", => ")",
"$C$", => ",",
// in theory we can demangle any Unicode code point, but
// for simplicity we just catch the common ones.
"$u{20}" => " ",
"$u{27}" => "'",
"$u{5b}" => "[",
"$u{5d}" => "]"
"$u{20}", => " ",
"$u{27}", => "'",
"$u{5b}", => "[",
"$u{5d}", => "]"
)
} else {
let idx = match rest.find('$') {

View File

@ -9,18 +9,18 @@
// except according to those terms.
macro_rules! errors_everywhere {
($ty:ty <) => () //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments
($ty:ty < foo ,) => () //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
($ty:ty , ) => ()
( ( $ty:ty ) ) => ()
( { $ty:ty } ) => ()
( [ $ty:ty ] ) => ()
($bl:block < ) => ()
($pa:pat >) => () //~ ERROR `$pa:pat` is followed by `>` which is not allowed for `pat`
($pa:pat , ) => ()
($pa:pat | ) => ()
($pa:pat $pb:pat $ty:ty ,) => ()
($($ty:ty)-+) => () //~ ERROR `$ty:ty` is followed by `-` which is not allowed for `ty`
($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
($ty:ty , ) => ();
( ( $ty:ty ) ) => ();
( { $ty:ty } ) => ();
( [ $ty:ty ] ) => ();
($bl:block < ) => ();
($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat`
($pa:pat , ) => ();
($pa:pat | ) => (); //~ ERROR `$pa:pat` is followed by `|`
($pa:pat $pb:pat $ty:ty ,) => ();
($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty`
}
fn main() { }

View File

@ -29,7 +29,7 @@ fn odd(x: uint) -> bool { x % 2 == 1 }
fn dummy_rng() -> DummyRng { DummyRng::new_unseeded() }
macro_rules! tests {
($($expr:expr: $ty:ty /($($test:expr),*);)+) => (pub fn main() {$({
($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({
const C: $ty = $expr;
static S: $ty = $expr;
assert!(eq(C($($test),*), $expr($($test),*)));
@ -40,45 +40,44 @@ macro_rules! tests {
tests! {
// Free function.
id: fn(int) -> int /(5);
id::<int>: fn(int) -> int /(5);
id, fn(int) -> int, (5);
id::<int>, fn(int) -> int, (5);
// Enum variant constructor.
Some: fn(int) -> Option<int> /(5);
Some::<int>: fn(int) -> Option<int> /(5);
Some, fn(int) -> Option<int>, (5);
Some::<int>, fn(int) -> Option<int>, (5);
// Tuple struct constructor.
Newt: fn(int) -> Newt<int> /(5);
Newt::<int>: fn(int) -> Newt<int> /(5);
Newt, fn(int) -> Newt<int>, (5);
Newt::<int>, fn(int) -> Newt<int>, (5);
// Inherent static methods.
Vec::new: fn() -> Vec<()> /();
Vec::<()>::new: fn() -> Vec<()> /();
Vec::with_capacity: fn(uint) -> Vec<()> /(5);
Vec::<()>::with_capacity: fn(uint) -> Vec<()> /(5);
Bitv::from_fn: fn(uint, fn(uint) -> bool) -> Bitv /(5, odd);
Bitv::from_fn::<fn(uint) -> bool>: fn(uint, fn(uint) -> bool) -> Bitv /(5, odd);
Vec::new, fn() -> Vec<()>, ();
Vec::<()>::new, fn() -> Vec<()>, ();
Vec::with_capacity, fn(uint) -> Vec<()>, (5);
Vec::<()>::with_capacity, fn(uint) -> Vec<()>, (5);
Bitv::from_fn, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
Bitv::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
// Inherent non-static method.
Vec::map_in_place: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
/(vec![b'f', b'o', b'o'], u8_as_i8);
Vec::map_in_place::<i8, fn(u8) -> i8>: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
/(vec![b'f', b'o', b'o'], u8_as_i8);
Vec::map_in_place, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>, (vec![b'f', b'o', b'o'], u8_as_i8);
Vec::map_in_place::<i8, fn(u8) -> i8>, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>,
(vec![b'f', b'o', b'o'], u8_as_i8);
// FIXME these break with "type parameter might not appear here pointing at `<u8>`.
// Vec::<u8>::map_in_place: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
// /(vec![b'f', b'o', b'o'], u8_as_i8);
// , (vec![b'f', b'o', b'o'], u8_as_i8);
// Vec::<u8>::map_in_place::<i8, fn(u8) -> i8>: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
// /(vec![b'f', b'o', b'o'], u8_as_i8);
// , (vec![b'f', b'o', b'o'], u8_as_i8);
// Trait static methods.
// FIXME qualified path expressions aka UFCS i.e. <T as Trait>::method.
Default::default: fn() -> int /();
Rand::rand: fn(&mut DummyRng) -> int /(&mut dummy_rng());
Rand::rand::<DummyRng>: fn(&mut DummyRng) -> int /(&mut dummy_rng());
Default::default, fn() -> int, ();
Rand::rand, fn(&mut DummyRng) -> int, (&mut dummy_rng());
Rand::rand::<DummyRng>, fn(&mut DummyRng) -> int, (&mut dummy_rng());
// Trait non-static methods.
Clone::clone: fn(&int) -> int /(&5);
FromIterator::from_iter: fn(OptionIter<int>) -> Vec<int> /(Some(5).into_iter());
FromIterator::from_iter::<OptionIter<int>>: fn(OptionIter<int>) -> Vec<int>
/(Some(5).into_iter());
Clone::clone, fn(&int) -> int, (&5);
FromIterator::from_iter, fn(OptionIter<int>) -> Vec<int>, (Some(5).into_iter());
FromIterator::from_iter::<OptionIter<int>>, fn(OptionIter<int>) -> Vec<int>
, (Some(5).into_iter());
}

View File

@ -35,10 +35,10 @@ impl<T> E<T> {
}
macro_rules! check_option {
($e:expr: $T:ty) => {{
check_option!($e: $T, |ptr| assert!(*ptr == $e));
($e:expr, $T:ty) => {{
check_option!($e, $T, |ptr| assert!(*ptr == $e));
}};
($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
($e:expr, $T:ty, |$v:ident| $chk:expr) => {{
assert!(option::Option::None::<$T>.is_none());
let e = $e;
let s_ = option::Option::Some::<$T>(e);
@ -48,10 +48,10 @@ macro_rules! check_option {
}
macro_rules! check_fancy {
($e:expr: $T:ty) => {{
check_fancy!($e: $T, |ptr| assert!(*ptr == $e));
($e:expr, $T:ty) => {{
check_fancy!($e, $T, |ptr| assert!(*ptr == $e));
}};
($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
($e:expr, $T:ty, |$v:ident| $chk:expr) => {{
assert!(E::Nothing::<$T>((), ((), ()), [23i8; 0]).is_none());
let e = $e;
let t_ = E::Thing::<$T>(23, e);
@ -71,12 +71,12 @@ macro_rules! check_type {
}
pub fn main() {
check_type!(&17: &int);
check_type!(box 18: Box<int>);
check_type!("foo".to_string(): String);
check_type!(vec!(20, 22): Vec<int> );
check_type!(&17, &int);
check_type!(box 18, Box<int>);
check_type!("foo".to_string(), String);
check_type!(vec!(20, 22), Vec<int> );
let mint: uint = unsafe { mem::transmute(main) };
check_type!(main: fn(), |pthing| {
check_type!(main, fn(), |pthing| {
assert!(mint == unsafe { mem::transmute(*pthing) })
});
}