Skip to content

Commit 61413ae

Browse files
committed
Auto merge of rust-lang#142003 - matthiaskrgr:rollup-ad8l9ns, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#136687 (Improve the documentation of `Display` and `FromStr`, and their interactions) - rust-lang#137306 (Remove `i128` and `u128` from `improper_ctypes_definitions`) - rust-lang#138699 (build dist for x86_64-pc-solaris and sparcv9-sun-solaris) - rust-lang#141250 (add s390x z17 target features) - rust-lang#141467 (make `OsString::new` and `PathBuf::new` unstably const) - rust-lang#141871 (index: add method for checking range on DenseBitSet) - rust-lang#141888 (Use non-2015 edition paths in tests that do not test for their resolution) - rust-lang#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

0 commit comments

Comments
 (0)