Skip to content

Commit e093b65

Browse files
committed
Auto merge of rust-lang#73746 - Manishearth:rollup-80jnynm, r=Manishearth
Rollup of 14 pull requests Successful merges: - rust-lang#72617 (Add a fast path for `std::thread::panicking`.) - rust-lang#72738 (Self contained linking option) - rust-lang#72770 (Implement mixed script confusable lint.) - rust-lang#73418 (Add unstable `core::mem::variant_count` intrinsic) - rust-lang#73460 (Emit line info for generator variants) - rust-lang#73534 (Provide suggestions for some moved value errors) - rust-lang#73538 (make commented examples use valid syntax, and be more consistent ) - rust-lang#73581 (Create 0766 error code) - rust-lang#73619 (Document the mod keyword) - rust-lang#73621 (Document the mut keyword) - rust-lang#73648 (Document the return keyword) - rust-lang#73673 (Fix ptr doc warnings.) - rust-lang#73674 (Tweak binop errors) - rust-lang#73687 (Clean up E0701 explanation) Failed merges: - rust-lang#73708 (Explain move errors that occur due to method calls involving `self` (take two)) r? @ghost
2 parents 1033351 + 8c5d794 commit e093b65

File tree

83 files changed

+1846
-555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1846
-555
lines changed

Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -5405,15 +5405,15 @@ dependencies = [
54055405

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

54125412
[[package]]
54135413
name = "unicode-security"
5414-
version = "0.0.3"
5414+
version = "0.0.5"
54155415
source = "registry+https://github.com/rust-lang/crates.io-index"
5416-
checksum = "a5f9011bbed9c13372bc8df618b55a38138445199caf3b61d432c6859c36dee0"
5416+
checksum = "5d87c28edc5b263377e448d6cdcb935c06b95413d8013ba6fae470558ccab18f"
54175417
dependencies = [
54185418
"unicode-normalization",
54195419
"unicode-script",

config.toml.example

+28-10
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,24 @@
118118
# nightlies are already produced for. The current platform must be able to run
119119
# binaries of this build triple and the nightly will be used to bootstrap the
120120
# first compiler.
121-
#build = "x86_64-unknown-linux-gnu" # defaults to your host platform
121+
#
122+
# Defaults to host platform
123+
#build = "x86_64-unknown-linux-gnu"
122124

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

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

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

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

314320
# Whether or not debug assertions are enabled for the compiler and standard
315321
# library.
316-
#debug-assertions = debug
322+
#
323+
# Defaults to rust.debug value
324+
#debug-assertions = false
317325

318326
# Whether or not debug assertions are enabled for the standard library.
319327
# Overrides the `debug-assertions` option, if defined.
320-
#debug-assertions-std = debug-assertions
328+
#
329+
# Defaults to rust.debug-assertions value
330+
#debug-assertions-std = false
321331

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

331343
# Debuginfo level for the compiler.
332-
#debuginfo-level-rustc = debuginfo-level
344+
#
345+
# Defaults to rust.debuginfo-level value
346+
#debuginfo-level-rustc = 0
333347

334348
# Debuginfo level for the standard library.
335-
#debuginfo-level-std = debuginfo-level
349+
#
350+
# Defaults to rust.debuginfo-level value
351+
#debuginfo-level-std = 0
336352

337353
# Debuginfo level for the tools.
338-
#debuginfo-level-tools = debuginfo-level
354+
#
355+
# Defaults to rust.debuginfo-level value
356+
#debuginfo-level-tools = 0
339357

340358
# Debuginfo level for the test suites run with compiletest.
341359
# FIXME(#61117): Some tests fail when this option is enabled.

src/libcore/intrinsics.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,15 @@ extern "rust-intrinsic" {
19171917
#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
19181918
pub fn discriminant_value<T>(v: &T) -> <T as DiscriminantKind>::Discriminant;
19191919

1920+
/// Returns the number of variants of the type `T` cast to a `usize`;
1921+
/// if `T` has no variants, returns 0. Uninhabited variants will be counted.
1922+
///
1923+
/// The to-be-stabilized version of this intrinsic is
1924+
/// [`std::mem::variant_count`](../../std/mem/fn.variant_count.html)
1925+
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
1926+
#[cfg(not(bootstrap))]
1927+
pub fn variant_count<T>() -> usize;
1928+
19201929
/// Rust's "try catch" construct which invokes the function pointer `try_fn`
19211930
/// with the data pointer `data`.
19221931
///
@@ -1960,6 +1969,12 @@ extern "rust-intrinsic" {
19601969
pub fn ptr_guaranteed_ne<T>(ptr: *const T, other: *const T) -> bool;
19611970
}
19621971

1972+
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
1973+
#[cfg(bootstrap)]
1974+
pub const fn variant_count<T>() -> usize {
1975+
0
1976+
}
1977+
19631978
// Some functions are defined here because they accidentally got made
19641979
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
19651980
// (`transmute` also falls into this category, but it cannot be wrapped due to the

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
#![feature(unsized_locals)]
125125
#![feature(untagged_unions)]
126126
#![feature(unwind_attributes)]
127+
#![feature(variant_count)]
127128
#![feature(doc_alias)]
128129
#![feature(mmx_target_feature)]
129130
#![feature(tbm_target_feature)]

src/libcore/mem/mod.rs

+30
Original file line numberDiff line numberDiff line change
@@ -999,3 +999,33 @@ impl<T> fmt::Debug for Discriminant<T> {
999999
pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
10001000
Discriminant(intrinsics::discriminant_value(v))
10011001
}
1002+
1003+
/// Returns the number of variants in the enum type `T`.
1004+
///
1005+
/// If `T` is not an enum, calling this function will not result in undefined behavior, but the
1006+
/// return value is unspecified. Equally, if `T` is an enum with more variants than `usize::MAX`
1007+
/// the return value is unspecified. Uninhabited variants will be counted.
1008+
///
1009+
/// # Examples
1010+
///
1011+
/// ```
1012+
/// # #![feature(never_type)]
1013+
/// # #![feature(variant_count)]
1014+
///
1015+
/// use std::mem;
1016+
///
1017+
/// enum Void {}
1018+
/// enum Foo { A(&'static str), B(i32), C(i32) }
1019+
///
1020+
/// assert_eq!(mem::variant_count::<Void>(), 0);
1021+
/// assert_eq!(mem::variant_count::<Foo>(), 3);
1022+
///
1023+
/// assert_eq!(mem::variant_count::<Option<!>>(), 2);
1024+
/// assert_eq!(mem::variant_count::<Result<!, !>>(), 2);
1025+
/// ```
1026+
#[inline(always)]
1027+
#[unstable(feature = "variant_count", issue = "73662")]
1028+
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
1029+
pub const fn variant_count<T>() -> usize {
1030+
intrinsics::variant_count::<T>()
1031+
}

src/libcore/ptr/const_ptr.rs

-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ impl<T: ?Sized> *const T {
316316
/// differently have not been explored. This method should not be used to introduce such
317317
/// differences, and it should also not be stabilized before we have a better understanding
318318
/// of this issue.
319-
/// ```
320319
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
321320
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
322321
#[inline]
@@ -349,7 +348,6 @@ impl<T: ?Sized> *const T {
349348
/// differently have not been explored. This method should not be used to introduce such
350349
/// differences, and it should also not be stabilized before we have a better understanding
351350
/// of this issue.
352-
/// ```
353351
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
354352
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
355353
#[inline]

src/libcore/ptr/mut_ptr.rs

-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ impl<T: ?Sized> *mut T {
294294
/// differently have not been explored. This method should not be used to introduce such
295295
/// differences, and it should also not be stabilized before we have a better understanding
296296
/// of this issue.
297-
/// ```
298297
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
299298
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
300299
#[inline]
@@ -327,7 +326,6 @@ impl<T: ?Sized> *mut T {
327326
/// differently have not been explored. This method should not be used to introduce such
328327
/// differences, and it should also not be stabilized before we have a better understanding
329328
/// of this issue.
330-
/// ```
331329
#[unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
332330
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
333331
#[inline]

0 commit comments

Comments
 (0)