Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6c699a3

Browse files
committed
Auto merge of #146255 - fmease:rollup-1v0kp8i, r=fmease
Rollup of 11 pull requests Successful merges: - #138944 (Add `__isPlatformVersionAtLeast` and `__isOSVersionAtLeast` symbols) - #139113 (unstable book: in a sanitizer example, check the code) - #145735 (style-guide: Document absence of trailing whitespace) - #146041 (tidy: --bless now makes escheck run with --fix) - #146144 (compiler: Apply target features to the entry function) - #146225 (Simplify `{f16, f32, f64, f128}::midpoint()`) - #146234 (change file-is-generated doc comment to inner) - #146241 (rustc_infer: change top-level doc comment to inner) - #146242 (Ensure that `--html-after-content` option is used to check `scrape_examples_ice` rustdoc GUI test) - #146243 (remove couple of redundant clones) - #146250 (Bump stage0 rustfmt) Failed merges: - #146200 (Simplify rustdoc-gui tester by calling directly browser-ui-test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 99317ef + 55a62d5 commit 6c699a3

File tree

34 files changed

+1329
-202
lines changed

34 files changed

+1329
-202
lines changed

‎compiler/rustc_codegen_llvm/src/attributes.rs‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,19 @@ pub(crate) fn tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribu
296296
.map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu))
297297
}
298298

299+
/// Get the `target-features` LLVM attribute.
300+
pub(crate) fn target_features_attr<'ll>(
301+
cx: &CodegenCx<'ll, '_>,
302+
function_features: Vec<String>,
303+
) -> Option<&'ll Attribute> {
304+
let global_features = cx.tcx.global_backend_features(()).iter().map(String::as_str);
305+
let function_features = function_features.iter().map(String::as_str);
306+
let target_features =
307+
global_features.chain(function_features).intersperse(",").collect::<String>();
308+
(!target_features.is_empty())
309+
.then(|| llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features))
310+
}
311+
299312
/// Get the `NonLazyBind` LLVM attribute,
300313
/// if the codegen options allow skipping the PLT.
301314
pub(crate) fn non_lazy_bind_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
@@ -523,14 +536,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
523536
}
524537
}
525538

526-
let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str());
527-
let function_features = function_features.iter().map(|s| s.as_str());
528-
let target_features: String =
529-
global_features.chain(function_features).intersperse(",").collect();
530-
531-
if !target_features.is_empty() {
532-
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features));
533-
}
539+
to_add.extend(target_features_attr(cx, function_features));
534540

535541
attributes::apply_to_llfn(llfn, Function, &to_add);
536542
}

‎compiler/rustc_codegen_llvm/src/context.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,15 +853,21 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
853853
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function> {
854854
let entry_name = self.sess().target.entry_name.as_ref();
855855
if self.get_declared_value(entry_name).is_none() {
856-
Some(self.declare_entry_fn(
856+
let llfn = self.declare_entry_fn(
857857
entry_name,
858858
llvm::CallConv::from_conv(
859859
self.sess().target.entry_abi,
860860
self.sess().target.arch.borrow(),
861861
),
862862
llvm::UnnamedAddr::Global,
863863
fn_type,
864-
))
864+
);
865+
attributes::apply_to_llfn(
866+
llfn,
867+
llvm::AttributePlace::Function,
868+
attributes::target_features_attr(self, vec![]).as_slice(),
869+
);
870+
Some(llfn)
865871
} else {
866872
// If the symbol already exists, it is an error: for example, the user wrote
867873
// #[no_mangle] extern "C" fn main(..) {..}

‎compiler/rustc_codegen_ssa/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<M> ModuleCodegen<M> {
119119
});
120120

121121
CompiledModule {
122-
name: self.name.clone(),
122+
name: self.name,
123123
object,
124124
dwarf_object,
125125
bytecode,

‎compiler/rustc_infer/src/infer/context.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///! Definition of `InferCtxtLike` from the librarified type layer.
1+
//! Definition of `InferCtxtLike` from the librarified type layer.
22
use rustc_hir::def_id::DefId;
33
use rustc_middle::traits::ObligationCause;
44
use rustc_middle::ty::relate::RelateResult;

‎compiler/rustc_mir_transform/src/coverage/expansion.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl ExpnNode {
8282
Self {
8383
expn_id,
8484

85-
expn_kind: expn_data.kind.clone(),
85+
expn_kind: expn_data.kind,
8686
call_site,
8787
call_site_expn_id,
8888

‎compiler/rustc_resolve/src/late/diagnostics.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3099,7 +3099,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
30993099
|err, _, span, message, suggestion, span_suggs| {
31003100
err.multipart_suggestion_verbose(
31013101
message,
3102-
std::iter::once((span, suggestion)).chain(span_suggs.clone()).collect(),
3102+
std::iter::once((span, suggestion)).chain(span_suggs).collect(),
31033103
Applicability::MaybeIncorrect,
31043104
);
31053105
true

‎compiler/rustc_symbol_mangling/src/v0.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ pub(super) fn mangle<'tcx>(
8282
}
8383

8484
pub fn mangle_internal_symbol<'tcx>(tcx: TyCtxt<'tcx>, item_name: &str) -> String {
85-
if item_name == "rust_eh_personality" {
85+
match item_name {
8686
// rust_eh_personality must not be renamed as LLVM hard-codes the name
87-
return "rust_eh_personality".to_owned();
87+
"rust_eh_personality" => return item_name.to_owned(),
88+
// Apple availability symbols need to not be mangled to be usable by
89+
// C/Objective-C code.
90+
"__isPlatformVersionAtLeast" | "__isOSVersionAtLeast" => return item_name.to_owned(),
91+
_ => {}
8892
}
8993

9094
let prefix = "_R";

‎compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
318318
let (expected, found) = if expected_str == found_str {
319319
(join_path_syms(&expected_abs), join_path_syms(&found_abs))
320320
} else {
321-
(expected_str.clone(), found_str.clone())
321+
(expected_str, found_str)
322322
};
323323

324324
// We've displayed "expected `a::b`, found `a::b`". We add context to

‎library/core/src/num/f128.rs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,6 @@ impl f128 {
832832
#[unstable(feature = "f128", issue = "116909")]
833833
#[rustc_const_unstable(feature = "f128", issue = "116909")]
834834
pub const fn midpoint(self, other: f128) -> f128 {
835-
const LO: f128 = f128::MIN_POSITIVE * 2.;
836835
const HI: f128 = f128::MAX / 2.;
837836

838837
let (a, b) = (self, other);
@@ -842,14 +841,7 @@ impl f128 {
842841
if abs_a <= HI && abs_b <= HI {
843842
// Overflow is impossible
844843
(a + b) / 2.
845-
} else if abs_a < LO {
846-
// Not safe to halve `a` (would underflow)
847-
a + (b / 2.)
848-
} else if abs_b < LO {
849-
// Not safe to halve `b` (would underflow)
850-
(a / 2.) + b
851844
} else {
852-
// Safe to halve `a` and `b`
853845
(a / 2.) + (b / 2.)
854846
}
855847
}

‎library/core/src/num/f16.rs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ impl f16 {
820820
#[unstable(feature = "f16", issue = "116909")]
821821
#[rustc_const_unstable(feature = "f16", issue = "116909")]
822822
pub const fn midpoint(self, other: f16) -> f16 {
823-
const LO: f16 = f16::MIN_POSITIVE * 2.;
824823
const HI: f16 = f16::MAX / 2.;
825824

826825
let (a, b) = (self, other);
@@ -830,14 +829,7 @@ impl f16 {
830829
if abs_a <= HI && abs_b <= HI {
831830
// Overflow is impossible
832831
(a + b) / 2.
833-
} else if abs_a < LO {
834-
// Not safe to halve `a` (would underflow)
835-
a + (b / 2.)
836-
} else if abs_b < LO {
837-
// Not safe to halve `b` (would underflow)
838-
(a / 2.) + b
839832
} else {
840-
// Safe to halve `a` and `b`
841833
(a / 2.) + (b / 2.)
842834
}
843835
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /