diff --git a/src/doc/unstable-book/src/language-features/self-in-typedefs.md b/src/doc/unstable-book/src/language-features/self-in-typedefs.md deleted file mode 100644 index 2416e85c17d1f..0000000000000 --- a/src/doc/unstable-book/src/language-features/self-in-typedefs.md +++ /dev/null @@ -1,24 +0,0 @@ -# `self_in_typedefs` - -The tracking issue for this feature is: [#49303] - -[#49303]: https://github.com/rust-lang/rust/issues/49303 - ------------------------- - -The `self_in_typedefs` feature gate lets you use the special `Self` identifier -in `struct`, `enum`, and `union` type definitions. - -A simple example is: - -```rust -#![feature(self_in_typedefs)] - -enum List -where - Self: PartialOrd // can write `Self` instead of `List` -{ - Nil, - Cons(T, Box) // likewise here -} -``` diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c1d4643c2403e..fdac1e3b81652 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2373,13 +2373,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { self.with_current_self_item(item, |this| { this.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| { let item_def_id = this.definitions.local_def_id(item.id); - if this.session.features_untracked().self_in_typedefs { - this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| { - visit::walk_item(this, item); - }); - } else { + this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| { visit::walk_item(this, item); - } + }); }); }); } @@ -3185,16 +3181,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { if is_self_type(path, ns) { __diagnostic_used!(E0411); err.code(DiagnosticId::Error("E0411".into())); - let available_in = if this.session.features_untracked().self_in_typedefs { - "impls, traits, and type definitions" - } else { - "traits and impls" - }; - err.span_label(span, format!("`Self` is only available in {}", available_in)); - if this.current_self_item.is_some() && nightly_options::is_nightly_build() { - err.help("add #![feature(self_in_typedefs)] to the crate attributes \ - to enable"); - } + err.span_label(span, format!("`Self` is only available in impls, traits, \ + and type definitions")); return (err, Vec::new()); } if is_self_value(path, ns) { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index d0c4d1c7dce0a..1ced452e45866 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -462,9 +462,6 @@ declare_features! ( // Allows `use x::y;` to resolve through `self::x`, not just `::x` (active, uniform_paths, "1.30.0", Some(53130), None), - // Allows `Self` in type definitions - (active, self_in_typedefs, "1.30.0", Some(49303), None), - // Allows unsized rvalues at arguments and parameters (active, unsized_locals, "1.30.0", Some(48055), None), @@ -675,21 +672,23 @@ declare_features! ( (accepted, extern_prelude, "1.30.0", Some(44660), None), // Parentheses in patterns (accepted, pattern_parentheses, "1.31.0", Some(51087), None), - // Allows the definition of `const fn` functions. + // Allows the definition of `const fn` functions (accepted, min_const_fn, "1.31.0", Some(53555), None), // Scoped lints (accepted, tool_lints, "1.31.0", Some(44690), None), // impl Iterator for &mut Iterator // impl Debug for Foo<'_> (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None), - // `extern crate foo as bar;` puts `bar` into extern prelude. + // `extern crate foo as bar;` puts `bar` into extern prelude (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None), // Allows use of the :literal macro fragment specifier (RFC 1576) (accepted, macro_literal_matcher, "1.31.0", Some(35625), None), // Use `?` as the Kleene "at most one" operator (accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None), - // Self struct constructor (RFC 2302) + // `Self` struct constructor (RFC 2302) (accepted, self_struct_ctor, "1.32.0", Some(51994), None), + // `Self` in type definitions (RFC 2300) + (accepted, self_in_typedefs, "1.32.0", Some(49303), None), ); // If you change this, please modify `src/doc/unstable-book` as well. You must diff --git a/src/test/run-pass/self/self-in-typedefs.rs b/src/test/run-pass/self/self-in-typedefs.rs index 92eccb47e1894..84a7e18f91ad2 100644 --- a/src/test/run-pass/self/self-in-typedefs.rs +++ b/src/test/run-pass/self/self-in-typedefs.rs @@ -9,12 +9,11 @@ // except according to those terms. // run-pass -#![allow(unions_with_drop_fields)] -#![feature(self_in_typedefs)] #![feature(untagged_unions)] #![allow(dead_code)] +#![allow(unions_with_drop_fields)] enum A<'a, T: 'a> where diff --git a/src/test/ui/error-codes/E0411.stderr b/src/test/ui/error-codes/E0411.stderr index a5f2e3a7b93de..4e85f651b5533 100644 --- a/src/test/ui/error-codes/E0411.stderr +++ b/src/test/ui/error-codes/E0411.stderr @@ -2,7 +2,7 @@ error[E0411]: cannot find type `Self` in this scope --> $DIR/E0411.rs:12:6 | LL | ::foo; //~ ERROR E0411 - | ^^^^ `Self` is only available in traits and impls + | ^^^^ `Self` is only available in impls, traits, and type definitions error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs b/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs deleted file mode 100644 index 4b476a0a645b1..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum StackList<'a, T: 'a> { - Nil, - Cons(T, &'a Self) - //~^ ERROR cannot find type `Self` in this scope - //~| `Self` is only available in traits and impls -} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr b/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr deleted file mode 100644 index ab04953f3e50c..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0411]: cannot find type `Self` in this scope - --> $DIR/feature-gate-self_in_typedefs.rs:13:17 - | -LL | Cons(T, &'a Self) - | ^^^^ `Self` is only available in traits and impls - | - = help: add #![feature(self_in_typedefs)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0411`. diff --git a/src/test/ui/issues/issue-36638.rs b/src/test/ui/issues/issue-36638.rs index 5e43536ef3f90..acb501c29fceb 100644 --- a/src/test/ui/issues/issue-36638.rs +++ b/src/test/ui/issues/issue-36638.rs @@ -12,6 +12,7 @@ struct Foo(Self); //~^ ERROR expected identifier, found keyword `Self` +//~^^ ERROR E0392 trait Bar {} //~^ ERROR expected identifier, found keyword `Self` diff --git a/src/test/ui/issues/issue-36638.stderr b/src/test/ui/issues/issue-36638.stderr index d111fb469bfe1..155eb170b091f 100644 --- a/src/test/ui/issues/issue-36638.stderr +++ b/src/test/ui/issues/issue-36638.stderr @@ -5,10 +5,19 @@ LL | struct Foo(Self); | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/issue-36638.rs:16:11 + --> $DIR/issue-36638.rs:17:11 | LL | trait Bar {} | ^^^^ expected identifier, found keyword -error: aborting due to 2 previous errors +error[E0392]: parameter `Self` is never used + --> $DIR/issue-36638.rs:13:12 + | +LL | struct Foo(Self); + | ^^^^ unused type parameter + | + = help: consider removing `Self` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/resolve/issue-24968.stderr b/src/test/ui/resolve/issue-24968.stderr index 9a1d5ea170e65..cfb2034050485 100644 --- a/src/test/ui/resolve/issue-24968.stderr +++ b/src/test/ui/resolve/issue-24968.stderr @@ -2,7 +2,7 @@ error[E0411]: cannot find type `Self` in this scope --> $DIR/issue-24968.rs:11:11 | LL | fn foo(_: Self) { - | ^^^^ `Self` is only available in traits and impls + | ^^^^ `Self` is only available in impls, traits, and type definitions error: aborting due to previous error diff --git a/src/test/ui/resolve/resolve-self-in-impl-2.stderr b/src/test/ui/resolve/resolve-self-in-impl-2.stderr index 183b9b66327b4..b3a8261bcfc74 100644 --- a/src/test/ui/resolve/resolve-self-in-impl-2.stderr +++ b/src/test/ui/resolve/resolve-self-in-impl-2.stderr @@ -2,7 +2,7 @@ error[E0411]: expected trait, found self type `Self` --> $DIR/resolve-self-in-impl-2.rs:14:6 | LL | impl Self for S {} //~ ERROR expected trait, found self type `Self` - | ^^^^ `Self` is only available in traits and impls + | ^^^^ `Self` is only available in impls, traits, and type definitions error[E0405]: cannot find trait `N` in `Self` --> $DIR/resolve-self-in-impl-2.rs:15:12