Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #98025

Merged
merged 10 commits into from
Jun 12, 2022
12 changes: 8 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
let strip = strip_value(sess);

if sess.target.is_like_osx {
match strip {
Strip::Debuginfo => strip_symbols_in_osx(sess, &out_filename, Some("-S")),
Strip::Symbols => strip_symbols_in_osx(sess, &out_filename, None),
Strip::None => {}
match (strip, crate_type) {
(Strip::Debuginfo, _) => strip_symbols_in_osx(sess, &out_filename, Some("-S")),
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
strip_symbols_in_osx(sess, &out_filename, Some("-x"))
}
(Strip::Symbols, _) => strip_symbols_in_osx(sess, &out_filename, None),
(Strip::None, _) => {}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
Mismatch::Variable(infer::ExpectedFound { expected, found }),
)
}
ValuePairs::TraitRefs(_) => (false, Mismatch::Fixed("trait")),
ValuePairs::TraitRefs(_) | ValuePairs::PolyTraitRefs(_) => {
(false, Mismatch::Fixed("trait"))
}
_ => (false, Mismatch::Fixed("type")),
};
let vals = match self.values_str(values) {
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ impl str {
/// let s = "this is old";
///
/// assert_eq!("this is new", s.replace("old", "new"));
/// assert_eq!("than an old", s.replace("is", "an"));
/// ```
///
/// When the pattern doesn't match:
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl AtomicBool {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
/// #![feature(atomic_from_mut, inline_const)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bools = [const { AtomicBool::new(false) }; 10];
Expand Down Expand Up @@ -381,7 +381,7 @@ impl AtomicBool {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, scoped_threads)]
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bools = [false; 10];
Expand Down Expand Up @@ -1015,7 +1015,7 @@ impl<T> AtomicPtr<T> {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
/// #![feature(atomic_from_mut, inline_const)]
/// use std::ptr::null_mut;
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
Expand Down Expand Up @@ -1052,7 +1052,7 @@ impl<T> AtomicPtr<T> {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, scoped_threads)]
/// #![feature(atomic_from_mut)]
/// use std::ptr::null_mut;
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
Expand Down Expand Up @@ -1607,7 +1607,7 @@ macro_rules! atomic_int {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, inline_const, scoped_threads)]
/// #![feature(atomic_from_mut, inline_const)]
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
///
#[doc = concat!("let mut some_ints = [const { ", stringify!($atomic_type), "::new(0) }; 10];")]
Expand Down Expand Up @@ -1640,7 +1640,7 @@ macro_rules! atomic_int {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut, scoped_threads)]
/// #![feature(atomic_from_mut)]
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
///
/// let mut some_ints = [0; 10];
Expand Down
4 changes: 3 additions & 1 deletion library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,9 @@ impl Termination for ! {
impl<E: fmt::Debug> Termination for Result<!, E> {
fn report(self) -> ExitCode {
let Err(err) = self;
eprintln!("Error: {err:?}");
// Ignore error if the write fails, for example because stderr is
// already closed. There is not much point panicking at this point.
let _ = writeln!(io::stderr(), "Error: {err:?}");
ExitCode::FAILURE
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ use crate::time::Duration;
#[macro_use]
mod local;

#[unstable(feature = "scoped_threads", issue = "93203")]
#[stable(feature = "scoped_threads", since = "1.63.0")]
mod scoped;

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

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
18 changes: 10 additions & 8 deletions library/std/src/thread/scoped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::sync::Arc;
/// A scope to spawn scoped threads in.
///
/// See [`scope`] for details.
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub struct Scope<'scope, 'env: 'scope> {
data: ScopeData,
/// Invariance over 'scope, to make sure 'scope cannot shrink,
Expand All @@ -17,8 +18,6 @@ pub struct Scope<'scope, 'env: 'scope> {
/// Without invariance, this would compile fine but be unsound:
///
/// ```compile_fail,E0373
/// #![feature(scoped_threads)]
///
/// std::thread::scope(|s| {
/// s.spawn(|| {
/// let a = String::from("abcd");
Expand All @@ -33,6 +32,7 @@ pub struct Scope<'scope, 'env: 'scope> {
/// An owned permission to join on a scoped thread (block on its termination).
///
/// See [`Scope::spawn`] for details.
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub struct ScopedJoinHandle<'scope, T>(JoinInner<'scope, T>);

pub(super) struct ScopeData {
Expand Down Expand Up @@ -82,7 +82,6 @@ impl ScopeData {
/// # Example
///
/// ```
/// #![feature(scoped_threads)]
/// use std::thread;
///
/// let mut a = vec![1, 2, 3];
Expand Down Expand Up @@ -126,6 +125,7 @@ impl ScopeData {
///
/// The `'env: 'scope` bound is part of the definition of the `Scope` type.
#[track_caller]
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub fn scope<'env, F, T>(f: F) -> T
where
F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T,
Expand Down Expand Up @@ -183,6 +183,7 @@ impl<'scope, 'env> Scope<'scope, 'env> {
/// to recover from such errors.
///
/// [`join`]: ScopedJoinHandle::join
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>
where
F: FnOnce() -> T + Send + 'scope,
Expand All @@ -207,7 +208,6 @@ impl Builder {
/// # Example
///
/// ```
/// #![feature(scoped_threads)]
/// use std::thread;
///
/// let mut a = vec![1, 2, 3];
Expand Down Expand Up @@ -240,6 +240,7 @@ impl Builder {
/// a.push(4);
/// assert_eq!(x, a.len());
/// ```
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub fn spawn_scoped<'scope, 'env, F, T>(
self,
scope: &'scope Scope<'scope, 'env>,
Expand All @@ -259,8 +260,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
/// # Examples
///
/// ```
/// #![feature(scoped_threads)]
///
/// use std::thread;
///
/// thread::scope(|s| {
Expand All @@ -271,6 +270,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
/// });
/// ```
#[must_use]
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub fn thread(&self) -> &Thread {
&self.0.thread
}
Expand All @@ -292,8 +292,6 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
/// # Examples
///
/// ```
/// #![feature(scoped_threads)]
///
/// use std::thread;
///
/// thread::scope(|s| {
Expand All @@ -303,6 +301,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
/// assert!(t.join().is_err());
/// });
/// ```
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub fn join(self) -> Result<T> {
self.0.join()
}
Expand All @@ -316,11 +315,13 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
///
/// This function does not block. To block while waiting on the thread to finish,
/// use [`join`][Self::join].
#[stable(feature = "scoped_threads", since = "1.63.0")]
pub fn is_finished(&self) -> bool {
Arc::strong_count(&self.0.packet) == 1
}
}

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

#[stable(feature = "scoped_threads", since = "1.63.0")]
impl<'scope, T> fmt::Debug for ScopedJoinHandle<'scope, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ScopedJoinHandle").finish_non_exhaustive()
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generator/resume-arg-late-bound.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0308]: mismatched types
LL | test(gen);
| ^^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'a> Generator<&'a mut bool>`
found type `Generator<&mut bool>`
= note: expected trait `for<'a> Generator<&'a mut bool>`
found trait `Generator<&mut bool>`
note: the lifetime requirement is introduced here
--> $DIR/resume-arg-late-bound.rs:8:17
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0308]: mismatched types
LL | foo(bar, "string", |s| s.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>`
found type `for<'r> FnOnce<(&'r &str,)>`
= note: expected trait `for<'r, 's> FnOnce<(&'r &'s str,)>`
found trait `for<'r> FnOnce<(&'r &str,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:45:24
|
Expand All @@ -23,8 +23,8 @@ error[E0308]: mismatched types
LL | foo(bar, "string", |s| s.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `FnOnce<(&&str,)>`
found type `for<'r> FnOnce<(&'r &str,)>`
= note: expected trait `FnOnce<(&&str,)>`
found trait `for<'r> FnOnce<(&'r &str,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:45:24
|
Expand All @@ -42,8 +42,8 @@ error[E0308]: mismatched types
LL | foo(baz, "string", |s| s.0.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>`
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
= note: expected trait `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>`
found trait `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:48:24
|
Expand All @@ -61,8 +61,8 @@ error[E0308]: mismatched types
LL | foo(baz, "string", |s| s.0.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `FnOnce<(&Wrapper<'_>,)>`
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
= note: expected trait `FnOnce<(&Wrapper<'_>,)>`
found trait `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:48:24
|
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/issues/issue-27942.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0308]: mismatched types
LL | fn select(&self) -> BufferViewHandle<R>;
| ^^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected type `Resources<'_>`
found type `Resources<'a>`
= note: expected trait `Resources<'_>`
found trait `Resources<'a>`
note: the anonymous lifetime defined here...
--> $DIR/issue-27942.rs:5:15
|
Expand All @@ -23,8 +23,8 @@ error[E0308]: mismatched types
LL | fn select(&self) -> BufferViewHandle<R>;
| ^^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected type `Resources<'_>`
found type `Resources<'a>`
= note: expected trait `Resources<'_>`
found trait `Resources<'a>`
note: the lifetime `'a` as defined here...
--> $DIR/issue-27942.rs:3:18
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/lifetimes/issue-79187-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ error[E0308]: mismatched types
LL | take_foo(|a| a);
| ^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'r> Fn<(&'r i32,)>`
found type `Fn<(&i32,)>`
= note: expected trait `for<'r> Fn<(&'r i32,)>`
found trait `Fn<(&i32,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-79187-2.rs:8:14
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/lifetimes/issue-79187.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0308]: mismatched types
LL | thing(f);
| ^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'r> FnOnce<(&'r u32,)>`
found type `FnOnce<(&u32,)>`
= note: expected trait `for<'r> FnOnce<(&'r u32,)>`
found trait `FnOnce<(&u32,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-79187.rs:4:13
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ error[E0308]: mismatched types
LL | f(data, identity)
| ^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'r> Fn<(&'r T,)>`
found type `Fn<(&T,)>`
= note: expected trait `for<'r> Fn<(&'r T,)>`
found trait `Fn<(&T,)>`
note: the lifetime requirement is introduced here
--> $DIR/issue_74400.rs:8:34
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/mismatched_types/closure-mismatch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ error[E0308]: mismatched types
LL | baz(|_| ());
| ^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'r> Fn<(&'r (),)>`
found type `Fn<(&(),)>`
= note: expected trait `for<'r> Fn<(&'r (),)>`
found trait `Fn<(&(),)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/closure-mismatch.rs:8:9
|
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/rfc1623.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ error[E0308]: mismatched types
LL | f: &id,
| ^^^ one type is more general than the other
|
= note: expected type `for<'a, 'b> Fn<(&'a Foo<'b>,)>`
found type `Fn<(&Foo<'_>,)>`
= note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>`
found trait `Fn<(&Foo<'_>,)>`

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

error: implementation of `FnOnce` is not general enough
--> $DIR/rfc1623.rs:28:8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0308]: mismatched types
LL | |x| x
| ^^^^^ one type is more general than the other
|
= note: expected type `for<'r> Fn<(&'r X,)>`
found type `Fn<(&X,)>`
= note: expected trait `for<'r> Fn<(&'r X,)>`
found trait `Fn<(&X,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-57611-trait-alias.rs:21:9
|
Expand Down