Skip to content

Commit 9d36909

Browse files
authored
Unrolled build for #141072
Rollup merge of #141072 - Rynibami:stabilize-const-result-flatten, r=jhpratt Stabilize feature `result_flattening` Stabilizes the `Result::flatten` method ## Implementations - [x] Implementation `Result::flatten`: #70140 - [x] Implementation `const` `Result::flatten`: #130692 - [x] Update stabilization attribute macros (this PR) ## Stabilization process - [x] Created this PR [suggested](#70142 (comment)) by ``@RalfJung`` - [x] FCP (haven't found any, is it applicable here?) - [ ] Close issue #70142
2 parents f0999ff + 48538ed commit 9d36909

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(decl_macro)]
1313
#![feature(panic_backtrace_config)]
1414
#![feature(panic_update_hook)]
15-
#![feature(result_flattening)]
1615
#![feature(rustdoc_internals)]
1716
#![feature(try_blocks)]
1817
// tidy-alphabetical-end

library/core/src/result.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,6 @@ impl<T, E> Result<Result<T, E>, E> {
17221722
/// # Examples
17231723
///
17241724
/// ```
1725-
/// #![feature(result_flattening)]
17261725
/// let x: Result<Result<&'static str, u32>, u32> = Ok(Ok("hello"));
17271726
/// assert_eq!(Ok("hello"), x.flatten());
17281727
///
@@ -1736,14 +1735,14 @@ impl<T, E> Result<Result<T, E>, E> {
17361735
/// Flattening only removes one level of nesting at a time:
17371736
///
17381737
/// ```
1739-
/// #![feature(result_flattening)]
17401738
/// let x: Result<Result<Result<&'static str, u32>, u32>, u32> = Ok(Ok(Ok("hello")));
17411739
/// assert_eq!(Ok(Ok("hello")), x.flatten());
17421740
/// assert_eq!(Ok("hello"), x.flatten().flatten());
17431741
/// ```
17441742
#[inline]
1745-
#[unstable(feature = "result_flattening", issue = "70142")]
1746-
#[rustc_const_unstable(feature = "result_flattening", issue = "70142")]
1743+
#[stable(feature = "result_flattening", since = "CURRENT_RUSTC_VERSION")]
1744+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
1745+
#[rustc_const_stable(feature = "result_flattening", since = "CURRENT_RUSTC_VERSION")]
17471746
pub const fn flatten(self) -> Result<T, E> {
17481747
// FIXME(const-hack): could be written with `and_then`
17491748
match self {

src/tools/clippy/tests/ui/map_flatten.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::map_flatten)]
2-
#![feature(result_flattening)]
2+
33
//@no-rustfix
44
// issue #8506, multi-line
55
#[rustfmt::skip]

src/tools/clippy/tests/ui/map_flatten_fixable.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(result_flattening)]
21
#![allow(
32
clippy::let_underscore_untyped,
43
clippy::missing_docs_in_private_items,

src/tools/clippy/tests/ui/map_flatten_fixable.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(result_flattening)]
21
#![allow(
32
clippy::let_underscore_untyped,
43
clippy::missing_docs_in_private_items,

src/tools/clippy/tests/ui/map_flatten_fixable.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: called `map(..).flatten()` on `Iterator`
2-
--> tests/ui/map_flatten_fixable.rs:17:47
2+
--> tests/ui/map_flatten_fixable.rs:16:47
33
|
44
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)`
@@ -8,43 +8,43 @@ LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().coll
88
= help: to override `-D warnings` add `#[allow(clippy::map_flatten)]`
99

1010
error: called `map(..).flatten()` on `Iterator`
11-
--> tests/ui/map_flatten_fixable.rs:19:47
11+
--> tests/ui/map_flatten_fixable.rs:18:47
1212
|
1313
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)`
1515

1616
error: called `map(..).flatten()` on `Iterator`
17-
--> tests/ui/map_flatten_fixable.rs:21:47
17+
--> tests/ui/map_flatten_fixable.rs:20:47
1818
|
1919
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)`
2121

2222
error: called `map(..).flatten()` on `Iterator`
23-
--> tests/ui/map_flatten_fixable.rs:23:47
23+
--> tests/ui/map_flatten_fixable.rs:22:47
2424
|
2525
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))`
2727

2828
error: called `map(..).flatten()` on `Iterator`
29-
--> tests/ui/map_flatten_fixable.rs:27:47
29+
--> tests/ui/map_flatten_fixable.rs:26:47
3030
|
3131
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
3232
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)`
3333

3434
error: called `map(..).flatten()` on `Option`
35-
--> tests/ui/map_flatten_fixable.rs:31:40
35+
--> tests/ui/map_flatten_fixable.rs:30:40
3636
|
3737
LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();
3838
| ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
3939

4040
error: called `map(..).flatten()` on `Result`
41-
--> tests/ui/map_flatten_fixable.rs:35:42
41+
--> tests/ui/map_flatten_fixable.rs:34:42
4242
|
4343
LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();
4444
| ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
4545

4646
error: called `map(..).flatten()` on `Iterator`
47-
--> tests/ui/map_flatten_fixable.rs:45:10
47+
--> tests/ui/map_flatten_fixable.rs:44:10
4848
|
4949
LL | .map(|n| match n {
5050
| __________^
@@ -74,7 +74,7 @@ LL ~ });
7474
|
7575

7676
error: called `map(..).flatten()` on `Option`
77-
--> tests/ui/map_flatten_fixable.rs:66:10
77+
--> tests/ui/map_flatten_fixable.rs:65:10
7878
|
7979
LL | .map(|_| {
8080
| __________^

0 commit comments

Comments
 (0)