Skip to content

Commit 6715446

Browse files
committed
Auto merge of rust-lang#125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#124570 (Miscellaneous cleanups) - rust-lang#124772 (Refactor documentation for Apple targets) - rust-lang#125011 (Add opt-for-size core lib feature flag) - rust-lang#125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`) - rust-lang#125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS) - rust-lang#125266 (compiler: add simd_ctpop intrinsic) - rust-lang#125348 (Small fixes to `std::path::absolute` docs) Failed merges: - rust-lang#125296 (Fix `unexpected_cfgs` lint on std) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e8fbd99 + e6e05d5 commit 6715446

File tree

42 files changed

+680
-439
lines changed

Some content is hidden

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

42 files changed

+680
-439
lines changed

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+2
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
348348
| sym::simd_bswap
349349
| sym::simd_bitreverse
350350
| sym::simd_ctlz
351+
| sym::simd_ctpop
351352
| sym::simd_cttz => {
352353
intrinsic_args!(fx, args => (a); intrinsic);
353354

@@ -367,6 +368,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
367368
(ty::Uint(_) | ty::Int(_), sym::simd_bswap) => fx.bcx.ins().bswap(lane),
368369
(ty::Uint(_) | ty::Int(_), sym::simd_bitreverse) => fx.bcx.ins().bitrev(lane),
369370
(ty::Uint(_) | ty::Int(_), sym::simd_ctlz) => fx.bcx.ins().clz(lane),
371+
(ty::Uint(_) | ty::Int(_), sym::simd_ctpop) => fx.bcx.ins().popcnt(lane),
370372
(ty::Uint(_) | ty::Int(_), sym::simd_cttz) => fx.bcx.ins().ctz(lane),
371373

372374
_ => unreachable!(),

compiler/rustc_codegen_llvm/src/intrinsic.rs

+29-19
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
23362336
}
23372337

23382338
// Unary integer intrinsics
2339-
if matches!(name, sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctlz | sym::simd_cttz) {
2339+
if matches!(
2340+
name,
2341+
sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctlz | sym::simd_ctpop | sym::simd_cttz
2342+
) {
23402343
let vec_ty = bx.cx.type_vector(
23412344
match *in_elem.kind() {
23422345
ty::Int(i) => bx.cx.type_int_from_ty(i),
@@ -2354,31 +2357,38 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
23542357
sym::simd_bswap => "bswap",
23552358
sym::simd_bitreverse => "bitreverse",
23562359
sym::simd_ctlz => "ctlz",
2360+
sym::simd_ctpop => "ctpop",
23572361
sym::simd_cttz => "cttz",
23582362
_ => unreachable!(),
23592363
};
23602364
let int_size = in_elem.int_size_and_signed(bx.tcx()).0.bits();
23612365
let llvm_intrinsic = &format!("llvm.{}.v{}i{}", intrinsic_name, in_len, int_size,);
23622366

2363-
return if name == sym::simd_bswap && int_size == 8 {
2367+
return match name {
23642368
// byte swap is no-op for i8/u8
2365-
Ok(args[0].immediate())
2366-
} else if matches!(name, sym::simd_ctlz | sym::simd_cttz) {
2367-
let fn_ty = bx.type_func(&[vec_ty, bx.type_i1()], vec_ty);
2368-
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
2369-
Ok(bx.call(
2370-
fn_ty,
2371-
None,
2372-
None,
2373-
f,
2374-
&[args[0].immediate(), bx.const_int(bx.type_i1(), 0)],
2375-
None,
2376-
None,
2377-
))
2378-
} else {
2379-
let fn_ty = bx.type_func(&[vec_ty], vec_ty);
2380-
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
2381-
Ok(bx.call(fn_ty, None, None, f, &[args[0].immediate()], None, None))
2369+
sym::simd_bswap if int_size == 8 => Ok(args[0].immediate()),
2370+
sym::simd_ctlz | sym::simd_cttz => {
2371+
// for the (int, i1 immediate) pair, the second arg adds `(0, true) => poison`
2372+
let fn_ty = bx.type_func(&[vec_ty, bx.type_i1()], vec_ty);
2373+
let dont_poison_on_zero = bx.const_int(bx.type_i1(), 0);
2374+
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
2375+
Ok(bx.call(
2376+
fn_ty,
2377+
None,
2378+
None,
2379+
f,
2380+
&[args[0].immediate(), dont_poison_on_zero],
2381+
None,
2382+
None,
2383+
))
2384+
}
2385+
sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctpop => {
2386+
// simple unary argument cases
2387+
let fn_ty = bx.type_func(&[vec_ty], vec_ty);
2388+
let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);
2389+
Ok(bx.call(fn_ty, None, None, f, &[args[0].immediate()], None, None))
2390+
}
2391+
_ => unreachable!(),
23822392
};
23832393
}
23842394

compiler/rustc_const_eval/src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*!
2-
3-
Rust MIR: a lowered representation of Rust.
4-
5-
*/
6-
71
#![allow(internal_features)]
82
#![allow(rustc::diagnostic_outside_of_impl)]
93
#![feature(rustdoc_internals)]

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ pub fn check_intrinsic_type(
607607
| sym::simd_bitreverse
608608
| sym::simd_ctlz
609609
| sym::simd_cttz
610+
| sym::simd_ctpop
610611
| sym::simd_fsqrt
611612
| sym::simd_fsin
612613
| sym::simd_fcos

compiler/rustc_metadata/src/lib.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
// tidy-alphabetical-start
2+
#![allow(internal_features)]
3+
#![allow(rustc::potential_query_instability)]
14
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
25
#![doc(rust_logo)]
3-
#![feature(rustdoc_internals)]
4-
#![allow(internal_features)]
6+
#![feature(coroutines)]
57
#![feature(decl_macro)]
68
#![feature(error_iter)]
79
#![feature(extract_if)]
8-
#![feature(coroutines)]
10+
#![feature(if_let_guard)]
911
#![feature(iter_from_coroutine)]
1012
#![feature(let_chains)]
11-
#![feature(if_let_guard)]
12-
#![feature(proc_macro_internals)]
1313
#![feature(macro_metavar_expr)]
1414
#![feature(min_specialization)]
15-
#![feature(trusted_len)]
16-
#![feature(try_blocks)]
1715
#![feature(never_type)]
18-
#![allow(rustc::potential_query_instability)]
16+
#![feature(proc_macro_internals)]
17+
#![feature(rustdoc_internals)]
18+
#![feature(trusted_len)]
19+
// tidy-alphabetical-end
1920

2021
extern crate proc_macro;
2122

compiler/rustc_metadata/src/rmeta/mod.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
use crate::creader::CrateMetadataRef;
2-
use decoder::Metadata;
2+
pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob};
3+
use decoder::{DecodeContext, Metadata};
34
use def_path_hash_map::DefPathHashMapRef;
4-
use rustc_data_structures::fx::FxHashMap;
5-
use rustc_macros::{Decodable, Encodable, TyDecodable, TyEncodable};
6-
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
7-
use rustc_middle::middle::lib_features::FeatureStability;
8-
use table::TableBuilder;
9-
5+
use encoder::EncodeContext;
6+
pub use encoder::{encode_metadata, rendered_const, EncodedMetadata};
107
use rustc_ast as ast;
118
use rustc_ast::expand::StrippedCfgItem;
129
use rustc_attr as attr;
10+
use rustc_data_structures::fx::FxHashMap;
1311
use rustc_data_structures::svh::Svh;
1412
use rustc_hir as hir;
1513
use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap};
@@ -18,10 +16,13 @@ use rustc_hir::definitions::DefKey;
1816
use rustc_hir::lang_items::LangItem;
1917
use rustc_index::bit_set::BitSet;
2018
use rustc_index::IndexVec;
19+
use rustc_macros::{Decodable, Encodable, TyDecodable, TyEncodable};
2120
use rustc_macros::{MetadataDecodable, MetadataEncodable};
2221
use rustc_middle::metadata::ModChild;
2322
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
23+
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
2424
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
25+
use rustc_middle::middle::lib_features::FeatureStability;
2526
use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault;
2627
use rustc_middle::mir;
2728
use rustc_middle::trivially_parameterized_over_tcx;
@@ -33,20 +34,14 @@ use rustc_serialize::opaque::FileEncoder;
3334
use rustc_session::config::SymbolManglingVersion;
3435
use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
3536
use rustc_span::edition::Edition;
36-
use rustc_span::hygiene::{ExpnIndex, MacroKind};
37+
use rustc_span::hygiene::{ExpnIndex, MacroKind, SyntaxContextData};
3738
use rustc_span::symbol::{Ident, Symbol};
3839
use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span};
3940
use rustc_target::abi::{FieldIdx, VariantIdx};
4041
use rustc_target::spec::{PanicStrategy, TargetTriple};
41-
4242
use std::marker::PhantomData;
4343
use std::num::NonZero;
44-
45-
use decoder::DecodeContext;
46-
pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob};
47-
use encoder::EncodeContext;
48-
pub use encoder::{encode_metadata, rendered_const, EncodedMetadata};
49-
use rustc_span::hygiene::SyntaxContextData;
44+
use table::TableBuilder;
5045

5146
mod decoder;
5247
mod def_path_hash_map;

compiler/rustc_middle/src/lib.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,46 @@
2222
//!
2323
//! This API is completely unstable and subject to change.
2424
25+
// tidy-alphabetical-start
26+
#![allow(internal_features)]
27+
#![allow(rustc::diagnostic_outside_of_impl)]
28+
#![allow(rustc::potential_query_instability)]
29+
#![allow(rustc::untranslatable_diagnostic)]
2530
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2631
#![doc(rust_logo)]
27-
#![feature(min_exhaustive_patterns)]
28-
#![feature(rustdoc_internals)]
2932
#![feature(allocator_api)]
3033
#![feature(array_windows)]
3134
#![feature(assert_matches)]
3235
#![feature(box_patterns)]
3336
#![feature(closure_track_caller)]
34-
#![feature(core_intrinsics)]
37+
#![feature(const_option)]
3538
#![feature(const_type_name)]
36-
#![feature(discriminant_kind)]
39+
#![feature(core_intrinsics)]
3740
#![feature(coroutines)]
38-
#![feature(stmt_expr_attributes)]
41+
#![feature(decl_macro)]
42+
#![feature(discriminant_kind)]
43+
#![feature(extern_types)]
44+
#![feature(extract_if)]
3945
#![feature(if_let_guard)]
46+
#![feature(intra_doc_pointers)]
4047
#![feature(iter_from_coroutine)]
48+
#![feature(let_chains)]
49+
#![feature(macro_metavar_expr)]
50+
#![feature(min_exhaustive_patterns)]
51+
#![feature(min_specialization)]
4152
#![feature(negative_impls)]
4253
#![feature(never_type)]
43-
#![feature(extern_types)]
4454
#![feature(new_uninit)]
45-
#![feature(let_chains)]
46-
#![feature(min_specialization)]
47-
#![feature(trusted_len)]
48-
#![feature(type_alias_impl_trait)]
49-
#![feature(strict_provenance)]
55+
#![feature(ptr_alignment_type)]
5056
#![feature(rustc_attrs)]
51-
#![feature(control_flow_enum)]
57+
#![feature(rustdoc_internals)]
58+
#![feature(strict_provenance)]
5259
#![feature(trait_upcasting)]
60+
#![feature(trusted_len)]
5361
#![feature(try_blocks)]
54-
#![feature(decl_macro)]
55-
#![feature(extract_if)]
56-
#![feature(intra_doc_pointers)]
62+
#![feature(type_alias_impl_trait)]
5763
#![feature(yeet_expr)]
58-
#![feature(const_option)]
59-
#![feature(ptr_alignment_type)]
60-
#![feature(macro_metavar_expr)]
61-
#![allow(internal_features)]
62-
#![allow(rustc::potential_query_instability)]
63-
#![allow(rustc::diagnostic_outside_of_impl)]
64-
#![allow(rustc::untranslatable_diagnostic)]
64+
// tidy-alphabetical-end
6565

6666
#[macro_use]
6767
extern crate tracing;

compiler/rustc_passes/src/check_attr.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ use std::collections::hash_map::Entry;
4242

4343
#[derive(LintDiagnostic)]
4444
#[diag(passes_diagnostic_diagnostic_on_unimplemented_only_for_traits)]
45-
pub struct DiagnosticOnUnimplementedOnlyForTraits;
45+
struct DiagnosticOnUnimplementedOnlyForTraits;
4646

47-
pub(crate) fn target_from_impl_item<'tcx>(
48-
tcx: TyCtxt<'tcx>,
49-
impl_item: &hir::ImplItem<'_>,
50-
) -> Target {
47+
fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>) -> Target {
5148
match impl_item.kind {
5249
hir::ImplItemKind::Const(..) => Target::AssocConst,
5350
hir::ImplItemKind::Fn(..) => {
@@ -99,7 +96,7 @@ struct CheckAttrVisitor<'tcx> {
9996
}
10097

10198
impl<'tcx> CheckAttrVisitor<'tcx> {
102-
pub fn dcx(&self) -> &'tcx DiagCtxt {
99+
fn dcx(&self) -> &'tcx DiagCtxt {
103100
self.tcx.dcx()
104101
}
105102

compiler/rustc_passes/src/lang_items.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> {
149149
}
150150
};
151151

152-
// When there's a duplicate lang item, something went very wrong and there's no value in recovering or doing anything.
153-
// Give the user the one message to let them debug the mess they created and then wish them farewell.
152+
// When there's a duplicate lang item, something went very wrong and there's no value
153+
// in recovering or doing anything. Give the user the one message to let them debug the
154+
// mess they created and then wish them farewell.
154155
self.tcx.dcx().emit_fatal(DuplicateLangItem {
155156
local_span: item_span,
156157
lang_item_name,

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,7 @@ symbols! {
16821682
simd_cast_ptr,
16831683
simd_ceil,
16841684
simd_ctlz,
1685+
simd_ctpop,
16851686
simd_cttz,
16861687
simd_div,
16871688
simd_eq,

compiler/rustc_target/src/spec/base/apple/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ fn macos_default_deployment_target(arch: Arch) -> (u32, u32) {
272272

273273
fn macos_deployment_target(arch: Arch) -> (u32, u32) {
274274
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
275+
// Note: If bumping this version, remember to update it in the rustc/platform-support docs.
275276
from_set_deployment_target("MACOSX_DEPLOYMENT_TARGET")
276277
.unwrap_or_else(|| macos_default_deployment_target(arch))
277278
}
@@ -320,6 +321,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
320321

321322
fn ios_deployment_target(arch: Arch, abi: &str) -> (u32, u32) {
322323
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
324+
// Note: If bumping this version, remember to update it in the rustc/platform-support docs.
323325
let (major, minor) = match (arch, abi) {
324326
(Arm64e, _) => (14, 0),
325327
// Mac Catalyst defaults to 13.1 in Clang.
@@ -352,6 +354,7 @@ pub fn ios_sim_llvm_target(arch: Arch) -> String {
352354

353355
fn tvos_deployment_target() -> (u32, u32) {
354356
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
357+
// Note: If bumping this version, remember to update it in the rustc platform-support docs.
355358
from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((10, 0))
356359
}
357360

@@ -367,6 +370,7 @@ pub fn tvos_sim_llvm_target(arch: Arch) -> String {
367370

368371
fn watchos_deployment_target() -> (u32, u32) {
369372
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
373+
// Note: If bumping this version, remember to update it in the rustc platform-support docs.
370374
from_set_deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0))
371375
}
372376

@@ -382,6 +386,7 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String {
382386

383387
fn visionos_deployment_target() -> (u32, u32) {
384388
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
389+
// Note: If bumping this version, remember to update it in the rustc platform-support docs.
385390
from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0))
386391
}
387392

library/alloc/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ compiler-builtins-no-asm = ["compiler_builtins/no-asm"]
3737
compiler-builtins-mangled-names = ["compiler_builtins/mangled-names"]
3838
compiler-builtins-weak-intrinsics = ["compiler_builtins/weak-intrinsics"]
3939
# Make panics and failed asserts immediately abort without formatting any message
40-
panic_immediate_abort = []
40+
panic_immediate_abort = ["core/panic_immediate_abort"]
41+
# Choose algorithms that are optimized for binary size instead of runtime performance
42+
optimize_for_size = ["core/optimize_for_size"]

library/core/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ rand_xorshift = { version = "0.3.0", default-features = false }
3131
[features]
3232
# Make panics and failed asserts immediately abort without formatting any message
3333
panic_immediate_abort = []
34+
# Choose algorithms that are optimized for binary size instead of runtime performance
35+
optimize_for_size = []
3436
# Make `RefCell` store additional debugging information, which is printed out when
3537
# a borrow error occurs
3638
debug_refcell = []

library/core/src/intrinsics/simd.rs

+7
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ extern "rust-intrinsic" {
569569
#[rustc_nounwind]
570570
pub fn simd_ctlz<T>(x: T) -> T;
571571

572+
/// Count the number of ones in each element.
573+
///
574+
/// `T` must be a vector of integers.
575+
#[rustc_nounwind]
576+
#[cfg(not(bootstrap))]
577+
pub fn simd_ctpop<T>(x: T) -> T;
578+
572579
/// Count the trailing zeros of each element.
573580
///
574581
/// `T` must be a vector of integers.

library/std/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ system-llvm-libunwind = ["unwind/system-llvm-libunwind"]
7878

7979
# Make panics and failed asserts immediately abort without formatting any message
8080
panic_immediate_abort = ["core/panic_immediate_abort", "alloc/panic_immediate_abort"]
81+
# Choose algorithms that are optimized for binary size instead of runtime performance
82+
optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"]
8183

8284
# Enable std_detect default features for stdarch/crates/std_detect:
8385
# https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml

0 commit comments

Comments
 (0)