Skip to content

Commit

Permalink
Rollup merge of rust-lang#49255 - cramertj:stable-impl-trait, r=nikom…
Browse files Browse the repository at this point in the history
…atsakis

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).
  • Loading branch information
kennytm committed Mar 24, 2018
2 parents 0acfcb8 + d818194 commit 6560452
Show file tree
Hide file tree
Showing 82 changed files with 65 additions and 300 deletions.

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
4 changes: 0 additions & 4 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
14 changes: 0 additions & 14 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,16 +961,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 @@ -989,13 +982,6 @@ impl<'a> LoweringContext<'a> {
}, lifetimes)
},
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)]
#![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))]
#![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 @@ -567,6 +561,10 @@ declare_features! (
(accepted, dotdoteq_in_patterns, "1.26.0", Some(28237), None),
// Termination trait in main (RFC 1937)
(accepted, termination_trait, "1.26.0", Some(43301), 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

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

#![feature(conservative_impl_trait)]

trait Quux {}

fn foo() -> impl Quux {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(conservative_impl_trait)]

use std::fmt::Debug;

fn elided(x: &i32) -> impl Copy { x }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(conservative_impl_trait)]

use std::fmt::Debug;

trait MultiRegionTrait<'a, 'b> {}
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/impl-trait/no-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(conservative_impl_trait)]

fn f() -> impl 'static {} //~ ERROR at least one trait must be specified

fn main() {}
2 changes: 0 additions & 2 deletions src/test/compile-fail/impl-trait/type_parameters_captured.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(conservative_impl_trait)]

use std::fmt::Debug;

trait Any {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/impl-trait/where-allowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

// Allowed
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/issue-32995-2.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(conservative_impl_trait)]
#![allow(unused)]

fn main() {
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/issue-35668.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(conservative_impl_trait)]

fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> {
a.iter().map(|a| a*a)
//~^ ERROR binary operation `*` cannot be applied to type `&T`
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-36379.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(conservative_impl_trait, rustc_attrs)]
#![feature(rustc_attrs)]

fn _test() -> impl Default { }

Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/private-inferred-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

#![feature(associated_consts)]
#![feature(conservative_impl_trait)]
#![feature(decl_macro)]
#![allow(private_in_public)]

Expand Down
Loading

0 comments on commit 6560452

Please sign in to comment.