Change 'BackendTypes::BasicBlock: Copy' to 'BackendTypes::BasicBlock: Clone', and carefully consider whether to require associative type impl Copy

rustc_codegen_ssa/src/traits/backend.rs:31

pub trait BackendTypes {
    type BasicBlock: Copy;
}

Does this imply that BasicBlock must be a raw pointer? Whether the abuse of Copy requirements seriously affects the writing of pure Rust codegen backend?(For example, use Rc for memory management, Instead of a raw pointer from an external library)

There are many associative type with this restriction, and I recommend careful consideration of this design.

No, as you can see by the LLVM implementation using a reference: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_llvm/context/struct.CodegenCx.html#impl-BackendTypes

It can also be an index into a list of basic blocks for the current function.

1 Like

https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_llvm/llvm_/ffi/foreigntype.BasicBlock.html

yes, It is exactly what I call the raw pointer, Although it is written like a reference.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.