• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ergoplatform / sigma-rust / 19715256552

26 Nov 2025 07:29PM UTC coverage: 86.888% (+8.4%) from 78.463%
19715256552

Pull #838

github

web-flow
Merge ff3964431 into 2f840d387
Pull Request #838: CI fixes

7 of 8 new or added lines in 7 files covered. (87.5%)

1628 existing lines in 221 files now uncovered.

27460 of 31604 relevant lines covered (86.89%)

253315.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/ergotree-ir/src/source_span.rs
1
//! Source position for an IR node in the source code
2

3
use alloc::boxed::Box;
4

5
use crate::mir::and::And;
6
use crate::mir::bin_op::BinOp;
7
use crate::mir::block::BlockValue;
8
use crate::mir::byte_array_to_bigint::ByteArrayToBigInt;
9
use crate::mir::byte_array_to_long::ByteArrayToLong;
10
use crate::mir::coll_append::Append;
11
use crate::mir::coll_by_index::ByIndex;
12
use crate::mir::coll_exists::Exists;
13
use crate::mir::coll_filter::Filter;
14
use crate::mir::coll_fold::Fold;
15
use crate::mir::coll_forall::ForAll;
16
use crate::mir::coll_map::Map;
17
use crate::mir::coll_slice::Slice;
18
use crate::mir::expr::Expr;
19
use crate::mir::extract_reg_as::ExtractRegisterAs;
20
use crate::mir::get_var::GetVar;
21
use crate::mir::logical_not::LogicalNot;
22
use crate::mir::method_call::MethodCall;
23
use crate::mir::negation::Negation;
24
use crate::mir::option_get::OptionGet;
25
use crate::mir::option_get_or_else::OptionGetOrElse;
26
use crate::mir::option_is_defined::OptionIsDefined;
27
use crate::mir::or::Or;
28
use crate::mir::property_call::PropertyCall;
29
use crate::mir::select_field::SelectField;
30
use crate::mir::subst_const::SubstConstants;
31
use crate::mir::tree_lookup::TreeLookup;
32
use crate::mir::val_def::ValDef;
33
use crate::traversable::Traversable;
34

35
/// Source position for the Expr
36
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
37
pub struct SourceSpan {
38
    /// Start position in the span
39
    pub offset: usize,
40
    /// The length of the span
41
    pub length: usize,
42
}
43

44
impl SourceSpan {
45
    /// Empty span
46
    pub fn empty() -> Self {
212,361✔
47
        SourceSpan {
212,361✔
48
            offset: 0,
212,361✔
49
            length: 0,
212,361✔
50
        }
212,361✔
51
    }
212,361✔
52
}
53

54
impl From<(usize, usize)> for SourceSpan {
55
    fn from(value: (usize, usize)) -> Self {
2✔
56
        SourceSpan {
2✔
57
            offset: value.0,
2✔
58
            length: value.1,
2✔
59
        }
2✔
60
    }
2✔
61
}
62

63
#[cfg(feature = "std")]
64
impl From<SourceSpan> for miette::SourceSpan {
65
    fn from(value: SourceSpan) -> Self {
×
NEW
66
        miette::SourceSpan::new(value.offset.into(), value.length)
×
UNCOV
67
    }
×
68
}
69

70
/// Wrapper for Expr with source position
71
#[derive(PartialEq, Eq, Debug, Clone)]
72
pub struct Spanned<T> {
73
    /// Source position
74
    pub source_span: SourceSpan,
75
    /// Wrapped value
76
    pub expr: T,
77
}
78

79
impl<T> Spanned<T> {
80
    /// Expression
81
    pub fn expr(&self) -> &T {
181,370✔
82
        &self.expr
181,370✔
83
    }
181,370✔
84
}
85

86
impl<T: Traversable> Traversable for Spanned<T> {
87
    type Item = T::Item;
88
    fn children<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Self::Item> + 'a> {
3✔
89
        self.expr.children()
3✔
90
    }
3✔
91
    fn children_mut<'a>(&'a mut self) -> Box<dyn Iterator<Item = &'a mut T::Item> + 'a> {
2,559✔
92
        self.expr.children_mut()
2,559✔
93
    }
2,559✔
94
}
95

96
macro_rules! into_expr {
97
    ($variant: ident) => {
98
        impl From<$variant> for Expr {
99
            fn from(v: $variant) -> Self {
77,043✔
100
                Expr::$variant(Spanned {
77,043✔
101
                    source_span: SourceSpan::empty(),
77,043✔
102
                    expr: v,
77,043✔
103
                })
77,043✔
104
            }
77,043✔
105
        }
106
    };
107
}
108

109
into_expr!(Append);
110
into_expr!(BlockValue);
111
into_expr!(ValDef);
112
into_expr!(BinOp);
113
into_expr!(ByIndex);
114
into_expr!(SubstConstants);
115
into_expr!(ByteArrayToLong);
116
into_expr!(ByteArrayToBigInt);
117
into_expr!(MethodCall);
118
into_expr!(PropertyCall);
119
into_expr!(Negation);
120
into_expr!(OptionGet);
121
into_expr!(OptionIsDefined);
122
into_expr!(OptionGetOrElse);
123
into_expr!(ExtractRegisterAs);
124
into_expr!(Slice);
125
into_expr!(Fold);
126
into_expr!(Map);
127
into_expr!(Filter);
128
into_expr!(Exists);
129
into_expr!(ForAll);
130
into_expr!(SelectField);
131
into_expr!(GetVar);
132
into_expr!(TreeLookup);
133
into_expr!(And);
134
into_expr!(Or);
135
into_expr!(LogicalNot);
136

137
impl<T> From<T> for Spanned<T> {
138
    fn from(v: T) -> Self {
7,336✔
139
        Spanned {
7,336✔
140
            source_span: SourceSpan::empty(),
7,336✔
141
            expr: v,
7,336✔
142
        }
7,336✔
143
    }
7,336✔
144
}
145

146
impl Expr {
147
    /// Source span for the Expr
148
    pub fn span(&self) -> SourceSpan {
155,155✔
149
        match self {
155,155✔
150
            Expr::Append(op) => op.source_span,
15✔
151
            Expr::Const(_) => SourceSpan::empty(),
110,656✔
152
            Expr::ConstPlaceholder(_) => SourceSpan::empty(),
×
153
            Expr::SubstConstants(op) => op.source_span,
512✔
154
            Expr::ByteArrayToLong(op) => op.source_span,
6✔
155
            Expr::ByteArrayToBigInt(op) => op.source_span,
10✔
156
            Expr::LongToByteArray(_) => SourceSpan::empty(),
4✔
157
            Expr::Collection(_) => SourceSpan::empty(),
1,028✔
158
            Expr::Tuple(_) => SourceSpan::empty(),
2✔
159
            Expr::CalcBlake2b256(_) => SourceSpan::empty(),
256✔
160
            Expr::CalcSha256(_) => SourceSpan::empty(),
256✔
161
            Expr::Context => SourceSpan::empty(),
86✔
162
            Expr::Global => SourceSpan::empty(),
4,317✔
163
            Expr::GlobalVars(_) => SourceSpan::empty(),
36✔
164
            Expr::FuncValue(_) => SourceSpan::empty(),
65✔
165
            Expr::Apply(_) => SourceSpan::empty(),
3✔
166
            Expr::MethodCall(op) => op.source_span,
23,364✔
167
            Expr::PropertyCall(op) => op.source_span,
109✔
168
            Expr::BlockValue(op) => op.source_span,
7✔
169
            Expr::ValDef(op) => op.source_span,
×
170
            Expr::ValUse(_) => SourceSpan::empty(),
109✔
171
            Expr::If(_) => SourceSpan::empty(),
12✔
172
            Expr::BinOp(op) => op.source_span,
2,995✔
173
            Expr::And(_) => SourceSpan::empty(),
256✔
174
            Expr::Or(_) => SourceSpan::empty(),
256✔
175
            Expr::Xor(_) => SourceSpan::empty(),
261✔
176
            Expr::Atleast(_) => SourceSpan::empty(),
79✔
177
            Expr::LogicalNot(_) => SourceSpan::empty(),
3✔
178
            Expr::Negation(op) => op.source_span,
10✔
179
            Expr::BitInversion(_) => SourceSpan::empty(),
20✔
180
            Expr::OptionGet(op) => op.source_span,
3✔
181
            Expr::OptionIsDefined(op) => op.source_span,
1✔
182
            Expr::OptionGetOrElse(op) => op.source_span,
6✔
183
            Expr::ExtractAmount(_) => SourceSpan::empty(),
49✔
184
            Expr::ExtractRegisterAs(op) => op.source_span,
9✔
185
            Expr::ExtractBytes(_) => SourceSpan::empty(),
1✔
186
            Expr::ExtractBytesWithNoRef(_) => SourceSpan::empty(),
1✔
187
            Expr::ExtractScriptBytes(_) => SourceSpan::empty(),
1✔
188
            Expr::ExtractCreationInfo(_) => SourceSpan::empty(),
1✔
189
            Expr::ExtractId(_) => SourceSpan::empty(),
1✔
190
            Expr::ByIndex(op) => op.source_span,
25✔
191
            Expr::SizeOf(_) => SourceSpan::empty(),
1✔
192
            Expr::Slice(op) => op.source_span,
9✔
193
            Expr::Fold(op) => op.source_span,
16✔
194
            Expr::Map(op) => op.source_span,
17✔
195
            Expr::Filter(op) => op.source_span,
16✔
196
            Expr::Exists(op) => op.source_span,
4✔
197
            Expr::ForAll(op) => op.source_span,
3✔
198
            Expr::SelectField(op) => op.source_span,
30✔
199
            Expr::BoolToSigmaProp(_) => SourceSpan::empty(),
258✔
200
            Expr::Upcast(_) => SourceSpan::empty(),
4,615✔
201
            Expr::Downcast(_) => SourceSpan::empty(),
3,136✔
202
            Expr::CreateProveDlog(_) => SourceSpan::empty(),
×
203
            Expr::CreateProveDhTuple(_) => SourceSpan::empty(),
×
204
            Expr::SigmaPropBytes(_) => SourceSpan::empty(),
264✔
205
            Expr::DecodePoint(_) => SourceSpan::empty(),
256✔
206
            Expr::SigmaAnd(_) => SourceSpan::empty(),
127✔
207
            Expr::SigmaOr(_) => SourceSpan::empty(),
282✔
208
            Expr::GetVar(op) => op.source_span,
4✔
209
            Expr::DeserializeRegister(_) => SourceSpan::empty(),
1✔
210
            Expr::DeserializeContext(_) => SourceSpan::empty(),
1✔
211
            Expr::MultiplyGroup(_) => SourceSpan::empty(),
512✔
212
            Expr::Exponentiate(_) => SourceSpan::empty(),
513✔
213
            Expr::XorOf(_) => SourceSpan::empty(),
256✔
214
            Expr::TreeLookup(op) => op.source_span,
2✔
215
            Expr::CreateAvlTree(_) => SourceSpan::empty(),
1✔
216
        }
217
    }
155,155✔
218
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc