Skip to content

Commit 8b36d9a

Browse files
authored
Rollup merge of rust-lang#49968 - christianpoveda:stabilize_dyn, r=nikomatsakis
Stabilize dyn trait This PR stabilizes RFC 2113. I followed the [stabilization guide](https://forge.rust-lang.org/stabilization-guide.html). Related issue: rust-lang#49218
2 parents a18e7a6 + b5c7cbf commit 8b36d9a

File tree

50 files changed

+155
-214
lines changed

Some content is hidden

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

50 files changed

+155
-214
lines changed

src/librustc/hir/lowering.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4107,15 +4107,13 @@ impl<'a> LoweringContext<'a> {
41074107
}
41084108

41094109
fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
4110-
if self.sess.features_untracked().dyn_trait {
4111-
self.sess.buffer_lint_with_diagnostic(
4112-
builtin::BARE_TRAIT_OBJECT,
4113-
id,
4114-
span,
4115-
"trait objects without an explicit `dyn` are deprecated",
4116-
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
4117-
)
4118-
}
4110+
self.sess.buffer_lint_with_diagnostic(
4111+
builtin::BARE_TRAIT_OBJECT,
4112+
id,
4113+
span,
4114+
"trait objects without an explicit `dyn` are deprecated",
4115+
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
4116+
)
41194117
}
41204118

41214119
fn wrap_in_try_constructor(

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#![feature(const_fn)]
4646
#![feature(core_intrinsics)]
4747
#![feature(drain_filter)]
48-
#![feature(dyn_trait)]
4948
#![feature(entry_or_default)]
49+
#![cfg_attr(stage0, feature(dyn_trait))]
5050
#![feature(from_ref)]
5151
#![feature(fs_read_write)]
5252
#![cfg_attr(windows, feature(libc))]

src/librustc_mir/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2424
#![feature(const_fn)]
2525
#![feature(core_intrinsics)]
2626
#![feature(decl_macro)]
27-
#![feature(dyn_trait)]
27+
#![cfg_attr(stage0, feature(dyn_trait))]
2828
#![feature(fs_read_write)]
2929
#![feature(macro_vis_matcher)]
3030
#![feature(exhaustive_patterns)]

src/librustc_typeck/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ This API is completely unstable and subject to change.
7171

7272
#![allow(non_camel_case_types)]
7373

74+
#![cfg_attr(stage0, feature(dyn_trait))]
75+
7476
#![feature(box_patterns)]
7577
#![feature(box_syntax)]
7678
#![feature(crate_visibility_modifier)]
@@ -81,7 +83,6 @@ This API is completely unstable and subject to change.
8183
#![feature(rustc_diagnostic_macros)]
8284
#![feature(slice_patterns)]
8385
#![feature(slice_sort_by_cached_key)]
84-
#![feature(dyn_trait)]
8586
#![feature(never_type)]
8687

8788
#[macro_use] extern crate log;

src/librustdoc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
html_root_url = "https://doc.rust-lang.org/nightly/",
1414
html_playground_url = "https://play.rust-lang.org/")]
1515

16+
#![cfg_attr(stage0, feature(dyn_trait))]
17+
1618
#![feature(ascii_ctype)]
1719
#![feature(rustc_private)]
1820
#![feature(box_patterns)]
@@ -23,7 +25,6 @@
2325
#![feature(test)]
2426
#![feature(vec_remove_item)]
2527
#![feature(entry_and_modify)]
26-
#![feature(dyn_trait)]
2728

2829
extern crate arena;
2930
extern crate getopts;

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ declare_features! (
375375
// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
376376
(active, non_exhaustive, "1.22.0", Some(44109), None),
377377

378-
// Trait object syntax with `dyn` prefix
379-
(active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),
380-
381378
// `crate` as visibility modifier, synonymous to `pub(crate)`
382379
(active, crate_visibility_modifier, "1.23.0", Some(45388), Some(Edition::Edition2018)),
383380

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

597596
// If you change this, please modify src/doc/unstable-book as well. You must
@@ -1657,10 +1656,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16571656
gate_feature_post!(&self, never_type, ty.span,
16581657
"The `!` type is experimental");
16591658
}
1660-
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
1661-
gate_feature_post!(&self, dyn_trait, ty.span,
1662-
"`dyn Trait` syntax is unstable");
1663-
}
16641659
_ => {}
16651660
}
16661661
visit::walk_ty(self, ty)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

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

1615
// Allowed

src/test/compile-fail/mir_check_cast_unsize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// compile-flags: -Z borrowck=mir
1212

1313
#![allow(dead_code)]
14-
#![feature(dyn_trait)]
1514

1615
use std::fmt::Debug;
1716

src/test/compile-fail/trait-bounds-not-on-struct.rs

Lines changed: 0 additions & 1 deletion
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(dyn_trait)]
1211
#![allow(bare_trait_object)]
1312

1413
struct Foo;

src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// compile-pass
1212
// failure-status: 1
1313

14-
#![feature(dyn_trait)]
15-
1614
use std::error::Error;
1715
use std::io;
1816

0 commit comments

Comments
 (0)