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 9 pull requests #87808

Merged
merged 23 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
52371f4
thread set_name haiku implementation.
devnexen Jul 28, 2021
a77d6ff
add long error explanation for E0625
bhgomes Aug 3, 2021
2fd874d
Fix overflow when calculating expected_min in generics diagnostics
SkiFire13 Aug 3, 2021
ae313da
Add regression tests
SkiFire13 Aug 3, 2021
e3389be
Bless test
SkiFire13 Aug 3, 2021
2f85aa6
remove trailing newline
bhgomes Aug 3, 2021
a96fd57
Validate FFI-safety warnings on naked functions
npmccallum Aug 3, 2021
1247f9b
Add back -Zno-profiler-runtime
Amanieu Aug 4, 2021
f280a12
Re-use std::sealed::Sealed in os/linux/process.
m-ou-se Aug 4, 2021
94ffa00
Promote `aarch64-apple-ios-sim` to Tier 2
badboy Aug 2, 2021
b1d14ef
dropck
BoxyUwU Aug 4, 2021
dc5f6d2
move full explanation to after erroneous example
bhgomes Aug 4, 2021
fa46715
remove tywf relation
BoxyUwU Aug 5, 2021
1db8737
alloc: Use intra doc links for the reserve function
est31 Aug 5, 2021
4b068dd
Rollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahc
JohnTitor Aug 6, 2021
772db06
Rollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeG…
JohnTitor Aug 6, 2021
5b43960
Rollup merge of #87727 - SkiFire13:fix-87718, r=jackh726
JohnTitor Aug 6, 2021
71ad503
Rollup merge of #87742 - npmccallum:naked_ffi, r=Amanieu
JohnTitor Aug 6, 2021
5a36cdb
Rollup merge of #87756 - Amanieu:no_profiler_runtime, r=jackh726
JohnTitor Aug 6, 2021
13f9a4c
Rollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514
JohnTitor Aug 6, 2021
41076a8
Rollup merge of #87760 - badboy:promote-ios-sim-target, r=Mark-Simula…
JohnTitor Aug 6, 2021
8bad350
Rollup merge of #87770 - BoxyUwU:cec-drop-impl, r=lcnr
JohnTitor Aug 6, 2021
b98c388
Rollup merge of #87780 - est31:intra_doc_links, r=jyn514
JohnTitor Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0625.md
Original file line number Diff line number Diff line change
@@ -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;
```
3 changes: 2 additions & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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")));
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_typeck/src/astconv/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_typeck/src/check/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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,
}
};
Expand Down
4 changes: 3 additions & 1 deletion library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
4 changes: 3 additions & 1 deletion library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
8 changes: 6 additions & 2 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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
///
Expand Down
4 changes: 3 additions & 1 deletion library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
15 changes: 3 additions & 12 deletions library/std/src/os/linux/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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` | ? | |
Expand Down
11 changes: 5 additions & 6 deletions src/doc/rustc/src/platform-support/aarch64-apple-ios-sim.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# aarch64-apple-ios-sim

**Tier: 3**
**Tier: 2**

Apple iOS Simulator on ARM64.

Expand Down Expand Up @@ -39,17 +39,16 @@ 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
rustc --target aarch64-apple-ios-sim your-code.rs
rustup target add aarch64-apple-ios-sim --toolchain nightly
```

On Rust Nightly it is possible to build without the target artifacts available:
Rust programs can be built for that target:

```text
cargo build -Z build-std --target aarch64-apple-ios-sim
rustc --target aarch64-apple-ios-sim your-code.rs
```

There is no easy way to run simple programs in the iOS simulator.
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/asm/naked-functions-ffi.rs
Original file line number Diff line number Diff line change
@@ -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)); }
}
20 changes: 20 additions & 0 deletions src/test/ui/asm/naked-functions-ffi.stderr
Original file line number Diff line number Diff line change
@@ -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

16 changes: 16 additions & 0 deletions src/test/ui/const-generics/const_evaluatable_checked/drop_impl.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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>) {}
Expand Down
Loading