Skip to content

Commit 652b6f8

Browse files
committed
Merge branch 'master' of github.com:EtomicBomb/rust
2 parents 476b79d + f54c83e commit 652b6f8

File tree

285 files changed

+4261
-1991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+4261
-1991
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
456456
if let Some(def_id) = def_id
457457
&& self.infcx.tcx.def_kind(def_id).is_fn_like()
458458
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
459-
&& let ty::Param(_) =
460-
self.infcx.tcx.fn_sig(def_id).skip_binder().skip_binder().inputs()
461-
[pos + offset]
462-
.kind()
459+
&& let Some(arg) = self
460+
.infcx
461+
.tcx
462+
.fn_sig(def_id)
463+
.skip_binder()
464+
.skip_binder()
465+
.inputs()
466+
.get(pos + offset)
467+
&& let ty::Param(_) = arg.kind()
463468
{
464469
let place = &self.move_data.move_paths[mpi].place;
465470
let ty = place.ty(self.body, self.infcx.tcx).ty;

compiler/rustc_codegen_cranelift/src/abi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use std::mem;
1010
use cranelift_codegen::ir::{ArgumentPurpose, SigRef};
1111
use cranelift_codegen::isa::CallConv;
1212
use cranelift_module::ModuleError;
13+
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
1314
use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall;
1415
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1516
use rustc_middle::ty::layout::FnAbiOf;
1617
use rustc_middle::ty::print::with_no_trimmed_paths;
1718
use rustc_middle::ty::TypeVisitableExt;
18-
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
1919
use rustc_session::Session;
2020
use rustc_span::source_map::Spanned;
2121
use rustc_target::abi::call::{Conv, FnAbi, PassMode};
@@ -505,7 +505,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
505505
let nop_inst = fx.bcx.ins().nop();
506506
fx.add_comment(
507507
nop_inst,
508-
format!("virtual call; self arg pass mode: {:?}", &fn_abi.args[0]),
508+
format!("virtual call; self arg pass mode: {:?}", fn_abi.args[0]),
509509
);
510510
}
511511

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use cranelift_codegen::CodegenError;
55
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
66
use cranelift_module::ModuleError;
77
use rustc_ast::InlineAsmOptions;
8+
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
89
use rustc_index::IndexVec;
910
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1011
use rustc_middle::ty::adjustment::PointerCoercion;
1112
use rustc_middle::ty::layout::FnAbiOf;
1213
use rustc_middle::ty::print::with_no_trimmed_paths;
1314
use rustc_middle::ty::TypeVisitableExt;
14-
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
1515

1616
use crate::constant::ConstantCx;
1717
use crate::debuginfo::{FunctionDebugContext, TypeDebugContext};

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ extern crate rustc_hir;
2424
extern crate rustc_incremental;
2525
extern crate rustc_index;
2626
extern crate rustc_metadata;
27-
extern crate rustc_monomorphize;
2827
extern crate rustc_session;
2928
extern crate rustc_span;
3029
extern crate rustc_target;

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ fn link_natively(
759759
sess.dcx().abort_if_errors();
760760

761761
// Invoke the system linker
762-
info!("{:?}", &cmd);
762+
info!("{cmd:?}");
763763
let retry_on_segfault = env::var("RUSTC_RETRY_LINKER_ON_SEGFAULT").is_ok();
764764
let unknown_arg_regex =
765765
Regex::new(r"(unknown|unrecognized) (command line )?(option|argument)").unwrap();
@@ -796,7 +796,7 @@ fn link_natively(
796796
cmd.arg(arg);
797797
}
798798
}
799-
info!("{:?}", &cmd);
799+
info!("{cmd:?}");
800800
continue;
801801
}
802802

@@ -817,7 +817,7 @@ fn link_natively(
817817
cmd.arg(arg);
818818
}
819819
}
820-
info!("{:?}", &cmd);
820+
info!("{cmd:?}");
821821
continue;
822822
}
823823

@@ -878,7 +878,7 @@ fn link_natively(
878878
cmd.arg(arg);
879879
}
880880
}
881-
info!("{:?}", &cmd);
881+
info!("{cmd:?}");
882882
continue;
883883
}
884884

@@ -996,7 +996,7 @@ fn link_natively(
996996
sess.dcx().emit_err(errors::UnableToExeLinker {
997997
linker_path,
998998
error: e,
999-
command_formatted: format!("{:?}", &cmd),
999+
command_formatted: format!("{cmd:?}"),
10001000
});
10011001
}
10021002

@@ -1567,7 +1567,7 @@ fn print_native_static_libs(
15671567
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
15681568
// Prefix for greppability
15691569
// Note: This must not be translated as tools are allowed to depend on this exact string.
1570-
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
1570+
sess.dcx().note(format!("native-static-libs: {}", lib_args.join(" ")));
15711571
}
15721572
}
15731573
}

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,34 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
806806
ongoing_codegen
807807
}
808808

809+
/// Returns whether a call from the current crate to the [`Instance`] would produce a call
810+
/// from `compiler_builtins` to a symbol the linker must resolve.
811+
///
812+
/// Such calls from `compiler_bultins` are effectively impossible for the linker to handle. Some
813+
/// linkers will optimize such that dead calls to unresolved symbols are not an error, but this is
814+
/// not guaranteed. So we used this function in codegen backends to ensure we do not generate any
815+
/// unlinkable calls.
816+
///
817+
/// Note that calls to LLVM intrinsics are uniquely okay because they won't make it to the linker.
818+
pub fn is_call_from_compiler_builtins_to_upstream_monomorphization<'tcx>(
819+
tcx: TyCtxt<'tcx>,
820+
instance: Instance<'tcx>,
821+
) -> bool {
822+
fn is_llvm_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
823+
if let Some(name) = tcx.codegen_fn_attrs(def_id).link_name {
824+
name.as_str().starts_with("llvm.")
825+
} else {
826+
false
827+
}
828+
}
829+
830+
let def_id = instance.def_id();
831+
!def_id.is_local()
832+
&& tcx.is_compiler_builtins(LOCAL_CRATE)
833+
&& !is_llvm_intrinsic(tcx, def_id)
834+
&& !tcx.should_codegen_locally(instance)
835+
}
836+
809837
impl CrateInfo {
810838
pub fn new(tcx: TyCtxt<'_>, target_cpu: String) -> CrateInfo {
811839
let crate_types = tcx.crate_types().to_vec();

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
328328
sym::link_section => {
329329
if let Some(val) = attr.value_str() {
330330
if val.as_str().bytes().any(|b| b == 0) {
331-
let msg = format!("illegal null byte in link_section value: `{}`", &val);
331+
let msg = format!("illegal null byte in link_section value: `{val}`");
332332
tcx.dcx().span_err(attr.span, msg);
333333
} else {
334334
codegen_fn_attrs.link_section = Some(val);
@@ -726,7 +726,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
726726
if *ordinal <= u16::MAX as u128 {
727727
Some(ordinal.get() as u16)
728728
} else {
729-
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
729+
let msg = format!("ordinal value in `link_ordinal` is too large: `{ordinal}`");
730730
tcx.dcx()
731731
.struct_span_err(attr.span, msg)
732732
.with_note("the value may not exceed `u16::MAX`")

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::operand::OperandValue::{Immediate, Pair, Ref, ZeroSized};
33
use super::place::{PlaceRef, PlaceValue};
44
use super::{CachedLlbb, FunctionCx, LocalRef};
55

6-
use crate::base;
6+
use crate::base::{self, is_call_from_compiler_builtins_to_upstream_monomorphization};
77
use crate::common::{self, IntPredicate};
88
use crate::errors::CompilerBuiltinsCannotCall;
99
use crate::meth;
@@ -18,7 +18,6 @@ use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, ValidityRequirement};
1818
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
1919
use rustc_middle::ty::{self, Instance, Ty};
2020
use rustc_middle::{bug, span_bug};
21-
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
2221
use rustc_session::config::OptLevel;
2322
use rustc_span::{source_map::Spanned, sym, Span};
2423
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg};

compiler/rustc_codegen_ssa/src/mono_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
130130

131131
let symbol_name = self.symbol_name(cx.tcx()).name;
132132

133-
debug!("symbol {}", &symbol_name);
133+
debug!("symbol {symbol_name}");
134134

135135
match *self {
136136
MonoItem::Static(def_id) => {

compiler/rustc_expand/src/mbe/macro_check.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ fn check_occurrences(
352352
check_ops_is_prefix(psess, node_id, macros, binders, ops, span, name);
353353
}
354354
TokenTree::MetaVarExpr(dl, ref mve) => {
355-
let Some(name) = mve.ident().map(MacroRulesNormalizedIdent::new) else {
356-
return;
357-
};
358-
check_ops_is_prefix(psess, node_id, macros, binders, ops, dl.entire(), name);
355+
mve.for_each_metavar((), |_, ident| {
356+
let name = MacroRulesNormalizedIdent::new(*ident);
357+
check_ops_is_prefix(psess, node_id, macros, binders, ops, dl.entire(), name);
358+
});
359359
}
360360
TokenTree::Delimited(.., ref del) => {
361361
check_nested_occurrences(psess, node_id, &del.tts, macros, binders, ops, guar);

0 commit comments

Comments
 (0)