提交 e126f3c6 编写于 作者: A Alex Crichton

Merge branch 'selfgate' of https://github.com/petrochenkov/rust into rollup

......@@ -3240,6 +3240,16 @@ pub fn check_struct_path(&self,
}
Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) |
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 {
ty::TyAdt(adt, substs) if !adt.is_enum() => {
Some((adt.struct_variant(), adt.did, substs))
......
......@@ -312,6 +312,9 @@ pub fn new() -> Features {
// The #![windows_subsystem] attribute
(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)),
);
declare_features! (
......
......@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(more_struct_aliases)]
struct S;
trait Tr {
......
// 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.
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,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(more_struct_aliases)]
struct Foo<A> { inner: A }
trait Bar { fn bar(); }
......
......@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(more_struct_aliases)]
struct S;
trait Tr {
......
......@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(more_struct_aliases)]
struct S<T, U = u16> {
a: T,
b: U,
......
......@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(more_struct_aliases)]
use std::ops::Add;
struct S<T, U = u16> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册