(
is_used_twice: &mut bool,
interval_value: i64,
unit_name: &str,
location: &SourceLocation,
)
| 314 | } |
| 315 | |
| 316 | fn check_interval_value_and_unit( |
| 317 | is_used_twice: &mut bool, |
| 318 | interval_value: i64, |
| 319 | unit_name: &str, |
| 320 | location: &SourceLocation, |
| 321 | ) -> Result<(), Box<Diagnostic>> { |
| 322 | if !*is_used_twice { |
| 323 | *is_used_twice = true; |
| 324 | return Ok(()); |
| 325 | } |
| 326 | |
| 327 | if !(-INTERVAL_MAX_VALUE..=INTERVAL_MAX_VALUE).contains(&interval_value) { |
| 328 | return Err(Diagnostic::error(&format!( |
| 329 | "Interval value for unit `{unit_name}` is out of the range", |
| 330 | )) |
| 331 | .add_help("Interval value must be in range from -170_000_000 to 170_000_000") |
| 332 | .with_location(*location) |
| 333 | .as_boxed()); |
| 334 | } |
| 335 | |
| 336 | Err(Diagnostic::error(&format!( |
| 337 | "Can't use the same interval unit `{unit_name}` twice", |
| 338 | )) |
| 339 | .with_location(*location) |
| 340 | .as_boxed()) |
| 341 | } |
| 342 | |
| 343 | #[cfg(test)] |
| 344 | mod tests { |
no test coverage detected
searching dependent graphs…