Skip to content

Commit 75356b7

Browse files
committed
Generalize BackendTypes over GenericCx
1 parent bfd88ce commit 75356b7

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

Diff for: compiler/rustc_codegen_llvm/src/builder.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ impl<'a, 'll> SBuilder<'a, 'll> {
167167
// FIXME(eddyb) pass `&CStr` directly to FFI once it's a thin pointer.
168168
const UNNAMED: *const c_char = c"".as_ptr();
169169

170-
impl<'ll, 'tcx> BackendTypes for Builder<'_, 'll, 'tcx> {
171-
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
172-
type Metadata = <CodegenCx<'ll, 'tcx> as BackendTypes>::Metadata;
173-
type Function = <CodegenCx<'ll, 'tcx> as BackendTypes>::Function;
174-
type BasicBlock = <CodegenCx<'ll, 'tcx> as BackendTypes>::BasicBlock;
175-
type Type = <CodegenCx<'ll, 'tcx> as BackendTypes>::Type;
176-
type Funclet = <CodegenCx<'ll, 'tcx> as BackendTypes>::Funclet;
177-
178-
type DIScope = <CodegenCx<'ll, 'tcx> as BackendTypes>::DIScope;
179-
type DILocation = <CodegenCx<'ll, 'tcx> as BackendTypes>::DILocation;
180-
type DIVariable = <CodegenCx<'ll, 'tcx> as BackendTypes>::DIVariable;
170+
impl<'ll, CX: Borrow<SCx<'ll>>> BackendTypes for GenericBuilder<'_, 'll, CX> {
171+
type Value = <GenericCx<'ll, CX> as BackendTypes>::Value;
172+
type Metadata = <GenericCx<'ll, CX> as BackendTypes>::Metadata;
173+
type Function = <GenericCx<'ll, CX> as BackendTypes>::Function;
174+
type BasicBlock = <GenericCx<'ll, CX> as BackendTypes>::BasicBlock;
175+
type Type = <GenericCx<'ll, CX> as BackendTypes>::Type;
176+
type Funclet = <GenericCx<'ll, CX> as BackendTypes>::Funclet;
177+
178+
type DIScope = <GenericCx<'ll, CX> as BackendTypes>::DIScope;
179+
type DILocation = <GenericCx<'ll, CX> as BackendTypes>::DILocation;
180+
type DIVariable = <GenericCx<'ll, CX> as BackendTypes>::DIVariable;
181181
}
182182

183183
impl abi::HasDataLayout for Builder<'_, '_, '_> {

Diff for: compiler/rustc_codegen_llvm/src/common.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Code that is useful in various codegen modules.
22
3+
use std::borrow::Borrow;
4+
35
use libc::{c_char, c_uint};
46
use rustc_abi as abi;
57
use rustc_abi::Primitive::Pointer;
@@ -18,6 +20,7 @@ use tracing::debug;
1820

1921
use crate::consts::const_alloc_to_llvm;
2022
pub(crate) use crate::context::CodegenCx;
23+
use crate::context::{GenericCx, SCx};
2124
use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, Metadata, True};
2225
use crate::type_::Type;
2326
use crate::value::Value;
@@ -81,7 +84,7 @@ impl<'ll> Funclet<'ll> {
8184
}
8285
}
8386

84-
impl<'ll> BackendTypes for CodegenCx<'ll, '_> {
87+
impl<'ll, CX: Borrow<SCx<'ll>>> BackendTypes for GenericCx<'ll, CX> {
8588
type Value = &'ll Value;
8689
type Metadata = &'ll Metadata;
8790
// FIXME(eddyb) replace this with a `Function` "subclass" of `Value`.

0 commit comments

Comments
 (0)