diff --git a/crates/hcl-rs/src/eval/error.rs b/crates/hcl-rs/src/eval/error.rs index ed39d262..61a3974d 100644 --- a/crates/hcl-rs/src/eval/error.rs +++ b/crates/hcl-rs/src/eval/error.rs @@ -211,12 +211,6 @@ pub enum ErrorKind { KeyExists(String), /// A function call in an expression returned an error. FuncCall(FuncName, String), - /// It was attempted to evaluate a raw expression. - #[deprecated( - since = "0.16.3", - note = "Support for raw expressions will be removed in an upcoming release" - )] - RawExpression, } impl From for ErrorKind { @@ -264,8 +258,6 @@ impl fmt::Display for ErrorKind { ErrorKind::FuncCall(name, msg) => { write!(f, "error calling function `{name}`: {msg}") } - #[allow(deprecated)] - ErrorKind::RawExpression => f.write_str("raw expressions cannot be evaluated"), } } } diff --git a/crates/hcl-rs/src/eval/impls.rs b/crates/hcl-rs/src/eval/impls.rs index 98fa16b1..35bb6132 100644 --- a/crates/hcl-rs/src/eval/impls.rs +++ b/crates/hcl-rs/src/eval/impls.rs @@ -95,8 +95,6 @@ impl Evaluate for Expression { Expression::Conditional(cond) => cond.evaluate(ctx), Expression::Operation(op) => op.evaluate(ctx), Expression::ForExpr(expr) => expr.evaluate(ctx), - #[allow(deprecated)] - Expression::Raw(_) => Err(ctx.error(ErrorKind::RawExpression)), other => Ok(Value::from(other.clone())), } } diff --git a/crates/hcl-rs/src/expr/de.rs b/crates/hcl-rs/src/expr/de.rs index 9d6423a0..07241ddf 100644 --- a/crates/hcl-rs/src/expr/de.rs +++ b/crates/hcl-rs/src/expr/de.rs @@ -51,7 +51,6 @@ impl<'de> de::Deserialize<'de> for Expression { Conditional, Operation, ForExpr, - Raw, } struct FieldVisitor; @@ -82,10 +81,9 @@ impl<'de> de::Deserialize<'de> for Expression { 11u64 => Ok(Field::Conditional), 12u64 => Ok(Field::Operation), 13u64 => Ok(Field::ForExpr), - 14u64 => Ok(Field::Raw), _ => Err(de::Error::invalid_value( Unexpected::Unsigned(value), - &"variant index 0 <= i < 15", + &"variant index 0 <= i < 14", )), } } @@ -109,7 +107,6 @@ impl<'de> de::Deserialize<'de> for Expression { "Conditional" => Ok(Field::Conditional), "Operation" => Ok(Field::Operation), "ForExpr" => Ok(Field::ForExpr), - "Raw" => Ok(Field::Raw), _ => Err(de::Error::unknown_variant(value, VARIANTS)), } } @@ -133,7 +130,6 @@ impl<'de> de::Deserialize<'de> for Expression { b"Conditional" => Ok(Field::Conditional), b"Operation" => Ok(Field::Operation), b"ForExpr" => Ok(Field::ForExpr), - b"Raw" => Ok(Field::Raw), _ => { let value = &String::from_utf8_lossy(value); Err(de::Error::unknown_variant(value, VARIANTS)) @@ -248,7 +244,6 @@ impl<'de> de::Deserialize<'de> for Expression { (Field::Conditional, v) => v.newtype_variant().map(Expression::Conditional), (Field::Operation, v) => v.newtype_variant().map(Expression::Operation), (Field::ForExpr, v) => v.newtype_variant().map(Expression::ForExpr), - (Field::Raw, v) => v.newtype_variant().map(Expression::Raw), } } } @@ -268,7 +263,6 @@ impl<'de> de::Deserialize<'de> for Expression { "Conditional", "Operation", "ForExpr", - "Raw", ]; deserializer.deserialize_enum("$hcl::Expression", VARIANTS, ExpressionVisitor) @@ -558,7 +552,6 @@ impl<'de> de::VariantAccess<'de> for Expression { Expression::String(v) => seed.deserialize(v.into_deserializer()), Expression::Array(v) => seed.deserialize(v.into_deserializer()), Expression::Object(v) => seed.deserialize(v.into_deserializer()), - Expression::Raw(v) => seed.deserialize(v.into_deserializer()), Expression::TemplateExpr(v) => seed.deserialize(*v), Expression::Variable(v) => seed.deserialize(v.into_deserializer()), Expression::Traversal(v) => seed.deserialize(v.into_deserializer()), @@ -1166,14 +1159,6 @@ impl<'de> de::VariantAccess<'de> for ObjectKey { } } -impl<'de> IntoDeserializer<'de, Error> for RawExpression { - type Deserializer = StringDeserializer; - - fn into_deserializer(self) -> Self::Deserializer { - self.into_inner().into_deserializer() - } -} - impl<'de> IntoDeserializer<'de, Error> for TemplateExpr { type Deserializer = Self; @@ -1281,7 +1266,7 @@ impl<'de> IntoDeserializer<'de, Error> for HeredocStripMode { impl_variant_name! { Expression => { - Null, Bool, Number, String, Array, Object, Raw, TemplateExpr, Variable, + Null, Bool, Number, String, Array, Object, TemplateExpr, Variable, Traversal, FuncCall, Parenthesis, Conditional, Operation, ForExpr }, ObjectKey => { Identifier, Expression }, diff --git a/crates/hcl-rs/src/expr/edit.rs b/crates/hcl-rs/src/expr/edit.rs index 01603246..becf377b 100644 --- a/crates/hcl-rs/src/expr/edit.rs +++ b/crates/hcl-rs/src/expr/edit.rs @@ -53,9 +53,6 @@ impl From for expr::Expression { Expression::Traversal(traversal) => expr::Traversal::from(*traversal).into(), Expression::Parenthesis(parens) => expr::Parenthesis::new((*parens).into()).into(), Expression::Conditional(cond) => expr::Conditional::from(*cond).into(), - Expression::Raw(raw) => { - template::StringTemplate::from(template_or_default(raw.as_str())).into() - } } } } diff --git a/crates/hcl-rs/src/expr/mod.rs b/crates/hcl-rs/src/expr/mod.rs index 2f80ab05..3d10cea6 100644 --- a/crates/hcl-rs/src/expr/mod.rs +++ b/crates/hcl-rs/src/expr/mod.rs @@ -3,8 +3,6 @@ //! The module contains the [`Expression`] enum which can represent any valid HCL expression in //! HCL attribute values and templates. -#![allow(deprecated)] - mod conditional; pub(crate) mod de; mod edit; @@ -31,7 +29,7 @@ use crate::ser::with_internal_serialization; use crate::{Identifier, Number, Result, Value}; use serde::{Deserialize, Serialize}; use std::borrow::Cow; -use std::fmt::{self, Display, Write}; +use std::fmt::{self, Display}; /// The object type used in the expression sub-language. pub type Object = vecmap::VecMap; @@ -71,13 +69,6 @@ pub enum Expression { Operation(Box), /// A construct for constructing a collection by projecting the items from another collection. ForExpr(Box), - /// Represents a raw HCL expression. This variant will never be emitted by the parser. See - /// [`RawExpression`] for more details. - #[deprecated( - since = "0.16.3", - note = "Support for raw expressions will be removed in an upcoming release" - )] - Raw(RawExpression), } impl Expression { @@ -101,7 +92,6 @@ impl From for Value { Expression::Object(object) => object.into_iter().collect(), Expression::TemplateExpr(expr) => Value::String(expr.to_string()), Expression::Parenthesis(expr) => Value::from(*expr), - Expression::Raw(raw) => Value::String(raw.into()), other => Value::String(format::to_interpolated_string(&other).unwrap()), } } @@ -217,12 +207,6 @@ impl From<()> for Expression { } } -impl From for Expression { - fn from(raw: RawExpression) -> Self { - Expression::Raw(raw) - } -} - impl From for Expression { fn from(traversal: Traversal) -> Self { Expression::Traversal(Box::new(traversal)) @@ -344,73 +328,6 @@ impl Display for ObjectKey { } } -/// A type that holds the value of a raw expression. It can be used to serialize arbitrary -/// HCL expressions. -/// -/// *Please note*: raw expressions are not validated during serialization, so it is your -/// responsiblity to ensure that they are valid HCL. -#[deprecated( - since = "0.16.3", - note = "Support for raw expressions will be removed in an upcoming release" -)] -#[derive(Deserialize, Debug, Clone, PartialEq, Eq, Hash)] -#[serde(transparent)] -pub struct RawExpression(String); - -impl RawExpression { - /// Creates a new `RawExpression` from something that can be converted to a `String`. - pub fn new(expr: E) -> RawExpression - where - E: Into, - { - RawExpression(expr.into()) - } - - /// Consumes `self` and returns the `RawExpression` as a `String`. If you want to represent the - /// `RawExpression` as an interpolated string, use `.to_string()` instead. - pub fn into_inner(self) -> String { - self.0 - } - - /// Returns the `RawExpression` as a `&str`. If you want to represent the `RawExpression` as - /// an interpolated string, use `.to_string()` instead. - pub fn as_str(&self) -> &str { - &self.0 - } -} - -impl From for RawExpression { - fn from(expr: String) -> Self { - RawExpression::new(expr) - } -} - -impl From<&str> for RawExpression { - fn from(expr: &str) -> Self { - RawExpression::new(expr) - } -} - -impl<'a> From> for RawExpression { - fn from(expr: Cow<'a, str>) -> Self { - RawExpression::new(expr) - } -} - -impl From for String { - fn from(expr: RawExpression) -> Self { - expr.to_string() - } -} - -impl Display for RawExpression { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("${")?; - f.write_str(&self.0)?; - f.write_char('}') - } -} - /// Convert a `T` into `hcl::Expression` which is an enum that can represent any valid HCL /// attribute value expression. /// diff --git a/crates/hcl-rs/src/expr/ser/mod.rs b/crates/hcl-rs/src/expr/ser/mod.rs index 32694f3f..ae2a8b80 100644 --- a/crates/hcl-rs/src/expr/ser/mod.rs +++ b/crates/hcl-rs/src/expr/ser/mod.rs @@ -36,7 +36,7 @@ macro_rules! impl_serialize_for_expr { impl_serialize_for_expr! { Conditional ForExpr FuncCall Operation UnaryOp BinaryOp - TemplateExpr Heredoc RawExpression Traversal Variable + TemplateExpr Heredoc Traversal Variable } impl ser::Serialize for HeredocStripMode { @@ -72,7 +72,6 @@ impl ser::Serialize for Expression { Expression::Conditional(cond) => cond.serialize(serializer), Expression::Operation(op) => op.serialize(serializer), Expression::ForExpr(expr) => expr.serialize(serializer), - Expression::Raw(raw) => raw.serialize(serializer), } } } diff --git a/crates/hcl-rs/src/format/impls.rs b/crates/hcl-rs/src/format/impls.rs index ca7d76c0..ab6bbbd5 100644 --- a/crates/hcl-rs/src/format/impls.rs +++ b/crates/hcl-rs/src/format/impls.rs @@ -1,6 +1,4 @@ use super::{private, Format, Formatter}; -#[allow(deprecated)] -use crate::expr::RawExpression; use crate::expr::{ BinaryOp, Conditional, Expression, ForExpr, FuncCall, FuncName, Heredoc, HeredocStripMode, ObjectKey, Operation, TemplateExpr, Traversal, TraversalOperator, UnaryOp, Variable, @@ -122,8 +120,6 @@ impl Format for Expression { Expression::String(string) => string.format(fmt), Expression::Array(array) => format_array(fmt, array.iter()), Expression::Object(object) => format_object(fmt, object.iter()), - #[allow(deprecated)] - Expression::Raw(raw) => raw.format(fmt), Expression::TemplateExpr(expr) => expr.format(fmt), Expression::Variable(var) => var.format(fmt), Expression::Traversal(traversal) => traversal.format(fmt), @@ -207,19 +203,6 @@ impl<'a> Format for StrKey<'a> { } } -#[allow(deprecated)] -impl private::Sealed for RawExpression {} - -#[allow(deprecated)] -impl Format for RawExpression { - fn format(&self, fmt: &mut Formatter) -> Result<()> - where - W: io::Write, - { - fmt.write_bytes(self.as_str().as_bytes()) - } -} - impl private::Sealed for TemplateExpr {} impl Format for TemplateExpr { diff --git a/crates/hcl-rs/src/lib.rs b/crates/hcl-rs/src/lib.rs index aeebe0ba..0b050d4a 100644 --- a/crates/hcl-rs/src/lib.rs +++ b/crates/hcl-rs/src/lib.rs @@ -64,10 +64,6 @@ pub use expr::{ UnaryOperator, Variable, }; -#[allow(deprecated)] -#[doc(hidden)] -pub use expr::RawExpression; - pub use ident::Identifier; pub use parser::parse; diff --git a/crates/hcl-rs/src/macros.rs b/crates/hcl-rs/src/macros.rs index 45431c49..226a88f1 100644 --- a/crates/hcl-rs/src/macros.rs +++ b/crates/hcl-rs/src/macros.rs @@ -361,10 +361,6 @@ macro_rules! object_key { $crate::expr::ObjectKey::Identifier($crate::Identifier::unchecked(std::stringify!($ident))) }; - (#{$expr:expr}) => { - $crate::expr::ObjectKey::Expression($crate::expression!(#{$expr})) - }; - (($expr:expr)) => { $crate::expr::ObjectKey::Expression($crate::expression!($expr)) }; @@ -586,11 +582,6 @@ macro_rules! expression_internal { $crate::expression_internal!(@object $object ($crate::object_key!($key)) ($($rest)*) ($($rest)*)); }; - // Munch a raw expression key. - (@object $object:ident () (#{$key:expr} $($rest:tt)*) $copy:tt) => { - $crate::expression_internal!(@object $object ($crate::object_key!(#{$key})) ($($rest)*) ($($rest)*)); - }; - // Munch a parenthesized expression key. (@object $object:ident () (($key:expr) $($rest:tt)*) $copy:tt) => { $crate::expression_internal!(@object $object ($crate::object_key!(($key))) ($($rest)*) ($($rest)*)); @@ -614,10 +605,6 @@ macro_rules! expression_internal { $crate::expr::Expression::Bool(false) }; - (#{$expr:expr}) => { - $crate::expr::Expression::Raw(($expr).into()) - }; - ([]) => { $crate::expr::Expression::Array(std::vec![]) }; diff --git a/crates/hcl-rs/src/template/mod.rs b/crates/hcl-rs/src/template/mod.rs index 2e9593dd..e655d61c 100644 --- a/crates/hcl-rs/src/template/mod.rs +++ b/crates/hcl-rs/src/template/mod.rs @@ -44,7 +44,7 @@ //! # fn main() -> Result<(), Box> { //! use hcl::Identifier; //! use hcl::expr::Variable; -//! use hcl::template::{ForDirective, StripMode, Template}; +//! use hcl::template::{ForDirective, Strip, Template}; //! use std::str::FromStr; //! //! let raw = r#" @@ -67,8 +67,8 @@ //! .add_interpolation(Variable::new("item")?) //! .add_literal("\n") //! ) -//! .with_for_strip(StripMode::End) -//! .with_endfor_strip(StripMode::End) +//! .with_for_strip(Strip::End) +//! .with_endfor_strip(Strip::End) //! ) //! .add_literal("\n"); //! @@ -95,10 +95,6 @@ use std::str::FromStr; #[doc(inline)] pub use hcl_primitives::template::Strip; -#[doc(hidden)] -#[deprecated(since = "0.14.0", note = "use `hcl::template::Strip` instead")] -pub type StripMode = Strip; - /// The main type to represent the HCL template sub-languange. /// /// A template behaves like an expression that always returns a string value. The different