Skip to content
Permalink
Browse files

librustc: Always parse `macro!()`/`macro![]` as expressions if not

followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]
  • Loading branch information
pcwalton authored and Jorge Aparicio committed Dec 18, 2014
1 parent c0b2885 commit ddb2466f6a1bb66f22824334022a4cee61c73bdc
Showing with 2,338 additions and 2,047 deletions.
  1. +17 −17 src/doc/guide-macros.md
  2. +1 −1 src/etc/regex-match-tests.py
  3. +9 −9 src/libcollections/bit.rs
  4. +13 −13 src/libcollections/enum_set.rs
  5. +3 −2 src/libcollections/macros.rs
  6. +1 −1 src/libcollections/slice.rs
  7. +4 −4 src/libcollections/str.rs
  8. +3 −3 src/libcollections/string.rs
  9. +6 −6 src/libcollections/tree/map.rs
  10. +2 −2 src/libcollections/trie/map.rs
  11. +5 −5 src/libcollections/vec.rs
  12. +4 −4 src/libcollections/vec_map.rs
  13. +28 −28 src/libcore/clone.rs
  14. +14 −12 src/libcore/cmp.rs
  15. +18 −17 src/libcore/default.rs
  16. +10 −8 src/libcore/fmt/mod.rs
  17. +25 −25 src/libcore/fmt/num.rs
  18. +26 −26 src/libcore/hash/mod.rs
  19. +6 −6 src/libcore/hash/sip.rs
  20. +25 −25 src/libcore/iter.rs
  21. +20 −19 src/libcore/macros.rs
  22. +3 −2 src/libcore/num/float_macros.rs
  23. +1 −1 src/libcore/num/i16.rs
  24. +1 −1 src/libcore/num/i32.rs
  25. +1 −1 src/libcore/num/i64.rs
  26. +1 −1 src/libcore/num/i8.rs
  27. +2 −2 src/libcore/num/int.rs
  28. +3 −2 src/libcore/num/int_macros.rs
  29. +138 −138 src/libcore/num/mod.rs
  30. +1 −1 src/libcore/num/u16.rs
  31. +1 −1 src/libcore/num/u32.rs
  32. +1 −1 src/libcore/num/u64.rs
  33. +1 −1 src/libcore/num/u8.rs
  34. +1 −1 src/libcore/num/uint.rs
  35. +3 −2 src/libcore/num/uint_macros.rs
  36. +69 −69 src/libcore/ops.rs
  37. +7 −7 src/libcore/ptr.rs
  38. +1 −1 src/libcore/result.rs
  39. +9 −9 src/libcore/slice.rs
  40. +17 −17 src/libcore/str.rs
  41. +10 −10 src/libcoretest/iter.rs
  42. +1 −1 src/libcoretest/num/i16.rs
  43. +1 −1 src/libcoretest/num/i32.rs
  44. +1 −1 src/libcoretest/num/i64.rs
  45. +1 −1 src/libcoretest/num/i8.rs
  46. +1 −1 src/libcoretest/num/int.rs
  47. +1 −1 src/libcoretest/num/int_macros.rs
  48. +2 −2 src/libcoretest/num/mod.rs
  49. +1 −1 src/libcoretest/num/u16.rs
  50. +1 −1 src/libcoretest/num/u32.rs
  51. +1 −1 src/libcoretest/num/u64.rs
  52. +1 −1 src/libcoretest/num/u8.rs
  53. +1 −1 src/libcoretest/num/uint.rs
  54. +1 −1 src/libcoretest/num/uint_macros.rs
  55. +5 −3 src/liblog/lib.rs
  56. +13 −12 src/liblog/macros.rs
  57. +1 −1 src/librand/isaac.rs
  58. +2 −2 src/librand/rand_impls.rs
  59. +2 −2 src/librbml/lib.rs
  60. +14 −12 src/libregex/parse.rs
  61. +14 −14 src/libregex/test/bench.rs
  62. +349 −349 src/libregex/test/matches.rs
  63. +2 −2 src/libregex/test/mod.rs
  64. +112 −112 src/libregex/test/tests.rs
  65. +4 −4 src/librustc/diagnostics.rs
  66. +1 −1 src/librustc/lib.rs
  67. +205 −82 src/librustc/lint/builtin.rs
  68. +9 −9 src/librustc/lint/context.rs
  69. +6 −6 src/librustc/lint/mod.rs
  70. +1 −1 src/librustc/metadata/tyencode.rs
  71. +1 −1 src/librustc/middle/const_eval.rs
  72. +2 −2 src/librustc/middle/expr_use_visitor.rs
  73. +3 −3 src/librustc/middle/infer/error_reporting.rs
  74. +2 −2 src/librustc/middle/mem_categorization.rs
  75. +8 −8 src/librustc/middle/ty.rs
  76. +5 −4 src/librustc/middle/weak_lang_items.rs
  77. +9 −9 src/librustc/session/config.rs
  78. +3 −3 src/librustc_back/sha2.rs
  79. +6 −3 src/librustc_back/svh.rs
  80. +3 −3 src/librustc_back/target/mod.rs
  81. +2 −2 src/librustc_borrowck/borrowck/mod.rs
  82. +1 −1 src/librustc_llvm/lib.rs
  83. +2 −2 src/librustc_trans/trans/_match.rs
  84. +1 −1 src/librustc_trans/trans/adt.rs
  85. +5 −3 src/librustc_trans/trans/base.rs
  86. +3 −3 src/librustc_trans/trans/context.rs
  87. +1 −1 src/librustc_trans/trans/datum.rs
  88. +2 −2 src/librustc_trans/trans/debuginfo.rs
  89. +4 −4 src/librustc_trans/trans/macros.rs
  90. +2 −2 src/librustc_trans/trans/type_.rs
  91. +2 −2 src/librustc_trans/trans/value.rs
  92. +2 −2 src/librustc_typeck/check/regionck.rs
  93. +6 −4 src/librustc_typeck/diagnostics.rs
  94. +1 −1 src/librustdoc/html/format.rs
  95. +3 −3 src/librustdoc/html/markdown.rs
  96. +2 −2 src/librustdoc/html/render.rs
  97. +1 −1 src/librustdoc/lib.rs
  98. +8 −8 src/librustrt/macros.rs
  99. +1 −1 src/libserialize/base64.rs
  100. +21 −21 src/libserialize/json.rs
  101. +6 −4 src/libserialize/serialize.rs
  102. +8 −8 src/libstd/ascii.rs
  103. +1 −1 src/libstd/collections/hash/map.rs
  104. +188 −188 src/libstd/comm/mod.rs
  105. +80 −80 src/libstd/comm/select.rs
  106. +5 −3 src/libstd/failure.rs
  107. +2 −2 src/libstd/io/extensions.rs
  108. +4 −4 src/libstd/io/fs.rs
  109. +2 −2 src/libstd/io/net/ip.rs
  110. +5 −3 src/libstd/io/stdio.rs
  111. +47 −45 src/libstd/macros.rs
  112. +2 −2 src/libstd/num/f32.rs
  113. +2 −2 src/libstd/num/f64.rs
  114. +2 −2 src/libstd/num/float_macros.rs
  115. +1 −1 src/libstd/num/i16.rs
  116. +1 −1 src/libstd/num/i32.rs
  117. +1 −1 src/libstd/num/i64.rs
  118. +1 −1 src/libstd/num/i8.rs
  119. +1 −1 src/libstd/num/int.rs
  120. +2 −2 src/libstd/num/int_macros.rs
  121. +18 −18 src/libstd/num/mod.rs
  122. +1 −1 src/libstd/num/u16.rs
  123. +1 −1 src/libstd/num/u32.rs
  124. +1 −1 src/libstd/num/u64.rs
  125. +1 −1 src/libstd/num/u8.rs
  126. +1 −1 src/libstd/num/uint.rs
  127. +2 −2 src/libstd/num/uint_macros.rs
  128. +21 −21 src/libstd/path/posix.rs
  129. +21 −21 src/libstd/path/windows.rs
  130. +1 −1 src/libstd/rand/mod.rs
  131. +9 −6 src/libstd/rt/backtrace.rs
  132. +2 −2 src/libstd/sys/unix/mod.rs
  133. +1 −1 src/libstd/sys/unix/process.rs
  134. +1 −1 src/libstd/sys/unix/timer.rs
  135. +6 −6 src/libstd/sys/windows/c.rs
  136. +2 −2 src/libstd/sys/windows/mod.rs
  137. +1 −1 src/libstd/sys/windows/timer.rs
  138. +16 −16 src/libstd/thread_local/mod.rs
  139. +9 −9 src/libstd/thread_local/scoped.rs
  140. +2 −2 src/libstd/time/duration.rs
  141. +15 −2 src/libsyntax/ast.rs
  142. +14 −10 src/libsyntax/ast_util.rs
  143. +2 −2 src/libsyntax/attr.rs
  144. +1 −1 src/libsyntax/codemap.rs
  145. +16 −15 src/libsyntax/diagnostics/macros.rs
  146. +10 −6 src/libsyntax/diagnostics/plugin.rs
  147. +32 −31 src/libsyntax/ext/expand.rs
  148. +2 −2 src/libsyntax/ext/mtwt.rs
  149. +61 −61 src/libsyntax/ext/quote.rs
  150. +3 −3 src/libsyntax/fold.rs
  151. +108 −43 src/libsyntax/parse/parser.rs
  152. +1 −1 src/libsyntax/parse/token.rs
  153. +29 −13 src/libsyntax/print/pprust.rs
  154. +1 −1 src/libterm/terminfo/parser/compiled.rs
  155. +2 −2 src/libtest/stats.rs
  156. +2 −4 src/test/auxiliary/lint_group_plugin_test.rs
  157. +1 −2 src/test/auxiliary/lint_plugin_test.rs
  158. +3 −3 src/test/auxiliary/lint_stability.rs
  159. +1 −1 src/test/auxiliary/macro_crate_def_only.rs
  160. +2 −2 src/test/auxiliary/macro_crate_test.rs
  161. +1 −1 src/test/auxiliary/macro_export_inner_module.rs
  162. +1 −1 src/test/bench/core-std.rs
  163. +1 −1 src/test/compile-fail/const-block-non-item-statement.rs
  164. +1 −1 src/test/compile-fail/gated-macro-rules.rs
  165. +1 −1 src/test/compile-fail/infinite-macro-expansion.rs
  166. +1 −1 src/test/compile-fail/issue-19734.rs
  167. +1 −1 src/test/compile-fail/issue-6596.rs
  168. +1 −1 src/test/compile-fail/liveness-return-last-stmt-semi.rs
  169. +2 −2 src/test/compile-fail/macro-incomplete-parse.rs
  170. +3 −3 src/test/compile-fail/macro-inner-attributes.rs
  171. +1 −1 src/test/compile-fail/macro-local-data-key-priv.rs
  172. +1 −1 src/test/compile-fail/macro-match-nonterminal.rs
  173. +3 −3 src/test/compile-fail/macro-outer-attributes.rs
  174. +3 −2 src/test/compile-fail/{macro-invocation-dot-help.rs → macros-no-semicolon-items.rs}
  175. +16 −0 src/test/compile-fail/macros-no-semicolon.rs
  176. +9 −9 src/test/compile-fail/method-macro-backtrace.rs
  177. +1 −1 src/test/compile-fail/{pattern-macro-hygeine.rs → pattern-macro-hygiene.rs}
  178. +13 −13 src/test/compile-fail/recursion_limit.rs
  179. +10 −10 src/test/debuginfo/lexical-scope-with-macro.rs
  180. +1 −1 src/test/run-pass-fulldeps/issue_16723_multiple_items_syntax_ext.rs
  181. +2 −2 src/test/run-pass/cleanup-rvalue-scopes.rs
  182. +1 −1 src/test/run-pass/const-binops.rs
  183. +1 −1 src/test/run-pass/core-run-destroy.rs
  184. +2 −2 src/test/run-pass/deriving-in-macro.rs
  185. +6 −6 src/test/run-pass/exponential-notation.rs
  186. +2 −2 src/test/run-pass/html-literals.rs
  187. +1 −1 src/test/run-pass/ifmt.rs
  188. +1 −1 src/test/run-pass/intrinsics-math.rs
  189. +1 −1 src/test/run-pass/issue-15189.rs
  190. +2 −2 src/test/run-pass/issue-15221.rs
  191. +1 −1 src/test/run-pass/issue-5060.rs
  192. +2 −2 src/test/run-pass/issue-7911.rs
  193. +4 −4 src/test/run-pass/issue-8709.rs
  194. +2 −2 src/test/run-pass/issue-8851.rs
  195. +2 −2 src/test/run-pass/issue-9110.rs
  196. +1 −1 src/test/run-pass/issue-9129.rs
  197. +1 −1 src/test/run-pass/let-var-hygiene.rs
  198. +2 −2 src/test/run-pass/log_syntax-trace_macros-macro-locations.rs
  199. +2 −2 src/test/run-pass/macro-2.rs
  200. +2 −2 src/test/run-pass/macro-attribute-expansion.rs
  201. +1 −1 src/test/run-pass/macro-attributes.rs
  202. +14 −0 src/test/run-pass/macro-delimiter-significance.rs
  203. +1 −1 src/test/run-pass/macro-include-items.rs
  204. +2 −1 src/test/run-pass/macro-interpolation.rs
  205. +2 −1 src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs
  206. +2 −2 src/test/run-pass/macro-meta-items.rs
  207. +1 −1 src/test/run-pass/macro-method-issue-4621.rs
  208. +2 −2 src/test/run-pass/macro-multiple-items.rs
  209. +2 −2 src/test/run-pass/macro-nt-list.rs
  210. +2 −2 src/test/run-pass/macro-of-higher-order.rs
  211. +5 −5 src/test/run-pass/macro-pat.rs
  212. +3 −3 src/test/run-pass/macro-stmt.rs
  213. +2 −2 src/test/run-pass/macro-with-attrs1.rs
  214. +2 −2 src/test/run-pass/macro-with-attrs2.rs
  215. +1 −1 src/test/run-pass/macro-with-braces-in-expr-position.rs
  216. +1 −1 src/test/run-pass/match-in-macro.rs
  217. +1 −1 src/test/run-pass/non-built-in-quote.rs
  218. +4 −4 src/test/run-pass/overloaded-index-assoc-list.rs
  219. +16 −16 src/test/run-pass/slice-2.rs
  220. +1 −1 src/test/run-pass/syntax-extension-source-utils.rs
  221. +2 −2 src/test/run-pass/typeck-macro-interaction-issue-8852.rs
  222. +1 −1 src/test/run-pass/vec-macro-with-brackets.rs
@@ -58,7 +58,7 @@ macro_rules! early_return(
_ => {}
}
);
)
);
// ...
early_return!(input_1 T::SpecialA);
// ...
@@ -179,8 +179,8 @@ macro_rules! early_return(
)+
_ => {}
}
);
)
)
);
// ...
early_return!(input_1, [T::SpecialA|T::SpecialC|T::SpecialD]);
// ...
@@ -275,17 +275,17 @@ macro_rules! biased_match (
_ => { $err }
};
)
)
);
# enum T1 { Good1(T2, uint), Bad1}
# struct T2 { body: T3 }
# enum T3 { Good2(uint), Bad2}
# fn f(x: T1) -> uint {
biased_match!((x) ~ (T1::Good1(g1, val)) else { return 0 };
binds g1, val )
binds g1, val );
biased_match!((g1.body) ~ (T3::Good2(result) )
else { panic!("Didn't get good_2") };
binds result )
binds result );
// complicated stuff goes here
return result + val;
# }
@@ -303,7 +303,7 @@ pattern we want is clear:
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
binds $( $bind_res:ident ),*
)
# => (0))
# => (0));
~~~~

However, it's not possible to directly expand to nested match statements. But
@@ -323,7 +323,7 @@ input patterns:
# #![feature(macro_rules)]
# macro_rules! b(
( binds $( $bind_res:ident ),* )
# => (0))
# => (0));
# fn main() {}
~~~~

@@ -337,7 +337,7 @@ input patterns:
$( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
binds $( $bind_res:ident ),*
)
# => (0))
# => (0));
~~~~

The resulting macro looks like this. Note that the separation into
@@ -366,7 +366,7 @@ macro_rules! biased_match_rec (
);
// Produce the requested values
( binds $( $bind_res:ident ),* ) => ( ($( $bind_res ),*) )
)
);
// Wrap the whole thing in a `let`.
macro_rules! biased_match (
@@ -388,7 +388,7 @@ macro_rules! biased_match (
binds $( $bind_res ),*
);
)
)
);
# enum T1 { Good1(T2, uint), Bad1}
@@ -398,7 +398,7 @@ macro_rules! biased_match (
biased_match!(
(x) ~ (T1::Good1(g1, val)) else { return 0 };
(g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get Good2") };
binds val, result )
binds val, result );
// complicated stuff goes here
return result + val;
# }
@@ -444,7 +444,7 @@ macro_rules! loop_x (
$e
}
);
)
);
fn main() {
'x: loop {
@@ -482,30 +482,30 @@ An example:

```rust
# #![feature(macro_rules)]
macro_rules! m1 (() => (()))
macro_rules! m1 (() => (()));
// visible here: m1
mod foo {
// visible here: m1
#[macro_export]
macro_rules! m2 (() => (()))
macro_rules! m2 (() => (()));
// visible here: m1, m2
}
// visible here: m1
macro_rules! m3 (() => (()))
macro_rules! m3 (() => (()));
// visible here: m1, m3
#[macro_escape]
mod bar {
// visible here: m1, m3
macro_rules! m4 (() => (()))
macro_rules! m4 (() => (()));
// visible here: m1, m3, m4
}
@@ -63,7 +63,7 @@ def read_tests(f):
def test_tostr(t):
lineno, pat, text, groups = t
options = map(group_tostr, groups)
return 'mat!(match_%s, r"%s", r"%s", %s)' \
return 'mat!{match_%s, r"%s", r"%s", %s}' \
% (lineno, pat, '' if text == "NULL" else text, ', '.join(options))


@@ -2083,7 +2083,7 @@ mod tests {
let bools = vec![true, false, true, true];
let bitv: Bitv = bools.iter().map(|n| *n).collect();

assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools)
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools);

let long = Vec::from_fn(10000, |i| i % 2 == 0);
let bitv: Bitv = long.iter().map(|n| *n).collect();
@@ -2112,8 +2112,8 @@ mod tests {
for &b in bools.iter() {
for &l in lengths.iter() {
let bitset = BitvSet::from_bitv(Bitv::with_capacity(l, b));
assert_eq!(bitset.contains(&1u), b)
assert_eq!(bitset.contains(&(l-1u)), b)
assert_eq!(bitset.contains(&1u), b);
assert_eq!(bitset.contains(&(l-1u)), b);
assert!(!bitset.contains(&l))
}
}
@@ -2321,12 +2321,12 @@ mod tests {
assert!(!a.is_disjoint(&d));
assert!(!d.is_disjoint(&a));

assert!(a.is_disjoint(&b))
assert!(a.is_disjoint(&c))
assert!(b.is_disjoint(&a))
assert!(b.is_disjoint(&c))
assert!(c.is_disjoint(&a))
assert!(c.is_disjoint(&b))
assert!(a.is_disjoint(&b));
assert!(a.is_disjoint(&c));
assert!(b.is_disjoint(&a));
assert!(b.is_disjoint(&c));
assert!(c.is_disjoint(&a));
assert!(c.is_disjoint(&b));
}

#[test]
@@ -411,7 +411,7 @@ mod test {

assert!(e1.is_subset(&e2));
assert!(e2.is_superset(&e1));
assert!(!e3.is_superset(&e2))
assert!(!e3.is_superset(&e2));
assert!(!e2.is_superset(&e3))
}

@@ -438,23 +438,23 @@ mod test {
let mut e1: EnumSet<Foo> = EnumSet::new();

let elems: ::vec::Vec<Foo> = e1.iter().collect();
assert!(elems.is_empty())
assert!(elems.is_empty());

e1.insert(A);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A], elems)
assert_eq!(vec![A], elems);

e1.insert(C);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A,C], elems)
assert_eq!(vec![A,C], elems);

e1.insert(C);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A,C], elems)
assert_eq!(vec![A,C], elems);

e1.insert(B);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A,B,C], elems)
assert_eq!(vec![A,B,C], elems);
}

///////////////////////////////////////////////////////////////////////////
@@ -472,35 +472,35 @@ mod test {

let e_union = e1 | e2;
let elems: ::vec::Vec<_> = e_union.iter().collect();
assert_eq!(vec![A,B,C], elems)
assert_eq!(vec![A,B,C], elems);

let e_intersection = e1 & e2;
let elems: ::vec::Vec<_> = e_intersection.iter().collect();
assert_eq!(vec![C], elems)
assert_eq!(vec![C], elems);

// Another way to express intersection
let e_intersection = e1 - (e1 - e2);
let elems: ::vec::Vec<_> = e_intersection.iter().collect();
assert_eq!(vec![C], elems)
assert_eq!(vec![C], elems);

let e_subtract = e1 - e2;
let elems: ::vec::Vec<_> = e_subtract.iter().collect();
assert_eq!(vec![A], elems)
assert_eq!(vec![A], elems);

// Bitwise XOR of two sets, aka symmetric difference
let e_symmetric_diff = e1 ^ e2;
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)
assert_eq!(vec![A,B], elems);

// Another way to express symmetric difference
let e_symmetric_diff = (e1 - e2) | (e2 - e1);
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)
assert_eq!(vec![A,B], elems);

// Yet another way to express symmetric difference
let e_symmetric_diff = (e1 | e2) - (e1 & e2);
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)
assert_eq!(vec![A,B], elems);
}

#[test]
@@ -11,12 +11,13 @@
#![macro_escape]

/// Creates a `std::vec::Vec` containing the arguments.
macro_rules! vec(
macro_rules! vec {
($($e:expr),*) => ({
// leading _ to allow empty construction without a warning.
let mut _temp = ::vec::Vec::new();
$(_temp.push($e);)*
_temp
});
($($e:expr),+,) => (vec!($($e),+))
)
}

@@ -2515,7 +2515,7 @@ mod tests {
assert_eq!(format!("{}", x), x_str);
assert_eq!(format!("{}", x.as_slice()), x_str);
})
)
);
let empty: Vec<int> = vec![];
test_show_vec!(empty, "[]");
test_show_vec!(vec![1i], "[1]");
@@ -415,14 +415,14 @@ Section: Misc
// Return the initial codepoint accumulator for the first byte.
// The first byte is special, only want bottom 5 bits for width 2, 4 bits
// for width 3, and 3 bits for width 4
macro_rules! utf8_first_byte(
macro_rules! utf8_first_byte {
($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as u32)
)
}

// return the value of $ch updated with continuation byte $byte
macro_rules! utf8_acc_cont_byte(
macro_rules! utf8_acc_cont_byte {
($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32)
)
}

/*
Section: MaybeOwned
@@ -167,7 +167,7 @@ impl String {
subseqidx = i;
res.as_mut_vec().push_all(REPLACEMENT);
}
}))
}));

if byte < 128u8 {
// subseqidx handles this
@@ -788,8 +788,8 @@ macro_rules! impl_eq {
}
}

impl_eq!(String, &'a str)
impl_eq!(CowString<'a>, String)
impl_eq! { String, &'a str }
impl_eq! { CowString<'a>, String }

impl<'a, 'b> PartialEq<&'b str> for CowString<'a> {
#[inline]
@@ -900,7 +900,7 @@ macro_rules! define_iterator {
) => {
// private methods on the forward iterator (item!() for the
// addr_mut in the next_ return value)
item!(impl<'a, K, V> $name<'a, K, V> {
item! { impl<'a, K, V> $name<'a, K, V> {
#[inline(always)]
fn next_(&mut self, forward: bool) -> Option<(&'a K, &'a $($addr_mut)* V)> {
while !self.stack.is_empty() || !self.node.is_null() {
@@ -968,10 +968,10 @@ macro_rules! define_iterator {
self.node = ptr::RawPtr::null();
}
}
})
} }

// the forward Iterator impl.
item!(impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $name<'a, K, V> {
item! { impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $name<'a, K, V> {
/// Advances the iterator to the next node (in order) and return a
/// tuple with a reference to the key and value. If there are no
/// more nodes, return `None`.
@@ -983,10 +983,10 @@ macro_rules! define_iterator {
fn size_hint(&self) -> (uint, Option<uint>) {
(self.remaining_min, Some(self.remaining_max))
}
})
} }

// the reverse Iterator impl.
item!(impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $rev_name<'a, K, V> {
item! { impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $rev_name<'a, K, V> {
fn next(&mut self) -> Option<(&'a K, &'a $($addr_mut)* V)> {
self.iter.next_(false)
}
@@ -995,7 +995,7 @@ macro_rules! define_iterator {
fn size_hint(&self) -> (uint, Option<uint>) {
self.iter.size_hint()
}
})
} }
}
} // end of define_iterator

@@ -1141,7 +1141,7 @@ macro_rules! iterator_impl {
}
}

item!(impl<'a, T> Iterator<(uint, &'a $($mut_)* T)> for $name<'a, T> {
item! { impl<'a, T> Iterator<(uint, &'a $($mut_)* T)> for $name<'a, T> {
// you might wonder why we're not even trying to act within the
// rules, and are just manipulating raw pointers like there's no
// such thing as invalid pointers and memory unsafety. The
@@ -1213,7 +1213,7 @@ macro_rules! iterator_impl {
fn size_hint(&self) -> (uint, Option<uint>) {
(self.remaining_min, Some(self.remaining_max))
}
})
} }
}
}

7 comments on commit ddb2466

@bors

This comment has been minimized.

Copy link
Contributor

@bors bors replied Dec 18, 2014

saw approval from alexcrichton
at japaric@ddb2466

@bors

This comment has been minimized.

Copy link
Contributor

@bors bors replied Dec 18, 2014

merging japaric/rust/macro-expressions = ddb2466 into auto

@bors

This comment has been minimized.

Copy link
Contributor

@bors bors replied Dec 18, 2014

status: {"merge_sha": "f9a48492a82f805aa40d8b6fea290badbab0d1b1"}

@bors

This comment has been minimized.

Copy link
Contributor

@bors bors replied Dec 18, 2014

japaric/rust/macro-expressions = ddb2466 merged ok, testing candidate = f9a4849

@bors

This comment has been minimized.

Copy link
Contributor

@bors bors replied Dec 18, 2014

fast-forwarding master to auto = f9a4849

@bors

This comment has been minimized.

Copy link
Contributor

@bors bors replied Dec 18, 2014

fast-forwarding master to auto = f9a4849

Please sign in to comment.
You can’t perform that action at this time.