Skip to content

Commit a0713cc

Browse files
committed
Relax some trait constraints
1 parent e19c4b9 commit a0713cc

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/librustc_codegen_llvm/builder.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1246,11 +1246,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
12461246
}
12471247
}
12481248

1249-
1250-
fn cx(&self) -> &CodegenCx<'ll, 'tcx> {
1251-
self.cx
1252-
}
1253-
12541249
unsafe fn delete_basic_block(&mut self, bb: &'ll BasicBlock) {
12551250
llvm::LLVMDeleteBasicBlock(bb);
12561251
}
@@ -1261,7 +1256,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
12611256
}
12621257

12631258
impl StaticBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
1264-
fn get_static(&mut self, def_id: DefId) -> &'ll Value {
1259+
fn get_static(&mut self, def_id: DefId) -> &'ll Value {
12651260
// Forward to the `get_static` method of `CodegenCx`
12661261
self.cx().get_static(def_id)
12671262
}

src/librustc_codegen_ssa/base.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {
356356
sess.target.target.options.is_like_msvc
357357
}
358358

359-
pub fn from_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
359+
pub fn from_immediate<'a, 'tcx: 'a, Bx: NumBuilderMethods<'tcx>>(
360360
bx: &mut Bx,
361361
val: Bx::Value
362362
) -> Bx::Value {
@@ -367,7 +367,7 @@ pub fn from_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
367367
}
368368
}
369369

370-
pub fn to_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
370+
pub fn to_immediate<'a, 'tcx: 'a, Bx: NumBuilderMethods<'tcx>>(
371371
bx: &mut Bx,
372372
val: Bx::Value,
373373
layout: layout::TyLayout<'_>,
@@ -378,7 +378,7 @@ pub fn to_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
378378
val
379379
}
380380

381-
pub fn to_immediate_scalar<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
381+
pub fn to_immediate_scalar<'a, 'tcx: 'a, Bx: NumBuilderMethods<'tcx>>(
382382
bx: &mut Bx,
383383
val: Bx::Value,
384384
scalar: &layout::Scalar,
@@ -389,15 +389,17 @@ pub fn to_immediate_scalar<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
389389
val
390390
}
391391

392-
pub fn memcpy_ty<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
392+
pub fn memcpy_ty<'a, 'tcx: 'a, Bx: MemoryBuilderMethods<'tcx>>(
393393
bx: &mut Bx,
394394
dst: Bx::Value,
395395
dst_align: Align,
396396
src: Bx::Value,
397397
src_align: Align,
398398
layout: TyLayout<'tcx>,
399399
flags: MemFlags,
400-
) {
400+
)
401+
where Bx::CodegenCx: ConstMethods<'tcx>
402+
{
401403
let size = layout.size.bytes();
402404
if size == 0 {
403405
return;

src/librustc_codegen_ssa/traits/builder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
190190
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;
191191
fn with_cx(cx: &'a Self::CodegenCx) -> Self;
192192
fn build_sibling_block<'b>(&self, name: &'b str) -> Self;
193-
fn cx(&self) -> &Self::CodegenCx;
194193
fn llbb(&self) -> Self::BasicBlock;
195194

196195
fn position_at_end(&mut self, llbb: Self::BasicBlock);

src/librustc_codegen_ssa/traits/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,10 @@ pub trait HasCodegen<'tcx>:
8585
Type = Self::Type,
8686
Funclet = Self::Funclet,
8787
DIScope = Self::DIScope,
88-
>;
88+
>
89+
+ BaseTypeMethods<'tcx>;
90+
91+
fn cx(&self) -> &Self::CodegenCx {
92+
&**self
93+
}
8994
}

0 commit comments

Comments
 (0)