fix(pattern_type_mismatch)): Fix mismatch with ref/deref

This commit is contained in:
tempdragon 2024-03-16 09:43:16 +08:00
parent a7d39b852a
commit 817d2f298e
3 changed files with 9 additions and 19 deletions

View File

@ -280,15 +280,18 @@ fn dbg_loc(
let pos = span.lo(); let pos = span.lo();
let DebugLoc { file, line, col } = self.lookup_debug_loc(pos); let DebugLoc { file, line, col } = self.lookup_debug_loc(pos);
let loc = match file.name { let loc = match file.name {
rustc_span::FileName::Real(ref name) => match name.clone() { rustc_span::FileName::Real(ref name) => match *name {
rustc_span::RealFileName::LocalPath(name) => { rustc_span::RealFileName::LocalPath(ref name) => {
if let Some(name) = name.to_str() { if let Some(name) = name.to_str() {
self.context.new_location(name, line as i32, col as i32) self.context.new_location(name, line as i32, col as i32)
} else { } else {
Location::null() Location::null()
} }
} }
rustc_span::RealFileName::Remapped { ref local_path, virtual_name: _unused } => { rustc_span::RealFileName::Remapped {
ref local_path,
virtual_name: ref _unused,
} => {
if let Some(name) = local_path.as_ref() { if let Some(name) = local_path.as_ref() {
if let Some(name) = name.to_str() { if let Some(name) = name.to_str() {
self.context.new_location(name, line as i32, col as i32) self.context.new_location(name, line as i32, col as i32)

View File

@ -181,19 +181,7 @@ fn declare_raw_fn<'gcc>(
.map(|(index, param)| cx.context.new_parameter(None, *param, format!("param{}", index))) // TODO(antoyo): set name. .map(|(index, param)| cx.context.new_parameter(None, *param, format!("param{}", index))) // TODO(antoyo): set name.
.collect(); .collect();
#[cfg(not(feature = "master"))] #[cfg(not(feature = "master"))]
let name = mangle_name(name); let name = &mangle_name(name);
#[cfg(not(feature = "master"))]
let func = cx.context.new_function(
None,
cx.linkage.get(),
return_type,
&params,
name.clone(),
variadic,
);
#[cfg(feature = "master")]
let func = let func =
cx.context.new_function(None, cx.linkage.get(), return_type, &params, name, variadic); cx.context.new_function(None, cx.linkage.get(), return_type, &params, name, variadic);
cx.functions.borrow_mut().insert(name.to_string(), func); cx.functions.borrow_mut().insert(name.to_string(), func);

View File

@ -164,8 +164,7 @@ fn codegen_intrinsic_call(
let tp_ty = fn_args.type_at(0); let tp_ty = fn_args.type_at(0);
let ptr = args[0].immediate(); let ptr = args[0].immediate();
// The reference was changed to clone to comply to clippy. // The reference was changed to clone to comply to clippy.
let load = if let PassMode::Cast { cast: ty, pad_i32: _ } = fn_abi.ret.mode.clone() let load = if let PassMode::Cast { cast: ref ty, pad_i32: _ } = fn_abi.ret.mode {
{
let gcc_ty = ty.gcc_type(self); let gcc_ty = ty.gcc_type(self);
self.volatile_load(gcc_ty, ptr) self.volatile_load(gcc_ty, ptr)
} else { } else {
@ -386,7 +385,7 @@ fn codegen_intrinsic_call(
if !fn_abi.ret.is_ignore() { if !fn_abi.ret.is_ignore() {
// The reference was changed to clone to comply to clippy. // The reference was changed to clone to comply to clippy.
if let PassMode::Cast { cast: ty, .. } = fn_abi.ret.mode.clone() { if let PassMode::Cast { cast: ref ty, .. } = fn_abi.ret.mode {
let ptr_llty = self.type_ptr_to(ty.gcc_type(self)); let ptr_llty = self.type_ptr_to(ty.gcc_type(self));
let ptr = self.pointercast(result.llval, ptr_llty); let ptr = self.pointercast(result.llval, ptr_llty);
self.store(llval, ptr, result.align); self.store(llval, ptr, result.align);