Skip to content

Commit 53305f1

Browse files
committed
Auto merge of #98025 - Dylan-DPC:rollup-cwt2hb7, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #97921 (additional docs example for replace **all** of str) - #97970 (Fix Termination impl panic on closed stderr) - #97991 (Use safer `strip=symbols`-flag for dylibs on macOS) - #97992 (Stabilize scoped threads.) - #98012 (`ValuePairs::PolyTraitRefs` should be called "trait"s in type error diagnostics) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ae2aa18 + 53090fe commit 53305f1

File tree

16 files changed

+61
-50
lines changed

16 files changed

+61
-50
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1003,10 +1003,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
10031003
let strip = strip_value(sess);
10041004

10051005
if sess.target.is_like_osx {
1006-
match strip {
1007-
Strip::Debuginfo => strip_symbols_in_osx(sess, &out_filename, Some("-S")),
1008-
Strip::Symbols => strip_symbols_in_osx(sess, &out_filename, None),
1009-
Strip::None => {}
1006+
match (strip, crate_type) {
1007+
(Strip::Debuginfo, _) => strip_symbols_in_osx(sess, &out_filename, Some("-S")),
1008+
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
1009+
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
1010+
strip_symbols_in_osx(sess, &out_filename, Some("-x"))
1011+
}
1012+
(Strip::Symbols, _) => strip_symbols_in_osx(sess, &out_filename, None),
1013+
(Strip::None, _) => {}
10101014
}
10111015
}
10121016
}

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15881588
Mismatch::Variable(infer::ExpectedFound { expected, found }),
15891589
)
15901590
}
1591-
ValuePairs::TraitRefs(_) => (false, Mismatch::Fixed("trait")),
1591+
ValuePairs::TraitRefs(_) | ValuePairs::PolyTraitRefs(_) => {
1592+
(false, Mismatch::Fixed("trait"))
1593+
}
15921594
_ => (false, Mismatch::Fixed("type")),
15931595
};
15941596
let vals = match self.values_str(values) {

library/alloc/src/str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ impl str {
271271
/// let s = "this is old";
272272
///
273273
/// assert_eq!("this is new", s.replace("old", "new"));
274+
/// assert_eq!("than an old", s.replace("is", "an"));
274275
/// ```
275276
///
276277
/// When the pattern doesn't match:

library/core/src/sync/atomic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl AtomicBool {
350350
/// # Examples
351351
///
352352
/// ```
353-
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
353+
/// #![feature(atomic_from_mut, inline_const)]
354354
/// use std::sync::atomic::{AtomicBool, Ordering};
355355
///
356356
/// let mut some_bools = [const { AtomicBool::new(false) }; 10];
@@ -381,7 +381,7 @@ impl AtomicBool {
381381
/// # Examples
382382
///
383383
/// ```
384-
/// #![feature(atomic_from_mut, scoped_threads)]
384+
/// #![feature(atomic_from_mut)]
385385
/// use std::sync::atomic::{AtomicBool, Ordering};
386386
///
387387
/// let mut some_bools = [false; 10];
@@ -1015,7 +1015,7 @@ impl<T> AtomicPtr<T> {
10151015
/// # Examples
10161016
///
10171017
/// ```
1018-
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
1018+
/// #![feature(atomic_from_mut, inline_const)]
10191019
/// use std::ptr::null_mut;
10201020
/// use std::sync::atomic::{AtomicPtr, Ordering};
10211021
///
@@ -1052,7 +1052,7 @@ impl<T> AtomicPtr<T> {
10521052
/// # Examples
10531053
///
10541054
/// ```
1055-
/// #![feature(atomic_from_mut, scoped_threads)]
1055+
/// #![feature(atomic_from_mut)]
10561056
/// use std::ptr::null_mut;
10571057
/// use std::sync::atomic::{AtomicPtr, Ordering};
10581058
///
@@ -1607,7 +1607,7 @@ macro_rules! atomic_int {
16071607
/// # Examples
16081608
///
16091609
/// ```
1610-
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
1610+
/// #![feature(atomic_from_mut, inline_const)]
16111611
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
16121612
///
16131613
#[doc = concat!("let mut some_ints = [const { ", stringify!($atomic_type), "::new(0) }; 10];")]
@@ -1640,7 +1640,7 @@ macro_rules! atomic_int {
16401640
/// # Examples
16411641
///
16421642
/// ```
1643-
/// #![feature(atomic_from_mut, scoped_threads)]
1643+
/// #![feature(atomic_from_mut)]
16441644
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
16451645
///
16461646
/// let mut some_ints = [0; 10];

library/std/src/process.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,9 @@ impl Termination for ! {
21612161
impl<E: fmt::Debug> Termination for Result<!, E> {
21622162
fn report(self) -> ExitCode {
21632163
let Err(err) = self;
2164-
eprintln!("Error: {err:?}");
2164+
// Ignore error if the write fails, for example because stderr is
2165+
// already closed. There is not much point panicking at this point.
2166+
let _ = writeln!(io::stderr(), "Error: {err:?}");
21652167
ExitCode::FAILURE
21662168
}
21672169
}

library/std/src/thread/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ use crate::time::Duration;
183183
#[macro_use]
184184
mod local;
185185

186-
#[unstable(feature = "scoped_threads", issue = "93203")]
186+
#[stable(feature = "scoped_threads", since = "1.63.0")]
187187
mod scoped;
188188

189-
#[unstable(feature = "scoped_threads", issue = "93203")]
189+
#[stable(feature = "scoped_threads", since = "1.63.0")]
190190
pub use scoped::{scope, Scope, ScopedJoinHandle};
191191

192192
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/thread/scoped.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::sync::Arc;
99
/// A scope to spawn scoped threads in.
1010
///
1111
/// See [`scope`] for details.
12+
#[stable(feature = "scoped_threads", since = "1.63.0")]
1213
pub struct Scope<'scope, 'env: 'scope> {
1314
data: ScopeData,
1415
/// Invariance over 'scope, to make sure 'scope cannot shrink,
@@ -17,8 +18,6 @@ pub struct Scope<'scope, 'env: 'scope> {
1718
/// Without invariance, this would compile fine but be unsound:
1819
///
1920
/// ```compile_fail,E0373
20-
/// #![feature(scoped_threads)]
21-
///
2221
/// std::thread::scope(|s| {
2322
/// s.spawn(|| {
2423
/// let a = String::from("abcd");
@@ -33,6 +32,7 @@ pub struct Scope<'scope, 'env: 'scope> {
3332
/// An owned permission to join on a scoped thread (block on its termination).
3433
///
3534
/// See [`Scope::spawn`] for details.
35+
#[stable(feature = "scoped_threads", since = "1.63.0")]
3636
pub struct ScopedJoinHandle<'scope, T>(JoinInner<'scope, T>);
3737

3838
pub(super) struct ScopeData {
@@ -82,7 +82,6 @@ impl ScopeData {
8282
/// # Example
8383
///
8484
/// ```
85-
/// #![feature(scoped_threads)]
8685
/// use std::thread;
8786
///
8887
/// let mut a = vec![1, 2, 3];
@@ -126,6 +125,7 @@ impl ScopeData {
126125
///
127126
/// The `'env: 'scope` bound is part of the definition of the `Scope` type.
128127
#[track_caller]
128+
#[stable(feature = "scoped_threads", since = "1.63.0")]
129129
pub fn scope<'env, F, T>(f: F) -> T
130130
where
131131
F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T,
@@ -183,6 +183,7 @@ impl<'scope, 'env> Scope<'scope, 'env> {
183183
/// to recover from such errors.
184184
///
185185
/// [`join`]: ScopedJoinHandle::join
186+
#[stable(feature = "scoped_threads", since = "1.63.0")]
186187
pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>
187188
where
188189
F: FnOnce() -> T + Send + 'scope,
@@ -207,7 +208,6 @@ impl Builder {
207208
/// # Example
208209
///
209210
/// ```
210-
/// #![feature(scoped_threads)]
211211
/// use std::thread;
212212
///
213213
/// let mut a = vec![1, 2, 3];
@@ -240,6 +240,7 @@ impl Builder {
240240
/// a.push(4);
241241
/// assert_eq!(x, a.len());
242242
/// ```
243+
#[stable(feature = "scoped_threads", since = "1.63.0")]
243244
pub fn spawn_scoped<'scope, 'env, F, T>(
244245
self,
245246
scope: &'scope Scope<'scope, 'env>,
@@ -259,8 +260,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
259260
/// # Examples
260261
///
261262
/// ```
262-
/// #![feature(scoped_threads)]
263-
///
264263
/// use std::thread;
265264
///
266265
/// thread::scope(|s| {
@@ -271,6 +270,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
271270
/// });
272271
/// ```
273272
#[must_use]
273+
#[stable(feature = "scoped_threads", since = "1.63.0")]
274274
pub fn thread(&self) -> &Thread {
275275
&self.0.thread
276276
}
@@ -292,8 +292,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
292292
/// # Examples
293293
///
294294
/// ```
295-
/// #![feature(scoped_threads)]
296-
///
297295
/// use std::thread;
298296
///
299297
/// thread::scope(|s| {
@@ -303,6 +301,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
303301
/// assert!(t.join().is_err());
304302
/// });
305303
/// ```
304+
#[stable(feature = "scoped_threads", since = "1.63.0")]
306305
pub fn join(self) -> Result<T> {
307306
self.0.join()
308307
}
@@ -316,11 +315,13 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
316315
///
317316
/// This function does not block. To block while waiting on the thread to finish,
318317
/// use [`join`][Self::join].
318+
#[stable(feature = "scoped_threads", since = "1.63.0")]
319319
pub fn is_finished(&self) -> bool {
320320
Arc::strong_count(&self.0.packet) == 1
321321
}
322322
}
323323

324+
#[stable(feature = "scoped_threads", since = "1.63.0")]
324325
impl fmt::Debug for Scope<'_, '_> {
325326
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
326327
f.debug_struct("Scope")
@@ -331,6 +332,7 @@ impl fmt::Debug for Scope<'_, '_> {
331332
}
332333
}
333334

335+
#[stable(feature = "scoped_threads", since = "1.63.0")]
334336
impl<'scope, T> fmt::Debug for ScopedJoinHandle<'scope, T> {
335337
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
336338
f.debug_struct("ScopedJoinHandle").finish_non_exhaustive()

src/test/ui/generator/resume-arg-late-bound.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | test(gen);
55
| ^^^^^^^^^ one type is more general than the other
66
|
7-
= note: expected type `for<'a> Generator<&'a mut bool>`
8-
found type `Generator<&mut bool>`
7+
= note: expected trait `for<'a> Generator<&'a mut bool>`
8+
found trait `Generator<&mut bool>`
99
note: the lifetime requirement is introduced here
1010
--> $DIR/resume-arg-late-bound.rs:8:17
1111
|

src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | foo(bar, "string", |s| s.len() == 5);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
66
|
7-
= note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>`
8-
found type `for<'r> FnOnce<(&'r &str,)>`
7+
= note: expected trait `for<'r, 's> FnOnce<(&'r &'s str,)>`
8+
found trait `for<'r> FnOnce<(&'r &str,)>`
99
note: this closure does not fulfill the lifetime requirements
1010
--> $DIR/issue-71955.rs:45:24
1111
|
@@ -23,8 +23,8 @@ error[E0308]: mismatched types
2323
LL | foo(bar, "string", |s| s.len() == 5);
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
2525
|
26-
= note: expected type `FnOnce<(&&str,)>`
27-
found type `for<'r> FnOnce<(&'r &str,)>`
26+
= note: expected trait `FnOnce<(&&str,)>`
27+
found trait `for<'r> FnOnce<(&'r &str,)>`
2828
note: this closure does not fulfill the lifetime requirements
2929
--> $DIR/issue-71955.rs:45:24
3030
|
@@ -42,8 +42,8 @@ error[E0308]: mismatched types
4242
LL | foo(baz, "string", |s| s.0.len() == 5);
4343
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
4444
|
45-
= note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>`
46-
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
45+
= note: expected trait `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>`
46+
found trait `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
4747
note: this closure does not fulfill the lifetime requirements
4848
--> $DIR/issue-71955.rs:48:24
4949
|
@@ -61,8 +61,8 @@ error[E0308]: mismatched types
6161
LL | foo(baz, "string", |s| s.0.len() == 5);
6262
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
6363
|
64-
= note: expected type `FnOnce<(&Wrapper<'_>,)>`
65-
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
64+
= note: expected trait `FnOnce<(&Wrapper<'_>,)>`
65+
found trait `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
6666
note: this closure does not fulfill the lifetime requirements
6767
--> $DIR/issue-71955.rs:48:24
6868
|

src/test/ui/issues/issue-27942.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | fn select(&self) -> BufferViewHandle<R>;
55
| ^^^^^^^^^^^^^^^^^^^ lifetime mismatch
66
|
7-
= note: expected type `Resources<'_>`
8-
found type `Resources<'a>`
7+
= note: expected trait `Resources<'_>`
8+
found trait `Resources<'a>`
99
note: the anonymous lifetime defined here...
1010
--> $DIR/issue-27942.rs:5:15
1111
|
@@ -23,8 +23,8 @@ error[E0308]: mismatched types
2323
LL | fn select(&self) -> BufferViewHandle<R>;
2424
| ^^^^^^^^^^^^^^^^^^^ lifetime mismatch
2525
|
26-
= note: expected type `Resources<'_>`
27-
found type `Resources<'a>`
26+
= note: expected trait `Resources<'_>`
27+
found trait `Resources<'a>`
2828
note: the lifetime `'a` as defined here...
2929
--> $DIR/issue-27942.rs:3:18
3030
|

src/test/ui/lifetimes/issue-79187-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ error[E0308]: mismatched types
3131
LL | take_foo(|a| a);
3232
| ^^^^^^^^^^^^^^^ one type is more general than the other
3333
|
34-
= note: expected type `for<'r> Fn<(&'r i32,)>`
35-
found type `Fn<(&i32,)>`
34+
= note: expected trait `for<'r> Fn<(&'r i32,)>`
35+
found trait `Fn<(&i32,)>`
3636
note: this closure does not fulfill the lifetime requirements
3737
--> $DIR/issue-79187-2.rs:8:14
3838
|

src/test/ui/lifetimes/issue-79187.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | thing(f);
55
| ^^^^^^^^ one type is more general than the other
66
|
7-
= note: expected type `for<'r> FnOnce<(&'r u32,)>`
8-
found type `FnOnce<(&u32,)>`
7+
= note: expected trait `for<'r> FnOnce<(&'r u32,)>`
8+
found trait `FnOnce<(&u32,)>`
99
note: this closure does not fulfill the lifetime requirements
1010
--> $DIR/issue-79187.rs:4:13
1111
|

src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ error[E0308]: mismatched types
1515
LL | f(data, identity)
1616
| ^^^^^^^^^^^^^^^^^ one type is more general than the other
1717
|
18-
= note: expected type `for<'r> Fn<(&'r T,)>`
19-
found type `Fn<(&T,)>`
18+
= note: expected trait `for<'r> Fn<(&'r T,)>`
19+
found trait `Fn<(&T,)>`
2020
note: the lifetime requirement is introduced here
2121
--> $DIR/issue_74400.rs:8:34
2222
|

src/test/ui/mismatched_types/closure-mismatch.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ error[E0308]: mismatched types
1313
LL | baz(|_| ());
1414
| ^^^^^^^^^^^ one type is more general than the other
1515
|
16-
= note: expected type `for<'r> Fn<(&'r (),)>`
17-
found type `Fn<(&(),)>`
16+
= note: expected trait `for<'r> Fn<(&'r (),)>`
17+
found trait `Fn<(&(),)>`
1818
note: this closure does not fulfill the lifetime requirements
1919
--> $DIR/closure-mismatch.rs:8:9
2020
|

src/test/ui/rfc1623.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ error[E0308]: mismatched types
44
LL | f: &id,
55
| ^^^ one type is more general than the other
66
|
7-
= note: expected type `for<'a, 'b> Fn<(&'a Foo<'b>,)>`
8-
found type `Fn<(&Foo<'_>,)>`
7+
= note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>`
8+
found trait `Fn<(&Foo<'_>,)>`
99

1010
error[E0308]: mismatched types
1111
--> $DIR/rfc1623.rs:28:8
1212
|
1313
LL | f: &id,
1414
| ^^^ one type is more general than the other
1515
|
16-
= note: expected type `for<'a, 'b> Fn<(&'a Foo<'b>,)>`
17-
found type `Fn<(&Foo<'_>,)>`
16+
= note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>`
17+
found trait `Fn<(&Foo<'_>,)>`
1818

1919
error: implementation of `FnOnce` is not general enough
2020
--> $DIR/rfc1623.rs:28:8

src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | |x| x
55
| ^^^^^ one type is more general than the other
66
|
7-
= note: expected type `for<'r> Fn<(&'r X,)>`
8-
found type `Fn<(&X,)>`
7+
= note: expected trait `for<'r> Fn<(&'r X,)>`
8+
found trait `Fn<(&X,)>`
99
note: this closure does not fulfill the lifetime requirements
1010
--> $DIR/issue-57611-trait-alias.rs:21:9
1111
|

0 commit comments

Comments
 (0)