use super::ReportBuilder;
use crate::location::Span;
use ariadne::{Color, Label, Report, ReportKind};
mod fields;
mod functions;
mod generics;
mod misc;
mod mutability;
mod optional;
mod traits;
pub(in crate::reporting) use fields::{
assignment_to_immutable, enum_variant_requires_data, enum_variant_without_data, missing_field,
positional_arg_in_struct, unknown_field,
};
pub(in crate::reporting) use functions::{
ambiguous_call, cannot_infer_enum_type, extern_fn_with_body, extern_impl_with_body,
function_return_type_mismatch, no_matching_overload, regular_fn_without_body,
required_param_after_default,
};
pub(in crate::reporting) use generics::{
duplicate_generic_param, generic_arity_mismatch, generic_constraint_violation,
missing_generic_arguments, out_of_scope_type_parameter,
};
pub(in crate::reporting) use misc::{
closure_capture_escapes_local_binding, expression_depth_exceeded, internal_error,
public_closure_field, too_many_definitions, visibility_violation,
};
pub(in crate::reporting) use mutability::{mutability_mismatch, use_after_sink};
pub(in crate::reporting) use optional::{
nil_assigned_to_non_optional, optional_used_as_non_optional,
};
pub(in crate::reporting) use traits::{
missing_trait_field, missing_trait_method, trait_field_type_mismatch,
trait_method_signature_mismatch,
};
pub(in crate::reporting) fn label(
filename: &str,
span: Span,
) -> Label<(&str, std::ops::Range<usize>)> {
Label::new((filename, span.start.offset..span.end.offset)).with_color(Color::Red)
}
pub(in crate::reporting) fn report<'a>(
filename: &'a str,
span: Span,
code: &'static str,
) -> ReportBuilder<'a> {
Report::build(ReportKind::Error, filename, span.start.offset).with_code(code)
}