Auto merge of #126518 - matthiaskrgr:rollup-wb70rzq, r=matthiaskrgr · model-checking/verify-rust-std@7e3c4f8 (original) (raw)

`@@ -3345,65 +3345,76 @@ impl Error for StripPrefixError {

`

3345

3345

`/// Makes the path absolute without accessing the filesystem.

`

3346

3346

`///

`

3347

3347

`/// If the path is relative, the current directory is used as the base directory.

`

3348

``

`-

/// All intermediate components will be resolved according to platforms-specific

`

3349

``

`` -

/// rules but unlike [canonicalize][crate::fs::canonicalize] this does not

``

``

3348

`+

/// All intermediate components will be resolved according to platform-specific

`

``

3349

`` +

/// rules, but unlike [canonicalize][crate::fs::canonicalize], this does not

``

3350

3350

`/// resolve symlinks and may succeed even if the path does not exist.

`

3351

3351

`///

`

3352

3352

`` /// If the path is empty or getting the

``

3353

``

`-

/// [current directory][crate::env::current_dir] fails then an error will be

`

``

3353

`+

/// [current directory][crate::env::current_dir] fails, then an error will be

`

3354

3354

`/// returned.

`

3355

3355

`///

`

``

3356

`+

/// # Platform-specific behavior

`

``

3357

`+

///

`

``

3358

`+

/// On POSIX platforms, the path is resolved using [POSIX semantics][posix-semantics],

`

``

3359

`` +

/// except that it stops short of resolving symlinks. This means it will keep ..

``

``

3360

`+

/// components and trailing slashes.

`

``

3361

`+

///

`

``

3362

`+

/// On Windows, for verbatim paths, this will simply return the path as given. For other

`

``

3363

`+

/// paths, this is currently equivalent to calling

`

``

3364

`` +

/// [GetFullPathNameW][windows-path].

``

``

3365

`+

///

`

``

3366

`+

/// Note that these [may change in the future][changes].

`

``

3367

`+

///

`

``

3368

`+

/// # Errors

`

``

3369

`+

///

`

``

3370

`+

/// This function may return an error in the following situations:

`

``

3371

`+

///

`

``

3372

`` +

/// * If path is syntactically invalid; in particular, if it is empty.

``

``

3373

`+

/// * If getting the [current directory][crate::env::current_dir] fails.

`

``

3374

`+

///

`

3356

3375

`/// # Examples

`

3357

3376

`///

`

3358

3377

`/// ## POSIX paths

`

3359

3378

`///

`

3360

3379

```` /// ```


`3361`

`3380`

`/// # #[cfg(unix)]

`

`3362`

`3381`

`/// fn main() -> std::io::Result<()> {

`

`3363`

``

`-

/// use std::path::{self, Path};

`

``

`3382`

`+

/// use std::path::{self, Path};

`

`3364`

`3383`

`///

`

`3365`

``

`-

/// // Relative to absolute

`

`3366`

``

`-

/// let absolute = path::absolute("foo/./bar")?;

`

`3367`

``

`-

/// assert!(absolute.ends_with("foo/bar"));

`

``

`3384`

`+

/// // Relative to absolute

`

``

`3385`

`+

/// let absolute = path::absolute("foo/./bar")?;

`

``

`3386`

`+

/// assert!(absolute.ends_with("foo/bar"));

`

`3368`

`3387`

`///

`

`3369`

``

`-

/// // Absolute to absolute

`

`3370`

``

`-

/// let absolute = path::absolute("/foo//test/.././bar.rs")?;

`

`3371`

``

`-

/// assert_eq!(absolute, Path::new("/foo/test/../bar.rs"));

`

`3372`

``

`-

/// Ok(())

`

``

`3388`

`+

/// // Absolute to absolute

`

``

`3389`

`+

/// let absolute = path::absolute("/foo//test/.././bar.rs")?;

`

``

`3390`

`+

/// assert_eq!(absolute, Path::new("/foo/test/../bar.rs"));

`

``

`3391`

`+

/// Ok(())

`

`3373`

`3392`

`/// }

`

`3374`

`3393`

`/// # #[cfg(not(unix))]

`

`3375`

`3394`

`/// # fn main() {}

`

`3376`

`3395`

```` /// ```

3377

3396

`///

`

3378

``

`-

/// The path is resolved using [POSIX semantics][posix-semantics] except that

`

3379

``

`` -

/// it stops short of resolving symlinks. This means it will keep ..

``

3380

``

`-

/// components and trailing slashes.

`

3381

``

`-

///

`

3382

3397

`/// ## Windows paths

`

3383

3398

`///

`

3384

3399

```` /// ```


`3385`

`3400`

`/// # #[cfg(windows)]

`

`3386`

`3401`

`/// fn main() -> std::io::Result<()> {

`

`3387`

``

`-

/// use std::path::{self, Path};

`

``

`3402`

`+

/// use std::path::{self, Path};

`

`3388`

`3403`

`///

`

`3389`

``

`-

/// // Relative to absolute

`

`3390`

``

`-

/// let absolute = path::absolute("foo/./bar")?;

`

`3391`

``

`-

/// assert!(absolute.ends_with(r"foo\bar"));

`

``

`3404`

`+

/// // Relative to absolute

`

``

`3405`

`+

/// let absolute = path::absolute("foo/./bar")?;

`

``

`3406`

`+

/// assert!(absolute.ends_with(r"foo\bar"));

`

`3392`

`3407`

`///

`

`3393`

``

`-

/// // Absolute to absolute

`

`3394`

``

`-

/// let absolute = path::absolute(r"C:\foo//test\..\./bar.rs")?;

`

``

`3408`

`+

/// // Absolute to absolute

`

``

`3409`

`+

/// let absolute = path::absolute(r"C:\foo//test\..\./bar.rs")?;

`

`3395`

`3410`

`///

`

`3396`

``

`-

/// assert_eq!(absolute, Path::new(r"C:\foo\bar.rs"));

`

`3397`

``

`-

/// Ok(())

`

``

`3411`

`+

/// assert_eq!(absolute, Path::new(r"C:\foo\bar.rs"));

`

``

`3412`

`+

/// Ok(())

`

`3398`

`3413`

`/// }

`

`3399`

`3414`

`/// # #[cfg(not(windows))]

`

`3400`

`3415`

`/// # fn main() {}

`

`3401`

`3416`

```` /// ```

3402

3417

`///

`

3403

``

`-

/// For verbatim paths this will simply return the path as given. For other

`

3404

``

`-

/// paths this is currently equivalent to calling

`

3405

``

`` -

/// [GetFullPathNameW][windows-path].

``

3406

``

`-

///

`

3407

3418

`/// Note that this [may change in the future][changes].

`

3408

3419

`///

`

3409

3420

`/// [changes]: io#platform-specific-behavior

`