Allow configuring whether can errors are acceptable in tests

This commit is contained in:
Ayaz Hafiz 2023-04-12 13:53:39 -05:00
parent 73e5a9ed46
commit b33393ca39
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 62 additions and 5 deletions

View file

@ -256,7 +256,6 @@ fn parse_queries(src: &str, line_info: &LineInfo) -> Vec<TypeQuery> {
pub struct InferOptions {
pub print_can_decls: bool,
pub print_only_under_alias: bool,
pub allow_errors: bool,
pub no_promote: bool,
}
@ -348,6 +347,7 @@ pub fn infer_queries<'a>(
src: &str,
dependencies: impl IntoIterator<Item = (&'a str, &'a str)>,
options: InferOptions,
allow_can_errors: bool,
) -> Result<InferredProgram, Box<dyn Error>> {
let (
LoadedModule {
@ -369,11 +369,11 @@ pub fn infer_queries<'a>(
let can_problems = can_problems.remove(&home).unwrap_or_default();
let type_problems = type_problems.remove(&home).unwrap_or_default();
if !options.allow_errors {
{
let (can_problems, type_problems) =
format_problems(&src, home, &interns, can_problems, type_problems);
if !can_problems.is_empty() {
if !can_problems.is_empty() && !allow_can_errors {
return Err(format!("Canonicalization problems: {can_problems}",).into());
}
if !type_problems.is_empty() {