@@ -2159,7 +2159,12 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2159
2159
let mut kind = ModuleKind :: Normal ;
2160
2160
let mut looking_for_name = false ;
2161
2161
for token in cursor. tokens ( ) . iter ( ) {
2162
- match token. spelling ( ) . to_str ( ) . unwrap ( ) {
2162
+ let spelling = token. spelling ( ) ;
2163
+ let name = match spelling. to_str ( ) {
2164
+ Ok ( name) => Cow :: Borrowed ( name) ,
2165
+ Err ( _) => spelling. to_string_lossy ( ) ,
2166
+ } ;
2167
+ match name. as_ref ( ) {
2163
2168
"inline" => {
2164
2169
debug_assert ! (
2165
2170
kind != ModuleKind :: Inline ,
@@ -2185,29 +2190,26 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2185
2190
assert ! ( looking_for_name) ;
2186
2191
break ;
2187
2192
}
2188
- name => {
2189
- if looking_for_name {
2190
- if module_name. is_none ( ) {
2191
- module_name = Some ( name. to_owned ( ) ) ;
2192
- }
2193
- break ;
2194
- } else {
2195
- // This is _likely_, but not certainly, a macro that's
2196
- // been placed just before the namespace keyword.
2197
- // Unfortunately, clang tokens don't let us easily see
2198
- // through the ifdef tokens, so we don't know what this
2199
- // token should really be. Instead of panicking though,
2200
- // we warn the user that we assumed the token was blank,
2201
- // and then move on.
2202
- //
2203
- // See also https://github.com/rust-lang/rust-bindgen/issues/1676.
2204
- warn ! (
2205
- "Ignored unknown namespace prefix '{}' at {:?} in {:?}" ,
2206
- name,
2207
- token,
2208
- cursor
2209
- ) ;
2193
+ name if looking_for_name => {
2194
+ if module_name. is_none ( ) {
2195
+ module_name = Some ( name. to_owned ( ) ) ;
2210
2196
}
2197
+ break ;
2198
+ }
2199
+ name => {
2200
+ // This is _likely_, but not certainly, a macro that's
2201
+ // been placed just before the namespace keyword.
2202
+ // Unfortunately, clang tokens don't let us easily see
2203
+ // through the ifdef tokens, so we don't know what this
2204
+ // token should really be. Instead of panicking though,
2205
+ // we warn the user that we assumed the token was blank,
2206
+ // and then move on.
2207
+ //
2208
+ // See also https://github.com/rust-lang/rust-bindgen/issues/1676.
2209
+ warn ! (
2210
+ "Ignored unknown namespace prefix '{}' at {:?} in {:?}" ,
2211
+ name, token, cursor
2212
+ ) ;
2211
2213
}
2212
2214
}
2213
2215
}
0 commit comments