Skip to content

Commit 6560452

Browse files
committed
Rollup merge of rust-lang#49255 - cramertj:stable-impl-trait, r=nikomatsakis
Stabilize impl Trait Blocked on: - [x] rust-lang#49041 and - [ ] completion of FCP in rust-lang#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 0acfcb8 + d818194 commit 6560452

File tree

82 files changed

+65
-300
lines changed

Some content is hidden

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

82 files changed

+65
-300
lines changed

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

-4
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
}

src/librustc/hir/lowering.rs

-14
Original file line numberDiff line numberDiff line change
@@ -961,16 +961,9 @@ impl<'a> LoweringContext<'a> {
961961
hir::TyTraitObject(bounds, lifetime_bound)
962962
}
963963
TyKind::ImplTrait(ref bounds) => {
964-
use syntax::feature_gate::{emit_feature_err, GateIssue};
965964
let span = t.span;
966965
match itctx {
967966
ImplTraitContext::Existential => {
968-
let has_feature = self.sess.features_untracked().conservative_impl_trait;
969-
if !t.span.allows_unstable() && !has_feature {
970-
emit_feature_err(&self.sess.parse_sess, "conservative_impl_trait",
971-
t.span, GateIssue::Language,
972-
"`impl Trait` in return position is experimental");
973-
}
974967
let def_index = self.resolver.definitions().opt_def_index(t.id).unwrap();
975968
let hir_bounds = self.lower_bounds(bounds, itctx);
976969
let (lifetimes, lifetime_defs) =
@@ -989,13 +982,6 @@ impl<'a> LoweringContext<'a> {
989982
}, lifetimes)
990983
},
991984
ImplTraitContext::Universal(def_id) => {
992-
let has_feature = self.sess.features_untracked().universal_impl_trait;
993-
if !t.span.allows_unstable() && !has_feature {
994-
emit_feature_err(&self.sess.parse_sess, "universal_impl_trait",
995-
t.span, GateIssue::Language,
996-
"`impl Trait` in argument position is experimental");
997-
}
998-
999985
let def_node_id = self.next_id().node_id;
1000986

1001987
// 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
#![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
#![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

@@ -567,6 +561,10 @@ declare_features! (
567561
(accepted, dotdoteq_in_patterns, "1.26.0", Some(28237), None),
568562
// Termination trait in main (RFC 1937)
569563
(accepted, termination_trait, "1.26.0", Some(43301), None),
564+
// Allows `impl Trait` in function arguments.
565+
(accepted, universal_impl_trait, "1.26.0", Some(34511), None),
566+
// Allows `impl Trait` in function return types.
567+
(accepted, conservative_impl_trait, "1.26.0", Some(34511), None),
570568
);
571569

572570
// 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 {

src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
// error-pattern:overflow evaluating the requirement `impl Quux`
1717

18-
#![feature(conservative_impl_trait)]
19-
2018
trait Quux {}
2119

2220
fn foo() -> impl Quux {

src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs

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

11-
#![feature(conservative_impl_trait)]
12-
1311
use std::fmt::Debug;
1412

1513
fn elided(x: &i32) -> impl Copy { x }

src/test/compile-fail/impl-trait/needs_least_region_or_bound.rs

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

11-
#![feature(conservative_impl_trait)]
12-
1311
use std::fmt::Debug;
1412

1513
trait MultiRegionTrait<'a, 'b> {}

src/test/compile-fail/impl-trait/no-trait.rs

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

11-
#![feature(conservative_impl_trait)]
12-
1311
fn f() -> impl 'static {} //~ ERROR at least one trait must be specified
1412

1513
fn main() {}

src/test/compile-fail/impl-trait/type_parameters_captured.rs

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

11-
#![feature(conservative_impl_trait)]
12-
1311
use std::fmt::Debug;
1412

1513
trait Any {}

src/test/compile-fail/impl-trait/where-allowed.rs

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

1111
//! A simple test for testing many permutations of allowedness of
1212
//! impl Trait
13-
#![feature(conservative_impl_trait, universal_impl_trait, dyn_trait)]
13+
#![feature(dyn_trait)]
1414
use std::fmt::Debug;
1515

1616
// Allowed

src/test/compile-fail/issue-32995-2.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(conservative_impl_trait)]
1211
#![allow(unused)]
1312

1413
fn main() {

src/test/compile-fail/issue-35668.rs

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

11-
#![feature(conservative_impl_trait)]
12-
1311
fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> {
1412
a.iter().map(|a| a*a)
1513
//~^ ERROR binary operation `*` cannot be applied to type `&T`

src/test/compile-fail/issue-36379.rs

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

11-
#![feature(conservative_impl_trait, rustc_attrs)]
11+
#![feature(rustc_attrs)]
1212

1313
fn _test() -> impl Default { }
1414

src/test/compile-fail/private-inferred-type.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![feature(associated_consts)]
12-
#![feature(conservative_impl_trait)]
1312
#![feature(decl_macro)]
1413
#![allow(private_in_public)]
1514

0 commit comments

Comments
 (0)