Auto merge of #87808 - JohnTitor:rollup-qqp79xs, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #87561 (thread set_name haiku implementation.)
 - #87715 (Add long error explanation for E0625)
 - #87727 (explicit_generic_args_with_impl_trait: fix min expected number of generics)
 - #87742 (Validate FFI-safety warnings on naked functions)
 - #87756 (Add back -Zno-profiler-runtime)
 - #87759 (Re-use std::sealed::Sealed in os/linux/process.)
 - #87760 (Promote `aarch64-apple-ios-sim` to Tier 2)
 - #87770 (permit drop impls with generic constants in where clauses)
 - #87780 (alloc: Use intra doc links for the reserve function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-08-06 05:02:35 +00:00
commit 1f94abcda6
26 changed files with 182 additions and 49 deletions

View File

@ -359,6 +359,7 @@ E0621: include_str!("./error_codes/E0621.md"),
E0622: include_str!("./error_codes/E0622.md"),
E0623: include_str!("./error_codes/E0623.md"),
E0624: include_str!("./error_codes/E0624.md"),
E0625: include_str!("./error_codes/E0625.md"),
E0626: include_str!("./error_codes/E0626.md"),
E0627: include_str!("./error_codes/E0627.md"),
E0628: include_str!("./error_codes/E0628.md"),
@ -622,7 +623,6 @@ E0783: include_str!("./error_codes/E0783.md"),
// E0611, // merged into E0616
// E0612, // merged into E0609
// E0613, // Removed (merged with E0609)
E0625, // thread-local statics cannot be accessed at compile-time
// E0629, // missing 'feature' (rustc_const_unstable)
// E0630, // rustc_const_unstable attribute must be paired with stable/unstable
// attribute

View File

@ -0,0 +1,28 @@
A compile-time const variable is referring to a thread-local static variable.
Erroneous code example:
```compile_fail,E0625
#![feature(thread_local)]
#[thread_local]
static X: usize = 12;
const Y: usize = 2 * X;
```
Static and const variables can refer to other const variables but a const
variable cannot refer to a thread-local static variable. In this example,
`Y` cannot refer to `X`. To fix this, the value can be extracted as a const
and then used:
```
#![feature(thread_local)]
const C: usize = 12;
#[thread_local]
static X: usize = C;
const Y: usize = 2 * C;
```

View File

@ -740,6 +740,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(new_llvm_pass_manager, Some(true));
tracked!(no_generate_arange_section, true);
tracked!(no_link, true);
tracked!(no_profiler_runtime, true);
tracked!(osx_rpath_install_name, true);
tracked!(panic_abort_tests, true);
tracked!(plt, Some(true));
@ -748,7 +749,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(print_fuel, Some("abc".to_string()));
tracked!(profile, true);
tracked!(profile_emit, Some(PathBuf::from("abc")));
tracked!(profiler_runtime, None);
tracked!(profiler_runtime, "abc".to_string());
tracked!(relax_elf_relocations, Some(true));
tracked!(relro_level, Some(RelroLevel::Full));
tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));

View File

@ -777,19 +777,17 @@ impl<'a> CrateLoader<'a> {
}
fn inject_profiler_runtime(&mut self, krate: &ast::Crate) {
let profiler_runtime = &self.sess.opts.debugging_opts.profiler_runtime;
if !(profiler_runtime.is_some()
&& (self.sess.instrument_coverage()
if self.sess.opts.debugging_opts.no_profiler_runtime
|| !(self.sess.instrument_coverage()
|| self.sess.opts.debugging_opts.profile
|| self.sess.opts.cg.profile_generate.enabled()))
|| self.sess.opts.cg.profile_generate.enabled())
{
return;
}
info!("loading profiler");
let name = Symbol::intern(profiler_runtime.as_ref().unwrap());
let name = Symbol::intern(&self.sess.opts.debugging_opts.profiler_runtime);
if name == sym::profiler_builtins && self.sess.contains_name(&krate.attrs, sym::no_core) {
self.sess.err(
"`profiler_builtins` crate (required by compiler options) \

View File

@ -1103,8 +1103,8 @@ impl CrateError {
if sess.is_nightly_build() {
err.help("consider building the standard library from source with `cargo build -Zbuild-std`");
}
} else if Some(crate_name)
== sess.opts.debugging_opts.profiler_runtime.as_deref().map(Symbol::intern)
} else if crate_name
== Symbol::intern(&sess.opts.debugging_opts.profiler_runtime)
{
err.note(&"the compiler may have been built without the profiler runtime");
}

View File

@ -1172,6 +1172,8 @@ options! {
"compile without linking"),
no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
"prevent automatic injection of the profiler_builtins crate"),
normalize_docs: bool = (false, parse_bool, [TRACKED],
"normalize associated items in rustdoc when generating documentation"),
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
@ -1217,8 +1219,8 @@ options! {
profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"file path to emit profiling data at runtime when using 'profile' \
(default based on relative source path)"),
profiler_runtime: Option<String> = (Some(String::from("profiler_builtins")), parse_opt_string, [TRACKED],
"name of the profiler runtime crate to automatically inject, or None to disable"),
profiler_runtime: String = (String::from("profiler_builtins"), parse_string, [TRACKED],
"name of the profiler runtime crate to automatically inject (default: `profiler_builtins`)"),
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
"enable queries of the dependency graph for regression testing (default: no)"),
query_stats: bool = (false, parse_bool, [UNTRACKED],

View File

@ -613,7 +613,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
param_counts.consts + named_type_param_count
- default_counts.types
- default_counts.consts
- synth_type_param_count
};
debug!("expected_min: {:?}", expected_min);
debug!("arg_counts.lifetimes: {:?}", gen_args.num_lifetime_params());

View File

@ -218,9 +218,9 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
// This closure is a more robust way to check `Predicate` equality
// than simple `==` checks (which were the previous implementation).
// It relies on `ty::relate` for `TraitPredicate` and `ProjectionPredicate`
// (which implement the Relate trait), while delegating on simple equality
// for the other `Predicate`.
// It relies on `ty::relate` for `TraitPredicate`, `ProjectionPredicate`,
// `ConstEvaluatable` and `TypeOutlives` (which implement the Relate trait),
// while delegating on simple equality for the other `Predicate`.
// This implementation solves (Issue #59497) and (Issue #58311).
// It is unclear to me at the moment whether the approach based on `relate`
// could be extended easily also to the other `Predicate`.
@ -235,6 +235,13 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
}
(
ty::PredicateKind::ConstEvaluatable(def_a, substs_a),
ty::PredicateKind::ConstEvaluatable(def_b, substs_b),
) => tcx.try_unify_abstract_consts(((def_a, substs_a), (def_b, substs_b))),
(ty::PredicateKind::TypeOutlives(a), ty::PredicateKind::TypeOutlives(b)) => {
relator.relate(predicate.rebind(a.0), p.rebind(b.0)).is_ok()
}
_ => predicate == p,
}
};

View File

@ -697,7 +697,9 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: VecDeque::reserve
///
/// # Errors
///

View File

@ -1035,7 +1035,9 @@ impl String {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: String::reserve
///
/// # Errors
///

View File

@ -811,7 +811,9 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: Vec::reserve
///
/// # Panics
///
@ -875,7 +877,9 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: Vec::reserve
///
/// # Errors
///

View File

@ -271,7 +271,9 @@ impl OsString {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer reserve if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: OsString::reserve
///
/// # Examples
///

View File

@ -5,6 +5,7 @@
use crate::io::Result;
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use crate::process;
use crate::sealed::Sealed;
#[cfg(not(doc))]
use crate::sys::fd::FileDesc;
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
@ -84,15 +85,10 @@ impl IntoRawFd for PidFd {
}
}
mod private_child_ext {
pub trait Sealed {}
impl Sealed for crate::process::Child {}
}
/// Os-specific extensions for [`Child`]
///
/// [`Child`]: process::Child
pub trait ChildExt: private_child_ext::Sealed {
pub trait ChildExt: Sealed {
/// Obtains a reference to the [`PidFd`] created for this [`Child`], if available.
///
/// A pidfd will only be available if its creation was requested with
@ -120,15 +116,10 @@ pub trait ChildExt: private_child_ext::Sealed {
fn take_pidfd(&mut self) -> Result<PidFd>;
}
mod private_command_ext {
pub trait Sealed {}
impl Sealed for crate::process::Command {}
}
/// Os-specific extensions for [`Command`]
///
/// [`Command`]: process::Command
pub trait CommandExt: private_command_ext::Sealed {
pub trait CommandExt: Sealed {
/// Sets whether a [`PidFd`](struct@PidFd) should be created for the [`Child`]
/// spawned by this [`Command`].
/// By default, no pidfd will be created.

View File

@ -205,6 +205,10 @@ pub struct Child {
pub stderr: Option<ChildStderr>,
}
/// Allows extension traits within `std`.
#[unstable(feature = "sealed", issue = "none")]
impl crate::sealed::Sealed for Child {}
impl AsInner<imp::Process> for Child {
fn as_inner(&self) -> &imp::Process {
&self.handle

View File

@ -164,16 +164,23 @@ impl Thread {
}
}
#[cfg(target_os = "haiku")]
pub fn set_name(name: &CStr) {
unsafe {
let thread_self = libc::find_thread(ptr::null_mut());
libc::rename_thread(thread_self, name.as_ptr());
}
}
#[cfg(any(
target_env = "newlib",
target_os = "haiku",
target_os = "l4re",
target_os = "emscripten",
target_os = "redox",
target_os = "vxworks"
))]
pub fn set_name(_name: &CStr) {
// Newlib, Haiku, Emscripten, and VxWorks have no way to set a thread name.
// Newlib, Emscripten, and VxWorks have no way to set a thread name.
}
pub fn sleep(dur: Duration) {

View File

@ -165,6 +165,7 @@ target | std | notes
`wasm32-unknown-unknown` | ✓ | WebAssembly
`wasm32-wasi` | ✓ | WebAssembly with WASI
`x86_64-apple-ios` | ✓ | 64-bit x86 iOS
[`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | ✓ | | Apple iOS Simulator on ARM64
`x86_64-fortanix-unknown-sgx` | ✓ | [Fortanix ABI] for 64-bit Intel SGX
`x86_64-fuchsia` | ✓ | 64-bit Fuchsia
`x86_64-linux-android` | ✓ | 64-bit x86 Android
@ -196,7 +197,6 @@ host tools.
target | std | host | notes
-------|:---:|:----:|-------
`aarch64-apple-ios-macabi` | ? | | Apple Catalyst on ARM64
[`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | ✓ | | Apple iOS Simulator on ARM64
`aarch64-apple-tvos` | * | | ARM64 tvOS
`aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD
`aarch64-unknown-hermit` | ? | |

View File

@ -1,6 +1,6 @@
# aarch64-apple-ios-sim
**Tier: 3**
**Tier: 2**
Apple iOS Simulator on ARM64.
@ -39,18 +39,17 @@ Currently there is no support to run the rustc test suite for this target.
*Note: Building for this target requires the corresponding iOS SDK, as provided by Xcode 12+.*
If `rustc` has support for that target and the library artifacts are available,
then Rust programs can be built for that target:
From Rust Nightly 1.56.0 (2021-08-03) on the artifacts are shipped pre-compiled:
```text
rustup target add aarch64-apple-ios-sim --toolchain nightly
```
Rust programs can be built for that target:
```text
rustc --target aarch64-apple-ios-sim your-code.rs
```
On Rust Nightly it is possible to build without the target artifacts available:
```text
cargo build -Z build-std --target aarch64-apple-ios-sim
```
There is no easy way to run simple programs in the iOS simulator.
Static library builds can be embedded into iOS applications.

View File

@ -0,0 +1,12 @@
// check-pass
// only-x86_64
#![feature(asm)]
#![feature(naked_functions)]
#![crate_type = "lib"]
#[naked]
pub extern "C" fn naked(p: char) -> u128 {
//~^ WARN uses type `char`
//~| WARN uses type `u128`
unsafe { asm!("", options(noreturn)); }
}

View File

@ -0,0 +1,20 @@
warning: `extern` fn uses type `char`, which is not FFI-safe
--> $DIR/naked-functions-ffi.rs:8:28
|
LL | pub extern "C" fn naked(p: char) -> u128 {
| ^^^^ not FFI-safe
|
= note: `#[warn(improper_ctypes_definitions)]` on by default
= help: consider using `u32` or `libc::wchar_t` instead
= note: the `char` type has no C equivalent
warning: `extern` fn uses type `u128`, which is not FFI-safe
--> $DIR/naked-functions-ffi.rs:8:37
|
LL | pub extern "C" fn naked(p: char) -> u128 {
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI
warning: 2 warnings emitted

View File

@ -0,0 +1,16 @@
//check-pass
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
struct Foo<const N: usize>
where
[(); N + 1]: ;
impl<const N: usize> Drop for Foo<N>
where
[(); N + 1]: ,
{
fn drop(&mut self) {}
}
fn main() {}

View File

@ -1,12 +1,12 @@
error[E0107]: this function takes at most 1 generic argument but 2 generic arguments were supplied
error[E0107]: this function takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/explicit-generic-args-for-impl.rs:6:5
|
LL | foo::<str, String>("".to_string());
| ^^^ ------ help: remove this generic argument
| |
| expected at most 1 generic argument
| expected 1 generic argument
|
note: function defined here, with at most 1 generic parameter: `T`
note: function defined here, with 1 generic parameter: `T`
--> $DIR/explicit-generic-args-for-impl.rs:3:4
|
LL | fn foo<T: ?Sized>(_f: impl AsRef<T>) {}

View File

@ -0,0 +1,9 @@
// check-pass
#![feature(explicit_generic_args_with_impl_trait)]
fn f<T: ?Sized>(_: impl AsRef<T>, _: impl AsRef<T>) {}
fn main() {
f::<[u8]>("a", b"a");
}

View File

@ -0,0 +1,8 @@
#![feature(explicit_generic_args_with_impl_trait)]
fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
fn main() {
f::<[u8]>("a", b"a");
//~^ ERROR: this function takes 2 generic arguments but 1 generic argument was supplied
}

View File

@ -0,0 +1,21 @@
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
--> $DIR/not-enough-args.rs:6:5
|
LL | f::<[u8]>("a", b"a");
| ^ ---- supplied 1 generic argument
| |
| expected 2 generic arguments
|
note: function defined here, with 2 generic parameters: `T`, `U`
--> $DIR/not-enough-args.rs:3:4
|
LL | fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
| ^ - -
help: add missing generic argument
|
LL | f::<[u8], U>("a", b"a");
| ^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0107`.

View File

@ -30,3 +30,4 @@ LL | A
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0625`.

View File

@ -40,5 +40,5 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2)
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0013, E0133, E0658.
Some errors have detailed explanations: E0013, E0133, E0625, E0658.
For more information about an error, try `rustc --explain E0013`.