]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #6271 : pnkfelix/rust/issue6009-condition-pub-priv-variants, r=graydon
authorbors <bors@rust-lang.org>
Tue, 7 May 2013 12:06:39 +0000 (05:06 -0700)
committerbors <bors@rust-lang.org>
Tue, 7 May 2013 12:06:39 +0000 (05:06 -0700)
@brson: r?  [please ignore the other one that was accidentally based off master due to back-button-bugs in github.com]

My goal is to resolve the question of whether we want to encourage (by example) consistent use of pub to make identifiers publicly-accessible, even in syntax extensions. (If people don't want that, then we can just let this pull request die.)

This is part one of two. Part two, whose contents should be clear from the FIXME's in this commit, would land after this gets incorporated into a snapshot.

(The eventual goal is to address issue #6009 , which was implied by my choice of branch name, but not mentioned in the pull request, so github did not notice it.)

1  2 
src/libsyntax/ext/expand.rs

index 0f2ad4cd54a3da7dacda4c9e33bc6e974ec0e23c,b1267ee7578169f0f91cdd4e11893c335d83db59..68c74c2d12b5520d448959917065d915cece69a3
@@@ -486,46 -483,25 +486,61 @@@ pub fn core_macros() -> ~str 
          )
      )
  
 +    macro_rules! assert_approx_eq (
 +        ($given:expr , $expected:expr) => (
 +            {
 +                use core::cmp::ApproxEq;
 +
 +                let given_val = $given;
 +                let expected_val = $expected;
 +                // check both directions of equality....
 +                if !(
 +                    given_val.approx_eq(&expected_val) &&
 +                    expected_val.approx_eq(&given_val)
 +                ) {
 +                    fail!(\"left: %? does not approximately equal right: %?\",
 +                          given_val, expected_val);
 +                }
 +            }
 +        );
 +        ($given:expr , $expected:expr , $epsilon:expr) => (
 +            {
 +                use core::cmp::ApproxEq;
 +
 +                let given_val = $given;
 +                let expected_val = $expected;
 +                let epsilon_val = $epsilon;
 +                // check both directions of equality....
 +                if !(
 +                    given_val.approx_eq_eps(&expected_val, &epsilon_val) &&
 +                    expected_val.approx_eq_eps(&given_val, &epsilon_val)
 +                ) {
 +                    fail!(\"left: %? does not approximately equal right: %? with epsilon: %?\",
 +                          given_val, expected_val, epsilon_val);
 +                }
 +            }
 +        )
 +    )
 +
      macro_rules! condition (
  
+         { pub $c:ident: $in:ty -> $out:ty; } => {
+             pub mod $c {
+                 fn key(_x: @::core::condition::Handler<$in,$out>) { }
+                 pub static cond :
+                     ::core::condition::Condition<'static,$in,$out> =
+                     ::core::condition::Condition {
+                         name: stringify!($c),
+                         key: key
+                     };
+             }
+         };
          { $c:ident: $in:ty -> $out:ty; } => {
  
+             // FIXME (#6009): remove mod's `pub` below once variant above lands.
              pub mod $c {
                  fn key(_x: @::core::condition::Handler<$in,$out>) { }