Rollup merge of #146299 - smirzaei:doc/improve-path-canonicalize-docs, r=jhpratt

docs(std): add error docs for path canonicalize

This PR adds the missing error documentation for both [Path.canonicalize](https://doc.rust-lang.org/std/path/struct.Path.html#method.canonicalize) and [PathBuf.canonicalize](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.canonicalize) methods. Since both methods are wappers around [fs::canonicalize](https://doc.rust-lang.org/std/fs/fn.canonicalize.html), the error doc is copied directly from that function.

This makes it faster to find what errors might arise when calling `path.canonicalize` or `path_buf.canonicalize` in the editor itself without needing to drill down to the  `fs::canonicalzie` docs.
This commit is contained in:
Matthias Krüger 2025-09-08 16:34:57 +02:00 committed by GitHub
commit d1ab870a07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3037,6 +3037,14 @@ impl Path {
///
/// This is an alias to [`fs::canonicalize`].
///
/// # Errors
///
/// This method will return an error in the following situations, but is not
/// limited to just these cases:
///
/// * `path` does not exist.
/// * A non-final component in path is not a directory.
///
/// # Examples
///
/// ```no_run