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]
This commit is contained in:
committed by
Jorge Aparicio
parent
c0b2885ee1
commit
ddb2466f6a
@@ -522,15 +522,15 @@ fn test_double_ended_chain() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let ys = [7i, 9, 11];
|
||||
let mut it = xs.iter().chain(ys.iter()).rev();
|
||||
assert_eq!(it.next().unwrap(), &11)
|
||||
assert_eq!(it.next().unwrap(), &9)
|
||||
assert_eq!(it.next_back().unwrap(), &1)
|
||||
assert_eq!(it.next_back().unwrap(), &2)
|
||||
assert_eq!(it.next_back().unwrap(), &3)
|
||||
assert_eq!(it.next_back().unwrap(), &4)
|
||||
assert_eq!(it.next_back().unwrap(), &5)
|
||||
assert_eq!(it.next_back().unwrap(), &7)
|
||||
assert_eq!(it.next_back(), None)
|
||||
assert_eq!(it.next().unwrap(), &11);
|
||||
assert_eq!(it.next().unwrap(), &9);
|
||||
assert_eq!(it.next_back().unwrap(), &1);
|
||||
assert_eq!(it.next_back().unwrap(), &2);
|
||||
assert_eq!(it.next_back().unwrap(), &3);
|
||||
assert_eq!(it.next_back().unwrap(), &4);
|
||||
assert_eq!(it.next_back().unwrap(), &5);
|
||||
assert_eq!(it.next_back().unwrap(), &7);
|
||||
assert_eq!(it.next_back(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -800,7 +800,7 @@ fn test_min_max() {
|
||||
#[test]
|
||||
fn test_min_max_result() {
|
||||
let r: MinMaxResult<int> = NoElements;
|
||||
assert_eq!(r.into_option(), None)
|
||||
assert_eq!(r.into_option(), None);
|
||||
|
||||
let r = OneElement(1i);
|
||||
assert_eq!(r.into_option(), Some((1,1)));
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
int_module!(i16, i16)
|
||||
int_module!(i16, i16);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
int_module!(i32, i32)
|
||||
int_module!(i32, i32);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
int_module!(i64, i64)
|
||||
int_module!(i64, i64);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
int_module!(i8, i8)
|
||||
int_module!(i8, i8);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
int_module!(int, int)
|
||||
int_module!(int, int);
|
||||
|
||||
@@ -202,4 +202,4 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
))
|
||||
));
|
||||
|
||||
@@ -62,9 +62,9 @@ mod test {
|
||||
let s : Option<i16> = from_str_radix("80000", 10);
|
||||
assert_eq!(s, None);
|
||||
let f : Option<f32> = from_str_radix("10000000000000000000000000000000000000000", 10);
|
||||
assert_eq!(f, Some(Float::infinity()))
|
||||
assert_eq!(f, Some(Float::infinity()));
|
||||
let fe : Option<f32> = from_str_radix("1e40", 10);
|
||||
assert_eq!(fe, Some(Float::infinity()))
|
||||
assert_eq!(fe, Some(Float::infinity()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
uint_module!(u16, u16)
|
||||
uint_module!(u16, u16);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
uint_module!(u32, u32)
|
||||
uint_module!(u32, u32);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
uint_module!(u64, u64)
|
||||
uint_module!(u64, u64);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
uint_module!(u8, u8)
|
||||
uint_module!(u8, u8);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
uint_module!(uint, uint)
|
||||
uint_module!(uint, uint);
|
||||
|
||||
@@ -124,4 +124,4 @@ mod tests {
|
||||
assert!(5u.checked_div(0) == None);
|
||||
}
|
||||
}
|
||||
))
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user