Skip to content

Commit 03a1781

Browse files
committed
fix: vec! macro resolution via alloc::vec self-import
`use alloc::vec::{self, Vec};` relies on the `self` import also bringing the `vec!` macro into scope alongside the `vec` module. On some rustc versions this only resolves the module (type namespace), so unqualified `vec![...]` calls in this file fail with "cannot find macro `vec` in this scope". Import `Drain` by name instead of the `vec` module, and fully qualify the two `vec!` invocations (`alloc::vec!` / `$crate::alloc::vec!`) so macro resolution no longer depends on the `self`-import quirk. Signed-off-by: Ravi Chamarthy <ravi@ciroos.ai>
1 parent 5f4240f commit 03a1781

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/tinyvec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::*;
22

3-
use alloc::vec::{self, Vec};
3+
use alloc::vec::{Drain, Vec};
44
use core::convert::TryFrom;
55
use tinyvec_macros::impl_mirrored;
66

@@ -46,7 +46,7 @@ macro_rules! tiny_vec {
4646
f($crate::array_vec!($array_type => $($elem),*))
4747
}
4848
$crate::TinyVecConstructor::Heap(f) => {
49-
f(vec![$($elem),*])
49+
f($crate::alloc::vec![$($elem),*])
5050
}
5151
}
5252
}
@@ -707,7 +707,7 @@ impl<A: Array> TinyVec<A> {
707707
if len <= A::CAPACITY {
708708
TinyVec::Inline(ArrayVec::from_array_len(A::default(), len))
709709
} else {
710-
TinyVec::Heap(vec![A::Item::default(); len])
710+
TinyVec::Heap(alloc::vec![A::Item::default(); len])
711711
}
712712
}
713713

@@ -1308,7 +1308,7 @@ pub enum TinyVecDrain<'p, A: Array> {
13081308
#[allow(missing_docs)]
13091309
Inline(ArrayVecDrain<'p, A::Item>),
13101310
#[allow(missing_docs)]
1311-
Heap(vec::Drain<'p, A::Item>),
1311+
Heap(Drain<'p, A::Item>),
13121312
}
13131313

13141314
impl<'p, A: Array> Iterator for TinyVecDrain<'p, A> {

0 commit comments

Comments
 (0)