33
44use super :: api:: LexingState ;
55use crate :: errors:: api:: Location ;
6- use crate :: errors:: dbg_assert;
76use crate :: lexer:: types:: api:: { EscapeSequence , LexingData } ;
87
98/// Used to describe the return status after lexing an [`EscapeSequence`];
@@ -69,7 +68,7 @@ fn end_escape_sequence(
6968 EscapeSequence :: ShortUnicode ( value) => {
7069 expect_max_length ( 4 , value) ;
7170 expect_min_length ( lex_data, 4 , value, location, sequence) ?;
72- dbg_assert ( last, "len = 4" ) ;
71+ debug_assert ! ( last, "len = 4" ) ;
7372 char:: from_u32 ( u32:: from_str_radix ( value, 16 ) . expect ( "max 8 chars and radix valid" ) )
7473 . ok_or_else ( || {
7574 lex_data. push_err (
@@ -93,7 +92,7 @@ fn end_escape_sequence(
9392 }
9493 expect_max_length ( 8 , value) ;
9594 expect_min_length ( lex_data, 8 , value, location, sequence) ?;
96- dbg_assert ( last, "len = 4" ) ;
95+ debug_assert ! ( last, "len = 4" ) ;
9796 char:: from_u32 ( u32:: from_str_radix ( value, 16 ) . expect ( "max 4 chars and radix valid" ) )
9897 . ok_or_else ( || {
9998 lex_data. push_err (
@@ -113,10 +112,10 @@ fn end_escape_sequence(
113112 }
114113 EscapeSequence :: Octal ( value) => {
115114 expect_max_length ( 3 , value) ;
116- dbg_assert ( !value. is_empty ( ) , "initialise with len 1" ) ;
115+ debug_assert ! ( !value. is_empty( ) , "initialise with len 1" ) ;
117116 let int =
118117 u32:: from_str_radix ( value, 8 ) . expect ( "Max 3 digits, so value <= 0777 & radix < 32" ) ;
119- dbg_assert ( int <= 0o377 , "unreachable: should never have pushed" ) ;
118+ debug_assert ! ( int <= 0o377 , "unreachable: should never have pushed" ) ;
120119 #[ expect( clippy:: as_conversions, clippy:: cast_possible_truncation) ]
121120 Ok ( char:: from ( int as u8 ) )
122121 }
@@ -128,7 +127,7 @@ fn end_escape_sequence(
128127#[ inline( always) ]
129128#[ expect( clippy:: inline_always) ]
130129fn expect_max_length ( size : usize , value : & str ) {
131- dbg_assert ( value. len ( ) <= size, "Never should have pushed here" ) ;
130+ debug_assert ! ( value. len( ) <= size, "Never should have pushed here" ) ;
132131}
133132
134133/// Returns the minimum number of characters expected after the escape sequence
@@ -170,9 +169,9 @@ pub fn handle_escape(
170169 escape_state : & mut EscapeState ,
171170 location : & Location ,
172171) {
173- dbg_assert (
172+ debug_assert ! (
174173 matches!( lex_state, LexingState :: Char ( None ) | LexingState :: Str ( _) ) ,
175- "Can't happen because error raised on escape creation if wrong state." ,
174+ "Can't happen because error raised on escape creation if wrong state."
176175 ) ;
177176 let escape_return = push_char_in_escape ( ch, lex_data, escape_state, location) ;
178177 if matches ! ( escape_return, EscapeSequenceReturnState :: Error ) {
0 commit comments