Skip to content

Commit f16f64b

Browse files
committed
Remove inherent function that has a trait method duplicate of a commonly imported trait
1 parent 241c83f commit f16f64b

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::assert_matches::assert_matches;
22

3-
use libc::{c_char, c_uint};
43
use rustc_abi::{BackendRepr, Float, Integer, Primitive, Scalar};
54
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
65
use rustc_codegen_ssa::mir::operand::OperandValue;
@@ -512,11 +511,7 @@ pub(crate) fn inline_asm_call<'ll>(
512511
// Store mark in a metadata node so we can map LLVM errors
513512
// back to source locations. See #17552.
514513
let key = "srcloc";
515-
let kind = llvm::LLVMGetMDKindIDInContext(
516-
bx.llcx,
517-
key.as_ptr().cast::<c_char>(),
518-
key.len() as c_uint,
519-
);
514+
let kind = bx.get_md_kind_id(key);
520515

521516
// `srcloc` contains one 64-bit integer for each line of assembly code,
522517
// where the lower 32 bits hold the lo byte position and the upper 32 bits

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

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::ptr;
33
use rustc_ast::expand::autodiff_attrs::{AutoDiffAttrs, AutoDiffItem, DiffActivity, DiffMode};
44
use rustc_codegen_ssa::ModuleCodegen;
55
use rustc_codegen_ssa::back::write::ModuleConfig;
6+
use rustc_codegen_ssa::traits::BaseTypeCodegenMethods as _;
67
use rustc_errors::FatalError;
78
use tracing::{debug, trace};
89

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

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use smallvec::SmallVec;
3232

3333
use crate::back::write::to_llvm_code_model;
3434
use crate::callee::get_fn;
35-
use crate::common::{self, AsCCharPtr};
35+
use crate::common::AsCCharPtr;
3636
use crate::debuginfo::metadata::apply_vcall_visibility_metadata;
3737
use crate::llvm::{Metadata, MetadataType};
3838
use crate::type_::Type;
@@ -652,24 +652,22 @@ impl<'ll> SimpleCx<'ll> {
652652
let isize_ty = llvm::Type::ix_llcx(llcx, pointer_size.bits());
653653
Self(SCx { llmod, llcx, isize_ty }, PhantomData)
654654
}
655+
}
655656

656-
pub(crate) fn val_ty(&self, v: &'ll Value) -> &'ll Type {
657-
common::val_ty(v)
658-
}
659-
657+
impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
660658
pub(crate) fn get_metadata_value(&self, metadata: &'ll Metadata) -> &'ll Value {
661-
unsafe { llvm::LLVMMetadataAsValue(self.llcx, metadata) }
659+
unsafe { llvm::LLVMMetadataAsValue(self.llcx(), metadata) }
662660
}
663661

664662
pub(crate) fn get_function(&self, name: &str) -> Option<&'ll Value> {
665663
let name = SmallCStr::new(name);
666-
unsafe { llvm::LLVMGetNamedFunction(self.llmod, name.as_ptr()) }
664+
unsafe { llvm::LLVMGetNamedFunction((**self).borrow().llmod, name.as_ptr()) }
667665
}
668666

669667
pub(crate) fn get_md_kind_id(&self, name: &str) -> u32 {
670668
unsafe {
671669
llvm::LLVMGetMDKindIDInContext(
672-
self.llcx,
670+
self.llcx(),
673671
name.as_ptr() as *const c_char,
674672
name.len() as c_uint,
675673
)
@@ -678,7 +676,7 @@ impl<'ll> SimpleCx<'ll> {
678676

679677
pub(crate) fn create_metadata(&self, name: String) -> Option<&'ll Metadata> {
680678
Some(unsafe {
681-
llvm::LLVMMDStringInContext2(self.llcx, name.as_ptr() as *const c_char, name.len())
679+
llvm::LLVMMDStringInContext2(self.llcx(), name.as_ptr() as *const c_char, name.len())
682680
})
683681
}
684682
}

Diff for: compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::ffi::CString;
88

99
use rustc_abi::Align;
1010
use rustc_codegen_ssa::traits::{
11-
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
11+
BaseTypeCodegenMethods as _, ConstCodegenMethods, StaticCodegenMethods,
1212
};
1313
use rustc_middle::mir::coverage::{
1414
BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping,

0 commit comments

Comments
 (0)