@@ -123,13 +123,17 @@ pub(crate) fn process_email_autolinks<'a>(
123
123
// - if remaining `i` is equal to the byte count `x`,
124
124
// set `e = sp.end.column` and finish.
125
125
// - if remaining `i` is less than the byte count `x`,
126
- // assert `sp.end.column - sp.start.column + 1 == x` (1),
126
+ // assert `sp.end.column - sp.start.column + 1 == x || rem == 0 ` (1),
127
127
// set `e = sp.start.column + i - 1` and finish.
128
128
//
129
129
// (1) If `x` doesn't equal the range covered between the start and end column,
130
130
// there's no way to determine sourcepos within the range. This is a bug if
131
131
// it happens; it suggests we've matched an email autolink with some smart
132
132
// punctuation in it, or worse.
133
+ //
134
+ // The one exception is if `rem == 0`. Given nothing to consume, we can
135
+ // happily restore what we popped, returning `sp.start.column - 1` for the
136
+ // end column of the original node.
133
137
fn consume_spx ( spx : & mut VecDeque < ( Sourcepos , usize ) > , mut rem : usize ) -> usize {
134
138
while let Some ( ( sp, x) ) = spx. pop_front ( ) {
135
139
if rem > x {
@@ -138,7 +142,7 @@ fn consume_spx(spx: &mut VecDeque<(Sourcepos, usize)>, mut rem: usize) -> usize
138
142
return sp. end . column ;
139
143
} else {
140
144
// rem < x
141
- assert_eq ! ( sp. end. column - sp. start. column + 1 , x ) ;
145
+ assert ! ( ( sp. end. column - sp. start. column + 1 == x ) || rem == 0 ) ;
142
146
spx. push_front ( (
143
147
(
144
148
sp. start . line ,
0 commit comments