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

Stabilize impl Trait #49255

Merged
merged 2 commits into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 3 additions & 24 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(iterator_try_fold)]
#![feature(iterator_flatten)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(iter_rfind)]
#![feature(iter_rfold)]
#![feature(iterator_repeat_with)]
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,8 +1789,6 @@ allowed as function return types.
Erroneous code example:

```compile_fail,E0562
#![feature(conservative_impl_trait)]

fn main() {
let count_to_ten: impl Iterator<Item=usize> = 0..10;
// error: `impl Trait` not allowed outside of function and inherent method
Expand All @@ -1804,8 +1802,6 @@ fn main() {
Make sure `impl Trait` only appears in return-type position.

```
#![feature(conservative_impl_trait)]

fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
0..n
}
Expand Down Expand Up @@ -2081,8 +2077,6 @@ appear within the `impl Trait` itself.
Erroneous code example:

```compile-fail,E0909
#![feature(conservative_impl_trait)]

use std::cell::Cell;

trait Trait<'a> { }
Expand All @@ -2109,8 +2103,6 @@ type. For example, changing the return type to `impl Trait<'y> + 'x`
would work:

```
#![feature(conservative_impl_trait)]

use std::cell::Cell;

trait Trait<'a> { }
Expand Down
22 changes: 0 additions & 22 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,20 +1108,9 @@ impl<'a> LoweringContext<'a> {
hir::TyTraitObject(bounds, lifetime_bound)
}
TyKind::ImplTrait(ref bounds) => {
use syntax::feature_gate::{emit_feature_err, GateIssue};
let span = t.span;
match itctx {
ImplTraitContext::Existential => {
let has_feature = self.sess.features_untracked().conservative_impl_trait;
if !t.span.allows_unstable() && !has_feature {
emit_feature_err(
&self.sess.parse_sess,
"conservative_impl_trait",
t.span,
GateIssue::Language,
"`impl Trait` in return position is experimental",
);
}
let def_index = self.resolver.definitions().opt_def_index(t.id).unwrap();
let hir_bounds = self.lower_bounds(bounds, itctx);
let (lifetimes, lifetime_defs) =
Expand All @@ -1143,17 +1132,6 @@ impl<'a> LoweringContext<'a> {
)
}
ImplTraitContext::Universal(def_id) => {
let has_feature = self.sess.features_untracked().universal_impl_trait;
if !t.span.allows_unstable() && !has_feature {
emit_feature_err(
&self.sess.parse_sess,
"universal_impl_trait",
t.span,
GateIssue::Language,
"`impl Trait` in argument position is experimental",
);
}

let def_node_id = self.next_id().node_id;

// Add a definition for the in-band TyParam
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(const_fn)]
#![cfg_attr(stage0, feature(copy_closures, clone_closures))]
#![feature(core_intrinsics)]
Expand All @@ -70,7 +70,7 @@
#![feature(specialization)]
#![feature(unboxed_closures)]
#![feature(underscore_lifetimes)]
#![feature(universal_impl_trait)]
#![cfg_attr(stage0, feature(universal_impl_trait))]
#![feature(trace_macros)]
#![feature(trusted_len)]
#![feature(catch_expr)]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
#![feature(unsize)]
#![feature(i128_type)]
#![feature(i128)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(underscore_lifetimes)]
#![feature(macro_vis_matcher)]
#![feature(allow_internal_unstable)]
#![feature(universal_impl_trait)]
#![cfg_attr(stage0, feature(universal_impl_trait))]

#![cfg_attr(unix, feature(libc))]
#![cfg_attr(test, feature(test))]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#![allow(unused_attributes)]
#![feature(range_contains)]
#![cfg_attr(unix, feature(libc))]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(i128_type)]
#![feature(optin_builtin_traits)]

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(fs_read_write)]
#![feature(i128_type)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#![deny(warnings)]

#![feature(box_patterns)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(fs_read_write)]
#![feature(i128_type)]
#![feature(libc)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(catch_expr)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(decl_macro)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![cfg_attr(stage0, feature(slice_patterns))]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(optin_builtin_traits)]
#![feature(inclusive_range_fields)]

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans_utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#![feature(i128_type)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]

extern crate ar;
extern crate flate2;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4600,7 +4600,6 @@ This error indicates that there is a mismatch between generic parameters and
impl Trait parameters in a trait declaration versus its impl.

```compile_fail,E0643
#![feature(universal_impl_trait)]
trait Foo {
fn foo(&self, _: &impl Iterator);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ This API is completely unstable and subject to change.
#![cfg_attr(stage0, feature(advanced_slice_patterns))]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![cfg_attr(stage0, feature(copy_closures, clone_closures))]
#![feature(crate_visibility_modifier)]
#![feature(from_ref)]
Expand Down
10 changes: 4 additions & 6 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,6 @@ declare_features! (
// Allows cfg(target_has_atomic = "...").
(active, cfg_target_has_atomic, "1.9.0", Some(32976), None),

// Allows `impl Trait` in function return types.
(active, conservative_impl_trait, "1.12.0", Some(34511), None),

// Allows `impl Trait` in function arguments.
(active, universal_impl_trait, "1.23.0", Some(34511), None),

// Allows exhaustive pattern matching on types that contain uninhabited types.
(active, exhaustive_patterns, "1.13.0", None, None),

Expand Down Expand Up @@ -566,6 +560,10 @@ declare_features! (
// Copy/Clone closures (RFC 2132)
(accepted, clone_closures, "1.26.0", Some(44490), None),
(accepted, copy_closures, "1.26.0", Some(44490), None),
// Allows `impl Trait` in function arguments.
(accepted, universal_impl_trait, "1.26.0", Some(34511), None),
// Allows `impl Trait` in function return types.
(accepted, conservative_impl_trait, "1.26.0", Some(34511), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/conservative_impl_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// #39872, #39553

#![feature(conservative_impl_trait)]
fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
//~^ ERROR the trait bound `(): std::iter::Iterator` is not satisfied [E0277]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(universal_impl_trait)]
use std::fmt::Debug;

trait Foo {
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/impl-trait/impl-generic-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(universal_impl_trait)]
use std::fmt::Debug;

trait Foo {
Expand Down
Loading