Skip to content

Commit 152b89b

Browse files
committed
No-std fixes for Box, String, Pin, c_char
1 parent 8b7643b commit 152b89b

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

macro/src/load.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn translate_qual_type(cx: &mut Errors, enm: &Enum, qual_type: &str) -> Path {
264264
.unwrap()
265265
.span();
266266
let ident = Ident::new(rust_std_name, span);
267-
let path = quote_spanned!(span=> ::std::os::raw::#ident);
267+
let path = quote_spanned!(span=> ::cxx::core::ffi::#ident);
268268
parse_quote!(#path)
269269
}
270270

macro/src/tokens.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ToTokens for ReceiverType<'_> {
3333
mutability,
3434
} = &self.0;
3535
if let Some((pin, langle, _rangle)) = pin_tokens {
36-
tokens.extend(quote_spanned!(pin.span=> ::std::pin::Pin));
36+
tokens.extend(quote_spanned!(pin.span=> ::cxx::core::pin::Pin));
3737
langle.to_tokens(tokens);
3838
}
3939
ampersand.to_tokens(tokens);
@@ -61,7 +61,7 @@ impl ToTokens for ReceiverTypeSelf<'_> {
6161
mutability,
6262
} = &self.0;
6363
if let Some((pin, langle, _rangle)) = pin_tokens {
64-
tokens.extend(quote_spanned!(pin.span=> ::std::pin::Pin));
64+
tokens.extend(quote_spanned!(pin.span=> ::cxx::core::pin::Pin));
6565
langle.to_tokens(tokens);
6666
}
6767
ampersand.to_tokens(tokens);

src/c_char.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![cfg(feature = "alloc")]
2-
1+
#[allow(missing_docs)]
32
pub type c_char = c_char_definition::c_char;
43

54
// Validate that our definition is consistent with libstd's definition, without

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ pub type Vector<T> = CxxVector<T>;
490490
// Not public API.
491491
#[doc(hidden)]
492492
pub mod private {
493+
pub use crate::c_char::c_char;
493494
pub use crate::cxx_vector::VectorElement;
494495
pub use crate::extern_type::{verify_extern_kind, verify_extern_type};
495496
pub use crate::function::FatFunction;

syntax/tokens.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ impl ToTokens for Type {
1313
Type::Ident(ident) => {
1414
if ident.rust == Char {
1515
let span = ident.rust.span();
16-
tokens.extend(quote_spanned!(span=> ::std::os::raw::));
16+
tokens.extend(quote_spanned!(span=> ::cxx::private::));
1717
} else if ident.rust == CxxString {
1818
let span = ident.rust.span();
1919
tokens.extend(quote_spanned!(span=> ::cxx::));
20+
} else if ident.rust == RustString {
21+
let span = ident.rust.span();
22+
tokens.extend(quote_spanned!(span=> ::cxx::alloc::string::));
2023
}
2124
ident.to_tokens(tokens);
2225
}
@@ -66,8 +69,11 @@ impl ToTokens for Ty1 {
6669
"UniquePtr" | "SharedPtr" | "WeakPtr" | "CxxVector" => {
6770
tokens.extend(quote_spanned!(span=> ::cxx::));
6871
}
72+
"Box" => {
73+
tokens.extend(quote_spanned!(span=> ::cxx::alloc::boxed::));
74+
}
6975
"Vec" => {
70-
tokens.extend(quote_spanned!(span=> ::std::vec::));
76+
tokens.extend(quote_spanned!(span=> ::cxx::alloc::vec::));
7177
}
7278
_ => {}
7379
}
@@ -90,7 +96,7 @@ impl ToTokens for Ref {
9096
mutability,
9197
} = self;
9298
if let Some((pin, langle, _rangle)) = pin_tokens {
93-
tokens.extend(quote_spanned!(pin.span=> ::std::pin::Pin));
99+
tokens.extend(quote_spanned!(pin.span=> ::cxx::core::pin::Pin));
94100
langle.to_tokens(tokens);
95101
}
96102
ampersand.to_tokens(tokens);

0 commit comments

Comments
 (0)