Skip to content

Commit 62a7aba

Browse files
committed
Allow # comments in only/ignore filters
1 parent c1b7511 commit 62a7aba

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Changed
1515

1616
* `only`/`ignore` filters now only accept integers, alphabetic characters, `-` and `_`
17+
* `only`/ `ignore` filters allow comments by ignoring everything from an `#` onwards
1718

1819
### Removed
1920

src/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ impl Condition {
306306
})).collect::<Result<Vec<_>, _>>()?;
307307
Ok(Condition::Bitwidth(bits))
308308
}
309-
"target" => Ok(Condition::Target(args.map(|arg|TargetSubStr::try_from(arg.to_owned())).collect::<Result<_, _>>()?)),
310-
"host" => Ok(Condition::Host(args.map(|arg|TargetSubStr::try_from(arg.to_owned())).collect::<Result<_, _>>()?)),
309+
"target" => Ok(Condition::Target(args.take_while(|&arg| arg != "#").map(|arg|TargetSubStr::try_from(arg.to_owned())).collect::<Result<_, _>>()?)),
310+
"host" => Ok(Condition::Host(args.take_while(|&arg| arg != "#").map(|arg|TargetSubStr::try_from(arg.to_owned())).collect::<Result<_, _>>()?)),
311311
_ => Err(format!("`{c}` is not a valid condition, expected `on-host`, /[0-9]+bit/, /host-.*/, or /target-.*/")),
312312
}
313313
}
@@ -612,7 +612,7 @@ impl CommentParser<Comments> {
612612
}
613613
Some(i) => {
614614
let (command, args) = command.split_at(i);
615-
// Commands are separated from their arguments by ':' or ' '
615+
// Commands are separated from their arguments by ':'
616616
let next = args
617617
.chars()
618618
.next()

src/parser/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn parse_x86_64() {
265265

266266
#[test]
267267
fn parse_two_only_filters() {
268-
let s = r"//@only-target: hello world";
268+
let s = r"//@only-target: hello world # some comment";
269269
let comments = Comments::parse(
270270
Spanned::new(
271271
s.as_bytes(),

0 commit comments

Comments
 (0)