Rust 1.85, edition=2024 (#15741)

This commit is contained in:
Jack Wright
2025-05-13 07:49:30 -07:00
committed by GitHub
parent 1a0986903f
commit c2ac8f730e
793 changed files with 4276 additions and 3687 deletions

View File

@@ -2,7 +2,7 @@
authors = ["The Nushell Project Developers"]
description = "Support for the NUON format."
repository = "https://github.com/nushell/nushell/tree/main/crates/nuon"
edition = "2021"
edition = "2024"
license = "MIT"
name = "nuon"
version = "0.104.1"
@@ -19,4 +19,4 @@ nu-utils = { path = "../nu-utils", version = "0.104.1", default-features = false
chrono = { workspace = true }
[lints]
workspace = true
workspace = true

View File

@@ -1,7 +1,7 @@
use nu_protocol::{
Filesize, IntoValue, Range, Record, ShellError, Span, Type, Unit, Value,
ast::{Expr, Expression, ListItem, RecordItem},
engine::{EngineState, StateWorkingSet},
Filesize, IntoValue, Range, Record, ShellError, Span, Type, Unit, Value,
};
use std::sync::Arc;
@@ -282,7 +282,7 @@ fn convert_to_value(
error: "Error when loading".into(),
msg: "only strings can be keys".into(),
span: key.span,
})
});
}
};
@@ -361,7 +361,7 @@ fn convert_to_value(
error: "Error when loading".into(),
msg: "only strings can be keys".into(),
span: expr.span,
})
});
}
};
@@ -408,7 +408,7 @@ fn convert_to_value(
error: "Error when loading".into(),
msg: "non-integer unit value".into(),
span: expr.span,
})
});
}
};

View File

@@ -3,19 +3,20 @@ mod from;
mod to;
pub use from::from_nuon;
pub use to::to_nuon;
pub use to::ToStyle;
pub use to::to_nuon;
#[cfg(test)]
mod tests {
use chrono::DateTime;
use nu_protocol::{
BlockId, IntRange, Range, Span, Value,
ast::{CellPath, PathMember, RangeInclusion},
engine::{Closure, EngineState},
record, BlockId, IntRange, Range, Span, Value,
record,
};
use crate::{from_nuon, to_nuon, ToStyle};
use crate::{ToStyle, from_nuon, to_nuon};
/// test something of the form
/// ```nushell
@@ -180,19 +181,21 @@ mod tests {
fn to_nuon_errs_on_closure() {
let engine_state = EngineState::new();
assert!(to_nuon(
&engine_state,
&Value::test_closure(Closure {
block_id: BlockId::new(0),
captures: vec![]
}),
ToStyle::Default,
None,
false,
)
.unwrap_err()
.to_string()
.contains("Unsupported input"));
assert!(
to_nuon(
&engine_state,
&Value::test_closure(Closure {
block_id: BlockId::new(0),
captures: vec![]
}),
ToStyle::Default,
None,
false,
)
.unwrap_err()
.to_string()
.contains("Unsupported input")
);
}
#[test]
@@ -325,29 +328,31 @@ mod tests {
fn to_nuon_converts_columns_with_spaces() {
let engine_state = EngineState::new();
assert!(from_nuon(
&to_nuon(
&engine_state,
&Value::test_list(vec![
Value::test_record(record!(
"a" => Value::test_int(1),
"b" => Value::test_int(2),
"c d" => Value::test_int(3)
)),
Value::test_record(record!(
"a" => Value::test_int(4),
"b" => Value::test_int(5),
"c d" => Value::test_int(6)
))
]),
ToStyle::Default,
assert!(
from_nuon(
&to_nuon(
&engine_state,
&Value::test_list(vec![
Value::test_record(record!(
"a" => Value::test_int(1),
"b" => Value::test_int(2),
"c d" => Value::test_int(3)
)),
Value::test_record(record!(
"a" => Value::test_int(4),
"b" => Value::test_int(5),
"c d" => Value::test_int(6)
))
]),
ToStyle::Default,
None,
false,
)
.unwrap(),
None,
false,
)
.unwrap(),
None,
)
.is_ok());
.is_ok()
);
}
#[test]
@@ -485,10 +490,12 @@ mod tests {
// }
// ```
fn read_code_should_fail_rather_than_panic() {
assert!(from_nuon(
include_str!("../../../tests/fixtures/formats/code.nu"),
None,
)
.is_err());
assert!(
from_nuon(
include_str!("../../../tests/fixtures/formats/code.nu"),
None,
)
.is_err()
);
}
}

View File

@@ -1,7 +1,7 @@
use core::fmt::Write;
use nu_engine::get_columns;
use nu_protocol::format::ObviousFloat;
use nu_protocol::{engine::EngineState, Range, ShellError, Span, Value};
use nu_protocol::{Range, ShellError, Span, Value, engine::EngineState};
use nu_utils::{escape_quote_string, needs_quoting};
/// control the way Nushell [`Value`] is converted to NUON data