Skip to content

Commit 61413ae

Browse files
committed
Auto merge of #142003 - matthiaskrgr:rollup-ad8l9ns, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #136687 (Improve the documentation of `Display` and `FromStr`, and their interactions) - #137306 (Remove `i128` and `u128` from `improper_ctypes_definitions`) - #138699 (build dist for x86_64-pc-solaris and sparcv9-sun-solaris) - #141250 (add s390x z17 target features) - #141467 (make `OsString::new` and `PathBuf::new` unstably const) - #141871 (index: add method for checking range on DenseBitSet) - #141888 (Use non-2015 edition paths in tests that do not test for their resolution) - #142000 (bootstrap: don't symlink source dir into stage0 sysroot) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d9a7393 + d31faac commit 61413ae

File tree

100 files changed

+688
-632
lines changed

Some content is hidden

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

100 files changed

+688
-632
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
282282
}
283283
// Filter out features that are not supported by the current LLVM version
284284
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
285+
(
286+
"s390x",
287+
"message-security-assist-extension12"
288+
| "concurrent-functions"
289+
| "miscellaneous-extensions-4"
290+
| "vector-enhancements-3"
291+
| "vector-packed-decimal-enhancement-3",
292+
) if get_version().0 < 20 => None,
285293
// Enable the evex512 target feature if an avx512 target feature is enabled.
286294
("x86", s) if s.starts_with("avx512") => Some(LLVMFeature::with_dependencies(
287295
s,

compiler/rustc_index/src/bit_set.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,32 @@ impl<T: Idx> DenseBitSet<T> {
234234
self.clear_excess_bits();
235235
}
236236

237+
/// Checks whether any bit in the given range is a 1.
238+
#[inline]
239+
pub fn contains_any(&self, elems: impl RangeBounds<T>) -> bool {
240+
let Some((start, end)) = inclusive_start_end(elems, self.domain_size) else {
241+
return false;
242+
};
243+
let (start_word_index, start_mask) = word_index_and_mask(start);
244+
let (end_word_index, end_mask) = word_index_and_mask(end);
245+
246+
if start_word_index == end_word_index {
247+
self.words[start_word_index] & (end_mask | (end_mask - start_mask)) != 0
248+
} else {
249+
if self.words[start_word_index] & !(start_mask - 1) != 0 {
250+
return true;
251+
}
252+
253+
let remaining = start_word_index + 1..end_word_index;
254+
if remaining.start <= remaining.end {
255+
self.words[remaining].iter().any(|&w| w != 0)
256+
|| self.words[end_word_index] & (end_mask | (end_mask - 1)) != 0
257+
} else {
258+
false
259+
}
260+
}
261+
}
262+
237263
/// Returns `true` if the set has changed.
238264
#[inline]
239265
pub fn remove(&mut self, elem: T) -> bool {

compiler/rustc_index/src/bit_set/tests.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,25 @@ fn dense_last_set_before() {
692692
}
693693
}
694694

695+
#[test]
696+
fn dense_contains_any() {
697+
let mut set: DenseBitSet<usize> = DenseBitSet::new_empty(300);
698+
assert!(!set.contains_any(0..300));
699+
set.insert_range(10..20);
700+
set.insert_range(60..70);
701+
set.insert_range(150..=250);
702+
703+
assert!(set.contains_any(0..30));
704+
assert!(set.contains_any(5..100));
705+
assert!(set.contains_any(250..255));
706+
707+
assert!(!set.contains_any(20..59));
708+
assert!(!set.contains_any(256..290));
709+
710+
set.insert(22);
711+
assert!(set.contains_any(20..59));
712+
}
713+
695714
#[bench]
696715
fn bench_insert(b: &mut Bencher) {
697716
let mut bs = DenseBitSet::new_filled(99999usize);

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,6 @@ lint_improper_ctypes = `extern` {$desc} uses type `{$ty}`, which is not FFI-safe
374374
.label = not FFI-safe
375375
.note = the type is defined here
376376
377-
lint_improper_ctypes_128bit = 128-bit integers don't currently have a known stable ABI
378-
379377
lint_improper_ctypes_array_help = consider passing a pointer to the array
380378
381379
lint_improper_ctypes_array_reason = passing raw arrays by value is not FFI-safe

compiler/rustc_lint/src/types.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use std::iter;
22
use std::ops::ControlFlow;
33

4-
use rustc_abi::{
5-
BackendRepr, Integer, IntegerType, TagEncoding, VariantIdx, Variants, WrappingRange,
6-
};
4+
use rustc_abi::{BackendRepr, TagEncoding, VariantIdx, Variants, WrappingRange};
75
use rustc_data_structures::fx::FxHashSet;
86
use rustc_errors::DiagMessage;
97
use rustc_hir::intravisit::VisitorExt;
@@ -1284,14 +1282,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
12841282
};
12851283
}
12861284

1287-
if let Some(IntegerType::Fixed(Integer::I128, _)) = def.repr().int {
1288-
return FfiUnsafe {
1289-
ty,
1290-
reason: fluent::lint_improper_ctypes_128bit,
1291-
help: None,
1292-
};
1293-
}
1294-
12951285
use improper_ctypes::check_non_exhaustive_variant;
12961286

12971287
let non_exhaustive = def.variant_list_has_applicable_non_exhaustive();
@@ -1324,10 +1314,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
13241314
// but only the base type is relevant for being representable in FFI.
13251315
ty::Pat(base, ..) => self.check_type_for_ffi(acc, base),
13261316

1327-
ty::Int(ty::IntTy::I128) | ty::Uint(ty::UintTy::U128) => {
1328-
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_128bit, help: None }
1329-
}
1330-
13311317
// Primitive types with a stable representation.
13321318
ty::Bool | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Never => FfiSafe,
13331319

compiler/rustc_target/src/target_features.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -710,29 +710,35 @@ static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
710710
// tidy-alphabetical-end
711711
];
712712

713+
#[rustfmt::skip]
713714
const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
714715
// tidy-alphabetical-start
715716
("backchain", Unstable(sym::s390x_target_feature), &[]),
717+
("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
716718
("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
717719
("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
718720
("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
719721
("high-word", Unstable(sym::s390x_target_feature), &[]),
722+
// LLVM does not define message-security-assist-extension versions 1, 2, 6, 10 and 11.
723+
("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
724+
("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
725+
("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
726+
("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
727+
("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
728+
("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
729+
("miscellaneous-extensions-2", Unstable(sym::s390x_target_feature), &[]),
730+
("miscellaneous-extensions-3", Unstable(sym::s390x_target_feature), &[]),
731+
("miscellaneous-extensions-4", Unstable(sym::s390x_target_feature), &[]),
720732
("nnp-assist", Unstable(sym::s390x_target_feature), &["vector"]),
721733
("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
722734
("vector", Unstable(sym::s390x_target_feature), &[]),
723735
("vector-enhancements-1", Unstable(sym::s390x_target_feature), &["vector"]),
724736
("vector-enhancements-2", Unstable(sym::s390x_target_feature), &["vector-enhancements-1"]),
737+
("vector-enhancements-3", Unstable(sym::s390x_target_feature), &["vector-enhancements-2"]),
725738
("vector-packed-decimal", Unstable(sym::s390x_target_feature), &["vector"]),
726-
(
727-
"vector-packed-decimal-enhancement",
728-
Unstable(sym::s390x_target_feature),
729-
&["vector-packed-decimal"],
730-
),
731-
(
732-
"vector-packed-decimal-enhancement-2",
733-
Unstable(sym::s390x_target_feature),
734-
&["vector-packed-decimal-enhancement"],
735-
),
739+
("vector-packed-decimal-enhancement", Unstable(sym::s390x_target_feature), &["vector-packed-decimal"]),
740+
("vector-packed-decimal-enhancement-2", Unstable(sym::s390x_target_feature), &["vector-packed-decimal-enhancement"]),
741+
("vector-packed-decimal-enhancement-3", Unstable(sym::s390x_target_feature), &["vector-packed-decimal-enhancement-2"]),
736742
// tidy-alphabetical-end
737743
];
738744

library/core/src/fmt/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,20 @@ pub use macros::Debug;
928928
/// [tostring]: ../../std/string/trait.ToString.html
929929
/// [tostring_function]: ../../std/string/trait.ToString.html#tymethod.to_string
930930
///
931+
/// # Completeness and parseability
932+
///
933+
/// `Display` for a type might not necessarily be a lossless or complete representation of the type.
934+
/// It may omit internal state, precision, or other information the type does not consider important
935+
/// for user-facing output, as determined by the type. As such, the output of `Display` might not be
936+
/// possible to parse, and even if it is, the result of parsing might not exactly match the original
937+
/// value.
938+
///
939+
/// However, if a type has a lossless `Display` implementation whose output is meant to be
940+
/// conveniently machine-parseable and not just meant for human consumption, then the type may wish
941+
/// to accept the same format in `FromStr`, and document that usage. Having both `Display` and
942+
/// `FromStr` implementations where the result of `Display` cannot be parsed with `FromStr` may
943+
/// surprise users.
944+
///
931945
/// # Internationalization
932946
///
933947
/// Because a type can only have one `Display` implementation, it is often preferable

library/core/src/primitive_docs.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,18 @@ mod prim_i64 {}
14281428
#[rustc_doc_primitive = "i128"]
14291429
//
14301430
/// The 128-bit signed integer type.
1431+
///
1432+
/// # ABI compatibility
1433+
///
1434+
/// Rust's `i128` is expected to be ABI-compatible with C's `__int128` on platforms where the type
1435+
/// is available, which includes most 64-bit architectures. If any platforms that do not specify
1436+
/// `__int128` are updated to introduce it, the Rust `i128` ABI on relevant targets will be changed
1437+
/// to match.
1438+
///
1439+
/// It is important to note that in C, `__int128` is _not_ the same as `_BitInt(128)`, and the two
1440+
/// types are allowed to have different ABIs. In particular, on x86, `__int128` and `_BitInt(128)`
1441+
/// do not use the same alignment. `i128` is intended to always match `__int128` and does not
1442+
/// attempt to match `_BitInt(128)` on platforms without `__int128`.
14311443
#[stable(feature = "i128", since = "1.26.0")]
14321444
mod prim_i128 {}
14331445

@@ -1458,6 +1470,8 @@ mod prim_u64 {}
14581470
#[rustc_doc_primitive = "u128"]
14591471
//
14601472
/// The 128-bit unsigned integer type.
1473+
///
1474+
/// Please see [the documentation for `i128`](prim@i128) for information on ABI compatibility.
14611475
#[stable(feature = "i128", since = "1.26.0")]
14621476
mod prim_u128 {}
14631477

library/core/src/str/traits.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,20 @@ unsafe impl SliceIndex<str> for ops::RangeToInclusive<usize> {
756756
/// parse an `i32` with `FromStr`, but not a `&i32`. You can parse a struct that
757757
/// contains an `i32`, but not one that contains an `&i32`.
758758
///
759+
/// # Input format and round-tripping
760+
///
761+
/// The input format expected by a type's `FromStr` implementation depends on the type. Check the
762+
/// type's documentation for the input formats it knows how to parse. Note that the input format of
763+
/// a type's `FromStr` implementation might not necessarily accept the output format of its
764+
/// `Display` implementation, and even if it does, the `Display` implementation may not be lossless
765+
/// so the round-trip may lose information.
766+
///
767+
/// However, if a type has a lossless `Display` implementation whose output is meant to be
768+
/// conveniently machine-parseable and not just meant for human consumption, then the type may wish
769+
/// to accept the same format in `FromStr`, and document that usage. Having both `Display` and
770+
/// `FromStr` implementations where the result of `Display` cannot be parsed with `FromStr` may
771+
/// surprise users.
772+
///
759773
/// # Examples
760774
///
761775
/// Basic implementation of `FromStr` on an example `Point` type:

library/std/src/ffi/os_str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ impl OsString {
137137
#[stable(feature = "rust1", since = "1.0.0")]
138138
#[must_use]
139139
#[inline]
140-
pub fn new() -> OsString {
140+
#[rustc_const_unstable(feature = "const_pathbuf_osstring_new", issue = "141520")]
141+
pub const fn new() -> OsString {
141142
OsString { inner: Buf::from_string(String::new()) }
142143
}
143144

library/std/src/path.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,8 @@ impl PathBuf {
11911191
#[stable(feature = "rust1", since = "1.0.0")]
11921192
#[must_use]
11931193
#[inline]
1194-
pub fn new() -> PathBuf {
1194+
#[rustc_const_unstable(feature = "const_pathbuf_osstring_new", issue = "141520")]
1195+
pub const fn new() -> PathBuf {
11951196
PathBuf { inner: OsString::new() }
11961197
}
11971198

library/std/src/sys/os_str/bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Buf {
115115
}
116116

117117
#[inline]
118-
pub fn from_string(s: String) -> Buf {
118+
pub const fn from_string(s: String) -> Buf {
119119
Buf { inner: s.into_bytes() }
120120
}
121121

library/std/src/sys/os_str/wtf8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl Buf {
9292
}
9393

9494
#[inline]
95-
pub fn from_string(s: String) -> Buf {
95+
pub const fn from_string(s: String) -> Buf {
9696
Buf { inner: Wtf8Buf::from_string(s) }
9797
}
9898

library/std/src/sys_common/wtf8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl Wtf8Buf {
209209
///
210210
/// Since WTF-8 is a superset of UTF-8, this always succeeds.
211211
#[inline]
212-
pub fn from_string(string: String) -> Wtf8Buf {
212+
pub const fn from_string(string: String) -> Wtf8Buf {
213213
Wtf8Buf { bytes: string.into_bytes(), is_known_utf8: true }
214214
}
215215

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,23 +1878,27 @@ impl Step for Sysroot {
18781878
// so that any tools relying on `rust-src` also work for local builds,
18791879
// and also for translating the virtual `/rustc/$hash` back to the real
18801880
// directory (for running tests with `rust.remap-debuginfo = true`).
1881-
let sysroot_lib_rustlib_src = sysroot.join("lib/rustlib/src");
1882-
t!(fs::create_dir_all(&sysroot_lib_rustlib_src));
1883-
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
1884-
if let Err(e) = symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust) {
1885-
eprintln!(
1886-
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
1887-
sysroot_lib_rustlib_src_rust.display(),
1888-
builder.src.display(),
1889-
e,
1890-
);
1891-
if builder.config.rust_remap_debuginfo {
1881+
if compiler.stage != 0 {
1882+
let sysroot_lib_rustlib_src = sysroot.join("lib/rustlib/src");
1883+
t!(fs::create_dir_all(&sysroot_lib_rustlib_src));
1884+
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
1885+
if let Err(e) =
1886+
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust)
1887+
{
18921888
eprintln!(
1893-
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
1889+
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
18941890
sysroot_lib_rustlib_src_rust.display(),
1891+
builder.src.display(),
1892+
e,
18951893
);
1894+
if builder.config.rust_remap_debuginfo {
1895+
eprintln!(
1896+
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
1897+
sysroot_lib_rustlib_src_rust.display(),
1898+
);
1899+
}
1900+
build_helper::exit!(1);
18961901
}
1897-
build_helper::exit!(1);
18981902
}
18991903

19001904
// rustc-src component is already part of CI rustc's sysroot
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:22.04
2+
3+
COPY scripts/cross-apt-packages.sh /tmp/
4+
RUN bash /tmp/cross-apt-packages.sh
5+
6+
# Required gcc dependencies.
7+
RUN apt-get update && \
8+
apt-get install -y --no-install-recommends \
9+
libgmp-dev \
10+
libmpfr-dev \
11+
libmpc-dev \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
COPY scripts/shared.sh /tmp/
15+
COPY scripts/solaris-toolchain.sh /tmp/
16+
17+
RUN bash /tmp/solaris-toolchain.sh sparcv9 sysroot
18+
RUN bash /tmp/solaris-toolchain.sh sparcv9 binutils
19+
RUN bash /tmp/solaris-toolchain.sh sparcv9 gcc
20+
21+
COPY scripts/sccache.sh /scripts/
22+
RUN sh /scripts/sccache.sh
23+
24+
COPY scripts/cmake.sh /scripts/
25+
RUN /scripts/cmake.sh
26+
27+
ENV \
28+
AR_sparcv9_sun_solaris=sparcv9-solaris-ar \
29+
RANLIB_sparcv9_sun_solaris=sparcv9-solaris-ranlib \
30+
CC_sparcv9_sun_solaris=sparcv9-solaris-gcc \
31+
CXX_sparcv9_sun_solaris=sparcv9-solaris-g++
32+
33+
ENV HOSTS=sparcv9-sun-solaris
34+
35+
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
36+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ ENV \
4343
CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++ \
4444
CXXFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
4545
LDFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -L/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/lib" \
46-
AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-ar \
47-
CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-gcc \
48-
CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
49-
AR_x86_64_pc_solaris=x86_64-pc-solaris2.10-ar \
50-
CC_x86_64_pc_solaris=x86_64-pc-solaris2.10-gcc \
51-
CXX_x86_64_pc_solaris=x86_64-pc-solaris2.10-g++ \
5246
CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-9 \
5347
CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-9 \
5448
AR_x86_64_fortanix_unknown_sgx=ar \
@@ -84,9 +78,6 @@ WORKDIR /tmp
8478
COPY scripts/shared.sh /tmp/
8579
COPY scripts/build-fuchsia-toolchain.sh /tmp/
8680
RUN /tmp/build-fuchsia-toolchain.sh
87-
COPY host-x86_64/dist-various-2/build-solaris-toolchain.sh /tmp/
88-
RUN /tmp/build-solaris-toolchain.sh x86_64 amd64 solaris-i386 pc
89-
RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc sun
9081
COPY host-x86_64/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
9182
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh
9283

@@ -118,8 +109,6 @@ ENV TARGETS=$TARGETS,wasm32-wasip1
118109
ENV TARGETS=$TARGETS,wasm32-wasip1-threads
119110
ENV TARGETS=$TARGETS,wasm32-wasip2
120111
ENV TARGETS=$TARGETS,wasm32v1-none
121-
ENV TARGETS=$TARGETS,sparcv9-sun-solaris
122-
ENV TARGETS=$TARGETS,x86_64-pc-solaris
123112
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
124113
ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx
125114
ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda

0 commit comments

Comments
 (0)