Skip to content

Commit f437391

Browse files
committed
handle remaining redundant import warnings
1 parent 18d869e commit f437391

File tree

9 files changed

+95
-111
lines changed

9 files changed

+95
-111
lines changed

capnp/src/capability.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
//!
2424
//! Roughly corresponds to capability.h in the C++ implementation.
2525
26-
#[cfg(feature = "alloc")]
27-
use alloc::boxed::Box;
2826
#[cfg(feature = "alloc")]
2927
use core::future::Future;
3028
#[cfg(feature = "alloc")]
31-
use core::marker::{PhantomData, Unpin};
29+
use core::marker::PhantomData;
3230
#[cfg(feature = "rpc_try")]
3331
use core::ops::Try;
3432
#[cfg(feature = "alloc")]
@@ -55,7 +53,7 @@ pub struct Promise<T, E> {
5553
#[cfg(feature = "alloc")]
5654
enum PromiseInner<T, E> {
5755
Immediate(Result<T, E>),
58-
Deferred(Pin<Box<dyn Future<Output = core::result::Result<T, E>> + 'static>>),
56+
Deferred(Pin<alloc::boxed::Box<dyn Future<Output = core::result::Result<T, E>> + 'static>>),
5957
Empty,
6058
}
6159

@@ -82,7 +80,7 @@ impl<T, E> Promise<T, E> {
8280
F: Future<Output = core::result::Result<T, E>> + 'static,
8381
{
8482
Self {
85-
inner: PromiseInner::Deferred(Box::pin(f)),
83+
inner: PromiseInner::Deferred(alloc::boxed::Box::pin(f)),
8684
}
8785
}
8886
}
@@ -146,15 +144,15 @@ where
146144
#[cfg(feature = "alloc")]
147145
pub struct Response<Results> {
148146
pub marker: PhantomData<Results>,
149-
pub hook: Box<dyn ResponseHook>,
147+
pub hook: alloc::boxed::Box<dyn ResponseHook>,
150148
}
151149

152150
#[cfg(feature = "alloc")]
153151
impl<Results> Response<Results>
154152
where
155153
Results: Pipelined + Owned,
156154
{
157-
pub fn new(hook: Box<dyn ResponseHook>) -> Self {
155+
pub fn new(hook: alloc::boxed::Box<dyn ResponseHook>) -> Self {
158156
Self {
159157
marker: PhantomData,
160158
hook,
@@ -169,15 +167,15 @@ where
169167
#[cfg(feature = "alloc")]
170168
pub struct Request<Params, Results> {
171169
pub marker: PhantomData<(Params, Results)>,
172-
pub hook: Box<dyn RequestHook>,
170+
pub hook: alloc::boxed::Box<dyn RequestHook>,
173171
}
174172

175173
#[cfg(feature = "alloc")]
176174
impl<Params, Results> Request<Params, Results>
177175
where
178176
Params: Owned,
179177
{
180-
pub fn new(hook: Box<dyn RequestHook>) -> Self {
178+
pub fn new(hook: alloc::boxed::Box<dyn RequestHook>) -> Self {
181179
Self {
182180
hook,
183181
marker: PhantomData,
@@ -220,12 +218,12 @@ where
220218
#[cfg(feature = "alloc")]
221219
pub struct Params<T> {
222220
pub marker: PhantomData<T>,
223-
pub hook: Box<dyn ParamsHook>,
221+
pub hook: alloc::boxed::Box<dyn ParamsHook>,
224222
}
225223

226224
#[cfg(feature = "alloc")]
227225
impl<T> Params<T> {
228-
pub fn new(hook: Box<dyn ParamsHook>) -> Self {
226+
pub fn new(hook: alloc::boxed::Box<dyn ParamsHook>) -> Self {
229227
Self {
230228
marker: PhantomData,
231229
hook,
@@ -243,15 +241,15 @@ impl<T> Params<T> {
243241
#[cfg(feature = "alloc")]
244242
pub struct Results<T> {
245243
pub marker: PhantomData<T>,
246-
pub hook: Box<dyn ResultsHook>,
244+
pub hook: alloc::boxed::Box<dyn ResultsHook>,
247245
}
248246

249247
#[cfg(feature = "alloc")]
250248
impl<T> Results<T>
251249
where
252250
T: Owned,
253251
{
254-
pub fn new(hook: Box<dyn ResultsHook>) -> Self {
252+
pub fn new(hook: alloc::boxed::Box<dyn ResultsHook>) -> Self {
255253
Self {
256254
marker: PhantomData,
257255
hook,
@@ -275,10 +273,10 @@ pub trait FromTypelessPipeline {
275273
#[cfg(feature = "alloc")]
276274
pub trait FromClientHook {
277275
/// Wraps a client hook to create a new client.
278-
fn new(hook: Box<dyn ClientHook>) -> Self;
276+
fn new(hook: alloc::boxed::Box<dyn ClientHook>) -> Self;
279277

280278
/// Unwraps client to get the underlying client hook.
281-
fn into_client_hook(self) -> Box<dyn ClientHook>;
279+
fn into_client_hook(self) -> alloc::boxed::Box<dyn ClientHook>;
282280

283281
/// Gets a reference to the underlying client hook.
284282
fn as_client_hook(&self) -> &dyn ClientHook;
@@ -297,12 +295,12 @@ pub trait FromClientHook {
297295
/// An untyped client.
298296
#[cfg(feature = "alloc")]
299297
pub struct Client {
300-
pub hook: Box<dyn ClientHook>,
298+
pub hook: alloc::boxed::Box<dyn ClientHook>,
301299
}
302300

303301
#[cfg(feature = "alloc")]
304302
impl Client {
305-
pub fn new(hook: Box<dyn ClientHook>) -> Self {
303+
pub fn new(hook: alloc::boxed::Box<dyn ClientHook>) -> Self {
306304
Self { hook }
307305
}
308306

capnp/src/capability_list.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
//! List of capabilities.
2222
#![cfg(feature = "alloc")]
2323

24-
use alloc::boxed::Box;
2524
use core::marker::PhantomData;
2625

2726
use crate::capability::FromClientHook;
@@ -182,7 +181,7 @@ where
182181
}
183182
}
184183

185-
pub fn set(&mut self, index: u32, value: Box<dyn ClientHook>) {
184+
pub fn set(&mut self, index: u32, value: alloc::boxed::Box<dyn ClientHook>) {
186185
assert!(index < self.len());
187186
self.builder
188187
.reborrow()

capnp/src/message.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@
6868
//! }
6969
//!
7070
//! ```
71-
#[cfg(feature = "alloc")]
72-
use alloc::vec::Vec;
73-
use core::convert::From;
7471
7572
use crate::any_pointer;
7673
use crate::private::arena::{BuilderArena, BuilderArenaImpl};
@@ -280,7 +277,7 @@ where
280277
/// of this message. Works by copying the message twice. For a canonicalization
281278
/// method that only requires one copy, see `message::Builder::set_root_canonical()`.
282279
#[cfg(feature = "alloc")]
283-
pub fn canonicalize(&self) -> Result<Vec<crate::Word>> {
280+
pub fn canonicalize(&self) -> Result<alloc::vec::Vec<crate::Word>> {
284281
let root = self.get_root_internal()?;
285282
let size = root.target_size()?.word_count + 1;
286283
let mut message = Builder::new(HeapAllocator::new().first_segment_words(size as u32));

capnp/src/private/arena.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
2020

21-
#[cfg(feature = "alloc")]
22-
use alloc::vec::Vec;
2321
use core::slice;
2422
use core::u64;
2523

@@ -173,7 +171,7 @@ struct BuilderSegment {
173171
}
174172

175173
#[cfg(feature = "alloc")]
176-
type BuilderSegmentArray = Vec<BuilderSegment>;
174+
type BuilderSegmentArray = alloc::vec::Vec<BuilderSegment>;
177175

178176
#[cfg(not(feature = "alloc"))]
179177
#[derive(Default)]
@@ -271,7 +269,7 @@ where
271269
} else {
272270
#[cfg(feature = "alloc")]
273271
{
274-
let mut v = Vec::with_capacity(reff.segments.len());
272+
let mut v = alloc::vec::Vec::with_capacity(reff.segments.len());
275273
for seg in &reff.segments {
276274
// See safety argument in above branch.
277275
let slice = unsafe {

capnp/src/private/capability.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
// THE SOFTWARE.
2121

22-
#![cfg(feature = "alloc")]
23-
use alloc::boxed::Box;
24-
2522
use crate::any_pointer;
2623
use crate::capability::{Params, Promise, RemotePromise, Request, Results};
2724
use crate::MessageSize;
@@ -33,18 +30,18 @@ pub trait ResponseHook {
3330
pub trait RequestHook {
3431
fn get(&mut self) -> any_pointer::Builder<'_>;
3532
fn get_brand(&self) -> usize;
36-
fn send(self: Box<Self>) -> RemotePromise<any_pointer::Owned>;
33+
fn send(self: alloc::boxed::Box<Self>) -> RemotePromise<any_pointer::Owned>;
3734
fn tail_send(
38-
self: Box<Self>,
35+
self: alloc::boxed::Box<Self>,
3936
) -> Option<(
4037
u32,
4138
crate::capability::Promise<(), crate::Error>,
42-
Box<dyn PipelineHook>,
39+
alloc::boxed::Box<dyn PipelineHook>,
4340
)>;
4441
}
4542

4643
pub trait ClientHook {
47-
fn add_ref(&self) -> Box<dyn ClientHook>;
44+
fn add_ref(&self) -> alloc::boxed::Box<dyn ClientHook>;
4845
fn new_call(
4946
&self,
5047
interface_id: u64,
@@ -56,8 +53,8 @@ pub trait ClientHook {
5653
&self,
5754
interface_id: u64,
5855
method_id: u16,
59-
params: Box<dyn ParamsHook>,
60-
results: Box<dyn ResultsHook>,
56+
params: alloc::boxed::Box<dyn ParamsHook>,
57+
results: alloc::boxed::Box<dyn ResultsHook>,
6158
) -> crate::capability::Promise<(), crate::Error>;
6259

6360
/// If this capability is associated with an rpc connection, then this method
@@ -71,21 +68,21 @@ pub trait ClientHook {
7168
/// of the capability. The caller may permanently replace this client with the resolved one if
7269
/// desired. Returns null if the client isn't a promise or hasn't resolved yet -- use
7370
/// `whenMoreResolved()` to distinguish between them.
74-
fn get_resolved(&self) -> Option<Box<dyn ClientHook>>;
71+
fn get_resolved(&self) -> Option<alloc::boxed::Box<dyn ClientHook>>;
7572

7673
/// If this client is a settled reference (not a promise), return nullptr. Otherwise, return a
7774
/// promise that eventually resolves to a new client that is closer to being the final, settled
7875
/// client (i.e. the value eventually returned by `getResolved()`). Calling this repeatedly
7976
/// should eventually produce a settled client.
8077
fn when_more_resolved(
8178
&self,
82-
) -> Option<crate::capability::Promise<Box<dyn ClientHook>, crate::Error>>;
79+
) -> Option<crate::capability::Promise<alloc::boxed::Box<dyn ClientHook>, crate::Error>>;
8380

8481
/// Repeatedly calls whenMoreResolved() until it returns nullptr.
8582
fn when_resolved(&self) -> Promise<(), crate::Error>;
8683
}
8784

88-
impl Clone for Box<dyn ClientHook> {
85+
impl Clone for alloc::boxed::Box<dyn ClientHook> {
8986
fn clone(&self) -> Self {
9087
self.add_ref()
9188
}
@@ -94,13 +91,16 @@ impl Clone for Box<dyn ClientHook> {
9491
pub trait ResultsHook {
9592
fn get(&mut self) -> crate::Result<any_pointer::Builder<'_>>;
9693
fn allow_cancellation(&self);
97-
fn tail_call(self: Box<Self>, request: Box<dyn RequestHook>) -> Promise<(), crate::Error>;
94+
fn tail_call(
95+
self: alloc::boxed::Box<Self>,
96+
request: alloc::boxed::Box<dyn RequestHook>,
97+
) -> Promise<(), crate::Error>;
9898
fn direct_tail_call(
99-
self: Box<Self>,
100-
request: Box<dyn RequestHook>,
99+
self: alloc::boxed::Box<Self>,
100+
request: alloc::boxed::Box<dyn RequestHook>,
101101
) -> (
102102
crate::capability::Promise<(), crate::Error>,
103-
Box<dyn PipelineHook>,
103+
alloc::boxed::Box<dyn PipelineHook>,
104104
);
105105
}
106106

@@ -131,17 +131,20 @@ pub fn internal_get_untyped_results<T>(typeful: Results<T>) -> Results<any_point
131131
}
132132

133133
pub trait PipelineHook {
134-
fn add_ref(&self) -> Box<dyn PipelineHook>;
135-
fn get_pipelined_cap(&self, ops: &[PipelineOp]) -> Box<dyn ClientHook>;
134+
fn add_ref(&self) -> alloc::boxed::Box<dyn PipelineHook>;
135+
fn get_pipelined_cap(&self, ops: &[PipelineOp]) -> alloc::boxed::Box<dyn ClientHook>;
136136

137137
/// Version of get_pipelined_cap() passing the array by move. May avoid a copy in some cases.
138138
/// Default implementation just calls the other version.
139-
fn get_pipelined_cap_move(&self, ops: alloc::vec::Vec<PipelineOp>) -> Box<dyn ClientHook> {
139+
fn get_pipelined_cap_move(
140+
&self,
141+
ops: alloc::vec::Vec<PipelineOp>,
142+
) -> alloc::boxed::Box<dyn ClientHook> {
140143
self.get_pipelined_cap(&ops)
141144
}
142145
}
143146

144-
impl Clone for Box<dyn PipelineHook> {
147+
impl Clone for alloc::boxed::Box<dyn PipelineHook> {
145148
fn clone(&self) -> Self {
146149
self.add_ref()
147150
}

0 commit comments

Comments
 (0)