Skip to content

Commit 25ed783

Browse files
committed
Allow Box containing shared type from other module
#541, but for Box in addition to Vec.
1 parent b110dfb commit 25ed783

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

syntax/check.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fn check_type_ident(cx: &mut Check, ident: &Ident) {
7676
fn check_type_box(cx: &mut Check, ptr: &Ty1) {
7777
if let Type::Ident(ident) = &ptr.inner {
7878
if cx.types.cxx.contains(&ident.rust)
79+
&& !cx.types.aliases.contains_key(&ident.rust)
7980
&& !cx.types.structs.contains_key(&ident.rust)
8081
&& !cx.types.enums.contains_key(&ident.rust)
8182
{
@@ -329,6 +330,7 @@ fn check_api_type(cx: &mut Check, ety: &ExternType) {
329330
TrivialReason::StructField(strct) => format!("a field of `{}`", strct.name.rust),
330331
TrivialReason::FunctionArgument(efn) => format!("an argument of `{}`", efn.name.rust),
331332
TrivialReason::FunctionReturn(efn) => format!("a return value of `{}`", efn.name.rust),
333+
TrivialReason::BoxTarget => format!("Box<{}>", ety.name.rust),
332334
TrivialReason::VecElement => format!("a vector element in Vec<{}>", ety.name.rust),
333335
};
334336
let msg = format!(

syntax/types.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,16 @@ impl<'a> Types<'a> {
202202
}
203203
}
204204
for ty in &all {
205-
if let Type::RustVec(ty) = ty {
206-
let reason = TrivialReason::VecElement;
207-
insist_alias_types_are_trivial(&ty.inner, reason);
205+
match ty {
206+
Type::RustBox(ty) => {
207+
let reason = TrivialReason::BoxTarget;
208+
insist_alias_types_are_trivial(&ty.inner, reason);
209+
}
210+
Type::RustVec(ty) => {
211+
let reason = TrivialReason::VecElement;
212+
insist_alias_types_are_trivial(&ty.inner, reason);
213+
}
214+
_ => {}
208215
}
209216
}
210217

@@ -303,6 +310,7 @@ pub enum TrivialReason<'a> {
303310
StructField(&'a Struct),
304311
FunctionArgument(&'a ExternFn),
305312
FunctionReturn(&'a ExternFn),
313+
BoxTarget,
306314
VecElement,
307315
}
308316

0 commit comments

Comments
 (0)