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 15 pull requests #73745

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f03cf99
Add a fast path for `std::thread::panicking`.
eduardosm May 26, 2020
560a996
Implement slice_strip feature
tesuji Jun 16, 2020
1b47e8f
examples should be of type bool
tshepang Jun 20, 2020
16e741c
explain the logic a bit
tshepang Jun 20, 2020
9766a93
Document the mod keyword
poliorcetics Jun 22, 2020
3c46e36
Document the mut keyword
poliorcetics Jun 22, 2020
e84552e
be more consistent with "defaults" placement
tshepang Jun 22, 2020
ef24faf
Refactor non_ascii_idents lints, exclude ascii pair for confusable_id…
crlf0710 May 10, 2020
b65ea1b
place non-obvious defaults on a separate line
tshepang Jun 22, 2020
9bb414f
Fix ptr doc warnings.
ehuss Jun 23, 2020
5aab1a9
Tweak binop errors
estebank Jun 24, 2020
b23baa7
fix
tshepang Jun 24, 2020
d8ea10c
Document the return keyword
poliorcetics Jun 24, 2020
65becef
Clean up E0701 explanation
GuillaumeGomez Jun 24, 2020
d36d351
Implement intrinsic
doctorn Jun 23, 2020
c2dfc25
Fix tests
doctorn Jun 24, 2020
4931996
Fix tests
doctorn Jun 24, 2020
771a1d8
Make `std::panicking::panic_count::is_zero` inline and move the slow …
eduardosm Jun 24, 2020
09af184
review comments: clean up code
estebank Jun 24, 2020
a5a831f
Emit line info for generator variants
tmandry Jun 17, 2020
eb726c0
Add Artificial flag to generator variants
tmandry Jun 18, 2020
367858a
Add test for generator debuginfo
tmandry Jun 18, 2020
242a5cd
Allow calling GeneratorSubsts::variant_name() without substs
tmandry Jun 20, 2020
547d863
Improve GeneratorLayout debug output
tmandry Jun 20, 2020
477ecc5
Generalize generator-debug test a bit
tmandry Jun 23, 2020
2d652d9
Add generator-debug test for MSVC
tmandry Jun 23, 2020
fe3df64
Give up on checking filename
tmandry Jun 24, 2020
887fbd9
Split out async fn and generator test
tmandry Jun 24, 2020
8f40dae
Suggest type param trait bound for binop only when appropriate
estebank Jun 24, 2020
520461f
Provide suggestions for some moved value errors
estebank Jun 20, 2020
3d09017
Add a compile fail example, binding -> variable, apply suggestions
poliorcetics Jun 25, 2020
2e3f517
Add unstable rustc option to control self-contained linkage mode
mati865 May 28, 2020
54293c1
Rename get_self_contained_lib_path
mati865 Jun 22, 2020
f27dcd7
Rename remaining `fallback` to `self_contained`
mati865 Jun 25, 2020
eb6d9a4
Add E0766 error for unterminated double quote byte string
GuillaumeGomez Jun 21, 2020
33302fa
Update UI test
GuillaumeGomez Jun 21, 2020
25e864e
Implement mixed script confusable lint.
crlf0710 Jun 23, 2020
bf6134d
Rollup merge of #72617 - eduardosm:panicking, r=Amanieu
Manishearth Jun 26, 2020
e98f991
Rollup merge of #72738 - mati865:self-contained-option, r=petrochenkov
Manishearth Jun 26, 2020
885776e
Rollup merge of #72770 - crlf0710:mixed_script_confusable, r=Manishearth
Manishearth Jun 26, 2020
2196bab
Rollup merge of #73414 - lzutao:slice_strip, r=dtolnay
Manishearth Jun 26, 2020
e3807d0
Rollup merge of #73418 - doctorn:variants-intrinsic, r=kennytm
Manishearth Jun 26, 2020
673d7ca
Rollup merge of #73460 - tmandry:variant-lineinfo, r=oli-obk
Manishearth Jun 26, 2020
050cb83
Rollup merge of #73534 - estebank:borrowck-suggestions, r=matthewjasper
Manishearth Jun 26, 2020
59768d4
Rollup merge of #73538 - tshepang:fix-example, r=nikomatsakis
Manishearth Jun 26, 2020
d2f7d6b
Rollup merge of #73581 - GuillaumeGomez:add-0766, r=varkor
Manishearth Jun 26, 2020
f1ca34e
Rollup merge of #73619 - poliorcetics:mod-keyword, r=steveklabnik
Manishearth Jun 26, 2020
7f1eb2e
Rollup merge of #73621 - poliorcetics:mut-keyword, r=steveklabnik
Manishearth Jun 26, 2020
7b744e1
Rollup merge of #73648 - poliorcetics:return-keyword, r=joshtriplett
Manishearth Jun 26, 2020
d51c959
Rollup merge of #73673 - ehuss:fix-ptr-docs, r=oli-obk
Manishearth Jun 26, 2020
f16d62c
Rollup merge of #73674 - estebank:op-trait-bound-suggestion, r=davidtwco
Manishearth Jun 26, 2020
351486a
Rollup merge of #73687 - GuillaumeGomez:cleanup-e0701, r=Dylan-DPC
Manishearth Jun 26, 2020
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
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
80 changes: 80 additions & 0 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,86 @@ impl<T> [T] {
m >= n && needle == &self[m - n..]
}

/// Returns a subslice with the prefix removed.
///
/// Returns [`None`] if slice does not start with `prefix`.
///
/// # Examples
///
/// ```
/// #![feature(slice_strip)]
/// let v = [10, 40, 30];
/// assert_eq!(v.strip_prefix(&[10]), Some(&[40, 30]));
/// assert_eq!(v.strip_prefix(&[10, 40]), Some(&[30]));
/// assert_eq!(v.strip_prefix(&[50]), None);
/// assert_eq!(v.strip_prefix(&[10, 50]), None);
/// ```
///
/// This method returns the original slice if `prefix` is an empty slice:
///
/// ```
/// #![feature(slice_strip)]
/// let v = &[10, 40, 30];
/// assert_eq!(v.strip_prefix(&[]), Some(v));
/// let v: &[u8] = &[];
/// assert_eq!(v.strip_prefix(&[]), Some(v));
/// ```
#[must_use = "returns the subslice without modifying the original"]
#[unstable(feature = "slice_strip", issue = "73413")]
pub fn strip_prefix(&self, prefix: &[T]) -> Option<&[T]>
where
T: PartialEq,
{
let n = prefix.len();
if n <= self.len() {
let (head, tail) = self.split_at(n);
if head == prefix {
return Some(tail);
}
}
None
}

/// Returns a subslice with the suffix removed.
///
/// Returns [`None`] if slice does not end with `suffix`.
///
/// # Examples
///
/// ```
/// #![feature(slice_strip)]
/// let v = [10, 40, 30];
/// assert_eq!(v.strip_suffix(&[30]), Some(&[10, 40]));
/// assert_eq!(v.strip_suffix(&[40, 30]), Some(&[10]));
/// assert_eq!(v.strip_suffix(&[50]), None);
/// assert_eq!(v.strip_suffix(&[50, 30]), None);
/// ```
///
/// This method returns the original slice if `suffix` is an empty slice:
///
/// ```
/// #![feature(slice_strip)]
/// let v = &[10, 40, 30];
/// assert_eq!(v.strip_suffix(&[]), Some(v));
/// let v: &[u8] = &[];
/// assert_eq!(v.strip_suffix(&[]), Some(v));
/// ```
#[must_use = "returns the subslice without modifying the original"]
#[unstable(feature = "slice_strip", issue = "73413")]
pub fn strip_suffix(&self, suffix: &[T]) -> Option<&[T]>
where
T: PartialEq,
{
let (len, n) = (self.len(), suffix.len());
if n <= len {
let (head, tail) = self.split_at(len - n);
if tail == suffix {
return Some(head);
}
}
None
}

/// Binary searches this sorted slice for a given element.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
Expand Down
Loading