Fix clippy::needless_borrow
in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
This commit is contained in:
parent
0ff8610964
commit
21a870515b
304 changed files with 1101 additions and 1174 deletions
|
@ -149,7 +149,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
|
|||
|
||||
self.cgu_reuse_tracker.set_expectation(
|
||||
cgu_name,
|
||||
&user_path,
|
||||
user_path,
|
||||
attr.span,
|
||||
expected_reuse,
|
||||
comp_kind,
|
||||
|
|
|
@ -175,8 +175,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
) -> io::Result<()> {
|
||||
let mut archive_path = archive_path.to_path_buf();
|
||||
if self.sess.target.llvm_target.contains("-apple-macosx") {
|
||||
if let Some(new_archive_path) =
|
||||
try_extract_macho_fat_archive(&self.sess, &archive_path)?
|
||||
if let Some(new_archive_path) = try_extract_macho_fat_archive(self.sess, &archive_path)?
|
||||
{
|
||||
archive_path = new_archive_path
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ pub fn each_linked_rlib(
|
|||
let crate_name = info.crate_name[&cnum];
|
||||
let used_crate_source = &info.used_crate_source[&cnum];
|
||||
if let Some((path, _)) = &used_crate_source.rlib {
|
||||
f(cnum, &path);
|
||||
f(cnum, path);
|
||||
} else {
|
||||
if used_crate_source.rmeta.is_some() {
|
||||
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
|
@ -524,7 +524,7 @@ fn link_staticlib<'a>(
|
|||
&& !ignored_for_lto(sess, &codegen_results.crate_info, cnum);
|
||||
|
||||
let native_libs = codegen_results.crate_info.native_libraries[&cnum].iter();
|
||||
let relevant = native_libs.clone().filter(|lib| relevant_lib(sess, &lib));
|
||||
let relevant = native_libs.clone().filter(|lib| relevant_lib(sess, lib));
|
||||
let relevant_libs: FxHashSet<_> = relevant.filter_map(|lib| lib.filename).collect();
|
||||
|
||||
let bundled_libs: FxHashSet<_> = native_libs.filter_map(|lib| lib.filename).collect();
|
||||
|
@ -689,7 +689,7 @@ fn link_dwarf_object<'a>(
|
|||
// Adding an executable is primarily done to make `thorin` check that all the referenced
|
||||
// dwarf objects are found in the end.
|
||||
package.add_executable(
|
||||
&executable_out_filename,
|
||||
executable_out_filename,
|
||||
thorin::MissingReferencedObjectBehaviour::Skip,
|
||||
)?;
|
||||
|
||||
|
@ -945,7 +945,7 @@ fn link_natively<'a>(
|
|||
{
|
||||
let is_vs_installed = windows_registry::find_vs_version().is_ok();
|
||||
let has_linker = windows_registry::find_tool(
|
||||
&sess.opts.target_triple.triple(),
|
||||
sess.opts.target_triple.triple(),
|
||||
"link.exe",
|
||||
)
|
||||
.is_some();
|
||||
|
@ -1038,14 +1038,14 @@ fn link_natively<'a>(
|
|||
if sess.target.is_like_osx {
|
||||
match (strip, crate_type) {
|
||||
(Strip::Debuginfo, _) => {
|
||||
strip_symbols_with_external_utility(sess, "strip", &out_filename, Some("-S"))
|
||||
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-S"))
|
||||
}
|
||||
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
|
||||
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
|
||||
strip_symbols_with_external_utility(sess, "strip", &out_filename, Some("-x"))
|
||||
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-x"))
|
||||
}
|
||||
(Strip::Symbols, _) => {
|
||||
strip_symbols_with_external_utility(sess, "strip", &out_filename, None)
|
||||
strip_symbols_with_external_utility(sess, "strip", out_filename, None)
|
||||
}
|
||||
(Strip::None, _) => {}
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ fn link_natively<'a>(
|
|||
match strip {
|
||||
// Always preserve the symbol table (-x).
|
||||
Strip::Debuginfo => {
|
||||
strip_symbols_with_external_utility(sess, stripcmd, &out_filename, Some("-x"))
|
||||
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
|
||||
}
|
||||
// Strip::Symbols is handled via the --strip-all linker option.
|
||||
Strip::Symbols => {}
|
||||
|
@ -1245,13 +1245,13 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) {
|
|||
// rpath to the library as well (the rpath should be absolute, see
|
||||
// PR #41352 for details).
|
||||
let filename = format!("rustc{channel}_rt.{name}");
|
||||
let path = find_sanitizer_runtime(&sess, &filename);
|
||||
let path = find_sanitizer_runtime(sess, &filename);
|
||||
let rpath = path.to_str().expect("non-utf8 component in path");
|
||||
linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
|
||||
linker.link_dylib(&filename, false, true);
|
||||
} else {
|
||||
let filename = format!("librustc{channel}_rt.{name}.a");
|
||||
let path = find_sanitizer_runtime(&sess, &filename).join(&filename);
|
||||
let path = find_sanitizer_runtime(sess, &filename).join(&filename);
|
||||
linker.link_whole_rlib(&path);
|
||||
}
|
||||
}
|
||||
|
@ -1685,7 +1685,7 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
|
|||
|
||||
// Returns true if linker is located within sysroot
|
||||
fn detect_self_contained_mingw(sess: &Session) -> bool {
|
||||
let (linker, _) = linker_and_flavor(&sess);
|
||||
let (linker, _) = linker_and_flavor(sess);
|
||||
// Assume `-C linker=rust-lld` as self-contained mode
|
||||
if linker == Path::new("rust-lld") {
|
||||
return true;
|
||||
|
@ -1737,7 +1737,7 @@ fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfC
|
|||
LinkSelfContainedDefault::InferredForMingw => {
|
||||
sess.host == sess.target
|
||||
&& sess.target.vendor != "uwp"
|
||||
&& detect_self_contained_mingw(&sess)
|
||||
&& detect_self_contained_mingw(sess)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -2432,7 +2432,7 @@ fn add_native_libs_from_crate(
|
|||
// If rlib contains native libs as archives, unpack them to tmpdir.
|
||||
let rlib = &codegen_results.crate_info.used_crate_source[&cnum].rlib.as_ref().unwrap().0;
|
||||
archive_builder_builder
|
||||
.extract_bundled_libs(rlib, tmpdir, &bundled_libs)
|
||||
.extract_bundled_libs(rlib, tmpdir, bundled_libs)
|
||||
.unwrap_or_else(|e| sess.emit_fatal(e));
|
||||
}
|
||||
|
||||
|
@ -2485,7 +2485,7 @@ fn add_native_libs_from_crate(
|
|||
cmd.link_whole_staticlib(
|
||||
name,
|
||||
verbatim,
|
||||
&search_paths.get_or_init(|| archive_search_paths(sess)),
|
||||
search_paths.get_or_init(|| archive_search_paths(sess)),
|
||||
);
|
||||
} else {
|
||||
cmd.link_staticlib(name, verbatim)
|
||||
|
@ -2719,7 +2719,7 @@ fn rehome_sysroot_lib_dir<'a>(sess: &'a Session, lib_dir: &Path) -> PathBuf {
|
|||
// already had `fix_windows_verbatim_for_gcc()` applied if needed.
|
||||
sysroot_lib_path
|
||||
} else {
|
||||
fix_windows_verbatim_for_gcc(&lib_dir)
|
||||
fix_windows_verbatim_for_gcc(lib_dir)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2756,7 +2756,7 @@ fn add_static_crate<'a>(
|
|||
let mut link_upstream = |path: &Path| {
|
||||
let rlib_path = if let Some(dir) = path.parent() {
|
||||
let file_name = path.file_name().expect("rlib path has no file name path component");
|
||||
rehome_sysroot_lib_dir(sess, &dir).join(file_name)
|
||||
rehome_sysroot_lib_dir(sess, dir).join(file_name)
|
||||
} else {
|
||||
fix_windows_verbatim_for_gcc(path)
|
||||
};
|
||||
|
@ -2793,7 +2793,7 @@ fn add_static_crate<'a>(
|
|||
let canonical = f.replace('-', "_");
|
||||
|
||||
let is_rust_object =
|
||||
canonical.starts_with(&canonical_name) && looks_like_rust_object_file(&f);
|
||||
canonical.starts_with(&canonical_name) && looks_like_rust_object_file(f);
|
||||
|
||||
// If we're performing LTO and this is a rust-generated object
|
||||
// file, then we don't need the object file as it's part of the
|
||||
|
|
|
@ -45,7 +45,7 @@ pub fn get_linker<'a>(
|
|||
self_contained: bool,
|
||||
target_cpu: &'a str,
|
||||
) -> Box<dyn Linker + 'a> {
|
||||
let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe");
|
||||
let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.triple(), "link.exe");
|
||||
|
||||
// If our linker looks like a batch script on Windows then to execute this
|
||||
// we'll need to spawn `cmd` explicitly. This is primarily done to handle
|
||||
|
@ -78,7 +78,7 @@ pub fn get_linker<'a>(
|
|||
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.vendor == "uwp" {
|
||||
if let Some(ref tool) = msvc_tool {
|
||||
let original_path = tool.path();
|
||||
if let Some(ref root_lib_path) = original_path.ancestors().nth(4) {
|
||||
if let Some(root_lib_path) = original_path.ancestors().nth(4) {
|
||||
let arch = match t.arch.as_ref() {
|
||||
"x86_64" => Some("x64"),
|
||||
"x86" => Some("x86"),
|
||||
|
@ -519,7 +519,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
// -force_load is the macOS equivalent of --whole-archive, but it
|
||||
// involves passing the full path to the library to link.
|
||||
self.linker_arg("-force_load");
|
||||
let lib = find_native_static_library(lib, verbatim, search_path, &self.sess);
|
||||
let lib = find_native_static_library(lib, verbatim, search_path, self.sess);
|
||||
self.linker_arg(&lib);
|
||||
}
|
||||
}
|
||||
|
@ -1590,7 +1590,7 @@ impl<'a> Linker for AixLinker<'a> {
|
|||
|
||||
fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]) {
|
||||
self.hint_static();
|
||||
let lib = find_native_static_library(lib, verbatim, search_path, &self.sess);
|
||||
let lib = find_native_static_library(lib, verbatim, search_path, self.sess);
|
||||
self.cmd.arg(format!("-bkeepfile:{}", lib.to_str().unwrap()));
|
||||
}
|
||||
|
||||
|
|
|
@ -621,7 +621,7 @@ fn wasm_import_module_map(tcx: TyCtxt<'_>, cnum: CrateNum) -> FxHashMap<DefId, S
|
|||
|
||||
let mut ret = FxHashMap::default();
|
||||
for (def_id, lib) in tcx.foreign_modules(cnum).iter() {
|
||||
let module = def_id_to_native_lib.get(&def_id).and_then(|s| s.wasm_import_module());
|
||||
let module = def_id_to_native_lib.get(def_id).and_then(|s| s.wasm_import_module());
|
||||
let Some(module) = module else { continue };
|
||||
ret.extend(lib.foreign_items.iter().map(|id| {
|
||||
assert_eq!(id.krate, cnum);
|
||||
|
|
|
@ -892,7 +892,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
|
||||
|
||||
let load_from_incr_comp_dir = |output_path: PathBuf, saved_path: &str| {
|
||||
let source_file = in_incr_comp_dir(&incr_comp_session_dir, saved_path);
|
||||
let source_file = in_incr_comp_dir(incr_comp_session_dir, saved_path);
|
||||
debug!(
|
||||
"copying preexisting module `{}` from {:?} to {}",
|
||||
module.name,
|
||||
|
@ -914,7 +914,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
|
||||
let object = load_from_incr_comp_dir(
|
||||
cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name)),
|
||||
&module.source.saved_files.get("o").expect("no saved object file in work product"),
|
||||
module.source.saved_files.get("o").expect("no saved object file in work product"),
|
||||
);
|
||||
let dwarf_object =
|
||||
module.source.saved_files.get("dwo").as_ref().and_then(|saved_dwarf_object_file| {
|
||||
|
@ -924,7 +924,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
.expect(
|
||||
"saved dwarf object in work product but `split_dwarf_path` returned `None`",
|
||||
);
|
||||
load_from_incr_comp_dir(dwarf_obj_out, &saved_dwarf_object_file)
|
||||
load_from_incr_comp_dir(dwarf_obj_out, saved_dwarf_object_file)
|
||||
});
|
||||
|
||||
WorkItemResult::Finished(CompiledModule {
|
||||
|
|
|
@ -148,10 +148,9 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
(&ty::Array(_, len), &ty::Slice(_)) => {
|
||||
cx.const_usize(len.eval_target_usize(cx.tcx(), ty::ParamEnv::reveal_all()))
|
||||
}
|
||||
(
|
||||
&ty::Dynamic(ref data_a, _, src_dyn_kind),
|
||||
&ty::Dynamic(ref data_b, _, target_dyn_kind),
|
||||
) if src_dyn_kind == target_dyn_kind => {
|
||||
(&ty::Dynamic(data_a, _, src_dyn_kind), &ty::Dynamic(data_b, _, target_dyn_kind))
|
||||
if src_dyn_kind == target_dyn_kind =>
|
||||
{
|
||||
let old_info =
|
||||
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
|
||||
if data_a.principal_def_id() == data_b.principal_def_id() {
|
||||
|
@ -458,8 +457,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
cx.set_frame_pointer_type(llfn);
|
||||
cx.apply_target_cpu_attr(llfn);
|
||||
|
||||
let llbb = Bx::append_block(&cx, llfn, "top");
|
||||
let mut bx = Bx::build(&cx, llbb);
|
||||
let llbb = Bx::append_block(cx, llfn, "top");
|
||||
let mut bx = Bx::build(cx, llbb);
|
||||
|
||||
bx.insert_reference_to_gdb_debug_scripts_section_global();
|
||||
|
||||
|
@ -685,7 +684,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
|
||||
// Calculate the CGU reuse
|
||||
let cgu_reuse = tcx.sess.time("find_cgu_reuse", || {
|
||||
codegen_units.iter().map(|cgu| determine_cgu_reuse(tcx, &cgu)).collect::<Vec<_>>()
|
||||
codegen_units.iter().map(|cgu| determine_cgu_reuse(tcx, cgu)).collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
crate::assert_module_sources::assert_module_sources(tcx, &|cgu_reuse_tracker| {
|
||||
|
|
|
@ -477,9 +477,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||
)
|
||||
.emit();
|
||||
InlineAttr::None
|
||||
} else if list_contains_name(&items, sym::always) {
|
||||
} else if list_contains_name(items, sym::always) {
|
||||
InlineAttr::Always
|
||||
} else if list_contains_name(&items, sym::never) {
|
||||
} else if list_contains_name(items, sym::never) {
|
||||
InlineAttr::Never
|
||||
} else {
|
||||
struct_span_err!(
|
||||
|
@ -514,9 +514,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||
if items.len() != 1 {
|
||||
err(attr.span, "expected one argument");
|
||||
OptimizeAttr::None
|
||||
} else if list_contains_name(&items, sym::size) {
|
||||
} else if list_contains_name(items, sym::size) {
|
||||
OptimizeAttr::Size
|
||||
} else if list_contains_name(&items, sym::speed) {
|
||||
} else if list_contains_name(items, sym::speed) {
|
||||
OptimizeAttr::Speed
|
||||
} else {
|
||||
err(items[0].span(), "invalid argument");
|
||||
|
|
|
@ -216,7 +216,7 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
output.push(']');
|
||||
}
|
||||
}
|
||||
ty::Dynamic(ref trait_data, ..) => {
|
||||
ty::Dynamic(trait_data, ..) => {
|
||||
let auto_traits: SmallVec<[DefId; 4]> = trait_data.auto_traits().collect();
|
||||
|
||||
let has_enclosing_parens = if cpp_like_debuginfo {
|
||||
|
|
|
@ -42,7 +42,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
// If there exists a local definition that dominates all uses of that local,
|
||||
// the definition should be visited first. Traverse blocks in an order that
|
||||
// is a topological sort of dominance partial order.
|
||||
for (bb, data) in traversal::reverse_postorder(&mir) {
|
||||
for (bb, data) in traversal::reverse_postorder(mir) {
|
||||
analyzer.visit_basic_block_data(bb, data);
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||
) => match &mut self.locals[local] {
|
||||
LocalKind::ZST => {}
|
||||
LocalKind::Memory => {}
|
||||
LocalKind::SSA(def) if def.dominates(location, &self.dominators) => {}
|
||||
LocalKind::SSA(def) if def.dominates(location, self.dominators) => {}
|
||||
// Reads from uninitialized variables (e.g., in dead code, after
|
||||
// optimizations) require locals to be in (uninitialized) memory.
|
||||
// N.B., there can be uninitialized reads of a local visited after
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
&self,
|
||||
fx: &'b mut FunctionCx<'a, 'tcx, Bx>,
|
||||
) -> Option<&'b Bx::Funclet> {
|
||||
let cleanup_kinds = (&fx.cleanup_kinds).as_ref()?;
|
||||
let cleanup_kinds = fx.cleanup_kinds.as_ref()?;
|
||||
let funclet_bb = cleanup_kinds[self.bb].funclet_bb(self.bb)?;
|
||||
// If `landing_pad_for` hasn't been called yet to create the `Funclet`,
|
||||
// it has to be now. This may not seem necessary, as RPO should lead
|
||||
|
@ -161,7 +161,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
) -> MergingSucc {
|
||||
// If there is a cleanup block and the function we're calling can unwind, then
|
||||
// do an invoke, otherwise do a call.
|
||||
let fn_ty = bx.fn_decl_backend_type(&fn_abi);
|
||||
let fn_ty = bx.fn_decl_backend_type(fn_abi);
|
||||
|
||||
let fn_attrs = if bx.tcx().def_kind(fx.instance.def_id()).has_codegen_attrs() {
|
||||
Some(bx.tcx().codegen_fn_attrs(fx.instance.def_id()))
|
||||
|
@ -204,9 +204,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
let invokeret = bx.invoke(
|
||||
fn_ty,
|
||||
fn_attrs,
|
||||
Some(&fn_abi),
|
||||
Some(fn_abi),
|
||||
fn_ptr,
|
||||
&llargs,
|
||||
llargs,
|
||||
ret_llbb,
|
||||
unwind_block,
|
||||
self.funclet(fx),
|
||||
|
@ -225,7 +225,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
}
|
||||
MergingSucc::False
|
||||
} else {
|
||||
let llret = bx.call(fn_ty, fn_attrs, Some(&fn_abi), fn_ptr, &llargs, self.funclet(fx));
|
||||
let llret = bx.call(fn_ty, fn_attrs, Some(fn_abi), fn_ptr, llargs, self.funclet(fx));
|
||||
if fx.mir[self.bb].is_cleanup {
|
||||
bx.apply_attrs_to_cleanup_callsite(llret);
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
|
||||
bx.codegen_inline_asm(
|
||||
template,
|
||||
&operands,
|
||||
operands,
|
||||
options,
|
||||
line_spans,
|
||||
instance,
|
||||
|
@ -281,7 +281,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
);
|
||||
MergingSucc::False
|
||||
} else {
|
||||
bx.codegen_inline_asm(template, &operands, options, line_spans, instance, None);
|
||||
bx.codegen_inline_asm(template, operands, options, line_spans, instance, None);
|
||||
|
||||
if let Some(target) = destination {
|
||||
self.funclet_br(fx, bx, target, mergeable_succ)
|
||||
|
@ -318,7 +318,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
discr: &mir::Operand<'tcx>,
|
||||
targets: &SwitchTargets,
|
||||
) {
|
||||
let discr = self.codegen_operand(bx, &discr);
|
||||
let discr = self.codegen_operand(bx, discr);
|
||||
let switch_ty = discr.layout.ty;
|
||||
let mut target_iter = targets.iter();
|
||||
if target_iter.len() == 1 {
|
||||
|
@ -498,7 +498,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
args = &args[..1];
|
||||
(
|
||||
meth::VirtualIndex::from_index(ty::COMMON_VTABLE_ENTRIES_DROPINPLACE)
|
||||
.get_fn(bx, vtable, ty, &fn_abi),
|
||||
.get_fn(bx, vtable, ty, fn_abi),
|
||||
fn_abi,
|
||||
)
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
debug!("args' = {:?}", args);
|
||||
(
|
||||
meth::VirtualIndex::from_index(ty::COMMON_VTABLE_ENTRIES_DROPINPLACE)
|
||||
.get_fn(bx, meta.immediate(), ty, &fn_abi),
|
||||
.get_fn(bx, meta.immediate(), ty, fn_abi),
|
||||
fn_abi,
|
||||
)
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
// promotes any complex rvalues to constants.
|
||||
if i == 2 && intrinsic == sym::simd_shuffle {
|
||||
if let mir::Operand::Constant(constant) = arg {
|
||||
let (llval, ty) = self.simd_shuffle_indices(&bx, constant);
|
||||
let (llval, ty) = self.simd_shuffle_indices(bx, constant);
|
||||
return OperandRef {
|
||||
val: Immediate(llval),
|
||||
layout: bx.layout_of(ty),
|
||||
|
@ -881,7 +881,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
Self::codegen_intrinsic_call(
|
||||
bx,
|
||||
*instance.as_ref().unwrap(),
|
||||
&fn_abi,
|
||||
fn_abi,
|
||||
&args,
|
||||
dest,
|
||||
span,
|
||||
|
@ -937,7 +937,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
bx,
|
||||
meta,
|
||||
op.layout.ty,
|
||||
&fn_abi,
|
||||
fn_abi,
|
||||
));
|
||||
llargs.push(data_ptr);
|
||||
continue 'make_args;
|
||||
|
@ -948,7 +948,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
bx,
|
||||
meta,
|
||||
op.layout.ty,
|
||||
&fn_abi,
|
||||
fn_abi,
|
||||
));
|
||||
llargs.push(data_ptr);
|
||||
continue;
|
||||
|
@ -975,7 +975,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
bx,
|
||||
meta.immediate(),
|
||||
op.layout.ty,
|
||||
&fn_abi,
|
||||
fn_abi,
|
||||
));
|
||||
llargs.push(data_ptr.llval);
|
||||
continue;
|
||||
|
@ -1587,9 +1587,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
self.set_debug_loc(&mut bx, mir::SourceInfo::outermost(self.mir.span));
|
||||
|
||||
let (fn_abi, fn_ptr) = common::build_langcall(&bx, None, reason.lang_item());
|
||||
let fn_ty = bx.fn_decl_backend_type(&fn_abi);
|
||||
let fn_ty = bx.fn_decl_backend_type(fn_abi);
|
||||
|
||||
let llret = bx.call(fn_ty, None, Some(&fn_abi), fn_ptr, &[], funclet.as_ref());
|
||||
let llret = bx.call(fn_ty, None, Some(fn_abi), fn_ptr, &[], funclet.as_ref());
|
||||
bx.apply_attrs_to_cleanup_callsite(llret);
|
||||
|
||||
bx.unreachable();
|
||||
|
@ -1662,10 +1662,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
self.codegen_place(
|
||||
bx,
|
||||
mir::PlaceRef { local: dest.local, projection: &dest.projection },
|
||||
)
|
||||
self.codegen_place(bx, mir::PlaceRef { local: dest.local, projection: dest.projection })
|
||||
};
|
||||
if fn_ret.is_indirect() {
|
||||
if dest.align < dest.layout.align.abi {
|
||||
|
@ -1696,7 +1693,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
|
||||
match dest {
|
||||
Nothing => (),
|
||||
Store(dst) => bx.store_arg(&ret_abi, llval, dst),
|
||||
Store(dst) => bx.store_arg(ret_abi, llval, dst),
|
||||
IndirectOperand(tmp, index) => {
|
||||
let op = bx.load_operand(tmp);
|
||||
tmp.storage_dead(bx);
|
||||
|
@ -1708,7 +1705,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
let op = if let PassMode::Cast { .. } = ret_abi.mode {
|
||||
let tmp = PlaceRef::alloca(bx, ret_abi.layout);
|
||||
tmp.storage_live(bx);
|
||||
bx.store_arg(&ret_abi, llval, tmp);
|
||||
bx.store_arg(ret_abi, llval, tmp);
|
||||
let op = bx.load_operand(tmp);
|
||||
tmp.storage_dead(bx);
|
||||
op
|
||||
|
|
|
@ -398,7 +398,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
let Some(dbg_loc) = self.dbg_loc(var.source_info) else { return };
|
||||
|
||||
let DebugInfoOffset { direct_offset, indirect_offsets, result: _ } =
|
||||
calculate_debuginfo_offset(bx, &var.projection, base.layout);
|
||||
calculate_debuginfo_offset(bx, var.projection, base.layout);
|
||||
|
||||
// When targeting MSVC, create extra allocas for arguments instead of pointing multiple
|
||||
// dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records
|
||||
|
@ -416,7 +416,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
|
||||
if should_create_individual_allocas {
|
||||
let DebugInfoOffset { direct_offset: _, indirect_offsets: _, result: place } =
|
||||
calculate_debuginfo_offset(bx, &var.projection, base);
|
||||
calculate_debuginfo_offset(bx, var.projection, base);
|
||||
|
||||
// Create a variable which will be a pointer to the actual value
|
||||
let ptr_ty = Ty::new_ptr(
|
||||
|
|
|
@ -168,7 +168,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
|
||||
debug!("fn_abi: {:?}", fn_abi);
|
||||
|
||||
let debug_context = cx.create_function_debug_context(instance, &fn_abi, llfn, &mir);
|
||||
let debug_context = cx.create_function_debug_context(instance, fn_abi, llfn, mir);
|
||||
|
||||
let start_llbb = Bx::append_block(cx, llfn, "start");
|
||||
let mut start_bx = Bx::build(cx, start_llbb);
|
||||
|
@ -180,7 +180,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
}
|
||||
|
||||
let cleanup_kinds =
|
||||
base::wants_new_eh_instructions(cx.tcx().sess).then(|| analyze::cleanup_kinds(&mir));
|
||||
base::wants_new_eh_instructions(cx.tcx().sess).then(|| analyze::cleanup_kinds(mir));
|
||||
|
||||
let cached_llbbs: IndexVec<mir::BasicBlock, CachedLlbb<Bx::BasicBlock>> =
|
||||
mir.basic_blocks
|
||||
|
@ -261,7 +261,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
drop(start_bx);
|
||||
|
||||
// Codegen the body of each block using reverse postorder
|
||||
for (bb, _) in traversal::reverse_postorder(&mir) {
|
||||
for (bb, _) in traversal::reverse_postorder(mir) {
|
||||
fx.codegen_block(bb);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -702,7 +702,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
};
|
||||
let fn_ptr = bx.get_fn_addr(instance);
|
||||
let fn_abi = bx.fn_abi_of_instance(instance, ty::List::empty());
|
||||
let fn_ty = bx.fn_decl_backend_type(&fn_abi);
|
||||
let fn_ty = bx.fn_decl_backend_type(fn_abi);
|
||||
let fn_attrs = if bx.tcx().def_kind(instance.def_id()).has_codegen_attrs() {
|
||||
Some(bx.tcx().codegen_fn_attrs(instance.def_id()))
|
||||
} else {
|
||||
|
|
|
@ -34,7 +34,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
|||
}
|
||||
MonoItem::GlobalAsm(item_id) => {
|
||||
let item = cx.tcx().hir().item(item_id);
|
||||
if let hir::ItemKind::GlobalAsm(ref asm) = item.kind {
|
||||
if let hir::ItemKind::GlobalAsm(asm) = item.kind {
|
||||
let operands: Vec<_> = asm
|
||||
.operands
|
||||
.iter()
|
||||
|
@ -88,7 +88,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
|||
}
|
||||
}
|
||||
MonoItem::Fn(instance) => {
|
||||
base::codegen_instance::<Bx>(&cx, instance);
|
||||
base::codegen_instance::<Bx>(cx, instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,10 +119,10 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
|||
|
||||
match *self {
|
||||
MonoItem::Static(def_id) => {
|
||||
cx.predefine_static(def_id, linkage, visibility, &symbol_name);
|
||||
cx.predefine_static(def_id, linkage, visibility, symbol_name);
|
||||
}
|
||||
MonoItem::Fn(instance) => {
|
||||
cx.predefine_fn(instance, linkage, visibility, &symbol_name);
|
||||
cx.predefine_fn(instance, linkage, visibility, symbol_name);
|
||||
}
|
||||
MonoItem::GlobalAsm(..) => {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue