From 47c6baeb11feb60824cd53750bb661bc13950317 Mon Sep 17 00:00:00 2001 From: Toni Peter Date: Tue, 7 Jan 2025 21:24:26 +0100 Subject: [PATCH] Add `#![feature(generic_const_exprs)]` to doctests Some of them were missing this feature annotation but used to compile and pass for some inexplicable reason. Now this missing feature gate causes an ICE (https://github.com/rust-lang/rust/issues/133199). This adds the feature gates in all the doctests, but does not yet address the fact that this ICE also occurs in calling crates that don't have `#![feature(generic_const_exprs)]` set. Maybe a workaround could be to check for this feature explicitly and throw a helpful error message in diman. --- src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ec2f1a5..4f45b8a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,6 +60,7 @@ //! ## Arithmetics and math //! Addition and subtraction of two quantities is allowed if the dimensions match: //! ``` +//! # #![feature(generic_const_exprs)] //! # use diman::si::dimensions::{Length}; //! # use diman::si::units::{kilometers, meters}; //! let l = 5.0 * meters + 10.0 * kilometers; @@ -94,6 +95,7 @@ //! ``` //! Exponentiation and related operations are supported via `squared`, `cubed`, `powi`, `sqrt`, `cbrt`: //! ``` +//! # #![feature(generic_const_exprs)] //! # use diman::si::dimensions::{Length}; //! # use diman::si::units::{meters, cubic_meters, square_meters}; //! let length = 2.0f64 * meters; @@ -139,6 +141,7 @@ //! //! Conversion into the underlying storage type can be done using the `value_in` function: //! ``` +//! # #![feature(generic_const_exprs)] //! # use diman::si::units::{kilometers, meters}; //! let length = 2.0f64 * kilometers; //! assert_eq!(format!("{} m", length.value_in(meters)), "2000 m"); @@ -181,6 +184,7 @@ //! ``` //! The combination of `value_unchecked` and `new_unchecked` comes in handy when using third party libraries that only takes the raw storage type as argument. As an example, suppose we have a function `foo` that takes a `Vec` and returns a `Vec`, and suppose it sorts the numbers or does some other unit safe operation. Then we could reasonably write: //! ``` +//! # #![feature(generic_const_exprs)] //! # use diman::si::dimensions::{Length}; //! # use diman::si::units::{meters, kilometers}; //! # fn foo(x: Vec) -> Vec { @@ -312,6 +316,7 @@ //! not needed too many times. Having to add a definition to the unit system for this case can be cumbersome. //! This is why the `Product` and `Quotient` types are provided: //! ``` +//! # #![feature(generic_const_exprs)] //! use diman::si::dimensions::{Length, Time}; //! use diman::{Product, Quotient}; //!