@@ -1507,7 +1507,7 @@ mod test {
1507
1507
#[ should_fail]
1508
1508
#[ test] fn macros_cant_escape_fns_test ( ) {
1509
1509
let src = "fn bogus() {macro_rules! z (() => (3+4));}\
1510
- fn inty() -> int { z!() }". to_string ( ) ;
1510
+ fn inty() -> i32 { z!() }". to_string ( ) ;
1511
1511
let sess = parse:: new_parse_sess ( ) ;
1512
1512
let crate_ast = parse:: parse_crate_from_source_str (
1513
1513
"<test>" . to_string ( ) ,
@@ -1521,7 +1521,7 @@ mod test {
1521
1521
#[ should_fail]
1522
1522
#[ test] fn macros_cant_escape_mods_test ( ) {
1523
1523
let src = "mod foo {macro_rules! z (() => (3+4));}\
1524
- fn inty() -> int { z!() }". to_string ( ) ;
1524
+ fn inty() -> i32 { z!() }". to_string ( ) ;
1525
1525
let sess = parse:: new_parse_sess ( ) ;
1526
1526
let crate_ast = parse:: parse_crate_from_source_str (
1527
1527
"<test>" . to_string ( ) ,
@@ -1533,7 +1533,7 @@ mod test {
1533
1533
// macro_use modules should allow macros to escape
1534
1534
#[ test] fn macros_can_escape_flattened_mods_test ( ) {
1535
1535
let src = "#[macro_use] mod foo {macro_rules! z (() => (3+4));}\
1536
- fn inty() -> int { z!() }". to_string ( ) ;
1536
+ fn inty() -> i32 { z!() }". to_string ( ) ;
1537
1537
let sess = parse:: new_parse_sess ( ) ;
1538
1538
let crate_ast = parse:: parse_crate_from_source_str (
1539
1539
"<test>" . to_string ( ) ,
@@ -1564,8 +1564,8 @@ mod test {
1564
1564
// should be able to use a bound identifier as a literal in a macro definition:
1565
1565
#[ test] fn self_macro_parsing ( ) {
1566
1566
expand_crate_str (
1567
- "macro_rules! foo ((zz) => (287u ;));
1568
- fn f(zz : int ) {foo!(zz);}" . to_string ( )
1567
+ "macro_rules! foo ((zz) => (287 ;));
1568
+ fn f(zz: i32 ) {foo!(zz);}" . to_string ( )
1569
1569
) ;
1570
1570
}
1571
1571
@@ -1601,23 +1601,23 @@ mod test {
1601
1601
fn automatic_renaming ( ) {
1602
1602
let tests: Vec < RenamingTest > =
1603
1603
vec ! ( // b & c should get new names throughout, in the expr too:
1604
- ( "fn a() -> int { let b = 13; let c = b; b+c }" ,
1604
+ ( "fn a() -> i32 { let b = 13; let c = b; b+c }" ,
1605
1605
vec!( vec!( 0 , 1 ) , vec!( 2 ) ) , false ) ,
1606
1606
// both x's should be renamed (how is this causing a bug?)
1607
- ( "fn main () {let x: int = 13;x;}" ,
1607
+ ( "fn main () {let x: i32 = 13;x;}" ,
1608
1608
vec!( vec!( 0 ) ) , false ) ,
1609
1609
// the use of b after the + should be renamed, the other one not:
1610
- ( "macro_rules! f (($x:ident) => (b + $x)); fn a() -> int { let b = 13; f!(b)}" ,
1610
+ ( "macro_rules! f (($x:ident) => (b + $x)); fn a() -> i32 { let b = 13; f!(b)}" ,
1611
1611
vec!( vec!( 1 ) ) , false ) ,
1612
1612
// the b before the plus should not be renamed (requires marks)
1613
- ( "macro_rules! f (($x:ident) => ({let b=9; ($x + b)})); fn a() -> int { f!(b)}" ,
1613
+ ( "macro_rules! f (($x:ident) => ({let b=9; ($x + b)})); fn a() -> i32 { f!(b)}" ,
1614
1614
vec!( vec!( 1 ) ) , false ) ,
1615
1615
// the marks going in and out of letty should cancel, allowing that $x to
1616
1616
// capture the one following the semicolon.
1617
1617
// this was an awesome test case, and caught a *lot* of bugs.
1618
1618
( "macro_rules! letty(($x:ident) => (let $x = 15;));
1619
1619
macro_rules! user(($x:ident) => ({letty!($x); $x}));
1620
- fn main() -> int {user!(z)}" ,
1620
+ fn main() -> i32 {user!(z)}" ,
1621
1621
vec!( vec!( 0 ) ) , false )
1622
1622
) ;
1623
1623
for ( idx, s) in tests. iter ( ) . enumerate ( ) {
@@ -1680,13 +1680,13 @@ mod test {
1680
1680
// can't write this test case until we have macro-generating macros.
1681
1681
1682
1682
// method arg hygiene
1683
- // method expands to fn get_x(&self_0, x_1:int ) {self_0 + self_2 + x_3 + x_1}
1683
+ // method expands to fn get_x(&self_0, x_1: i32 ) {self_0 + self_2 + x_3 + x_1}
1684
1684
#[ test] fn method_arg_hygiene ( ) {
1685
1685
run_renaming_test (
1686
1686
& ( "macro_rules! inject_x (()=>(x));
1687
1687
macro_rules! inject_self (()=>(self));
1688
1688
struct A;
1689
- impl A{fn get_x(&self, x: int ) {self + inject_self!() + inject_x!() + x;} }" ,
1689
+ impl A{fn get_x(&self, x: i32 ) {self + inject_self!() + inject_x!() + x;} }" ,
1690
1690
vec ! ( vec!( 0 ) , vec!( 3 ) ) ,
1691
1691
true ) ,
1692
1692
0 )
@@ -1706,21 +1706,21 @@ mod test {
1706
1706
}
1707
1707
1708
1708
// item fn hygiene
1709
- // expands to fn q(x_1:int ){fn g(x_2:int ){x_2 + x_1};}
1709
+ // expands to fn q(x_1: i32 ){fn g(x_2: i32 ){x_2 + x_1};}
1710
1710
#[ test] fn issue_9383 ( ) {
1711
1711
run_renaming_test (
1712
- & ( "macro_rules! bad_macro (($ex:expr) => (fn g(x:int ){ x + $ex }));
1713
- fn q(x:int ) { bad_macro!(x); }" ,
1712
+ & ( "macro_rules! bad_macro (($ex:expr) => (fn g(x: i32 ){ x + $ex }));
1713
+ fn q(x: i32 ) { bad_macro!(x); }" ,
1714
1714
vec ! ( vec!( 1 ) , vec!( 0 ) ) , true ) ,
1715
1715
0 )
1716
1716
}
1717
1717
1718
1718
// closure arg hygiene (ExprClosure)
1719
- // expands to fn f(){(|x_1 : int | {(x_2 + x_1)})(3);}
1719
+ // expands to fn f(){(|x_1 : i32 | {(x_2 + x_1)})(3);}
1720
1720
#[ test] fn closure_arg_hygiene ( ) {
1721
1721
run_renaming_test (
1722
1722
& ( "macro_rules! inject_x (()=>(x));
1723
- fn f(){(|x : int | {(inject_x!() + x)})(3);}" ,
1723
+ fn f(){(|x : i32 | {(inject_x!() + x)})(3);}" ,
1724
1724
vec ! ( vec!( 1 ) ) ,
1725
1725
true ) ,
1726
1726
0 )
@@ -1729,7 +1729,7 @@ mod test {
1729
1729
// macro_rules in method position. Sadly, unimplemented.
1730
1730
#[ test] fn macro_in_method_posn ( ) {
1731
1731
expand_crate_str (
1732
- "macro_rules! my_method (() => (fn thirteen(&self) -> int {13}));
1732
+ "macro_rules! my_method (() => (fn thirteen(&self) -> i32 {13}));
1733
1733
struct A;
1734
1734
impl A{ my_method!(); }
1735
1735
fn f(){A.thirteen;}" . to_string ( ) ) ;
@@ -1876,7 +1876,7 @@ foo_module!();
1876
1876
// it's the name of a 0-ary variant, and that 'i' appears twice in succession.
1877
1877
#[ test]
1878
1878
fn crate_bindings_test ( ) {
1879
- let the_crate = string_to_crate ( "fn main (a : int ) -> int {|b| {
1879
+ let the_crate = string_to_crate ( "fn main (a: i32 ) -> i32 {|b| {
1880
1880
match 34 {None => 3, Some(i) | i => j, Foo{k:z,l:y} => \" banana\" }} }" . to_string ( ) ) ;
1881
1881
let idents = crate_bindings ( & the_crate) ;
1882
1882
assert_eq ! ( idents, strs_to_idents( vec!( "a" , "b" , "None" , "i" , "i" , "z" , "y" ) ) ) ;
@@ -1885,10 +1885,10 @@ foo_module!();
1885
1885
// test the IdentRenamer directly
1886
1886
#[ test]
1887
1887
fn ident_renamer_test ( ) {
1888
- let the_crate = string_to_crate ( "fn f(x : int ){let x = x; x}" . to_string ( ) ) ;
1888
+ let the_crate = string_to_crate ( "fn f(x: i32 ){let x = x; x}" . to_string ( ) ) ;
1889
1889
let f_ident = token:: str_to_ident ( "f" ) ;
1890
1890
let x_ident = token:: str_to_ident ( "x" ) ;
1891
- let int_ident = token:: str_to_ident ( "int " ) ;
1891
+ let int_ident = token:: str_to_ident ( "i32 " ) ;
1892
1892
let renames = vec ! ( ( x_ident, Name ( 16 ) ) ) ;
1893
1893
let mut renamer = IdentRenamer { renames : & renames} ;
1894
1894
let renamed_crate = renamer. fold_crate ( the_crate) ;
@@ -1900,10 +1900,10 @@ foo_module!();
1900
1900
// test the PatIdentRenamer; only PatIdents get renamed
1901
1901
#[ test]
1902
1902
fn pat_ident_renamer_test ( ) {
1903
- let the_crate = string_to_crate ( "fn f(x : int ){let x = x; x}" . to_string ( ) ) ;
1903
+ let the_crate = string_to_crate ( "fn f(x: i32 ){let x = x; x}" . to_string ( ) ) ;
1904
1904
let f_ident = token:: str_to_ident ( "f" ) ;
1905
1905
let x_ident = token:: str_to_ident ( "x" ) ;
1906
- let int_ident = token:: str_to_ident ( "int " ) ;
1906
+ let int_ident = token:: str_to_ident ( "i32 " ) ;
1907
1907
let renames = vec ! ( ( x_ident, Name ( 16 ) ) ) ;
1908
1908
let mut renamer = PatIdentRenamer { renames : & renames} ;
1909
1909
let renamed_crate = renamer. fold_crate ( the_crate) ;
0 commit comments