Skip to content

Commit f594538

Browse files
committed
fixes
Signed-off-by: Shaobo He <[email protected]>
1 parent 0fd00f1 commit f594538

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

cedar-policy-core/src/ast/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,8 @@ impl<T: Default + Clone> expr_builder::ExprBuilder for ExprBuilder<T> {
995995
}
996996
}
997997

998-
fn with_source_loc(mut self, maybe_source_loc: &Loc) -> Self {
999-
self.source_loc = Some(maybe_source_loc.clone());
998+
fn with_source_loc(mut self, source_loc: &Loc) -> Self {
999+
self.source_loc = Some(source_loc.clone());
10001000
self
10011001
}
10021002

cedar-policy-core/src/ast/restricted_expr.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ impl RestrictedExpr {
8787
}
8888

8989
/// Return the `RestrictedExpr`, but with the new `source_loc` (or `None`).
90-
pub fn with_source_loc(self, source_loc: Loc) -> Self {
91-
Self(self.0.with_maybe_source_loc(Some(source_loc)))
90+
pub fn with_maybe_source_loc(self, source_loc: Option<Loc>) -> Self {
91+
Self(self.0.with_maybe_source_loc(source_loc))
9292
}
9393

9494
/// Create a `RestrictedExpr` that's just a single `Literal`.
@@ -240,10 +240,7 @@ impl RestrictedExpr {
240240

241241
impl From<Value> for RestrictedExpr {
242242
fn from(value: Value) -> RestrictedExpr {
243-
match value.loc {
244-
Some(loc) => RestrictedExpr::from(value.value).with_source_loc(loc),
245-
None => RestrictedExpr::from(value.value),
246-
}
243+
RestrictedExpr::from(value.value).with_maybe_source_loc(value.loc)
247244
}
248245
}
249246

cedar-policy-core/src/validator/schema/namespace_def.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,13 @@ impl<T: 'static> WithUnresolvedCommonTypeRefs<T> {
958958
f: impl FnOnce(T) -> U + 'static,
959959
) -> WithUnresolvedCommonTypeRefs<U> {
960960
match self {
961-
Self::WithUnresolved(resolve_func, loc) => WithUnresolvedCommonTypeRefs::new(
962-
move |common_type_defs| resolve_func(common_type_defs).map(f),
963-
loc,
964-
),
961+
Self::WithUnresolved(_, ref loc) => {
962+
let loc = loc.clone();
963+
WithUnresolvedCommonTypeRefs::new(
964+
|common_type_defs| self.resolve_common_type_refs(common_type_defs).map(f),
965+
loc,
966+
)
967+
}
965968
Self::WithoutUnresolved(v, loc) => {
966969
WithUnresolvedCommonTypeRefs::WithoutUnresolved(f(v), loc)
967970
}

0 commit comments

Comments
 (0)