Skip to content

Commit d6282a1

Browse files
ehussJayflux
authored andcommitted
Fix syntax checking on --bench files. (#153)
1 parent 379305f commit d6282a1

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

SyntaxCheckPlugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ def get_rustc_messages(self, settings, file_name):
129129
for (target_src, target_args) in targets:
130130
args = ['rustc', target_args, '--',
131131
'-Zno-trans', '-Zunstable-options', '--error-format=json']
132-
if (settings.get('rust_syntax_checking_include_tests', True) and
133-
'--test' not in target_args
134-
):
135-
args.append('--test')
136-
yield (target_src, self.run_cargo(args, cwd=cwd))
132+
133+
if settings.get('rust_syntax_checking_include_tests', True):
134+
if not ('--test' in target_args or '--bench' in target_args):
135+
args.append('--test')
136+
yield (target_src, self.run_cargo(args))
137137

138138
def determine_targets(self, settings, file_name):
139139
"""Detect the target/filters needed to pass to Cargo to compile
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Can't have a regular bench because [feature(test)] is restricted
2+
// to nightly.
3+
4+
#[asdf]
5+
// ^ERR The attribute `asdf` is currently unknown
6+
fn f() {}

tests/test_syntax_check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def test_messages(self):
123123
'multi-targets/src/lmod1.rs',
124124
'multi-targets/src/altmain.rs',
125125
'multi-targets/tests/common/helpers.rs',
126+
'error-tests/benches/bench_err.rs',
126127
# "children" without spans
127128
'error-tests/tests/arg-count-mismatch.rs',
128129
# "children" with spans

0 commit comments

Comments
 (0)