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 dyn trait #49968

Merged
merged 9 commits into from
Apr 27, 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
16 changes: 7 additions & 9 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4107,15 +4107,13 @@ impl<'a> LoweringContext<'a> {
}

fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
if self.sess.features_untracked().dyn_trait {
self.sess.buffer_lint_with_diagnostic(
builtin::BARE_TRAIT_OBJECT,
id,
span,
"trait objects without an explicit `dyn` are deprecated",
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
)
}
self.sess.buffer_lint_with_diagnostic(
builtin::BARE_TRAIT_OBJECT,
id,
span,
"trait objects without an explicit `dyn` are deprecated",
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
)
}

fn wrap_in_try_constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![feature(dyn_trait)]
#![feature(entry_or_default)]
#![cfg_attr(stage0, feature(dyn_trait))]
#![feature(from_ref)]
#![feature(fs_read_write)]
#![cfg_attr(windows, 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 @@ -24,7 +24,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(decl_macro)]
#![feature(dyn_trait)]
#![cfg_attr(stage0, feature(dyn_trait))]
#![feature(fs_read_write)]
#![feature(macro_vis_matcher)]
#![feature(exhaustive_patterns)]
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ This API is completely unstable and subject to change.

#![allow(non_camel_case_types)]

#![cfg_attr(stage0, feature(dyn_trait))]

#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)]
Expand All @@ -81,7 +83,6 @@ This API is completely unstable and subject to change.
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)]
#![feature(dyn_trait)]
#![feature(never_type)]

#[macro_use] extern crate log;
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
html_root_url = "https://doc.rust-lang.org/nightly/",
html_playground_url = "https://play.rust-lang.org/")]

#![cfg_attr(stage0, feature(dyn_trait))]

#![feature(ascii_ctype)]
#![feature(rustc_private)]
#![feature(box_patterns)]
Expand All @@ -23,7 +25,6 @@
#![feature(test)]
#![feature(vec_remove_item)]
#![feature(entry_and_modify)]
#![feature(dyn_trait)]

extern crate arena;
extern crate getopts;
Expand Down
9 changes: 2 additions & 7 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ declare_features! (
// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
(active, non_exhaustive, "1.22.0", Some(44109), None),

// Trait object syntax with `dyn` prefix
(active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),

// `crate` as visibility modifier, synonymous to `pub(crate)`
(active, crate_visibility_modifier, "1.23.0", Some(45388), Some(Edition::Edition2018)),

Expand Down Expand Up @@ -592,6 +589,8 @@ declare_features! (
(accepted, cfg_target_feature, "1.27.0", Some(29717), None),
// Allows #[target_feature(...)]
(accepted, target_feature, "1.27.0", None, None),
// Trait object syntax with `dyn` prefix
(accepted, dyn_trait, "1.27.0", Some(44662), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1657,10 +1656,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
gate_feature_post!(&self, never_type, ty.span,
"The `!` type is experimental");
}
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
gate_feature_post!(&self, dyn_trait, ty.span,
"`dyn Trait` syntax is unstable");
}
_ => {}
}
visit::walk_ty(self, ty)
Expand Down
1 change: 0 additions & 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,6 @@

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

// Allowed
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/mir_check_cast_unsize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// compile-flags: -Z borrowck=mir

#![allow(dead_code)]
#![feature(dyn_trait)]

use std::fmt::Debug;

Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/trait-bounds-not-on-struct.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(dyn_trait)]
#![allow(bare_trait_object)]

struct Foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// compile-pass
// failure-status: 1

#![feature(dyn_trait)]

use std::error::Error;
use std::io;

Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/dyn-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// ignore-pretty `dyn ::foo` parses differently in the current edition

#![feature(dyn_trait)]

use std::fmt::Display;

static BYTE: u8 = 33;
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(dyn_trait)]

use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
Expand Down
14 changes: 0 additions & 14 deletions src/test/ui/feature-gate-dyn-trait.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/feature-gate-dyn-trait.stderr

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/ui/impl_trait_projections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(dyn_trait)]

use std::fmt::Debug;
use std::option;

Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/impl_trait_projections.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
error[E0667]: `impl Trait` is not allowed in path parameters
--> $DIR/impl_trait_projections.rs:23:51
--> $DIR/impl_trait_projections.rs:21:51
|
LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item {
| ^^^^^^^^^^^^^

error[E0667]: `impl Trait` is not allowed in path parameters
--> $DIR/impl_trait_projections.rs:30:9
--> $DIR/impl_trait_projections.rs:28:9
|
LL | -> <impl Iterator as Iterator>::Item
| ^^^^^^^^^^^^^

error[E0667]: `impl Trait` is not allowed in path parameters
--> $DIR/impl_trait_projections.rs:37:27
--> $DIR/impl_trait_projections.rs:35:27
|
LL | -> <::std::ops::Range<impl Debug> as Iterator>::Item
| ^^^^^^^^^^

error[E0667]: `impl Trait` is not allowed in path parameters
--> $DIR/impl_trait_projections.rs:44:29
--> $DIR/impl_trait_projections.rs:42:29
|
LL | -> <dyn Iterator<Item = impl Debug> as Iterator>::Item
| ^^^^^^^^^^

error[E0223]: ambiguous associated type
--> $DIR/impl_trait_projections.rs:23:50
--> $DIR/impl_trait_projections.rs:21:50
|
LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item {
| ^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/in-band-lifetimes/impl/dyn-trait.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
warning: not reporting region error due to nll
--> $DIR/dyn-trait.rs:33:16
--> $DIR/dyn-trait.rs:32:16
|
LL | static_val(x); //~ ERROR cannot infer
| ^

error: free region `'a` does not outlive free region `'static`
--> $DIR/dyn-trait.rs:33:5
--> $DIR/dyn-trait.rs:32:5
|
LL | static_val(x); //~ ERROR cannot infer
| ^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/in-band-lifetimes/impl/dyn-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#![allow(warnings)]

#![feature(dyn_trait)]
#![feature(in_band_lifetimes)]

use std::fmt::Debug;
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/in-band-lifetimes/impl/dyn-trait.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/dyn-trait.rs:33:16
--> $DIR/dyn-trait.rs:32:16
|
LL | static_val(x); //~ ERROR cannot infer
| ^
|
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 32:1...
--> $DIR/dyn-trait.rs:32:1
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 31:1...
--> $DIR/dyn-trait.rs:31:1
|
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// Iterator>::Item`, to be exact).

#![allow(warnings)]
#![feature(dyn_trait)]
#![feature(rustc_attrs)]

trait Anything { }
Expand Down
24 changes: 12 additions & 12 deletions src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
warning: not reporting region error due to nll
--> $DIR/projection-no-regions-closure.rs:36:31
--> $DIR/projection-no-regions-closure.rs:35:31
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^

warning: not reporting region error due to nll
--> $DIR/projection-no-regions-closure.rs:54:31
--> $DIR/projection-no-regions-closure.rs:53:31
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^

note: External requirements
--> $DIR/projection-no-regions-closure.rs:36:23
--> $DIR/projection-no-regions-closure.rs:35:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -26,15 +26,15 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
= note: where <T as std::iter::Iterator>::Item: '_#2r

error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
--> $DIR/projection-no-regions-closure.rs:36:23
--> $DIR/projection-no-regions-closure.rs:35:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...

note: No external requirements
--> $DIR/projection-no-regions-closure.rs:32:1
--> $DIR/projection-no-regions-closure.rs:31:1
|
LL | / fn no_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>
LL | | where
Expand All @@ -51,7 +51,7 @@ LL | | }
]

note: External requirements
--> $DIR/projection-no-regions-closure.rs:46:23
--> $DIR/projection-no-regions-closure.rs:45:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -66,7 +66,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
= note: where <T as std::iter::Iterator>::Item: '_#2r

note: No external requirements
--> $DIR/projection-no-regions-closure.rs:42:1
--> $DIR/projection-no-regions-closure.rs:41:1
|
LL | / fn correct_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>
LL | | where
Expand All @@ -82,7 +82,7 @@ LL | | }
]

note: External requirements
--> $DIR/projection-no-regions-closure.rs:54:23
--> $DIR/projection-no-regions-closure.rs:53:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -98,15 +98,15 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
= note: where <T as std::iter::Iterator>::Item: '_#3r

error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
--> $DIR/projection-no-regions-closure.rs:54:23
--> $DIR/projection-no-regions-closure.rs:53:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...

note: No external requirements
--> $DIR/projection-no-regions-closure.rs:50:1
--> $DIR/projection-no-regions-closure.rs:49:1
|
LL | / fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>
LL | | where
Expand All @@ -124,7 +124,7 @@ LL | | }
]

note: External requirements
--> $DIR/projection-no-regions-closure.rs:65:23
--> $DIR/projection-no-regions-closure.rs:64:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -140,7 +140,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
= note: where <T as std::iter::Iterator>::Item: '_#3r

note: No external requirements
--> $DIR/projection-no-regions-closure.rs:60:1
--> $DIR/projection-no-regions-closure.rs:59:1
|
LL | / fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>
LL | | where
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/nll/ty-outlives/projection-no-regions-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// compile-flags:-Zborrowck=mir -Zverbose

#![allow(warnings)]
#![feature(dyn_trait)]

trait Anything { }

Expand Down
Loading