Skip to content

Commit 681f54f

Browse files
committed
fix filter to support & and |
1 parent b4d71ea commit 681f54f

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/librustc_mir/util/pretty.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,19 @@ pub enum PassWhere {
5757
/// where `<filter>` takes the following forms:
5858
///
5959
/// - `all` -- dump MIR for all fns, all passes, all everything
60-
/// - `substring1&substring2,...` -- `&`-separated list of substrings
61-
/// that can appear in the pass-name or the `item_path_str` for the given
62-
/// node-id. If any one of the substrings match, the data is dumped out.
60+
/// - a filter defined by a set of substrings combined with `&` and `|`
61+
/// (`&` has higher precedence). At least one of the `|`-separated groups
62+
/// must match; an `|`-separated group matches if all of its `&`-separated
63+
/// substrings are matched.
64+
///
65+
/// Example:
66+
///
67+
/// - `nll` == match if `nll` appears in the name
68+
/// - `foo & nll` == match if `foo` and `nll` both appear in the name
69+
/// - `foo & nll | typeck` == match if `foo` and `nll` both appear in the name
70+
/// or `typeck` appears in the name.
71+
/// - `foo & nll | bar & typeck` == match if `foo` and `nll` both appear in the name
72+
/// or `typeck` and `bar` both appear in the name.
6373
pub fn dump_mir<'a, 'gcx, 'tcx, F>(
6474
tcx: TyCtxt<'a, 'gcx, 'tcx>,
6575
pass_num: Option<&Display>,
@@ -104,8 +114,10 @@ pub fn dump_enabled<'a, 'gcx, 'tcx>(
104114
// see notes on #41697 below
105115
tcx.item_path_str(source.def_id)
106116
});
107-
filters.split("&").any(|filter| {
108-
filter == "all" || pass_name.contains(filter) || node_path.contains(filter)
117+
filters.split("|").any(|or_filter| {
118+
or_filter.split("&").all(|and_filter| {
119+
and_filter == "all" || pass_name.contains(and_filter) || node_path.contains(and_filter)
120+
})
109121
})
110122
}
111123

@@ -357,7 +369,8 @@ fn write_extra<'cx, 'gcx, 'tcx, F>(
357369
write: &mut Write,
358370
mut visit_op: F,
359371
) -> io::Result<()>
360-
where F: FnMut(&mut ExtraComments<'cx, 'gcx, 'tcx>)
372+
where
373+
F: FnMut(&mut ExtraComments<'cx, 'gcx, 'tcx>),
361374
{
362375
let mut extra_comments = ExtraComments {
363376
_tcx: tcx,

0 commit comments

Comments
 (0)