File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed
src/librustc_parse/parser Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -179,21 +179,22 @@ impl<'a> Parser<'a> {
179
179
}
180
180
}
181
181
182
+ /// Derive a submodule path from the first found `#[path = "path_string"]`.
183
+ /// The provided `dir_path` is joined with the `path_string`.
182
184
// Public for rustfmt usage.
183
185
pub fn submod_path_from_attr ( attrs : & [ Attribute ] , dir_path : & Path ) -> Option < PathBuf > {
184
- if let Some ( s) = attr:: first_attr_value_str_by_name ( attrs, sym:: path) {
185
- let s = s. as_str ( ) ;
186
+ // Extract path string from first `#[path = "path_string"]` attribute.
187
+ let path_string = attr:: first_attr_value_str_by_name ( attrs, sym:: path) ?;
188
+ let path_string = path_string. as_str ( ) ;
186
189
187
- // On windows, the base path might have the form
188
- // `\\?\foo\bar` in which case it does not tolerate
189
- // mixed `/` and `\` separators, so canonicalize
190
- // `/` to `\`.
191
- #[ cfg( windows) ]
192
- let s = s. replace ( "/" , "\\ " ) ;
193
- Some ( dir_path. join ( & * s) )
194
- } else {
195
- None
196
- }
190
+ // On windows, the base path might have the form
191
+ // `\\?\foo\bar` in which case it does not tolerate
192
+ // mixed `/` and `\` separators, so canonicalize
193
+ // `/` to `\`.
194
+ #[ cfg( windows) ]
195
+ let path_string = path_string. replace ( "/" , "\\ " ) ;
196
+
197
+ Some ( dir_path. join ( & * path_string) )
197
198
}
198
199
199
200
/// Returns a path to a module.
You can’t perform that action at this time.
0 commit comments