mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2025-02-13 10:47:43 +00:00
Suppress irrelevant "required by this bound" from error message
This commit is contained in:
parent
b17b9f3bf4
commit
1044d44f30
@ -20,20 +20,15 @@ pub fn bridge(namespace: &Namespace, ffi: ItemMod) -> Result<TokenStream> {
|
||||
|
||||
let mut expanded = TokenStream::new();
|
||||
let mut hidden = TokenStream::new();
|
||||
let mut has_rust_type = false;
|
||||
|
||||
for api in &apis {
|
||||
if let Api::RustType(ety) = api {
|
||||
expanded.extend(expand_rust_type(ety));
|
||||
if !has_rust_type {
|
||||
hidden.extend(quote!(
|
||||
const fn __assert_sized<T>() {}
|
||||
));
|
||||
has_rust_type = true;
|
||||
}
|
||||
let ident = &ety.ident;
|
||||
let span = ident.span();
|
||||
hidden.extend(quote_spanned!(span=> __assert_sized::<#ident>();));
|
||||
hidden.extend(quote_spanned! {span=>
|
||||
let _ = ::std::ptr::read::<#ident>;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/opaque_not_sized.rs:4:14
|
||||
|
|
||||
1 | #[cxx::bridge]
|
||||
| -------------- required by this bound in `ffi::_::__assert_sized`
|
||||
...
|
||||
4 | type TypeR;
|
||||
| ^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: within `TypeR`, the trait `std::marker::Sized` is not implemented for `str`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: required because it appears within the type `TypeR`
|
||||
--> $DIR/opaque_not_sized.rs:4:14
|
||||
|
|
||||
4 | type TypeR;
|
||||
| ^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: within `TypeR`, the trait `std::marker::Sized` is not implemented for `str`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: required because it appears within the type `TypeR`
|
||||
|
Loading…
x
Reference in New Issue
Block a user