@@ -3345,65 +3345,76 @@ impl Error for StripPrefixError {
33453345/// Makes the path absolute without accessing the filesystem.
33463346///
33473347/// 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
33503350/// resolve symlinks and may succeed even if the path does not exist.
33513351///
33523352/// 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
33543354/// returned.
33553355///
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+ ///
33563375/// # Examples
33573376///
33583377/// ## POSIX paths
33593378///
33603379/// ```
33613380/// # #[cfg(unix)]
33623381/// fn main() -> std::io::Result<()> {
3363- /// use std::path::{self, Path};
3382+ /// use std::path::{self, Path};
33643383///
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"));
33683387///
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(())
33733392/// }
33743393/// # #[cfg(not(unix))]
33753394/// # fn main() {}
33763395/// ```
33773396///
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- ///
33823397/// ## Windows paths
33833398///
33843399/// ```
33853400/// # #[cfg(windows)]
33863401/// fn main() -> std::io::Result<()> {
3387- /// use std::path::{self, Path};
3402+ /// use std::path::{self, Path};
33883403///
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"));
33923407///
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")?;
33953410///
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(())
33983413/// }
33993414/// # #[cfg(not(windows))]
34003415/// # fn main() {}
34013416/// ```
34023417///
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- ///
34073418/// Note that this [may change in the future][changes].
34083419///
34093420/// [changes]: io#platform-specific-behavior
0 commit comments