Skip to content

Commit fcee118

Browse files
committed
std: mark common functions in test crate pub(crate)
This is not a library, so there's no reason for them to be `pub`. Without doing this, compiling the test crates causes private dep lint errors: error: type `PathBuf` from private dependency 'std' in public interface --> library/std/tests/common/mod.rs:26:5 | 26 | pub fn join(&self, path: &str) -> PathBuf { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D exported-private-dependencies` implied by `-D warnings` error: type `Path` from private dependency 'std' in public interface --> library/std/tests/common/mod.rs:31:5 | 31 | pub fn path(&self) -> &Path { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not compile `std` (test "create_dir_all_bare") due to 2 previous errors This happens because Cargo passes `--extern 'priv:std=...` when compiling the test crate. I'm not sure if these warnings are desirable or not. They seem correct in a very pedantic way (the dependency on `std` is not marked public, since it's implicit), but also pointless (the test crate is not an API, so who cares what it does).
1 parent 3d3bd20 commit fcee118

File tree

1 file changed

+4
-6
lines changed
  • library/std/tests/common

1 file changed

+4
-6
lines changed

library/std/tests/common/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![allow(unused)]
22

3-
#![allow(exported_private_dependencies)]
4-
53
use std::env;
64
use std::fs;
75
use std::path::{Path, PathBuf};
@@ -22,15 +20,15 @@ pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng {
2220
}
2321

2422
// Copied from std::sys_common::io
25-
pub struct TempDir(PathBuf);
23+
pub(crate) struct TempDir(PathBuf);
2624

2725
impl TempDir {
28-
pub fn join(&self, path: &str) -> PathBuf {
26+
pub(crate) fn join(&self, path: &str) -> PathBuf {
2927
let TempDir(ref p) = *self;
3028
p.join(path)
3129
}
3230

33-
pub fn path(&self) -> &Path {
31+
pub(crate) fn path(&self) -> &Path {
3432
let TempDir(ref p) = *self;
3533
p
3634
}
@@ -51,7 +49,7 @@ impl Drop for TempDir {
5149
}
5250

5351
#[track_caller] // for `test_rng`
54-
pub fn tmpdir() -> TempDir {
52+
pub(crate) fn tmpdir() -> TempDir {
5553
let p = env::temp_dir();
5654
let mut r = test_rng();
5755
let ret = p.join(&format!("rust-{}", r.next_u32()));

0 commit comments

Comments
 (0)