rust-lang / rust-lang/rust-bindgen
Replacement types possibly confuse `used_template_params` somehow
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Reproduction:
C++:
/**
* <div rustbindgen="true" replaces="std::unique_ptr">
*/
template<typename T> class UniquePtr {
T* ptr;
};
#include <memory>
template <typename at> class au {
std::unique_ptr<at> aw;
};
class bb;
using bc = au<bb>;
Command-line:
cargo run -- test.hpp --no-layout-tests --enable-cxx-namespaces --allowlist-type bc -- -std=c++14
Rust output:
/* automatically generated by rust-bindgen 0.71.1 */
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
#[allow(unused_imports)]
use self::super::root;
pub mod std {
#[allow(unused_imports)]
use self::super::super::root;
#[doc = " <div rustbindgen=\"true\" replaces=\"std::unique_ptr\">"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct unique_ptr<T> {
pub _phantom_0:
::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
pub ptr: *mut T,
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct au {
pub aw: root::std::unique_ptr<T>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bb {
_unused: [u8; 0],
}
pub type bc = root::au;
}
Note this bit:
pub struct au {
pub aw: root::std::unique_ptr<T>,
}
... we're depending on a template parameter which doesn't exist in the outer struct.
Bindgen version 20aa65a0b9edfd5f8ab3e038197da5cb2c52ff18, today's HEAD.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test.hpp reproduction and run the listed cargo command against the current bindgen checkout. Inspect the generated Rust for the au field and verify that replacement-type handling does not leave an undeclared template parameter in the output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100