File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,9 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
31
31
( & ast:: ItemKind :: ExternCrate ( ref a_name) , & ast:: ItemKind :: ExternCrate ( ref b_name) ) => {
32
32
// `extern crate foo as bar;`
33
33
// ^^^ Comparing this.
34
- let a_orig_name = a_name. map_or_else ( || a. ident . as_str ( ) , rustc_span :: Symbol :: as_str ) ;
35
- let b_orig_name = b_name. map_or_else ( || b. ident . as_str ( ) , rustc_span :: Symbol :: as_str ) ;
36
- let result = a_orig_name. cmp ( & b_orig_name) ;
34
+ let a_orig_name = a_name. unwrap_or ( a. ident . name ) ;
35
+ let b_orig_name = b_name. unwrap_or ( b. ident . name ) ;
36
+ let result = a_orig_name. as_str ( ) . cmp ( b_orig_name. as_str ( ) ) ;
37
37
if result != Ordering :: Equal {
38
38
return result;
39
39
}
Original file line number Diff line number Diff line change @@ -95,15 +95,17 @@ pub(crate) enum ParserError {
95
95
96
96
impl < ' a > Parser < ' a > {
97
97
pub ( crate ) fn submod_path_from_attr ( attrs : & [ ast:: Attribute ] , path : & Path ) -> Option < PathBuf > {
98
- let path_string = first_attr_value_str_by_name ( attrs, sym:: path) ?. as_str ( ) ;
98
+ let path_sym = first_attr_value_str_by_name ( attrs, sym:: path) ?;
99
+ let path_str = path_sym. as_str ( ) ;
100
+
99
101
// On windows, the base path might have the form
100
102
// `\\?\foo\bar` in which case it does not tolerate
101
103
// mixed `/` and `\` separators, so canonicalize
102
104
// `/` to `\`.
103
105
#[ cfg( windows) ]
104
- let path_string = path_string . replace ( "/" , "\\ " ) ;
106
+ let path_str = path_str . replace ( "/" , "\\ " ) ;
105
107
106
- Some ( path. join ( & * path_string ) )
108
+ Some ( path. join ( path_str ) )
107
109
}
108
110
109
111
pub ( crate ) fn parse_file_as_module (
You can’t perform that action at this time.
0 commit comments