File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1537,10 +1537,8 @@ pub(super) fn lower_source_span(span: &Span) -> String {
15371537}
15381538
15391539pub ( super ) fn rust_function_ident ( name : & str ) -> String {
1540- name. split ( '.' )
1541- . map ( rust_ident)
1542- . collect :: < Vec < _ > > ( )
1543- . join ( "_" )
1540+ let joined = name. split ( '.' ) . collect :: < Vec < _ > > ( ) . join ( "_" ) ;
1541+ rust_ident ( & joined)
15441542}
15451543
15461544pub ( super ) fn rust_qualified_function_ident ( namespace : & str , name : & str ) -> String {
@@ -1735,3 +1733,15 @@ pub(super) fn cargo_crate_name(package_name: &str) -> String {
17351733pub ( super ) fn toml_string ( value : & str ) -> String {
17361734 value. replace ( '\\' , "\\ \\ " ) . replace ( '"' , "\\ \" " )
17371735}
1736+
1737+ #[ cfg( test) ]
1738+ mod tests {
1739+ use super :: { rust_function_ident, rust_ident} ;
1740+
1741+ #[ test]
1742+ fn rust_function_ident_escapes_after_flattening_dotted_names ( ) {
1743+ assert_eq ! ( rust_function_ident( "MultiBuffer.ref" ) , "MultiBuffer_ref" ) ;
1744+ assert_eq ! ( rust_function_ident( "gen" ) , "r#gen" ) ;
1745+ assert_eq ! ( rust_ident( "ref" ) , "r#ref" ) ;
1746+ }
1747+ }
You can’t perform that action at this time.
0 commit comments