Skip to content

Commit 7671253

Browse files
powerboat9CohenArthur
authored andcommitted
Remove direct error on macro rule count-related match failure
gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::match_repetition): Remove redundant rust_error_at call. gcc/testsuite/ChangeLog: * rust/compile/macro6.rs: Remove check for direct error. * rust/compile/macro7.rs: Likewise. * rust/compile/macro-issue2229.rs: New test. Signed-off-by: Owen Avery <[email protected]>
1 parent b028c7e commit 7671253

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

gcc/rust/expand/rust-macro-expand.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,6 @@ MacroExpander::match_repetition (Parser<MacroInvocLexer> &parser,
694694
gcc_unreachable ();
695695
}
696696

697-
if (!res)
698-
rust_error_at (rep.get_match_locus (),
699-
"invalid amount of matches for macro invocation. Expected "
700-
"between %s and %s, got %lu",
701-
lo_str.c_str (), hi_str.c_str (),
702-
(unsigned long) match_amount);
703-
704697
rust_debug_loc (rep.get_match_locus (), "%s matched %lu times",
705698
res ? "successfully" : "unsuccessfully",
706699
(unsigned long) match_amount);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
macro_rules! foo {
2+
($(+)+) => {e};
3+
() => {}
4+
}
5+
6+
foo!();

gcc/testsuite/rust/compile/macro6.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
macro_rules! zero_or_one {
2-
($($a:literal)?) => { // { dg-error "invalid amount of matches for macro invocation. Expected between 0 and 1, got 2" }
2+
($($a:literal)?) => {
33
f();
44
}
55
}

gcc/testsuite/rust/compile/macro7.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn f() {}
22

33
macro_rules! one_or_more {
4-
($($a:literal)+) => { // { dg-error "invalid amount of matches for macro invocation" }
4+
($($a:literal)+) => {
55
f();
66
};
77
}

0 commit comments

Comments
 (0)