Run cargo update and fix resulting warnings (#159)

There were compile errors on nightly builds that should be fixed by
this.
This commit is contained in:
Tiffany Bennett 2024-03-27 21:28:54 -07:00 committed by GitHub
parent 73998b3c47
commit c33040c746
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 916 additions and 619 deletions

1483
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use std::cmp::Ord;
use std::collections::BTreeMap;
pub(crate) fn btree_merge<K: Ord + Clone, V: Clone, F: Fn(&V, &V) -> Option<V>>(

View file

@ -46,7 +46,7 @@ impl Context {
Context {
registry: Registry::default(),
temporaries: BTreeMap::new(),
now: Local.timestamp(0, 0),
now: Local.timestamp_opt(0, 0).unwrap(),
use_humanize: true,
save_previous_result: false,
previous_result: None,

View file

@ -573,7 +573,6 @@ pub fn tokens(iter: &mut Iter<'_>) -> Vec<Token> {
#[cfg(test)]
mod tests {
use super::*;
use crate::ast::Expr;
fn do_parse(s: &str) -> Expr {
let mut iter = TokenIterator::new(s).peekable();

View file

@ -9,7 +9,6 @@ use crate::output::Digits;
use chrono::{DateTime, TimeZone};
use serde_derive::Serialize;
use std::collections::BTreeMap;
use std::convert::From;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::iter::once;
use std::rc::Rc;

View file

@ -306,12 +306,12 @@ fn attempt(
)
})
.map(GenericDateTime::Timezone),
(Ok(time), Err(_)) => Ok(now.with_timezone(&tz).date().and_time(time).unwrap())
.map(GenericDateTime::Timezone),
(Ok(time), Err(_)) => {
Ok(now.with_timezone(&tz).with_time(time).unwrap()).map(GenericDateTime::Timezone)
}
(Err(_), Ok(date)) => tz
.from_local_date(&date)
.from_local_datetime(&date.and_hms_opt(0, 0, 0).unwrap())
.earliest()
.map(|x| x.and_hms(0, 0, 0))
.ok_or_else(|| {
(
"Datetime does not represent a valid moment in time".to_string(),
@ -324,7 +324,7 @@ fn attempt(
} else {
let offset = parsed
.to_fixed_offset()
.unwrap_or_else(|_| FixedOffset::east(0));
.unwrap_or_else(|_| FixedOffset::east_opt(0).unwrap());
match (time, date) {
(Ok(time), Ok(date)) => offset
.from_local_datetime(&date.and_time(time))
@ -337,12 +337,11 @@ fn attempt(
})
.map(GenericDateTime::Fixed),
(Ok(time), Err(_)) => Ok(GenericDateTime::Fixed(
now.with_timezone(&offset).date().and_time(time).unwrap(),
now.with_timezone(&offset).with_time(time).unwrap(),
)),
(Err(_), Ok(date)) => offset
.from_local_date(&date)
.from_local_datetime(&date.and_hms_opt(0, 0, 0).unwrap())
.earliest()
.map(|x| x.and_hms(0, 0, 0))
.ok_or_else(|| {
(
"Datetime does not represent a valid moment in time".to_string(),

View file

@ -13,7 +13,7 @@ use crate::output::{
};
use crate::parsing::{datetime, formula};
use crate::types::{BaseUnit, Dimensionality, GenericDateTime, Number, Numeric};
use chrono::{DateTime, FixedOffset};
use chrono::FixedOffset;
use std::collections::BTreeMap;
use std::rc::Rc;
@ -24,7 +24,7 @@ pub(crate) fn eval_expr(ctx: &Context, expr: &Expr) -> Result<Value, QueryError>
match *expr {
Expr::Unit { ref name } if name == "now" => Ok(Value::DateTime(GenericDateTime::Fixed(
DateTime::from_utc(ctx.now.naive_utc(), *ctx.now.offset()),
ctx.now.fixed_offset(),
))),
Expr::Unit { ref name } => ctx
.lookup(name)
@ -931,7 +931,7 @@ pub(crate) fn eval_query(ctx: &Context, expr: &Query) -> Result<QueryReply, Quer
)))
}
};
let top = top.with_timezone(&FixedOffset::east(off as i32));
let top = top.with_timezone(&FixedOffset::east_opt(off as i32).unwrap());
Ok(QueryReply::Date(DateReply::new(ctx, top)))
}
Query::Convert(ref top, Conversion::Timezone(tz), None, Digits::Default) => {

View file

@ -5,7 +5,7 @@
use crate::output::{Digits, NumericParts};
use crate::types::{BigInt, BigRat};
use serde_derive::{Deserialize, Serialize};
use std::cmp::{Ordering, PartialOrd};
use std::cmp::Ordering;
use std::ops::{Add, Div, Mul, Neg, Sub};
/// Number type.

View file

@ -5,7 +5,6 @@
use assert_json_diff::assert_json_eq;
use rink_core::ast::{Def, DefEntry, Expr, ExprString, Property, Query};
use rink_core::parsing::text_query;
use serde_json;
use serde_json::{json, to_value};
fn expr(input: &str) -> Expr {

View file

@ -12,7 +12,7 @@ thread_local! {
// Use a fixed time, this one is the timestamp of the first
// commit to Rink (in -04:00 originally, but use local time here
// for determinism.)
ctx.set_time(Local.from_local_datetime(&NaiveDate::from_ymd(2016, 8, 2).and_hms(15, 33, 19)).unwrap());
ctx.set_time(Local.from_local_datetime(&NaiveDate::from_ymd_opt(2016, 8, 2).unwrap().and_hms_opt(15, 33, 19).unwrap()).unwrap());
ctx.use_humanize = true;
ctx
};

View file

@ -27,6 +27,7 @@ chrono = "0.4.13"
serde = "1"
serde_derive = "1"
serde_json = "1"
serde-wasm-bindgen = "0.6"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires

View file

@ -4,11 +4,9 @@
use chrono::{Local, TimeZone};
use js_sys::Date;
use rink_core;
use rink_core::ast;
use rink_core::parsing::text_query;
use serde_derive::*;
use serde_json;
use wasm_bindgen::prelude::*;
// Use `wee_alloc` as the global allocator.
@ -61,7 +59,7 @@ impl Query {
#[wasm_bindgen(js_name = getExpr)]
pub fn get_expr(&self) -> JsValue {
JsValue::from_serde(&self.query).unwrap()
serde_wasm_bindgen::to_value(&self.query).unwrap()
}
}
@ -83,18 +81,8 @@ impl Context {
#[wasm_bindgen(js_name = setTime)]
pub fn set_time(&mut self, date: Date) {
let year = date.get_utc_full_year();
let month = date.get_utc_month() + 1;
let day = date.get_utc_date();
let hour = date.get_utc_hours();
let min = date.get_utc_minutes();
let sec = date.get_utc_seconds();
let millis = date.get_utc_milliseconds();
self.context.set_time(
Local
.ymd(year as i32, month, day)
.and_hms_milli(hour, min, sec, millis),
);
self.context
.set_time(Local.timestamp_millis_opt(date.value_of() as i64).unwrap());
}
#[wasm_bindgen(js_name = loadCurrency)]
@ -122,7 +110,7 @@ impl Context {
#[wasm_bindgen]
pub fn eval(&mut self, expr: &Query) -> JsValue {
let value = Success::from(self.context.eval_query(&expr.query));
match JsValue::from_serde(&value) {
match serde_wasm_bindgen::to_value(&value) {
Ok(value) => value,
Err(err) => format!("Failed to serialize: {}\n{:#?}", err, value).into(),
}