File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -697,7 +697,7 @@ impl Cursor {
697
697
698
698
/// Gets the tokens that correspond to that cursor as `rcc` tokens.
699
699
pub fn rcc_tokens < ' a > ( self ) -> Vec < rcc:: Locatable < rcc:: Token > > {
700
- use rcc:: { Files , Lexer } ;
700
+ use rcc:: { Literal , Token , Files , Lexer } ;
701
701
702
702
self . tokens ( )
703
703
. iter ( )
@@ -713,7 +713,13 @@ impl Cursor {
713
713
let mut files = Files :: new ( ) ;
714
714
let id = files. add ( "" , "" . into ( ) ) ;
715
715
let mut lexer = Lexer :: new ( id, spelling, false ) ;
716
- Some ( lexer. next ( ) . unwrap ( ) . expect ( "rcc failed to parse clang token" ) )
716
+ let mut token = lexer. next ( ) . unwrap ( ) . expect ( "rcc failed to parse clang token" ) ;
717
+ // rcc generates null-terminated string immediately,
718
+ // but bindgen only adds the null-terminator during codegen.
719
+ if let Token :: Literal ( Literal :: Str ( ref mut string) ) = & mut token. data {
720
+ assert_eq ! ( string. pop( ) , Some ( b'\0' ) ) ;
721
+ }
722
+ Some ( token)
717
723
}
718
724
_ => {
719
725
error ! ( "Found unexpected token kind: {:?}" , token) ;
You can’t perform that action at this time.
0 commit comments