Skip to content

Commit

Permalink
Fix doc comment for location merging
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux#1785
  • Loading branch information
treiher committed Nov 4, 2024
1 parent 403ee0b commit 44177b8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion librapidflux/src/diagnostics/locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Location {
///
/// # Panics
///
/// This function panics if not all locations refer to the same source file.
/// This function will panic if attempting to merge locations with and without a source file.
pub fn merge(locations: &[Self]) -> Option<Self> {
assert!(
locations
Expand Down Expand Up @@ -403,6 +403,21 @@ Third",
],
None,
)]
#[case::location_merge_unknown(
&[
Location {
start: FilePosition::new(1, 4),
end: FilePosition::new(1, 10),
source: Some(PathBuf::from_str("bar.rflx").expect("failed to create path"))
},
UNKNOWN_LOCATION.clone(),
],
Some(Location {
start: FilePosition::new(1, 4),
end: FilePosition::new(1, 10),
source: Some(PathBuf::from_str("bar.rflx").expect("failed to create path"))
}),
)]
#[case::location_no_elements(&[], None)]
fn test_location_merge(#[case] locations: &[Location], #[case] expected: Option<Location>) {
assert_eq!(Location::merge(locations), expected);
Expand Down

0 comments on commit 44177b8

Please sign in to comment.