Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 9033d60

Browse files
committed
Auto merge of rust-lang#140562 - GuillaumeGomez:rollup-j5rbgt3, r=GuillaumeGomez
Rollup of 12 pull requests Successful merges: - rust-lang#138703 (chore: remove redundant words in comment) - rust-lang#139186 (Refactor `diy_float`) - rust-lang#139343 (Change signature of File::try_lock and File::try_lock_shared) - rust-lang#139780 (docs: Add example to `Iterator::take` with `by_ref`) - rust-lang#139802 (Fix some grammar errors and hyperlinks in doc for `trait Allocator`) - rust-lang#140034 (simd_select_bitmask: the 'padding' bits in the mask are just ignored) - rust-lang#140062 (std: mention `remove_dir_all` can emit `DirectoryNotEmpty` when concurrently written into) - rust-lang#140420 (rustdoc: Fix doctest heuristic for main fn wrapping) - rust-lang#140460 (Fix handling of LoongArch target features not supported by LLVM 19) - rust-lang#140538 (rustc-dev-guide subtree update) - rust-lang#140552 (allow `#[rustc_std_internal_symbol]` in combination with `#[naked]`) - rust-lang#140556 (Improve error output in case `nodejs` or `npm` is not installed for rustdoc-gui test suite) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3350c1e + 633788e commit 9033d60

Some content is hidden

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

53 files changed

+817
-422
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
273273
("aarch64", "fpmr") => None, // only existed in 18
274274
("arm", "fp16") => Some(LLVMFeature::new("fullfp16")),
275275
// Filter out features that are not supported by the current LLVM version
276+
("loongarch64", "div32" | "lam-bh" | "lamcas" | "ld-seq-sa" | "scq")
277+
if get_version().0 < 20 =>
278+
{
279+
None
280+
}
281+
// Filter out features that are not supported by the current LLVM version
276282
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
277283
// Enable the evex512 target feature if an avx512 target feature is enabled.
278284
("x86", s) if s.starts_with("avx512") => {

compiler/rustc_error_codes/src/error_codes/E0207.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'a> Contains for Foo {
195195
Please note that unconstrained lifetime parameters are not supported if they are
196196
being used by an associated type.
197197

198-
In cases where the associated type's lifetime is meant to be tied to the the
198+
In cases where the associated type's lifetime is meant to be tied to the
199199
self type, and none of the methods on the trait need ownership or different
200200
mutability, then an option is to implement the trait on a borrowed type:
201201

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
625625
sym::naked,
626626
sym::instruction_set,
627627
sym::repr,
628+
sym::rustc_std_internal_symbol,
628629
// code generation
629630
sym::cold,
630631
// documentation

compiler/rustc_target/src/target_features.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ impl Stability {
102102
// check whether they're named already elsewhere in rust
103103
// e.g. in stdarch and whether the given name matches LLVM's
104104
// if it doesn't, to_llvm_feature in llvm_util in rustc_codegen_llvm needs to be adapted.
105+
// Additionally, if the feature is not available in older version of LLVM supported by the current
106+
// rust, the same function must be updated to filter out these features to avoid triggering
107+
// warnings.
105108
//
106109
// Also note that all target features listed here must be purely additive: for target_feature 1.1 to
107110
// be sound, we can never allow features like `+soft-float` (on x86) to be controlled on a

library/core/src/alloc/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl fmt::Display for AllocError {
9090
/// # Safety
9191
///
9292
/// Memory blocks that are [*currently allocated*] by an allocator,
93-
/// must point to valid memory, and retain their validity while until either:
93+
/// must point to valid memory, and retain their validity until either:
9494
/// - the memory block is deallocated, or
9595
/// - the allocator is dropped.
9696
///
@@ -112,7 +112,9 @@ pub unsafe trait Allocator {
112112
///
113113
/// The returned block of memory remains valid as long as it is [*currently allocated*] and the shorter of:
114114
/// - the borrow-checker lifetime of the allocator type itself.
115-
/// - as long as at the allocator and all its clones has not been dropped.
115+
/// - as long as the allocator and all its clones have not been dropped.
116+
///
117+
/// [*currently allocated*]: #currently-allocated-memory
116118
///
117119
/// # Errors
118120
///

library/core/src/intrinsics/simd.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,9 @@ pub unsafe fn simd_select<M, T>(mask: M, if_true: T, if_false: T) -> T;
577577
/// For each element, if the bit in `mask` is `1`, select the element from
578578
/// `if_true`. If the corresponding bit in `mask` is `0`, select the element from
579579
/// `if_false`.
580+
/// The remaining bits of the mask are ignored.
580581
///
581582
/// The bitmask bit order matches `simd_bitmask`.
582-
///
583-
/// # Safety
584-
/// Padding bits must be all zero.
585583
#[rustc_intrinsic]
586584
#[rustc_nounwind]
587585
pub unsafe fn simd_select_bitmask<M, T>(m: M, yes: T, no: T) -> T;

library/core/src/iter/traits/iterator.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,24 @@ pub trait Iterator {
13401340
/// assert_eq!(iter.next(), Some(2));
13411341
/// assert_eq!(iter.next(), None);
13421342
/// ```
1343+
///
1344+
/// Use [`by_ref`] to take from the iterator without consuming it, and then
1345+
/// continue using the original iterator:
1346+
///
1347+
/// ```
1348+
/// let mut words = ["hello", "world", "of", "Rust"].into_iter();
1349+
///
1350+
/// // Take the first two words.
1351+
/// let hello_world: Vec<_> = words.by_ref().take(2).collect();
1352+
/// assert_eq!(hello_world, vec!["hello", "world"]);
1353+
///
1354+
/// // Collect the rest of the words.
1355+
/// // We can only do this because we used `by_ref` earlier.
1356+
/// let of_rust: Vec<_> = words.collect();
1357+
/// assert_eq!(of_rust, vec!["of", "Rust"]);
1358+
/// ```
1359+
///
1360+
/// [`by_ref`]: Iterator::by_ref
13431361
#[inline]
13441362
#[stable(feature = "rust1", since = "1.0.0")]
13451363
fn take(self, n: usize) -> Take<Self>

library/core/src/macros/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,8 +1748,8 @@ pub(crate) mod builtin {
17481748
/* compiler built-in */
17491749
}
17501750

1751-
/// Provide a list of type aliases and other opaque-type-containing type definitions.
1752-
/// This list will be used in the body of the item it is applied to define opaque
1751+
/// Provide a list of type aliases and other opaque-type-containing type definitions
1752+
/// to an item with a body. This list will be used in that body to define opaque
17531753
/// types' hidden types.
17541754
/// Can only be applied to things that have bodies.
17551755
#[unstable(

library/core/src/num/diy_float.rs

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,61 +21,29 @@ pub struct Fp {
2121

2222
impl Fp {
2323
/// Returns a correctly rounded product of itself and `other`.
24-
pub fn mul(&self, other: &Fp) -> Fp {
25-
const MASK: u64 = 0xffffffff;
26-
let a = self.f >> 32;
27-
let b = self.f & MASK;
28-
let c = other.f >> 32;
29-
let d = other.f & MASK;
30-
let ac = a * c;
31-
let bc = b * c;
32-
let ad = a * d;
33-
let bd = b * d;
34-
let tmp = (bd >> 32) + (ad & MASK) + (bc & MASK) + (1 << 31) /* round */;
35-
let f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
24+
pub fn mul(self, other: Self) -> Self {
25+
let (lo, hi) = self.f.widening_mul(other.f);
26+
let f = hi + (lo >> 63) /* round */;
3627
let e = self.e + other.e + 64;
37-
Fp { f, e }
28+
Self { f, e }
3829
}
3930

4031
/// Normalizes itself so that the resulting mantissa is at least `2^63`.
41-
pub fn normalize(&self) -> Fp {
42-
let mut f = self.f;
43-
let mut e = self.e;
44-
if f >> (64 - 32) == 0 {
45-
f <<= 32;
46-
e -= 32;
47-
}
48-
if f >> (64 - 16) == 0 {
49-
f <<= 16;
50-
e -= 16;
51-
}
52-
if f >> (64 - 8) == 0 {
53-
f <<= 8;
54-
e -= 8;
55-
}
56-
if f >> (64 - 4) == 0 {
57-
f <<= 4;
58-
e -= 4;
59-
}
60-
if f >> (64 - 2) == 0 {
61-
f <<= 2;
62-
e -= 2;
63-
}
64-
if f >> (64 - 1) == 0 {
65-
f <<= 1;
66-
e -= 1;
67-
}
32+
pub fn normalize(self) -> Self {
33+
let lz = self.f.leading_zeros();
34+
let f = self.f << lz;
35+
let e = self.e - lz as i16;
6836
debug_assert!(f >= (1 << 63));
69-
Fp { f, e }
37+
Self { f, e }
7038
}
7139

7240
/// Normalizes itself to have the shared exponent.
7341
/// It can only decrease the exponent (and thus increase the mantissa).
74-
pub fn normalize_to(&self, e: i16) -> Fp {
42+
pub fn normalize_to(self, e: i16) -> Self {
7543
let edelta = self.e - e;
7644
assert!(edelta >= 0);
7745
let edelta = edelta as usize;
7846
assert_eq!(self.f << edelta >> edelta, self.f);
79-
Fp { f: self.f << edelta, e }
47+
Self { f: self.f << edelta, e }
8048
}
8149
}

library/core/src/num/flt2dec/strategy/grisu.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ pub fn format_shortest_opt<'a>(
196196
let (minusk, cached) = cached_power(ALPHA - plus.e - 64, GAMMA - plus.e - 64);
197197

198198
// scale fps. this gives the maximal error of 1 ulp (proved from Theorem 5.1).
199-
let plus = plus.mul(&cached);
200-
let minus = minus.mul(&cached);
201-
let v = v.mul(&cached);
199+
let plus = plus.mul(cached);
200+
let minus = minus.mul(cached);
201+
let v = v.mul(cached);
202202
debug_assert_eq!(plus.e, minus.e);
203203
debug_assert_eq!(plus.e, v.e);
204204

@@ -480,7 +480,7 @@ pub fn format_exact_opt<'a>(
480480
// normalize and scale `v`.
481481
let v = Fp { f: d.mant, e: d.exp }.normalize();
482482
let (minusk, cached) = cached_power(ALPHA - v.e - 64, GAMMA - v.e - 64);
483-
let v = v.mul(&cached);
483+
let v = v.mul(cached);
484484

485485
// divide `v` into integral and fractional parts.
486486
let e = -v.e as usize;

0 commit comments

Comments
 (0)