File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,20 @@ fn non_debug_refs() {
104
104
assert ! ( let I ( 10 ) = & & I ( 10 ) ) ;
105
105
}
106
106
107
+ #[ test]
108
+ fn test_hygiene_bug ( ) {
109
+ // Test to see if we work around a hygiene bug in the Rust compiler.
110
+ // See https://github.com/rust-lang/rust/issues/74036
111
+ // and https://github.com/rust-lang/rust/issues/67062
112
+ macro_rules! assert_square {
113
+ ( $val: expr, $expected: expr) => { assert!( $val * $val == $expected) }
114
+ } ;
115
+
116
+ // If the hygiene bug is not fixed, this evaluates as 2 + 2 * 2 + 2 instead of (2 + 2) * (2 + ).
117
+ // So it will fail with assert!(8 == 16).
118
+ assert_square ! ( 2 + 2 , 16 ) ;
119
+ }
120
+
107
121
#[ test]
108
122
fn no_copy ( ) {
109
123
let a = String :: new ( ) ;
You can’t perform that action at this time.
0 commit comments