Skip to content

Commit 58dd07c

Browse files
authored
Give ambient authority arguments names. (#298)
Use `let _ = ambient_authority;` to suppress unused argument warnings rather than naming arguments `_`, because argument names show up in the documentation, and the fact that these arguments are unused is not part of the public interface.
1 parent daa7bcb commit 58dd07c

File tree

7 files changed

+41
-11
lines changed

7 files changed

+41
-11
lines changed

cap-directories/src/project_dirs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ impl ProjectDirs {
3434
qualifier: &str,
3535
organization: &str,
3636
application: &str,
37-
_: AmbientAuthority,
37+
ambient_authority: AmbientAuthority,
3838
) -> Option<Self> {
39+
let _ = ambient_authority;
3940
let inner = directories_next::ProjectDirs::from(qualifier, organization, application)?;
4041
Some(Self { inner })
4142
}

cap-primitives/src/net/pool.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ impl Pool {
5151
/// # Ambient Authority
5252
///
5353
/// This function allows ambient access to any IP address.
54-
pub fn insert_ip_net(&mut self, ip_net: ipnet::IpNet, port: u16, _: AmbientAuthority) {
54+
pub fn insert_ip_net(
55+
&mut self,
56+
ip_net: ipnet::IpNet,
57+
port: u16,
58+
ambient_authority: AmbientAuthority,
59+
) {
60+
let _ = ambient_authority;
61+
5562
self.grants.push(IpGrant {
5663
set: AddrSet::Net(ip_net),
5764
port,
@@ -63,7 +70,13 @@ impl Pool {
6370
/// # Ambient Authority
6471
///
6572
/// This function allows ambient access to any IP address.
66-
pub fn insert_socket_addr(&mut self, addr: net::SocketAddr, _: AmbientAuthority) {
73+
pub fn insert_socket_addr(
74+
&mut self,
75+
addr: net::SocketAddr,
76+
ambient_authority: AmbientAuthority,
77+
) {
78+
let _ = ambient_authority;
79+
6780
self.grants.push(IpGrant {
6881
set: AddrSet::Net(addr.ip().into()),
6982
port: addr.port(),

cap-primitives/src/rustix/fs/dir_utils.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ pub(crate) fn canonicalize_options() -> OpenOptions {
102102
///
103103
/// This function is not sandboxed and may trivially access any path that the
104104
/// host process has access to.
105-
pub(crate) fn open_ambient_dir_impl(path: &Path, _: AmbientAuthority) -> io::Result<fs::File> {
105+
pub(crate) fn open_ambient_dir_impl(
106+
path: &Path,
107+
ambient_authority: AmbientAuthority,
108+
) -> io::Result<fs::File> {
109+
let _ = ambient_authority;
110+
106111
let mut options = fs::OpenOptions::new();
107112
options.read(true);
108113

cap-primitives/src/time/monotonic_clock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ impl MonotonicClock {
1717
///
1818
/// This uses ambient authority to accesses clocks.
1919
#[inline]
20-
pub const fn new(_: AmbientAuthority) -> Self {
20+
pub const fn new(ambient_authority: AmbientAuthority) -> Self {
21+
let _ = ambient_authority;
2122
Self(())
2223
}
2324

cap-primitives/src/time/system_clock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl SystemClock {
2626
///
2727
/// This uses ambient authority to accesses clocks.
2828
#[inline]
29-
pub const fn new(_: AmbientAuthority) -> Self {
29+
pub const fn new(ambient_authority: AmbientAuthority) -> Self {
30+
let _ = ambient_authority;
3031
Self(())
3132
}
3233

cap-primitives/src/windows/fs/dir_utils.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ pub(crate) fn canonicalize_options() -> OpenOptions {
9292
///
9393
/// This function is not sandboxed and may trivially access any path that the
9494
/// host process has access to.
95-
pub(crate) fn open_ambient_dir_impl(path: &Path, _: AmbientAuthority) -> io::Result<fs::File> {
95+
pub(crate) fn open_ambient_dir_impl(
96+
path: &Path,
97+
ambient_authority: AmbientAuthority,
98+
) -> io::Result<fs::File> {
99+
let _ = ambient_authority;
100+
96101
// Set `FILE_FLAG_BACKUP_SEMANTICS` so that we can open directories. Unset
97102
// `FILE_SHARE_DELETE` so that directories can't be renamed or deleted
98103
// underneath us, since we use paths to implement many directory operations.

cap-rand/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ pub mod rngs {
7474
/// This function makes use of ambient authority to access the platform
7575
/// entropy source.
7676
#[inline]
77-
pub const fn default(_: AmbientAuthority) -> Self {
77+
pub const fn default(ambient_authority: AmbientAuthority) -> Self {
78+
let _ = ambient_authority;
7879
Self(())
7980
}
8081
}
@@ -161,7 +162,8 @@ pub mod rngs {
161162
/// This function makes use of ambient authority to access the platform entropy
162163
/// source.
163164
#[inline]
164-
pub fn thread_rng(_: AmbientAuthority) -> rngs::CapRng {
165+
pub fn thread_rng(ambient_authority: AmbientAuthority) -> rngs::CapRng {
166+
let _ = ambient_authority;
165167
rngs::CapRng {
166168
inner: rand::thread_rng(),
167169
}
@@ -176,7 +178,8 @@ pub fn thread_rng(_: AmbientAuthority) -> rngs::CapRng {
176178
/// This function makes use of ambient authority to access the platform entropy
177179
/// source.
178180
#[inline]
179-
pub fn std_rng_from_entropy(_: AmbientAuthority) -> rngs::StdRng {
181+
pub fn std_rng_from_entropy(ambient_authority: AmbientAuthority) -> rngs::StdRng {
182+
let _ = ambient_authority;
180183
rand::rngs::StdRng::from_entropy()
181184
}
182185

@@ -189,9 +192,10 @@ pub fn std_rng_from_entropy(_: AmbientAuthority) -> rngs::StdRng {
189192
/// This function makes use of ambient authority to access the platform entropy
190193
/// source.
191194
#[inline]
192-
pub fn random<T>(_: AmbientAuthority) -> T
195+
pub fn random<T>(ambient_authority: AmbientAuthority) -> T
193196
where
194197
crate::distributions::Standard: crate::distributions::Distribution<T>,
195198
{
199+
let _ = ambient_authority;
196200
rand::random()
197201
}

0 commit comments

Comments
 (0)