Skip to content

Commit 5deb00b

Browse files
committed
Ensure we use the in-crate type for traits returning references
1 parent f0603d5 commit 5deb00b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

c-bindings-gen/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,13 +1326,13 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
13261326
if let syn::ReturnType::Type(_, rtype) = &$m.sig.output {
13271327
if let syn::Type::Reference(r) = &**rtype {
13281328
assert_eq!($m.sig.inputs.len(), 1); // Must only take self
1329-
writeln!(w, "extern \"C\" fn {}_{}_set_{}(trait_self_arg: &{}) {{", ident, $trait.ident, $m.sig.ident, $trait.ident).unwrap();
1329+
writeln!(w, "extern \"C\" fn {}_{}_set_{}(trait_self_arg: &crate::{}) {{", ident, $trait.ident, $m.sig.ident, $trait_path).unwrap();
13301330
writeln!(w, "\t// This is a bit race-y in the general case, but for our specific use-cases today, we're safe").unwrap();
13311331
writeln!(w, "\t// Specifically, we must ensure that the first time we're called it can never be in parallel").unwrap();
13321332
write!(w, "\tif ").unwrap();
13331333
$types.write_empty_rust_val_check(Some(&meth_gen_types), w, &*r.elem, &format!("unsafe {{ &*trait_self_arg.{}.get() }}", $m.sig.ident));
13341334
writeln!(w, " {{").unwrap();
1335-
writeln!(w, "\t\t*unsafe {{ &mut *(&*(trait_self_arg as *const {})).{}.get() }} = {}_{}_{}(trait_self_arg.this_arg).into();", $trait.ident, $m.sig.ident, ident, $trait.ident, $m.sig.ident).unwrap();
1335+
writeln!(w, "\t\t*unsafe {{ &mut *(&*(trait_self_arg as *const crate::{})).{}.get() }} = {}_{}_{}(trait_self_arg.this_arg).into();", $trait_path, $m.sig.ident, ident, $trait.ident, $m.sig.ident).unwrap();
13361336
writeln!(w, "\t}}").unwrap();
13371337
writeln!(w, "}}").unwrap();
13381338
}

0 commit comments

Comments
 (0)