Skip to content

Commit 19bc0a8

Browse files
authored
Mark Path::join as must_use
I've accidentally did `mut_path_buf.jon(a_path);`, expecting this to be an in-place modification. Seems like we can easily warn in such cases?
1 parent 8ee24f6 commit 19bc0a8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/libstd/path.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2219,6 +2219,7 @@ impl Path {
22192219
/// assert_eq!(Path::new("/etc").join("passwd"), PathBuf::from("/etc/passwd"));
22202220
/// ```
22212221
#[stable(feature = "rust1", since = "1.0.0")]
2222+
#[must_use]
22222223
pub fn join<P: AsRef<Path>>(&self, path: P) -> PathBuf {
22232224
self._join(path.as_ref())
22242225
}

0 commit comments

Comments
 (0)