File tree 1 file changed +13
-4
lines changed 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -166,12 +166,21 @@ impl SysrootBuilder {
166
166
self
167
167
}
168
168
169
+
170
+ /// Our configured target can be either a built-in target name, or a path to a target file.
171
+ /// We use the same logic as rustc to tell which is which:
172
+ /// https://github.com/rust-lang/rust/blob/8d39ec1825024f3014e1f847942ac5bbfcf055b0/compiler/rustc_session/src/config.rs#L2252-L2263
169
173
fn target_name ( & self ) -> & OsStr {
170
174
let path = Path :: new ( & self . target ) ;
171
- // If this is a filename, the name is obtained by stripping directory and extension.
172
- // That will also work fine for built-in target names.
173
- path. file_stem ( )
174
- . expect ( "target name must contain a file name" )
175
+ if path. extension ( ) . and_then ( OsStr :: to_str) == Some ( "json" ) {
176
+ // Path::file_stem and Path::extension are the last component of the path split on the
177
+ // rightmost '.' so if we have an extension we must have a file_name.
178
+ path. file_stem ( ) . unwrap ( )
179
+ } else {
180
+ // The configured target doesn't end in ".json", so we assume that this is a builtin
181
+ // target.
182
+ & self . target
183
+ }
175
184
}
176
185
177
186
fn target_dir ( & self ) -> PathBuf {
You can’t perform that action at this time.
0 commit comments