Skip to content

Commit

Permalink
Auto merge of #73746 - Manishearth:rollup-80jnynm, r=Manishearth
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

Successful merges:

 - #72617 (Add a fast path for `std::thread::panicking`.)
 - #72738 (Self contained linking option)
 - #72770 (Implement mixed script confusable lint.)
 - #73418 (Add unstable `core::mem::variant_count` intrinsic)
 - #73460 (Emit line info for generator variants)
 - #73534 (Provide suggestions for some moved value errors)
 - #73538 (make commented examples use valid syntax, and be more consistent )
 - #73581 (Create 0766 error code)
 - #73619 (Document the mod keyword)
 - #73621 (Document the mut keyword)
 - #73648 (Document the return keyword)
 - #73673 (Fix ptr doc warnings.)
 - #73674 (Tweak binop errors)
 - #73687 (Clean up E0701 explanation)

Failed merges:

 - #73708 (Explain move errors that occur due to method calls involving `self` (take two))

r? @ghost
  • Loading branch information
bors committed Jun 26, 2020
2 parents 1033351 + 8c5d794 commit e093b65
Show file tree
Hide file tree
Showing 83 changed files with 1,846 additions and 555 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5405,15 +5405,15 @@ dependencies = [

[[package]]
name = "unicode-script"
version = "0.4.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b2c5c29e805da6817f5af6a627d65adb045cebf05cccd5a3493d6109454391c"
checksum = "58b33414ea8db4b7ea0343548dbdc31d27aef06beacf7044a87e564d9b0feb7d"

[[package]]
name = "unicode-security"
version = "0.0.3"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5f9011bbed9c13372bc8df618b55a38138445199caf3b61d432c6859c36dee0"
checksum = "5d87c28edc5b263377e448d6cdcb935c06b95413d8013ba6fae470558ccab18f"
dependencies = [
"unicode-normalization",
"unicode-script",
Expand Down
38 changes: 28 additions & 10 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,24 @@
# nightlies are already produced for. The current platform must be able to run
# binaries of this build triple and the nightly will be used to bootstrap the
# first compiler.
#build = "x86_64-unknown-linux-gnu" # defaults to your host platform
#
# Defaults to host platform
#build = "x86_64-unknown-linux-gnu"

# In addition to the build triple, other triples to produce full compiler
# toolchains for. Each of these triples will be bootstrapped from the build
# triple and then will continue to bootstrap themselves. This platform must
# currently be able to run all of the triples provided here.
#host = ["x86_64-unknown-linux-gnu"] # defaults to just the build triple
#
# Defaults to just the build triple
#host = ["x86_64-unknown-linux-gnu"]

# In addition to all host triples, other triples to produce the standard library
# for. Each host triple will be used to produce a copy of the standard library
# for each target triple.
#target = ["x86_64-unknown-linux-gnu"] # defaults to just the build triple
#
# Defaults to just the build triple
#target = ["x86_64-unknown-linux-gnu"]

# Use this directory to store build artifacts.
# You can use "$ROOT" to indicate the root of the git repository.
Expand Down Expand Up @@ -174,7 +180,7 @@
# Python interpreter to use for various tasks throughout the build, notably
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
#
# Defaults to the Python interpreter used to execute x.py.
# Defaults to the Python interpreter used to execute x.py
#python = "python"

# Force Cargo to check that Cargo.lock describes the precise dependency
Expand Down Expand Up @@ -313,11 +319,15 @@

# Whether or not debug assertions are enabled for the compiler and standard
# library.
#debug-assertions = debug
#
# Defaults to rust.debug value
#debug-assertions = false

# Whether or not debug assertions are enabled for the standard library.
# Overrides the `debug-assertions` option, if defined.
#debug-assertions-std = debug-assertions
#
# Defaults to rust.debug-assertions value
#debug-assertions-std = false

# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
# `0` - no debug info
Expand All @@ -326,16 +336,24 @@
# Can be overridden for specific subsets of Rust code (rustc, std or tools).
# Debuginfo for tests run with compiletest is not controlled by this option
# and needs to be enabled separately with `debuginfo-level-tests`.
#debuginfo-level = if debug { 2 } else { 0 }
#
# Defaults to 2 if debug is true
#debuginfo-level = 0

# Debuginfo level for the compiler.
#debuginfo-level-rustc = debuginfo-level
#
# Defaults to rust.debuginfo-level value
#debuginfo-level-rustc = 0

# Debuginfo level for the standard library.
#debuginfo-level-std = debuginfo-level
#
# Defaults to rust.debuginfo-level value
#debuginfo-level-std = 0

# Debuginfo level for the tools.
#debuginfo-level-tools = debuginfo-level
#
# Defaults to rust.debuginfo-level value
#debuginfo-level-tools = 0

# Debuginfo level for the test suites run with compiletest.
# FIXME(#61117): Some tests fail when this option is enabled.
Expand Down
15 changes: 15 additions & 0 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,15 @@ extern "rust-intrinsic" {
#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
pub fn discriminant_value<T>(v: &T) -> <T as DiscriminantKind>::Discriminant;

/// Returns the number of variants of the type `T` cast to a `usize`;
/// if `T` has no variants, returns 0. Uninhabited variants will be counted.
///
/// The to-be-stabilized version of this intrinsic is
/// [`std::mem::variant_count`](../../std/mem/fn.variant_count.html)
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
#[cfg(not(bootstrap))]
pub fn variant_count<T>() -> usize;

/// Rust's "try catch" construct which invokes the function pointer `try_fn`
/// with the data pointer `data`.
///
Expand Down Expand Up @@ -1960,6 +1969,12 @@ extern "rust-intrinsic" {
pub fn ptr_guaranteed_ne<T>(ptr: *const T, other: *const T) -> bool;
}

#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
#[cfg(bootstrap)]
pub const fn variant_count<T>() -> usize {
0
}

// Some functions are defined here because they accidentally got made
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
// (`transmute` also falls into this category, but it cannot be wrapped due to the
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
#![feature(unsized_locals)]
#![feature(untagged_unions)]
#![feature(unwind_attributes)]
#![feature(variant_count)]
#![feature(doc_alias)]
#![feature(mmx_target_feature)]
#![feature(tbm_target_feature)]
Expand Down
30 changes: 30 additions & 0 deletions src/libcore/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,3 +999,33 @@ impl<T> fmt::Debug for Discriminant<T> {
pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
Discriminant(intrinsics::discriminant_value(v))
}

/// Returns the number of variants in the enum type `T`.
///
/// If `T` is not an enum, calling this function will not result in undefined behavior, but the
/// return value is unspecified. Equally, if `T` is an enum with more variants than `usize::MAX`
/// the return value is unspecified. Uninhabited variants will be counted.
///
/// # Examples
///
/// ```
/// # #![feature(never_type)]
/// # #![feature(variant_count)]
///
/// use std::mem;
///
/// enum Void {}
/// enum Foo { A(&'static str), B(i32), C(i32) }
///
/// assert_eq!(mem::variant_count::<Void>(), 0);
/// assert_eq!(mem::variant_count::<Foo>(), 3);
///
/// assert_eq!(mem::variant_count::<Option<!>>(), 2);
/// assert_eq!(mem::variant_count::<Result<!, !>>(), 2);
/// ```
#[inline(always)]
#[unstable(feature = "variant_count", issue = "73662")]
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
pub const fn variant_count<T>() -> usize {
intrinsics::variant_count::<T>()
}
2 changes: 0 additions & 2 deletions src/libcore/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ impl<T: ?Sized> *const T {
/// differently have not been explored. This method should not be used to introduce such
/// differences, and it should also not be stabilized before we have a better understanding
/// of this issue.
/// ```
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[inline]
Expand Down Expand Up @@ -349,7 +348,6 @@ impl<T: ?Sized> *const T {
/// differently have not been explored. This method should not be used to introduce such
/// differences, and it should also not be stabilized before we have a better understanding
/// of this issue.
/// ```
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[inline]
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ impl<T: ?Sized> *mut T {
/// differently have not been explored. This method should not be used to introduce such
/// differences, and it should also not be stabilized before we have a better understanding
/// of this issue.
/// ```
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[inline]
Expand Down Expand Up @@ -327,7 +326,6 @@ impl<T: ?Sized> *mut T {
/// differently have not been explored. This method should not be used to introduce such
/// differences, and it should also not be stabilized before we have a better understanding
/// of this issue.
/// ```
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
#[inline]
Expand Down
Loading

0 comments on commit e093b65

Please sign in to comment.