Stabilize Self and associated types in struct expressions and patterns
This commit is contained in:
parent
249b444efa
commit
5056a43752
@ -3328,16 +3328,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) |
|
Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) |
|
||||||
Def::AssociatedTy(..) | Def::SelfTy(..) => {
|
Def::AssociatedTy(..) | Def::SelfTy(..) => {
|
||||||
match def {
|
|
||||||
Def::AssociatedTy(..) | Def::SelfTy(..)
|
|
||||||
if !self.tcx.sess.features.borrow().more_struct_aliases => {
|
|
||||||
emit_feature_err(&self.tcx.sess.parse_sess,
|
|
||||||
"more_struct_aliases", path_span, GateIssue::Language,
|
|
||||||
"`Self` and associated types in struct \
|
|
||||||
expressions and patterns are unstable");
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyAdt(adt, substs) if !adt.is_enum() => {
|
ty::TyAdt(adt, substs) if !adt.is_enum() => {
|
||||||
Some((adt.struct_variant(), adt.did, substs))
|
Some((adt.struct_variant(), adt.did, substs))
|
||||||
|
@ -295,10 +295,6 @@ declare_features! (
|
|||||||
// The #![windows_subsystem] attribute
|
// The #![windows_subsystem] attribute
|
||||||
(active, windows_subsystem, "1.14.0", Some(37499)),
|
(active, windows_subsystem, "1.14.0", Some(37499)),
|
||||||
|
|
||||||
// Allows using `Self` and associated types in struct expressions and patterns.
|
|
||||||
(active, more_struct_aliases, "1.14.0", Some(37544)),
|
|
||||||
|
|
||||||
|
|
||||||
// Allows #[link(..., cfg(..))]
|
// Allows #[link(..., cfg(..))]
|
||||||
(active, link_cfg, "1.14.0", Some(37406)),
|
(active, link_cfg, "1.14.0", Some(37406)),
|
||||||
|
|
||||||
@ -378,6 +374,8 @@ declare_features! (
|
|||||||
// Allows `..` in tuple (struct) patterns
|
// Allows `..` in tuple (struct) patterns
|
||||||
(accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)),
|
(accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)),
|
||||||
(accepted, item_like_imports, "1.14.0", Some(35120)),
|
(accepted, item_like_imports, "1.14.0", Some(35120)),
|
||||||
|
// Allows using `Self` and associated types in struct expressions and patterns.
|
||||||
|
(accepted, more_struct_aliases, "1.14.0", Some(37544)),
|
||||||
);
|
);
|
||||||
// (changing above list without updating src/doc/reference.md makes @cmr sad)
|
// (changing above list without updating src/doc/reference.md makes @cmr sad)
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(more_struct_aliases)]
|
|
||||||
|
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
trait Tr {
|
trait Tr {
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
// Copyright 2016 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 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <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.
|
|
||||||
|
|
||||||
// gate-test-more_struct_aliases
|
|
||||||
|
|
||||||
struct S;
|
|
||||||
|
|
||||||
trait Tr {
|
|
||||||
type A;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn f<T: Tr<A = S>>() {
|
|
||||||
let _ = T::A {};
|
|
||||||
//~^ ERROR `Self` and associated types in struct expressions and patterns are unstable
|
|
||||||
}
|
|
||||||
|
|
||||||
impl S {
|
|
||||||
fn f() {
|
|
||||||
let _ = Self {};
|
|
||||||
//~^ ERROR `Self` and associated types in struct expressions and patterns are unstable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(more_struct_aliases)]
|
|
||||||
|
|
||||||
struct Foo<A> { inner: A }
|
struct Foo<A> { inner: A }
|
||||||
|
|
||||||
trait Bar { fn bar(); }
|
trait Bar { fn bar(); }
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(more_struct_aliases)]
|
|
||||||
|
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
trait Tr {
|
trait Tr {
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(more_struct_aliases)]
|
|
||||||
|
|
||||||
struct S<T, U = u16> {
|
struct S<T, U = u16> {
|
||||||
a: T,
|
a: T,
|
||||||
b: U,
|
b: U,
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(more_struct_aliases)]
|
|
||||||
|
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
struct S<T, U = u16> {
|
struct S<T, U = u16> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user