@@ -32,10 +32,7 @@ pub enum ValidationError {
3232 /// A key primitive is invalid (empty or too long).
3333 InvalidPrimitive ( String ) ,
3434 /// The repo name does not match the expected derived name.
35- RepoNameMismatch {
36- expected : String ,
37- actual : String ,
38- } ,
35+ RepoNameMismatch { expected : String , actual : String } ,
3936 /// The compilation target is unusual for the paradigm (warning-level).
4037 UnusualTarget {
4138 paradigm : Paradigm ,
@@ -49,7 +46,10 @@ impl std::fmt::Display for ValidationError {
4946 ValidationError :: InvalidLanguageName ( name) => {
5047 write ! ( f, "Invalid language name: '{}'" , name)
5148 }
52- ValidationError :: IncompatibleTypeSystem { paradigm, type_system } => {
49+ ValidationError :: IncompatibleTypeSystem {
50+ paradigm,
51+ type_system,
52+ } => {
5353 write ! (
5454 f,
5555 "Type system '{}' is incompatible with paradigm '{}'" ,
@@ -110,7 +110,11 @@ pub fn validate_language_description(manifest: &Manifest) -> ValidationReport {
110110 // 1. Language name: must be non-empty, ASCII alphanumeric + hyphens
111111 if model. name . is_empty ( ) {
112112 errors. push ( ValidationError :: InvalidLanguageName ( model. name . clone ( ) ) ) ;
113- } else if !model. name . chars ( ) . all ( |c| c. is_ascii_alphanumeric ( ) || c == '-' || c == '+' ) {
113+ } else if !model
114+ . name
115+ . chars ( )
116+ . all ( |c| c. is_ascii_alphanumeric ( ) || c == '-' || c == '+' )
117+ {
114118 errors. push ( ValidationError :: InvalidLanguageName ( model. name . clone ( ) ) ) ;
115119 }
116120
@@ -145,10 +149,7 @@ pub fn validate_language_description(manifest: &Manifest) -> ValidationReport {
145149/// - "logic" paradigm with "none" type system is technically valid
146150/// but unusual (most logic languages have types)
147151/// - "array" paradigm with "dependent" types is uncommon
148- fn check_paradigm_type_compatibility (
149- model : & LanguageModel ,
150- _errors : & mut Vec < ValidationError > ,
151- ) {
152+ fn check_paradigm_type_compatibility ( model : & LanguageModel , _errors : & mut Vec < ValidationError > ) {
152153 // Currently all combinations are valid. This function is a hook
153154 // for future constraints as the -iser ecosystem grows.
154155 // The Idris2 ABI proofs handle the hard constraints at compile time;
@@ -158,10 +159,7 @@ fn check_paradigm_type_compatibility(
158159
159160/// Check that the paradigm and target are consistent.
160161/// Flags unusual but not impossible combinations as warnings.
161- fn check_paradigm_target_consistency (
162- model : & LanguageModel ,
163- warnings : & mut Vec < ValidationError > ,
164- ) {
162+ fn check_paradigm_target_consistency ( model : & LanguageModel , warnings : & mut Vec < ValidationError > ) {
165163 // Logic languages on GPU is unusual
166164 if model. paradigm == Paradigm :: Logic && model. compilation_target == CompilationTarget :: Gpu {
167165 warnings. push ( ValidationError :: UnusualTarget {
@@ -184,7 +182,10 @@ pub fn validate_or_bail(manifest: &Manifest) -> Result<ValidationReport> {
184182 let report = validate_language_description ( manifest) ;
185183 if !report. is_valid ( ) {
186184 let msgs: Vec < String > = report. errors . iter ( ) . map ( |e| e. to_string ( ) ) . collect ( ) ;
187- anyhow:: bail!( "Language description validation failed:\n {}" , msgs. join( "\n " ) ) ;
185+ anyhow:: bail!(
186+ "Language description validation failed:\n {}" ,
187+ msgs. join( "\n " )
188+ ) ;
188189 }
189190 Ok ( report)
190191}
@@ -281,6 +282,11 @@ description = "Prolog -iser"
281282 let m = parse_manifest ( toml) . unwrap ( ) ;
282283 let report = validate_language_description ( & m) ;
283284 assert ! ( report. is_valid( ) ) ;
284- assert ! ( report. warnings. iter( ) . any( |w| matches!( w, ValidationError :: UnusualTarget { .. } ) ) ) ;
285+ assert ! (
286+ report
287+ . warnings
288+ . iter( )
289+ . any( |w| matches!( w, ValidationError :: UnusualTarget { .. } ) )
290+ ) ;
285291 }
286292}
0 commit comments