Skip to content

Commit 5e4603f

Browse files
committed
Auto merge of #49255 - cramertj:stable-impl-trait, r=nikomatsakis
Stabilize impl Trait Blocked on: - [x] #49041 and - [ ] completion of FCP in #34511 (comment) (3 days from now). I have not yet done any docs work for this-- I probably won't get to it until this weekend (might be a project for the flight to the all-hands).
2 parents 184156e + 0f5b52e commit 5e4603f

File tree

88 files changed

+72
-343
lines changed

Some content is hidden

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

88 files changed

+72
-343
lines changed

src/Cargo.lock

+3-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/doc/unstable-book/src/language-features/conservative-impl-trait.md

-66
This file was deleted.

src/doc/unstable-book/src/language-features/universal-impl-trait.md

-32
This file was deleted.

src/libcore/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
2828
#![feature(iterator_try_fold)]
2929
#![feature(iterator_flatten)]
30-
#![feature(conservative_impl_trait)]
30+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
3131
#![feature(iter_rfind)]
3232
#![feature(iter_rfold)]
3333
#![feature(iterator_repeat_with)]

src/librustc/diagnostics.rs

-8
Original file line numberDiff line numberDiff line change
@@ -1789,8 +1789,6 @@ allowed as function return types.
17891789
Erroneous code example:
17901790
17911791
```compile_fail,E0562
1792-
#![feature(conservative_impl_trait)]
1793-
17941792
fn main() {
17951793
let count_to_ten: impl Iterator<Item=usize> = 0..10;
17961794
// error: `impl Trait` not allowed outside of function and inherent method
@@ -1804,8 +1802,6 @@ fn main() {
18041802
Make sure `impl Trait` only appears in return-type position.
18051803
18061804
```
1807-
#![feature(conservative_impl_trait)]
1808-
18091805
fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
18101806
0..n
18111807
}
@@ -2081,8 +2077,6 @@ appear within the `impl Trait` itself.
20812077
Erroneous code example:
20822078
20832079
```compile-fail,E0909
2084-
#![feature(conservative_impl_trait)]
2085-
20862080
use std::cell::Cell;
20872081
20882082
trait Trait<'a> { }
@@ -2109,8 +2103,6 @@ type. For example, changing the return type to `impl Trait<'y> + 'x`
21092103
would work:
21102104
21112105
```
2112-
#![feature(conservative_impl_trait)]
2113-
21142106
use std::cell::Cell;
21152107
21162108
trait Trait<'a> { }

src/librustc/hir/lowering.rs

-22
Original file line numberDiff line numberDiff line change
@@ -1108,20 +1108,9 @@ impl<'a> LoweringContext<'a> {
11081108
hir::TyTraitObject(bounds, lifetime_bound)
11091109
}
11101110
TyKind::ImplTrait(ref bounds) => {
1111-
use syntax::feature_gate::{emit_feature_err, GateIssue};
11121111
let span = t.span;
11131112
match itctx {
11141113
ImplTraitContext::Existential => {
1115-
let has_feature = self.sess.features_untracked().conservative_impl_trait;
1116-
if !t.span.allows_unstable() && !has_feature {
1117-
emit_feature_err(
1118-
&self.sess.parse_sess,
1119-
"conservative_impl_trait",
1120-
t.span,
1121-
GateIssue::Language,
1122-
"`impl Trait` in return position is experimental",
1123-
);
1124-
}
11251114
let def_index = self.resolver.definitions().opt_def_index(t.id).unwrap();
11261115
let hir_bounds = self.lower_bounds(bounds, itctx);
11271116
let (lifetimes, lifetime_defs) =
@@ -1143,17 +1132,6 @@ impl<'a> LoweringContext<'a> {
11431132
)
11441133
}
11451134
ImplTraitContext::Universal(def_id) => {
1146-
let has_feature = self.sess.features_untracked().universal_impl_trait;
1147-
if !t.span.allows_unstable() && !has_feature {
1148-
emit_feature_err(
1149-
&self.sess.parse_sess,
1150-
"universal_impl_trait",
1151-
t.span,
1152-
GateIssue::Language,
1153-
"`impl Trait` in argument position is experimental",
1154-
);
1155-
}
1156-
11571135
let def_node_id = self.next_id().node_id;
11581136

11591137
// Add a definition for the in-band TyParam

src/librustc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#![feature(box_patterns)]
4545
#![feature(box_syntax)]
46-
#![feature(conservative_impl_trait)]
46+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
4747
#![feature(const_fn)]
4848
#![cfg_attr(stage0, feature(copy_closures, clone_closures))]
4949
#![feature(core_intrinsics)]
@@ -70,7 +70,7 @@
7070
#![feature(specialization)]
7171
#![feature(unboxed_closures)]
7272
#![feature(underscore_lifetimes)]
73-
#![feature(universal_impl_trait)]
73+
#![cfg_attr(stage0, feature(universal_impl_trait))]
7474
#![feature(trace_macros)]
7575
#![feature(trusted_len)]
7676
#![feature(catch_expr)]

src/librustc_data_structures/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
#![feature(unsize)]
2929
#![feature(i128_type)]
3030
#![feature(i128)]
31-
#![feature(conservative_impl_trait)]
31+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
3232
#![feature(specialization)]
3333
#![feature(optin_builtin_traits)]
3434
#![feature(underscore_lifetimes)]
3535
#![feature(macro_vis_matcher)]
3636
#![feature(allow_internal_unstable)]
37-
#![feature(universal_impl_trait)]
37+
#![cfg_attr(stage0, feature(universal_impl_trait))]
3838

3939
#![cfg_attr(unix, feature(libc))]
4040
#![cfg_attr(test, feature(test))]

src/librustc_errors/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![allow(unused_attributes)]
1818
#![feature(range_contains)]
1919
#![cfg_attr(unix, feature(libc))]
20-
#![feature(conservative_impl_trait)]
20+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
2121
#![feature(i128_type)]
2222
#![feature(optin_builtin_traits)]
2323

src/librustc_incremental/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
html_root_url = "https://doc.rust-lang.org/nightly/")]
1616
#![deny(warnings)]
1717

18-
#![feature(conservative_impl_trait)]
18+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
1919
#![feature(fs_read_write)]
2020
#![feature(i128_type)]
2121
#![cfg_attr(stage0, feature(inclusive_range_syntax))]

src/librustc_metadata/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#![deny(warnings)]
1515

1616
#![feature(box_patterns)]
17-
#![feature(conservative_impl_trait)]
17+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
1818
#![feature(fs_read_write)]
1919
#![feature(i128_type)]
2020
#![feature(libc)]

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2121
#![feature(box_patterns)]
2222
#![feature(box_syntax)]
2323
#![feature(catch_expr)]
24-
#![feature(conservative_impl_trait)]
24+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
2525
#![feature(const_fn)]
2626
#![feature(core_intrinsics)]
2727
#![feature(decl_macro)]

src/librustc_trans/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#![feature(quote)]
3232
#![feature(rustc_diagnostic_macros)]
3333
#![cfg_attr(stage0, feature(slice_patterns))]
34-
#![feature(conservative_impl_trait)]
34+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
3535
#![feature(optin_builtin_traits)]
3636
#![feature(inclusive_range_fields)]
3737

src/librustc_trans_utils/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#![feature(i128_type)]
2525
#![feature(quote)]
2626
#![feature(rustc_diagnostic_macros)]
27-
#![feature(conservative_impl_trait)]
27+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
2828

2929
extern crate ar;
3030
extern crate flate2;

src/librustc_typeck/diagnostics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4600,7 +4600,6 @@ This error indicates that there is a mismatch between generic parameters and
46004600
impl Trait parameters in a trait declaration versus its impl.
46014601
46024602
```compile_fail,E0643
4603-
#![feature(universal_impl_trait)]
46044603
trait Foo {
46054604
fn foo(&self, _: &impl Iterator);
46064605
}

src/librustc_typeck/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ This API is completely unstable and subject to change.
7575
#![cfg_attr(stage0, feature(advanced_slice_patterns))]
7676
#![feature(box_patterns)]
7777
#![feature(box_syntax)]
78-
#![feature(conservative_impl_trait)]
78+
#![cfg_attr(stage0, feature(conservative_impl_trait))]
7979
#![cfg_attr(stage0, feature(copy_closures, clone_closures))]
8080
#![feature(crate_visibility_modifier)]
8181
#![feature(from_ref)]

src/libsyntax/feature_gate.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,6 @@ declare_features! (
276276
// Allows cfg(target_has_atomic = "...").
277277
(active, cfg_target_has_atomic, "1.9.0", Some(32976), None),
278278

279-
// Allows `impl Trait` in function return types.
280-
(active, conservative_impl_trait, "1.12.0", Some(34511), None),
281-
282-
// Allows `impl Trait` in function arguments.
283-
(active, universal_impl_trait, "1.23.0", Some(34511), None),
284-
285279
// Allows exhaustive pattern matching on types that contain uninhabited types.
286280
(active, exhaustive_patterns, "1.13.0", None, None),
287281

@@ -566,6 +560,10 @@ declare_features! (
566560
// Copy/Clone closures (RFC 2132)
567561
(accepted, clone_closures, "1.26.0", Some(44490), None),
568562
(accepted, copy_closures, "1.26.0", Some(44490), None),
563+
// Allows `impl Trait` in function arguments.
564+
(accepted, universal_impl_trait, "1.26.0", Some(34511), None),
565+
// Allows `impl Trait` in function return types.
566+
(accepted, conservative_impl_trait, "1.26.0", Some(34511), None),
569567
);
570568

571569
// If you change this, please modify src/doc/unstable-book as well. You must

src/test/compile-fail/conservative_impl_trait.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// #39872, #39553
1212

13-
#![feature(conservative_impl_trait)]
1413
fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
1514
//~^ ERROR the trait bound `(): std::iter::Iterator` is not satisfied [E0277]
1615
}

src/test/compile-fail/impl-trait/impl-generic-mismatch-ab.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(universal_impl_trait)]
1211
use std::fmt::Debug;
1312

1413
trait Foo {

src/test/compile-fail/impl-trait/impl-generic-mismatch.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(universal_impl_trait)]
1211
use std::fmt::Debug;
1312

1413
trait Foo {

0 commit comments

Comments
 (0)