Use absolute paths consistently in generated code

This commit is contained in:
David Tolnay 2020-04-25 13:12:14 -07:00
parent d1413040ae
commit 91d1bb9b7d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 8 additions and 8 deletions

View File

@ -990,7 +990,7 @@ fn write_rust_vec_extern(out: &mut OutFile, ty: &Type) {
);
writeln!(
out,
"void cxxbridge02$rust_vec${}$vector_from(const ::rust::Vec<{}> *ptr, const std::vector<{}> &vector) noexcept;",
"void cxxbridge02$rust_vec${}$vector_from(const ::rust::Vec<{}> *ptr, const ::std::vector<{}> &vector) noexcept;",
instance, inner, inner
);
writeln!(
@ -1043,12 +1043,12 @@ fn write_rust_vec_impl(out: &mut OutFile, ty: &Type) {
writeln!(out, "template <>");
writeln!(
out,
"Vec<{}>::operator std::vector<{}>() const noexcept {{",
"Vec<{}>::operator ::std::vector<{}>() const noexcept {{",
inner, inner
);
writeln!(
out,
" std::vector<{}> v; v.reserve(this->size()); cxxbridge02$rust_vec${}$vector_from(this, v); return v;",
" ::std::vector<{}> v; v.reserve(this->size()); cxxbridge02$rust_vec${}$vector_from(this, v); return v;",
inner, instance,
);
writeln!(out, "}}");
@ -1149,7 +1149,7 @@ fn write_vector(out: &mut OutFile, ident: &Ident) {
writeln!(out, "#define CXXBRIDGE02_vector_{}", instance);
writeln!(
out,
"size_t cxxbridge02$std$vector${}$length(const std::vector<{}> &s) noexcept {{",
"size_t cxxbridge02$std$vector${}$length(const ::std::vector<{}> &s) noexcept {{",
instance, inner,
);
writeln!(out, " return s.size();");
@ -1157,7 +1157,7 @@ fn write_vector(out: &mut OutFile, ident: &Ident) {
writeln!(
out,
"void cxxbridge02$std$vector${}$push_back(std::vector<{}> &s, const {} &item) noexcept {{",
"void cxxbridge02$std$vector${}$push_back(::std::vector<{}> &s, const {} &item) noexcept {{",
instance, inner, inner
);
writeln!(out, " s.push_back(item);");
@ -1165,7 +1165,7 @@ fn write_vector(out: &mut OutFile, ident: &Ident) {
writeln!(
out,
"const {} *cxxbridge02$std$vector${}$get_unchecked(const std::vector<{}> &s, size_t pos) noexcept {{",
"const {} *cxxbridge02$std$vector${}$get_unchecked(const ::std::vector<{}> &s, size_t pos) noexcept {{",
inner, instance, inner,
);
writeln!(out, " return &s[pos];");

View File

@ -27,9 +27,9 @@ impl ToTypename for Type {
Type::RustBox(ptr) => format!("rust_box<{}>", ptr.inner.to_typename(namespace)),
Type::RustVec(ptr) => format!("rust_vec<{}>", ptr.inner.to_typename(namespace)),
Type::UniquePtr(ptr) => {
format!("std::unique_ptr<{}>", ptr.inner.to_typename(namespace))
format!("::std::unique_ptr<{}>", ptr.inner.to_typename(namespace))
}
Type::Vector(ptr) => format!("std::vector<{}>", ptr.inner.to_typename(namespace)),
Type::Vector(ptr) => format!("::std::vector<{}>", ptr.inner.to_typename(namespace)),
_ => unimplemented!(),
}
}