Auto merge of #70534 - Centril:rollup-t59tcx2, r=Centril
Rollup of 3 pull requests Successful merges: - #70140 (Add Result<Result<T, E>, E>::flatten -> Result<T, E>) - #70526 (reduce `rustc_attr` usage in places) - #70527 (Update LLVM submodule) Failed merges: r? @ghost
This commit is contained in:
commit
285519d412
|
@ -4013,7 +4013,6 @@ dependencies = [
|
|||
"log",
|
||||
"rustc_ast",
|
||||
"rustc_ast_pretty",
|
||||
"rustc_attr",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_feature",
|
||||
|
|
|
@ -230,9 +230,9 @@
|
|||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::fmt;
|
||||
use crate::iter::{self, FromIterator, FusedIterator, TrustedLen};
|
||||
use crate::ops::{self, Deref, DerefMut};
|
||||
use crate::{convert, fmt};
|
||||
|
||||
/// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]).
|
||||
///
|
||||
|
@ -1214,6 +1214,38 @@ impl<T, E> Result<Option<T>, E> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T, E> Result<Result<T, E>, E> {
|
||||
/// Converts from `Result<Result<T, E>, E>` to `Result<T, E>`
|
||||
///
|
||||
/// # Examples
|
||||
/// Basic usage:
|
||||
/// ```
|
||||
/// #![feature(result_flattening)]
|
||||
/// let x: Result<Result<&'static str, u32>, u32> = Ok(Ok("hello"));
|
||||
/// assert_eq!(Ok("hello"), x.flatten());
|
||||
///
|
||||
/// let x: Result<Result<&'static str, u32>, u32> = Ok(Err(6));
|
||||
/// assert_eq!(Err(6), x.flatten());
|
||||
///
|
||||
/// let x: Result<Result<&'static str, u32>, u32> = Err(6);
|
||||
/// assert_eq!(Err(6), x.flatten());
|
||||
/// ```
|
||||
///
|
||||
/// Flattening once only removes one level of nesting:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(result_flattening)]
|
||||
/// let x: Result<Result<Result<&'static str, u32>, u32>, u32> = Ok(Ok(Ok("hello")));
|
||||
/// assert_eq!(Ok(Ok("hello")), x.flatten());
|
||||
/// assert_eq!(Ok("hello"), x.flatten().flatten());
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "result_flattening", issue = "70142")]
|
||||
pub fn flatten(self) -> Result<T, E> {
|
||||
self.and_then(convert::identity)
|
||||
}
|
||||
}
|
||||
|
||||
// This is a separate function to reduce the code size of the methods
|
||||
#[inline(never)]
|
||||
#[cold]
|
||||
|
|
|
@ -21,7 +21,7 @@ use crate::attributes;
|
|||
use crate::llvm::AttributePlace::Function;
|
||||
use crate::llvm::{self, Attribute};
|
||||
use crate::llvm_util;
|
||||
pub use rustc_attr::{self as attr, InlineAttr, OptimizeAttr};
|
||||
pub use rustc_attr::{InlineAttr, OptimizeAttr};
|
||||
|
||||
use crate::context::CodegenCx;
|
||||
use crate::value::Value;
|
||||
|
|
|
@ -13,7 +13,6 @@ doctest = false
|
|||
bitflags = "1.0"
|
||||
log = "0.4"
|
||||
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
|
||||
rustc_attr = { path = "../librustc_attr" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_feature = { path = "../librustc_feature" }
|
||||
rustc_lexer = { path = "../librustc_lexer" }
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9f65ad057357b307180955831968f79e74090a90
|
||||
Subproject commit 992e608cfc5d1c126a23c640222fd396a3bdeb9f
|
Loading…
Reference in New Issue