summaryrefslogtreecommitdiffstats
path: root/vendor/time/src/lib.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
commite02c5b5930c2c9ba3e5423fe12e2ef0155017297 (patch)
treefd60ebbbb5299e16e5fca8c773ddb74f764760db /vendor/time/src/lib.rs
parentAdding debian version 1.73.0+dfsg1-1. (diff)
downloadrustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.tar.xz
rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/time/src/lib.rs')
-rw-r--r--vendor/time/src/lib.rs231
1 files changed, 2 insertions, 229 deletions
diff --git a/vendor/time/src/lib.rs b/vendor/time/src/lib.rs
index 2ab59cf8e..110c28648 100644
--- a/vendor/time/src/lib.rs
+++ b/vendor/time/src/lib.rs
@@ -76,55 +76,7 @@
#![doc(html_playground_url = "https://play.rust-lang.org")]
#![cfg_attr(__time_03_docs, feature(doc_auto_cfg, doc_notable_trait))]
-#![cfg_attr(coverage_nightly, feature(no_coverage))]
#![cfg_attr(not(feature = "std"), no_std)]
-#![deny(
- anonymous_parameters,
- clippy::all,
- clippy::alloc_instead_of_core,
- clippy::explicit_auto_deref,
- clippy::obfuscated_if_else,
- clippy::std_instead_of_core,
- clippy::undocumented_unsafe_blocks,
- illegal_floating_point_literal_pattern,
- late_bound_lifetime_arguments,
- path_statements,
- patterns_in_fns_without_body,
- rust_2018_idioms,
- trivial_casts,
- trivial_numeric_casts,
- unreachable_pub,
- unsafe_op_in_unsafe_fn,
- unused_extern_crates,
- rustdoc::broken_intra_doc_links,
- rustdoc::private_intra_doc_links
-)]
-#![warn(
- clippy::dbg_macro,
- clippy::decimal_literal_representation,
- clippy::get_unwrap,
- clippy::missing_docs_in_private_items,
- clippy::nursery,
- clippy::print_stdout,
- clippy::todo,
- clippy::unimplemented,
- clippy::uninlined_format_args,
- clippy::unnested_or_patterns,
- clippy::unwrap_in_result,
- clippy::unwrap_used,
- clippy::use_debug,
- deprecated_in_future,
- missing_copy_implementations,
- missing_debug_implementations,
- unused_qualifications,
- variant_size_differences
-)]
-#![allow(
- clippy::redundant_pub_crate, // suggests bad style
- clippy::option_if_let_else, // suggests terrible code
- clippy::unused_peekable, // temporary due to bug: remove when Rust 1.66 is released
- clippy::std_instead_of_core, // temporary due to bug: remove when Rust 1.66 is released
-)]
#![doc(html_favicon_url = "https://avatars0.githubusercontent.com/u/55999857")]
#![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/55999857")]
#![doc(test(attr(deny(warnings))))]
@@ -133,185 +85,6 @@
#[cfg(feature = "alloc")]
extern crate alloc;
-// TODO(jhpratt) remove this after a while
-#[cfg(unsound_local_offset)]
-compile_error!(
- "The `unsound_local_offset` flag was removed in time 0.3.18. If you need this functionality, \
- see the `time::util::local_offset::set_soundness` function."
-);
-
-// region: macros
-/// Helper macro for easily implementing `OpAssign`.
-macro_rules! __impl_assign {
- ($sym:tt $op:ident $fn:ident $target:ty : $($(#[$attr:meta])* $t:ty),+) => {$(
- #[allow(unused_qualifications)]
- $(#[$attr])*
- impl core::ops::$op<$t> for $target {
- fn $fn(&mut self, rhs: $t) {
- *self = *self $sym rhs;
- }
- }
- )+};
-}
-
-/// Implement `AddAssign` for the provided types.
-macro_rules! impl_add_assign {
- ($target:ty : $($(#[$attr:meta])* $t:ty),+ $(,)?) => {
- __impl_assign!(+ AddAssign add_assign $target : $($(#[$attr])* $t),+);
- };
-}
-
-/// Implement `SubAssign` for the provided types.
-macro_rules! impl_sub_assign {
- ($target:ty : $($(#[$attr:meta])* $t:ty),+ $(,)?) => {
- __impl_assign!(- SubAssign sub_assign $target : $($(#[$attr])* $t),+);
- };
-}
-
-/// Implement `MulAssign` for the provided types.
-macro_rules! impl_mul_assign {
- ($target:ty : $($(#[$attr:meta])* $t:ty),+ $(,)?) => {
- __impl_assign!(* MulAssign mul_assign $target : $($(#[$attr])* $t),+);
- };
-}
-
-/// Implement `DivAssign` for the provided types.
-macro_rules! impl_div_assign {
- ($target:ty : $($(#[$attr:meta])* $t:ty),+ $(,)?) => {
- __impl_assign!(/ DivAssign div_assign $target : $($(#[$attr])* $t),+);
- };
-}
-
-/// Division of integers, rounding the resulting value towards negative infinity.
-macro_rules! div_floor {
- ($a:expr, $b:expr) => {{
- let _a = $a;
- let _b = $b;
-
- let (_quotient, _remainder) = (_a / _b, _a % _b);
-
- if (_remainder > 0 && _b < 0) || (_remainder < 0 && _b > 0) {
- _quotient - 1
- } else {
- _quotient
- }
- }};
-}
-
-/// Cascade an out-of-bounds value.
-macro_rules! cascade {
- (@ordinal ordinal) => {};
- (@year year) => {};
-
- // Cascade an out-of-bounds value from "from" to "to".
- ($from:ident in $min:literal.. $max:expr => $to:tt) => {
- #[allow(unused_comparisons, unused_assignments)]
- let min = $min;
- let max = $max;
- if $from >= max {
- $from -= max - min;
- $to += 1;
- } else if $from < min {
- $from += max - min;
- $to -= 1;
- }
- };
-
- // Special case the ordinal-to-year cascade, as it has different behavior.
- ($ordinal:ident => $year:ident) => {
- // We need to actually capture the idents. Without this, macro hygiene causes errors.
- cascade!(@ordinal $ordinal);
- cascade!(@year $year);
- #[allow(unused_assignments)]
- if $ordinal > crate::util::days_in_year($year) as i16 {
- $ordinal -= crate::util::days_in_year($year) as i16;
- $year += 1;
- } else if $ordinal < 1 {
- $year -= 1;
- $ordinal += crate::util::days_in_year($year) as i16;
- }
- };
-}
-
-/// Returns `Err(error::ComponentRange)` if the value is not in range.
-macro_rules! ensure_value_in_range {
- ($value:ident in $start:expr => $end:expr) => {{
- let _start = $start;
- let _end = $end;
- #[allow(trivial_numeric_casts, unused_comparisons)]
- if $value < _start || $value > _end {
- return Err(crate::error::ComponentRange {
- name: stringify!($value),
- minimum: _start as _,
- maximum: _end as _,
- value: $value as _,
- conditional_range: false,
- });
- }
- }};
-
- ($value:ident conditionally in $start:expr => $end:expr) => {{
- let _start = $start;
- let _end = $end;
- #[allow(trivial_numeric_casts, unused_comparisons)]
- if $value < _start || $value > _end {
- return Err(crate::error::ComponentRange {
- name: stringify!($value),
- minimum: _start as _,
- maximum: _end as _,
- value: $value as _,
- conditional_range: true,
- });
- }
- }};
-}
-
-/// Try to unwrap an expression, returning if not possible.
-///
-/// This is similar to the `?` operator, but does not perform `.into()`. Because of this, it is
-/// usable in `const` contexts.
-macro_rules! const_try {
- ($e:expr) => {
- match $e {
- Ok(value) => value,
- Err(error) => return Err(error),
- }
- };
-}
-
-/// Try to unwrap an expression, returning if not possible.
-///
-/// This is similar to the `?` operator, but is usable in `const` contexts.
-macro_rules! const_try_opt {
- ($e:expr) => {
- match $e {
- Some(value) => value,
- None => return None,
- }
- };
-}
-
-/// Try to unwrap an expression, panicking if not possible.
-///
-/// This is similar to `$e.expect($message)`, but is usable in `const` contexts.
-macro_rules! expect_opt {
- ($e:expr, $message:literal) => {
- match $e {
- Some(value) => value,
- None => crate::expect_failed($message),
- }
- };
-}
-
-/// `unreachable!()`, but better.
-macro_rules! bug {
- () => { compile_error!("provide an error message to help fix a possible bug") };
- ($descr:literal $($rest:tt)?) => {
- panic!(concat!("internal error: ", $descr) $($rest)?)
- }
-}
-// endregion macros
-
mod date;
mod date_time;
mod duration;
@@ -323,6 +96,7 @@ pub mod format_description;
pub mod formatting;
#[cfg(feature = "std")]
mod instant;
+mod internal_macros;
#[cfg(feature = "macros")]
pub mod macros;
mod month;
@@ -345,8 +119,7 @@ mod utc_offset;
pub mod util;
mod weekday;
-// Not public yet.
-use time_core::convert;
+pub use time_core::convert;
pub use crate::date::Date;
use crate::date_time::DateTime;