Update some macro tests

This commit is contained in:
Ingvar Stepanyan 2018-01-24 19:25:57 +00:00
parent c750442e04
commit 9318b4d2cf
3 changed files with 33 additions and 22 deletions

View File

@ -97,7 +97,7 @@ fn execute() -> i32 {
}
macro_rules! print_usage {
($print:ident, $opts:ident, $reason:expr) => ({
($print: ident, $opts: ident, $reason: expr) => ({
let msg = format!("{}\nusage: cargo fmt [options]", $reason);
$print!(
"{}\nThis utility formats all bin and lib files of the current crate using rustfmt. \

View File

@ -1,5 +1,6 @@
macro_rules! test {
($($t:tt)*) => {}
($($t: tt)*) => {
};
}
fn main() {

View File

@ -141,7 +141,8 @@ fn issue_1555() {
fn issue1178() {
macro_rules! foo {
(#[$attr:meta] $name:ident) => {}
(#[$attr: meta] $name: ident) => {
};
}
foo!(
@ -246,11 +247,15 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
// #878
macro_rules! try_opt {
($expr:expr) => (match $expr {
Some(val) => val,
($expr: expr) => {
match $expr {
Some(val) => val,
None => { return None; }
})
None => {
return None;
}
}
};
}
// #2214
@ -885,24 +890,29 @@ fn macro_in_pattern_position() {
};
}
macro foo() {
}
pub macro bar($x: ident + $y: expr;) {
fn foo($x: Foo) {
long_function(
a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),
$x.bar($y),
);
macro foo {
() => {
}
}
macro foo() {
// a comment
fn foo() {
// another comment
bar();
pub macro bar {
($x: ident + $y: expr;) => {
fn foo($x: Foo) {
long_function(
a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),
$x.bar($y),
);
}
}
}
macro foo {
() => {
// a comment
fn foo() {
// another comment
bar();
}
}
}