@@ -260,6 +260,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
260260 let this = self . eval_context_ref ( ) ;
261261 let target_os = & this. tcx . sess . target . os ;
262262
263+ // Below we assume that everything non-Windows works like Unix, at least
264+ // when it comes to file system path conventions.
263265 #[ cfg( windows) ]
264266 return if target_os == "windows" {
265267 // Windows-on-Windows, all fine.
@@ -297,6 +299,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
297299 {
298300 converted. remove ( 0 ) ;
299301 }
302+ // If the path starts with `\\`, it is a magic Windows path. Conveniently, paths
303+ // starting with `//` on Unix are also magic where the first component can have
304+ // "application-specific" meaning, which is reflected e.g. by `path::absolute`
305+ // leaving leading `//` alone (but normalizing leading `///` to `/`). So we
306+ // don't have to do anything, the magic Windows path should work mostly fine as
307+ // a magic Unix path.
300308 }
301309 }
302310 Cow :: Owned ( OsString :: from_wide ( & converted) )
@@ -324,13 +332,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
324332 {
325333 converted. remove ( 0 ) ;
326334 }
327- // If this start withs a `\` but not a `\\`, then for Windows this is a relative
328- // path. But the host path is absolute as it started with `/`. We add `\\?` so
329- // it starts with `\\?\` which is some magic path on Windows that *is*
330- // considered absolute.
335+ // If this starts withs a `\` but not a `\\`, then for Windows this is a
336+ // relative path (relative to "the root of the current directory", e.g. the
337+ // drive letter). But the host path on Unix is absolute as it starts with `/`.
331338 else if converted. get ( 0 ) . copied ( ) == Some ( b'\\' )
332339 && converted. get ( 1 ) . copied ( ) != Some ( b'\\' )
333340 {
341+ // We add `\\?` so it starts with `\\?\` which is some magic path on Windows
342+ // that *is* considered absolute. This way we store the absolute host path
343+ // in something that looks like an absolute path to the (Windows) target.
334344 converted. splice ( 0 ..0 , b"\\ \\ ?" . iter ( ) . copied ( ) ) ;
335345 }
336346 }
0 commit comments