use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[error("{file}:{line}:{column}")]
pub struct Location {
file: &'static str,
line: u32,
column: u32,
}
impl Location {
#[doc(hidden)]
#[deprecated(
note = "This function is not meant to be called directly. Use `nu_protocol::location` instead."
)]
pub fn new(file: &'static str, line: u32, column: u32) -> Self {
Location { file, line, column }
}
}
#[macro_export]
macro_rules! location {
() => {{
#[allow(deprecated)]
$crate::shell_error::location::Location::new(file!(), line!(), column!())
}};
}
#[test]
fn test_location_macro() {
let location = crate::location!();
let line = line!() - 1; let file = file!();
assert_eq!(location.line, line);
assert_eq!(location.file, file);
}