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 8 pull requests #68971

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bdacdf4
Remove unused core_intrinsics feature gate from bootstrap
bjorn3 Nov 17, 2019
095963f
Remove unused feature gates from librustc
bjorn3 Nov 17, 2019
f9971c5
Remove unused feature gates from cg_llvm
bjorn3 Nov 17, 2019
c2da8b3
Remove unused feature gates from cg_ssa and cg_utils
bjorn3 Nov 17, 2019
2a4596a
Remove unused feature gates from librustc_data_structures
bjorn3 Nov 17, 2019
cf862df
Remove unused feature gates from librustc_driver
bjorn3 Nov 17, 2019
3e61d52
Remove unused feature gates from librustc_errors
bjorn3 Nov 17, 2019
c00d8aa
Reorder declarations of Result::export/unwrap to match Option
brson Feb 5, 2020
db9b578
Reorder declarations of Result::expect_err/unwrap_err to match Option
brson Feb 5, 2020
8251e12
Don't use the word 'unwrap' to describe core unwrapping functions
brson Feb 7, 2020
d252791
Remove unused feature gate from librustc_incremental
bjorn3 Nov 17, 2019
6638b86
Remove unused feature gates from librustc_interface
bjorn3 Nov 17, 2019
74994af
Remove unused feature gate from librustc_lint
bjorn3 Nov 17, 2019
6305c68
Remove unused feature gates from librustc_metadata
bjorn3 Nov 17, 2019
341594e
Remove unused feature gates from librustc_mir
bjorn3 Nov 17, 2019
1bfba4f
Remove unused feature gate from librustc_resolve
bjorn3 Nov 17, 2019
1a26c1c
Remove unused feature gate from librustc_target
bjorn3 Nov 17, 2019
8f672cd
Remove unused feature gates from librustc_typeck
bjorn3 Nov 17, 2019
b759999
Remove unused feature gates from librustdoc
bjorn3 Nov 17, 2019
9d6bdcc
Remove unused feature gate from libserialize
bjorn3 Nov 17, 2019
91d01e7
Remove unused feature gates from libsyntax_pos
bjorn3 Nov 17, 2019
e386656
Rustfmt
bjorn3 Dec 23, 2019
5827d78
Fix test
bjorn3 Jan 25, 2020
73936ab
print generic bounds on associated types
basil-cow Feb 7, 2020
ab6ea2b
add regression test
basil-cow Feb 7, 2020
bf82582
add hir printing
basil-cow Feb 7, 2020
66fd4e6
Make `associated_items` query return a slice
jonas-schievink Feb 6, 2020
f416573
Use `associated_items` query in impl overlap check
jonas-schievink Feb 6, 2020
52f7711
Add a fast path to inherent impl overlap check
jonas-schievink Feb 6, 2020
e0cb1ae
Make `provided_trait_methods` use `impl Iterator`
jonas-schievink Feb 7, 2020
58a9284
Add missing import
jonas-schievink Feb 8, 2020
1177d06
Clean up E0277 and E0282 explanations
GuillaumeGomez Feb 8, 2020
d6ccbf6
rustc_codegen_llvm: remove unnecessary special-casing of root scopes'…
eddyb Feb 8, 2020
1385fc4
rustc_codegen_llvm: remove InternalDebugLocation and simplify dbg_var…
eddyb Feb 8, 2020
bdb72e7
rustc_codegen_ssa: remove unnecessary source_locations_enabled.
eddyb Feb 8, 2020
4ac468c
Mark several functions and methods in core::cmp as #[must_use]
mjbshaw Feb 8, 2020
619051e
Move librustc_hir/def_id.rs to librustc_span/def_id.rs
Aaron1011 Feb 8, 2020
57b72b8
Rollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPC
Dylan-DPC Feb 8, 2020
3a8f125
Rollup merge of #68718 - Aaron1011:move-def-hir-span, r=petrochenkov
Dylan-DPC Feb 8, 2020
c3bd20a
Rollup merge of #68911 - jonas-schievink:inherent-overlap, r=petroche…
Dylan-DPC Feb 8, 2020
699fc5f
Rollup merge of #68913 - Areredify:gat_pretty, r=cramertj
Dylan-DPC Feb 8, 2020
43137f4
Rollup merge of #68918 - brson:unwrapdoc, r=Dylan-DPC
Dylan-DPC Feb 8, 2020
b495246
Rollup merge of #68946 - mjbshaw:must_use, r=mjbshaw
Dylan-DPC Feb 8, 2020
9f38e14
Rollup merge of #68958 - GuillaumeGomez:clean-up-e0277-e0282, r=Dylan…
Dylan-DPC Feb 8, 2020
2737732
Rollup merge of #68960 - eddyb:llvm-dbg-cleanup, r=nagisa
Dylan-DPC Feb 8, 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
1 change: 0 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
//! More documentation can be found in each respective module below, and you can
//! also check out the `src/bootstrap/README.md` file for more information.

#![feature(core_intrinsics)]
#![feature(drain_filter)]

use std::cell::{Cell, RefCell};
Expand Down
13 changes: 13 additions & 0 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ impl Ordering {
/// assert!(data == b);
/// ```
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn reverse(self) -> Ordering {
match self {
Expand Down Expand Up @@ -398,6 +399,7 @@ impl Ordering {
/// assert_eq!(result, Ordering::Less);
/// ```
#[inline]
#[must_use]
#[stable(feature = "ordering_chaining", since = "1.17.0")]
pub fn then(self, other: Ordering) -> Ordering {
match self {
Expand Down Expand Up @@ -435,6 +437,7 @@ impl Ordering {
/// assert_eq!(result, Ordering::Less);
/// ```
#[inline]
#[must_use]
#[stable(feature = "ordering_chaining", since = "1.17.0")]
pub fn then_with<F: FnOnce() -> Ordering>(self, f: F) -> Ordering {
match self {
Expand Down Expand Up @@ -576,6 +579,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// assert_eq!(10.cmp(&5), Ordering::Greater);
/// assert_eq!(5.cmp(&5), Ordering::Equal);
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
fn cmp(&self, other: &Self) -> Ordering;

Expand All @@ -591,6 +595,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// ```
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
#[must_use]
fn max(self, other: Self) -> Self
where
Self: Sized,
Expand All @@ -610,6 +615,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// ```
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
#[must_use]
fn min(self, other: Self) -> Self
where
Self: Sized,
Expand All @@ -635,6 +641,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// assert!(0.clamp(-2, 1) == 0);
/// assert!(2.clamp(-2, 1) == 1);
/// ```
#[must_use]
#[unstable(feature = "clamp", issue = "44095")]
fn clamp(self, min: Self, max: Self) -> Self
where
Expand Down Expand Up @@ -915,6 +922,7 @@ pub macro PartialOrd($item:item) {
/// assert_eq!(2, cmp::min(2, 2));
/// ```
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn min<T: Ord>(v1: T, v2: T) -> T {
v1.min(v2)
Expand All @@ -935,6 +943,7 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
/// assert_eq!(cmp::min_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2);
/// ```
#[inline]
#[must_use]
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
match compare(&v1, &v2) {
Expand All @@ -958,6 +967,7 @@ pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
/// assert_eq!(cmp::min_by_key(-2, 2, |x: &i32| x.abs()), -2);
/// ```
#[inline]
#[must_use]
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
min_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
Expand All @@ -978,6 +988,7 @@ pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
/// assert_eq!(2, cmp::max(2, 2));
/// ```
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn max<T: Ord>(v1: T, v2: T) -> T {
v1.max(v2)
Expand All @@ -998,6 +1009,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
/// assert_eq!(cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 2);
/// ```
#[inline]
#[must_use]
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
match compare(&v1, &v2) {
Expand All @@ -1021,6 +1033,7 @@ pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
/// assert_eq!(cmp::max_by_key(-2, 2, |x: &i32| x.abs()), 2);
/// ```
#[inline]
#[must_use]
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
pub fn max_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
max_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
Expand Down
26 changes: 16 additions & 10 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl<T> Option<T> {
// Getting to contained values
/////////////////////////////////////////////////////////////////////////

/// Unwraps an option, yielding the content of a [`Some`].
/// Returns the contained [`Some`] value, consuming the `self` value.
///
/// # Panics
///
Expand Down Expand Up @@ -348,17 +348,22 @@ impl<T> Option<T> {
}
}

/// Moves the value `v` out of the `Option<T>` if it is [`Some(v)`].
/// Returns the contained [`Some`] value, consuming the `self` value.
///
/// In general, because this function may panic, its use is discouraged.
/// Because this function may panic, its use is generally discouraged.
/// Instead, prefer to use pattern matching and handle the [`None`]
/// case explicitly.
/// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or
/// [`unwrap_or_default`].
///
/// [`unwrap_or`]: #method.unwrap_or
/// [`unwrap_or_else`]: #method.unwrap_or_else
/// [`unwrap_or_default`]: #method.unwrap_or_default
///
/// # Panics
///
/// Panics if the self value equals [`None`].
///
/// [`Some(v)`]: #variant.Some
/// [`Some`]: #variant.Some
/// [`None`]: #variant.None
///
/// # Examples
Expand All @@ -382,12 +387,13 @@ impl<T> Option<T> {
}
}

/// Returns the contained value or a default.
/// Returns the contained [`Some`] value or a provided default.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
/// which is lazily evaluated.
///
/// [`Some`]: #variant.Some
/// [`unwrap_or_else`]: #method.unwrap_or_else
///
/// # Examples
Expand All @@ -405,7 +411,7 @@ impl<T> Option<T> {
}
}

/// Returns the contained value or computes it from a closure.
/// Returns the contained [`Some`] value or computes it from a closure.
///
/// # Examples
///
Expand Down Expand Up @@ -986,7 +992,7 @@ impl<T: Clone> Option<&mut T> {
}

impl<T: fmt::Debug> Option<T> {
/// Unwraps an option, expecting [`None`] and returning nothing.
/// Consumes `self` while expecting [`None`] and returning nothing.
///
/// # Panics
///
Expand Down Expand Up @@ -1029,7 +1035,7 @@ impl<T: fmt::Debug> Option<T> {
}
}

/// Unwraps an option, expecting [`None`] and returning nothing.
/// Consumes `self` while expecting [`None`] and returning nothing.
///
/// # Panics
///
Expand Down Expand Up @@ -1074,7 +1080,7 @@ impl<T: fmt::Debug> Option<T> {
}

impl<T: Default> Option<T> {
/// Returns the contained value or a default
/// Returns the contained [`Some`] value or a default
///
/// Consumes the `self` argument then, if [`Some`], returns the contained
/// value, otherwise if [`None`], returns the [default value] for that
Expand Down
112 changes: 59 additions & 53 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,7 @@ impl<T, E> Result<T, E> {
}
}

/// Unwraps a result, yielding the content of an [`Ok`].
/// Else, it returns `optb`.
/// Returns the contained [`Ok`] value or a provided default.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
Expand All @@ -814,27 +813,25 @@ impl<T, E> Result<T, E> {
/// Basic usage:
///
/// ```
/// let optb = 2;
/// let default = 2;
/// let x: Result<u32, &str> = Ok(9);
/// assert_eq!(x.unwrap_or(optb), 9);
/// assert_eq!(x.unwrap_or(default), 9);
///
/// let x: Result<u32, &str> = Err("error");
/// assert_eq!(x.unwrap_or(optb), optb);
/// assert_eq!(x.unwrap_or(default), default);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn unwrap_or(self, optb: T) -> T {
pub fn unwrap_or(self, default: T) -> T {
match self {
Ok(t) => t,
Err(_) => optb,
Err(_) => default,
}
}

/// Unwraps a result, yielding the content of an [`Ok`].
/// If the value is an [`Err`] then it calls `op` with its value.
/// Returns the contained [`Ok`] value or computes it from a closure.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples
///
Expand Down Expand Up @@ -937,7 +934,44 @@ impl<T: Clone, E> Result<&mut T, E> {
}

impl<T, E: fmt::Debug> Result<T, E> {
/// Unwraps a result, yielding the content of an [`Ok`].
/// Returns the contained [`Ok`] value, consuming the `self` value.
///
/// # Panics
///
/// Panics if the value is an [`Err`], with a panic message including the
/// passed message, and the content of the [`Err`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples
///
/// Basic usage:
///
/// ```{.should_panic}
/// let x: Result<u32, &str> = Err("emergency failure");
/// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
/// ```
#[inline]
#[track_caller]
#[stable(feature = "result_expect", since = "1.4.0")]
pub fn expect(self, msg: &str) -> T {
match self {
Ok(t) => t,
Err(e) => unwrap_failed(msg, &e),
}
}

/// Returns the contained [`Ok`] value, consuming the `self` value.
///
/// Because this function may panic, its use is generally discouraged.
/// Instead, prefer to use pattern matching and handle the [`Err`]
/// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or
/// [`unwrap_or_default`].
///
/// [`unwrap_or`]: #method.unwrap_or
/// [`unwrap_or_else`]: #method.unwrap_or_else
/// [`unwrap_or_default`]: #method.unwrap_or_default
///
/// # Panics
///
Expand Down Expand Up @@ -969,13 +1003,15 @@ impl<T, E: fmt::Debug> Result<T, E> {
Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", &e),
}
}
}

/// Unwraps a result, yielding the content of an [`Ok`].
impl<T: fmt::Debug, E> Result<T, E> {
/// Returns the contained [`Err`] value, consuming the `self` value.
///
/// # Panics
///
/// Panics if the value is an [`Err`], with a panic message including the
/// passed message, and the content of the [`Err`].
/// Panics if the value is an [`Ok`], with a panic message including the
/// passed message, and the content of the [`Ok`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
Expand All @@ -985,22 +1021,20 @@ impl<T, E: fmt::Debug> Result<T, E> {
/// Basic usage:
///
/// ```{.should_panic}
/// let x: Result<u32, &str> = Err("emergency failure");
/// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
/// let x: Result<u32, &str> = Ok(10);
/// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
/// ```
#[inline]
#[track_caller]
#[stable(feature = "result_expect", since = "1.4.0")]
pub fn expect(self, msg: &str) -> T {
#[stable(feature = "result_expect_err", since = "1.17.0")]
pub fn expect_err(self, msg: &str) -> E {
match self {
Ok(t) => t,
Err(e) => unwrap_failed(msg, &e),
Ok(t) => unwrap_failed(msg, &t),
Err(e) => e,
}
}
}

impl<T: fmt::Debug, E> Result<T, E> {
/// Unwraps a result, yielding the content of an [`Err`].
/// Returns the contained [`Err`] value, consuming the `self` value.
///
/// # Panics
///
Expand Down Expand Up @@ -1031,38 +1065,10 @@ impl<T: fmt::Debug, E> Result<T, E> {
Err(e) => e,
}
}

/// Unwraps a result, yielding the content of an [`Err`].
///
/// # Panics
///
/// Panics if the value is an [`Ok`], with a panic message including the
/// passed message, and the content of the [`Ok`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples
///
/// Basic usage:
///
/// ```{.should_panic}
/// let x: Result<u32, &str> = Ok(10);
/// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
/// ```
#[inline]
#[track_caller]
#[stable(feature = "result_expect_err", since = "1.17.0")]
pub fn expect_err(self, msg: &str) -> E {
match self {
Ok(t) => unwrap_failed(msg, &t),
Err(e) => e,
}
}
}

impl<T: Default, E> Result<T, E> {
/// Returns the contained value or a default
/// Returns the contained [`Ok`] value or a default
///
/// Consumes the `self` argument then, if [`Ok`], returns the contained
/// value, otherwise if [`Err`], returns the default value for that
Expand Down Expand Up @@ -1101,7 +1107,7 @@ impl<T: Default, E> Result<T, E> {

#[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")]
impl<T, E: Into<!>> Result<T, E> {
/// Unwraps a result that can never be an [`Err`], yielding the content of the [`Ok`].
/// Returns the contained [`Ok`] value, but never panics.
///
/// Unlike [`unwrap`], this method is known to never panic on the
/// result types it is implemented for. Therefore, it can be used
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
self.hash_spans
}

#[inline]
fn hash_def_id(&mut self, def_id: DefId, hasher: &mut StableHasher) {
let hcx = self;
hcx.def_path_hash(def_id).hash_stable(hcx, hasher);
}

fn byte_pos_to_line_and_col(
&mut self,
byte: BytePos,
Expand Down
Loading