Skip to content

Commit 8039cb3

Browse files
committed
Test that every expr can be scanned
1 parent 0132c44 commit 8039cb3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/test_precedence.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use std::fs;
4949
use std::path::Path;
5050
use std::process;
5151
use std::sync::atomic::{AtomicUsize, Ordering};
52+
use syn::parse::Parser as _;
5253

5354
#[macro_use]
5455
mod macros;
@@ -57,7 +58,6 @@ mod common;
5758
mod repo;
5859

5960
#[path = "../src/scan_expr.rs"]
60-
#[allow(dead_code)]
6161
mod scan_expr;
6262

6363
#[test]
@@ -119,7 +119,8 @@ fn test_expressions(path: &Path, edition: Edition, exprs: Vec<syn::Expr>) -> (us
119119

120120
rustc_span::create_session_if_not_set_then(edition, |_| {
121121
for expr in exprs {
122-
let source_code = expr.to_token_stream().to_string();
122+
let expr_tokens = expr.to_token_stream();
123+
let source_code = expr_tokens.to_string();
123124
let librustc_ast = if let Some(e) = librustc_parse_and_rewrite(&source_code) {
124125
e
125126
} else {
@@ -177,6 +178,16 @@ fn test_expressions(path: &Path, edition: Edition, exprs: Vec<syn::Expr>) -> (us
177178
continue;
178179
}
179180

181+
if scan_expr::scan_expr.parse2(expr_tokens).is_err() {
182+
failed += 1;
183+
errorf!(
184+
"\nFAIL {} - failed to scan expr\n{}\n",
185+
path.display(),
186+
source_code,
187+
);
188+
continue;
189+
}
190+
180191
passed += 1;
181192
}
182193
});

0 commit comments

Comments
 (0)