File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -904,7 +904,13 @@ fn cooked_byte(input: Cursor) -> PResult<()> {
904
904
} ;
905
905
if ok {
906
906
match bytes. next ( ) {
907
- Some ( ( offset, _) ) => Ok ( ( input. advance ( offset) , ( ) ) ) ,
907
+ Some ( ( offset, _) ) => {
908
+ if input. chars ( ) . as_str ( ) . is_char_boundary ( offset) {
909
+ Ok ( ( input. advance ( offset) , ( ) ) )
910
+ } else {
911
+ Err ( LexError )
912
+ }
913
+ }
908
914
None => Ok ( ( input. advance ( input. len ( ) ) , ( ) ) ) ,
909
915
}
910
916
} else {
Original file line number Diff line number Diff line change 1
1
extern crate proc_macro2;
2
2
3
+ use std:: str;
4
+
3
5
use proc_macro2:: { Term , Literal , TokenStream } ;
4
6
5
7
#[ cfg( procmacro2_semver_exempt) ]
@@ -161,3 +163,10 @@ fn span_join() {
161
163
162
164
assert_eq ! ( joined1. unwrap( ) . source_file( ) , source1[ 0 ] . span. source_file( ) ) ;
163
165
}
166
+
167
+ #[ test]
168
+ fn no_panic ( ) {
169
+ let s = str:: from_utf8 ( b"b\' \xc2 \x86 \x00 \x00 \x00 ^\" " ) . unwrap ( ) ;
170
+ assert ! ( s. parse:: <proc_macro2:: TokenStream >( ) . is_err( ) ) ;
171
+ }
172
+
You can’t perform that action at this time.
0 commit comments