Skip to content

Commit 48051e4

Browse files
authored
Rollup merge of rust-lang#65266 - rust-lang:must-use-join, r=dtolnay
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?
2 parents e4eb54d + 19bc0a8 commit 48051e4

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)