Skip to content

Commit de6aa2b

Browse files
authored
fix: Fix broken build (microsoft#453)
The clone optimization PR didn't have the latest changes for "azure_policy". Integration resulted in compile errors. Also fix errors due to updated clippy lints. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
1 parent dbba57f commit de6aa2b

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/builtins/time/compat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,15 @@ struct GoTimeFormatItems<'a> {
267267
}
268268

269269
impl GoTimeFormatItems<'_> {
270-
fn parse(reminder: &str) -> GoTimeFormatItems {
270+
fn parse(reminder: &str) -> GoTimeFormatItems<'_> {
271271
GoTimeFormatItems {
272272
reminder,
273273
queue: &[],
274274
mode: GoTimeFormatItemsMode::Parse,
275275
}
276276
}
277277

278-
fn format(reminder: &str) -> GoTimeFormatItems {
278+
fn format(reminder: &str) -> GoTimeFormatItems<'_> {
279279
GoTimeFormatItems {
280280
reminder,
281281
queue: &[],

src/builtins/units.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn parse(span: &Span, params: &[Ref<Expr>], args: &[Value], _strict: bool) -> Re
108108
n.mul_assign(&Number::two_pow(e)?)?;
109109
Ok(Value::from(n))
110110
} else {
111-
return Ok(Value::Undefined);
111+
Ok(Value::Undefined)
112112
}
113113
}
114114

src/engine.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,28 @@ pub struct Engine {
2323
rego_v1: bool,
2424
}
2525

26+
#[cfg(feature = "azure_policy")]
2627
#[derive(Debug, Clone, Serialize)]
2728
pub struct PolicyPackageNameDefinition {
2829
pub source_file: String,
2930
pub package_name: String,
3031
}
3132

33+
#[cfg(feature = "azure_policy")]
3234
#[derive(Debug, Clone, Serialize)]
3335
pub struct PolicyParameter {
3436
pub name: String,
3537
pub modifiable: bool,
3638
pub required: bool,
3739
}
3840

41+
#[cfg(feature = "azure_policy")]
3942
#[derive(Debug, Clone, Serialize)]
4043
pub struct PolicyModifier {
4144
pub name: String,
4245
}
4346

47+
#[cfg(feature = "azure_policy")]
4448
#[derive(Debug, Clone, Serialize)]
4549
pub struct PolicyParameters {
4650
pub source_file: String,
@@ -954,7 +958,7 @@ impl Engine {
954958
#[cfg_attr(docsrs, doc(cfg(feature = "azure_policy")))]
955959
pub fn get_policy_package_names(&self) -> Result<Vec<PolicyPackageNameDefinition>> {
956960
let mut package_names = vec![];
957-
for m in &self.modules {
961+
for m in self.modules.iter() {
958962
let package_name = Interpreter::get_path_string(&m.package.refr, None)?;
959963
package_names.push(PolicyPackageNameDefinition {
960964
source_file: m.package.span.source.file().to_string(),
@@ -987,7 +991,7 @@ impl Engine {
987991
#[cfg_attr(docsrs, doc(cfg(feature = "azure_policy")))]
988992
pub fn get_policy_parameters(&self) -> Result<Vec<PolicyParameters>> {
989993
let mut policy_parameter_definitions = vec![];
990-
for m in &self.modules {
994+
for m in self.modules.iter() {
991995
let mut parameters = vec![];
992996
let mut modifiers = vec![];
993997

src/interpreter.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,9 +3696,7 @@ impl Interpreter {
36963696
MapEntry::Occupied(o) => {
36973697
if idx + 1 == comps.len() {
36983698
for (_, i) in o.get() {
3699-
if index.is_some() && i.is_some() {
3700-
let old = i.as_ref().unwrap();
3701-
let new = index.as_ref().unwrap();
3699+
if let (Some(old), Some(new)) = (i, &index) {
37023700
if old == new {
37033701
bail!(refr.span().error("multiple default rules for the variable with the same index"));
37043702
}

src/lexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl cmp::Eq for SourceStr {}
120120

121121
impl cmp::PartialOrd for SourceStr {
122122
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
123-
Some(self.text().cmp(other.text()))
123+
Some(self.cmp(other))
124124
}
125125
}
126126

0 commit comments

Comments
 (0)