Skip to content

Commit 229c004

Browse files
committed
Seal all filesystem related extension traits.
1 parent 5f22daa commit 229c004

File tree

19 files changed

+77
-31
lines changed

19 files changed

+77
-31
lines changed

library/std/src/fs.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ pub struct File {
9292
inner: fs_imp::File,
9393
}
9494

95+
/// Allows extension traits within `std`.
96+
#[unstable(feature = "sealed", issue = "none")]
97+
impl crate::sealed::Sealed for File {}
98+
9599
/// Metadata information about a file.
96100
///
97101
/// This structure is returned from the [`metadata`] or
@@ -102,6 +106,10 @@ pub struct File {
102106
#[derive(Clone)]
103107
pub struct Metadata(fs_imp::FileAttr);
104108

109+
/// Allows extension traits within `std`.
110+
#[unstable(feature = "sealed", issue = "none")]
111+
impl crate::sealed::Sealed for Metadata {}
112+
105113
/// Iterator over the entries in a directory.
106114
///
107115
/// This iterator is returned from the [`read_dir`] function of this module and
@@ -128,6 +136,10 @@ pub struct ReadDir(fs_imp::ReadDir);
128136
#[stable(feature = "rust1", since = "1.0.0")]
129137
pub struct DirEntry(fs_imp::DirEntry);
130138

139+
/// Allows extension traits within `std`.
140+
#[unstable(feature = "sealed", issue = "none")]
141+
impl crate::sealed::Sealed for DirEntry {}
142+
131143
/// Options and flags which can be used to configure how a file is opened.
132144
///
133145
/// This builder exposes the ability to configure how a [`File`] is opened and
@@ -167,6 +179,10 @@ pub struct DirEntry(fs_imp::DirEntry);
167179
#[stable(feature = "rust1", since = "1.0.0")]
168180
pub struct OpenOptions(fs_imp::OpenOptions);
169181

182+
/// Allows extension traits within `std`.
183+
#[unstable(feature = "sealed", issue = "none")]
184+
impl crate::sealed::Sealed for OpenOptions {}
185+
170186
/// Representation of the various permissions on a file.
171187
///
172188
/// This module only currently provides one bit of information,
@@ -179,12 +195,20 @@ pub struct OpenOptions(fs_imp::OpenOptions);
179195
#[stable(feature = "rust1", since = "1.0.0")]
180196
pub struct Permissions(fs_imp::FilePermissions);
181197

198+
/// Allows extension traits within `std`.
199+
#[unstable(feature = "sealed", issue = "none")]
200+
impl crate::sealed::Sealed for Permissions {}
201+
182202
/// A structure representing a type of file with accessors for each file type.
183203
/// It is returned by [`Metadata::file_type`] method.
184204
#[stable(feature = "file_type", since = "1.1.0")]
185205
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
186206
pub struct FileType(fs_imp::FileType);
187207

208+
/// Allows extension traits within `std`.
209+
#[unstable(feature = "sealed", issue = "none")]
210+
impl crate::sealed::Sealed for FileType {}
211+
188212
/// A builder used to create directories in various manners.
189213
///
190214
/// This builder also supports platform-specific options.
@@ -195,6 +219,10 @@ pub struct DirBuilder {
195219
recursive: bool,
196220
}
197221

222+
/// Allows extension traits within `std`.
223+
#[unstable(feature = "sealed", issue = "none")]
224+
impl crate::sealed::Sealed for DirBuilder {}
225+
198226
/// Indicates how large a buffer to pre-allocate before reading the entire file.
199227
fn initial_buffer_size(file: &File) -> usize {
200228
// Allocate one extra byte so the buffer doesn't need to grow before the

library/std/src/os/android/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
#[allow(deprecated)]
@@ -10,7 +11,7 @@ use crate::os::android::raw;
1011
///
1112
/// [`fs::Metadata`]: crate::fs::Metadata
1213
#[stable(feature = "metadata_ext", since = "1.1.0")]
13-
pub trait MetadataExt {
14+
pub trait MetadataExt: Sealed {
1415
/// Gain a reference to the underlying `stat` structure which contains
1516
/// the raw information returned by the OS.
1617
///

library/std/src/os/dragonfly/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
#[allow(deprecated)]
@@ -10,7 +11,7 @@ use crate::os::dragonfly::raw;
1011
///
1112
/// [`fs::Metadata`]: crate::fs::Metadata
1213
#[stable(feature = "metadata_ext", since = "1.1.0")]
13-
pub trait MetadataExt {
14+
pub trait MetadataExt: Sealed {
1415
/// Gain a reference to the underlying `stat` structure which contains
1516
/// the raw information returned by the OS.
1617
///

library/std/src/os/emscripten/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
#[allow(deprecated)]
@@ -10,7 +11,7 @@ use crate::os::emscripten::raw;
1011
///
1112
/// [`fs::Metadata`]: crate::fs::Metadata
1213
#[stable(feature = "metadata_ext", since = "1.1.0")]
13-
pub trait MetadataExt {
14+
pub trait MetadataExt: Sealed {
1415
/// Gain a reference to the underlying `stat` structure which contains
1516
/// the raw information returned by the OS.
1617
///

library/std/src/os/freebsd/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
#[allow(deprecated)]
@@ -10,7 +11,7 @@ use crate::os::freebsd::raw;
1011
///
1112
/// [`fs::Metadata`]: crate::fs::Metadata
1213
#[stable(feature = "metadata_ext", since = "1.1.0")]
13-
pub trait MetadataExt {
14+
pub trait MetadataExt: Sealed {
1415
/// Gain a reference to the underlying `stat` structure which contains
1516
/// the raw information returned by the OS.
1617
///

library/std/src/os/fuchsia/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
/// OS-specific extensions to [`fs::Metadata`].
78
///
89
/// [`fs::Metadata`]: crate::fs::Metadata
910
#[stable(feature = "metadata_ext", since = "1.1.0")]
10-
pub trait MetadataExt {
11+
pub trait MetadataExt: Sealed {
1112
#[stable(feature = "metadata_ext2", since = "1.8.0")]
1213
fn st_dev(&self) -> u64;
1314
#[stable(feature = "metadata_ext2", since = "1.8.0")]

library/std/src/os/haiku/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
#[allow(deprecated)]
@@ -10,7 +11,7 @@ use crate::os::haiku::raw;
1011
///
1112
/// [`fs::Metadata`]: crate::fs::Metadata
1213
#[stable(feature = "metadata_ext", since = "1.1.0")]
13-
pub trait MetadataExt {
14+
pub trait MetadataExt: Sealed {
1415
/// Gain a reference to the underlying `stat` structure which contains
1516
/// the raw information returned by the OS.
1617
///

library/std/src/os/illumos/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
#[allow(deprecated)]
@@ -10,7 +11,7 @@ use crate::os::illumos::raw;
1011
///
1112
/// [`fs::Metadata`]: crate::fs::Metadata
1213
#[stable(feature = "metadata_ext", since = "1.1.0")]
13-
pub trait MetadataExt {
14+
pub trait MetadataExt: Sealed {
1415
/// Gain a reference to the underlying `stat` structure which contains
1516
/// the raw information returned by the OS.
1617
///

library/std/src/os/ios/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![stable(feature = "metadata_ext", since = "1.1.0")]
22

33
use crate::fs::Metadata;
4+
use crate::sealed::Sealed;
45
use crate::sys_common::AsInner;
56

67
#[allow(deprecated)]
@@ -10,7 +11,7 @@ use crate::os::ios::raw;
1011
///
1112
/// [`fs::Metadata`]: crate::fs::Metadata
1213
#[stable(feature = "metadata_ext", since = "1.1.0")]
13-
pub trait MetadataExt {
14+
pub trait MetadataExt: Sealed {
1415
/// Gain a reference to the underlying `stat` structure which contains
1516
/// the raw information returned by the OS.
1617
///

library/std/src/os/linux/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![stable(feature = "metadata_ext", since = "1.1.0")]
44

55
use crate::fs::Metadata;
6+
use crate::sealed::Sealed;
67
use crate::sys_common::AsInner;
78

89
#[allow(deprecated)]
@@ -12,7 +13,7 @@ use crate::os::linux::raw;
1213
///
1314
/// [`fs::Metadata`]: crate::fs::Metadata
1415
#[stable(feature = "metadata_ext", since = "1.1.0")]
15-
pub trait MetadataExt {
16+
pub trait MetadataExt: Sealed {
1617
/// Gain a reference to the underlying `stat` structure which contains
1718
/// the raw information returned by the OS.
1819
///

0 commit comments

Comments
 (0)