Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ab5ba049
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ab5ba049
编写于
9月 15, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Partially stabilize RFC 1506 "Clarify relationships between ADTs"
上级
38a959a5
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
23 addition
and
115 deletion
+23
-115
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+0
-7
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+17
-18
src/test/compile-fail/auxiliary/empty-struct.rs
src/test/compile-fail/auxiliary/empty-struct.rs
+0
-2
src/test/compile-fail/auxiliary/namespace-mix-new.rs
src/test/compile-fail/auxiliary/namespace-mix-new.rs
+1
-1
src/test/compile-fail/auxiliary/namespace-mix-old.rs
src/test/compile-fail/auxiliary/namespace-mix-old.rs
+0
-2
src/test/compile-fail/empty-struct-braces-pat-2.rs
src/test/compile-fail/empty-struct-braces-pat-2.rs
+0
-2
src/test/compile-fail/empty-struct-braces-pat-3.rs
src/test/compile-fail/empty-struct-braces-pat-3.rs
+0
-2
src/test/compile-fail/empty-struct-tuple-pat.rs
src/test/compile-fail/empty-struct-tuple-pat.rs
+0
-2
src/test/compile-fail/empty-struct-unit-pat.rs
src/test/compile-fail/empty-struct-unit-pat.rs
+0
-2
src/test/compile-fail/feature-gate-relaxed-adts-2.rs
src/test/compile-fail/feature-gate-relaxed-adts-2.rs
+0
-27
src/test/compile-fail/issue-16819.rs
src/test/compile-fail/issue-16819.rs
+0
-26
src/test/compile-fail/issue-17800.rs
src/test/compile-fail/issue-17800.rs
+0
-2
src/test/compile-fail/issue-4736.rs
src/test/compile-fail/issue-4736.rs
+0
-2
src/test/compile-fail/namespace-mix-new.rs
src/test/compile-fail/namespace-mix-new.rs
+1
-1
src/test/compile-fail/namespace-mix-old.rs
src/test/compile-fail/namespace-mix-old.rs
+0
-2
src/test/compile-fail/numeric-fields-feature-gate.rs
src/test/compile-fail/numeric-fields-feature-gate.rs
+4
-12
src/test/run-pass-fulldeps/empty-struct-braces-derive.rs
src/test/run-pass-fulldeps/empty-struct-braces-derive.rs
+0
-1
src/test/run-pass/auxiliary/empty-struct.rs
src/test/run-pass/auxiliary/empty-struct.rs
+0
-2
src/test/run-pass/empty-struct-braces.rs
src/test/run-pass/empty-struct-braces.rs
+0
-2
未找到文件。
src/librustc_typeck/check/mod.rs
浏览文件 @
ab5ba049
...
...
@@ -3261,13 +3261,6 @@ pub fn check_struct_path(&self,
};
if
let
Some
((
variant
,
did
,
substs
))
=
variant
{
if
variant
.ctor_kind
==
CtorKind
::
Fn
&&
!
self
.tcx.sess.features
.borrow
()
.relaxed_adts
{
emit_feature_err
(
&
self
.tcx.sess.parse_sess
,
"relaxed_adts"
,
path
.span
,
GateIssue
::
Language
,
"tuple structs and variants in struct patterns are unstable"
);
}
// Check bounds on type arguments used in the path.
let
type_predicates
=
self
.tcx
.lookup_predicates
(
did
);
let
bounds
=
self
.instantiate_bounds
(
path
.span
,
substs
,
&
type_predicates
);
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
ab5ba049
...
...
@@ -271,7 +271,6 @@ pub fn new() -> Features {
// Allows `impl Trait` in function return types.
(
active
,
conservative_impl_trait
,
"1.12.0"
,
Some
(
34511
)),
// Allows tuple structs and variants in more contexts,
// Permits numeric fields in struct expressions and patterns.
(
active
,
relaxed_adts
,
"1.12.0"
,
Some
(
35626
)),
...
...
@@ -996,6 +995,10 @@ fn contains_novel_literal(item: &ast::MetaItem) -> bool {
}
}
fn
starts_with_digit
(
s
:
&
str
)
->
bool
{
s
.as_bytes
()
.first
()
.cloned
()
.map_or
(
false
,
|
b
|
b
>=
b
'0'
&&
b
<=
b
'9'
)
}
impl
<
'a
>
Visitor
for
PostExpansionVisitor
<
'a
>
{
fn
visit_attribute
(
&
mut
self
,
attr
:
&
ast
::
Attribute
)
{
if
!
self
.context.cm
.span_allows_unstable
(
attr
.span
)
{
...
...
@@ -1175,6 +1178,11 @@ fn visit_expr(&mut self, e: &ast::Expr) {
gate_feature_post!
(
&
self
,
field_init_shorthand
,
field
.span
,
"struct field shorthands are unstable"
);
}
if
starts_with_digit
(
&
field
.ident.node.name
.as_str
())
{
gate_feature_post!
(
&
self
,
relaxed_adts
,
field
.span
,
"numeric fields in struct expressions are unstable"
);
}
}
}
_
=>
{}
...
...
@@ -1201,10 +1209,14 @@ fn visit_pat(&mut self, pattern: &ast::Pat) {
pattern
.span
,
"box pattern syntax is experimental"
);
}
PatKind
::
TupleStruct
(
_
,
ref
fields
,
ddpos
)
if
ddpos
.is_none
()
&&
fields
.is_empty
()
=>
{
gate_feature_post!
(
&
self
,
relaxed_adts
,
pattern
.span
,
"empty tuple structs patterns are unstable"
);
PatKind
::
Struct
(
_
,
ref
fields
,
_
)
=>
{
for
field
in
fields
{
if
starts_with_digit
(
&
field
.node.ident.name
.as_str
())
{
gate_feature_post!
(
&
self
,
relaxed_adts
,
field
.span
,
"numeric fields in struct patterns are unstable"
);
}
}
}
_
=>
{}
}
...
...
@@ -1287,19 +1299,6 @@ fn visit_impl_item(&mut self, ii: &ast::ImplItem) {
visit
::
walk_impl_item
(
self
,
ii
);
}
fn
visit_variant_data
(
&
mut
self
,
vdata
:
&
ast
::
VariantData
,
_
:
ast
::
Ident
,
_
:
&
ast
::
Generics
,
_
:
NodeId
,
span
:
Span
)
{
if
vdata
.fields
()
.is_empty
()
{
if
vdata
.is_tuple
()
{
gate_feature_post!
(
&
self
,
relaxed_adts
,
span
,
"empty tuple structs and enum variants are unstable,
\
use unit structs and enum variants instead"
);
}
}
visit
::
walk_struct_def
(
self
,
vdata
)
}
fn
visit_vis
(
&
mut
self
,
vis
:
&
ast
::
Visibility
)
{
let
span
=
match
*
vis
{
ast
::
Visibility
::
Crate
(
span
)
=>
span
,
...
...
src/test/compile-fail/auxiliary/empty-struct.rs
浏览文件 @
ab5ba049
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(relaxed_adts)]
pub
struct
XEmpty1
{}
pub
struct
XEmpty2
;
pub
struct
XEmpty6
();
...
...
src/test/compile-fail/auxiliary/namespace-mix-new.rs
浏览文件 @
ab5ba049
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(item_like_imports
,
relaxed_adts
)]
#![feature(item_like_imports)]
pub
mod
c
{
pub
struct
S
{}
...
...
src/test/compile-fail/auxiliary/namespace-mix-old.rs
浏览文件 @
ab5ba049
...
...
@@ -10,8 +10,6 @@
// FIXME: Remove when `item_like_imports` is stabilized.
#![feature(relaxed_adts)]
pub
mod
c
{
pub
struct
S
{}
pub
struct
TS
();
...
...
src/test/compile-fail/empty-struct-braces-pat-2.rs
浏览文件 @
ab5ba049
...
...
@@ -12,8 +12,6 @@
// aux-build:empty-struct.rs
#![feature(relaxed_adts)]
extern
crate
empty_struct
;
use
empty_struct
::
*
;
...
...
src/test/compile-fail/empty-struct-braces-pat-3.rs
浏览文件 @
ab5ba049
...
...
@@ -12,8 +12,6 @@
// aux-build:empty-struct.rs
#![feature(relaxed_adts)]
extern
crate
empty_struct
;
use
empty_struct
::
*
;
...
...
src/test/compile-fail/empty-struct-tuple-pat.rs
浏览文件 @
ab5ba049
...
...
@@ -12,8 +12,6 @@
// aux-build:empty-struct.rs
#![feature(relaxed_adts)]
extern
crate
empty_struct
;
use
empty_struct
::
*
;
...
...
src/test/compile-fail/empty-struct-unit-pat.rs
浏览文件 @
ab5ba049
...
...
@@ -12,8 +12,6 @@
// aux-build:empty-struct.rs
#![feature(relaxed_adts)]
extern
crate
empty_struct
;
use
empty_struct
::
*
;
...
...
src/test/compile-fail/feature-gate-relaxed-adts-2.rs
已删除
100644 → 0
浏览文件 @
38a959a5
// 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
Z
(
u8
,
u8
);
enum
E
{
U
(
u8
,
u8
),
}
fn
main
()
{
match
Z
(
0
,
1
)
{
Z
{
..
}
=>
{}
//~ ERROR tuple structs and variants in struct patterns are unstable
}
match
E
::
U
(
0
,
1
)
{
E
::
U
{
..
}
=>
{}
//~ ERROR tuple structs and variants in struct patterns are unstable
}
let
z1
=
Z
(
0
,
1
);
let
z2
=
Z
{
..
z1
};
//~ ERROR tuple structs and variants in struct patterns are unstable
}
src/test/compile-fail/issue-16819.rs
已删除
100644 → 0
浏览文件 @
38a959a5
// Copyright 2015 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
TS
(
//~ ERROR empty tuple structs and enum variants are unstable
#[cfg(untrue)]
i32
,
);
enum
E
{
TV
(
//~ ERROR empty tuple structs and enum variants are unstable
#[cfg(untrue)]
i32
,
)
}
fn
main
()
{
let
s
=
TS
;
let
tv
=
E
::
TV
;
}
src/test/compile-fail/issue-17800.rs
浏览文件 @
ab5ba049
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(relaxed_adts)]
enum
MyOption
<
T
>
{
MySome
(
T
),
MyNone
,
...
...
src/test/compile-fail/issue-4736.rs
浏览文件 @
ab5ba049
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(relaxed_adts)]
struct
NonCopyable
(());
fn
main
()
{
...
...
src/test/compile-fail/namespace-mix-new.rs
浏览文件 @
ab5ba049
...
...
@@ -10,7 +10,7 @@
// aux-build:namespace-mix-new.rs
#![feature(item_like_imports
,
relaxed_adts
)]
#![feature(item_like_imports)]
extern
crate
namespace_mix_new
;
use
namespace_mix_new
::
*
;
...
...
src/test/compile-fail/namespace-mix-old.rs
浏览文件 @
ab5ba049
...
...
@@ -12,8 +12,6 @@
// aux-build:namespace-mix-old.rs
#![feature(relaxed_adts)]
extern
crate
namespace_mix_old
;
use
namespace_mix_old
::{
xm1
,
xm2
,
xm3
,
xm4
,
xm5
,
xm6
,
xm7
,
xm8
,
xm9
,
xmA
,
xmB
,
xmC
};
...
...
src/test/compile-fail/
feature-gate-relaxed-adts
.rs
→
src/test/compile-fail/
numeric-fields-feature-gate
.rs
浏览文件 @
ab5ba049
...
...
@@ -8,19 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
S
();
//~ ERROR empty tuple structs and enum variants are unstable
struct
Z
(
u8
,
u8
);
enum
E
{
V
(),
//~ ERROR empty tuple structs and enum variants are unstable
U
(
u8
,
u8
),
}
struct
S
(
u8
);
fn
main
()
{
match
S
()
{
S
()
=>
{}
//~ ERROR empty tuple structs patterns are unstable
}
match
E
::
V
()
{
E
::
V
()
=>
{}
//~ ERROR empty tuple structs patterns are unstable
let
s
=
S
{
0
:
10
};
//~ ERROR numeric fields in struct expressions are unstable
match
s
{
S
{
0
:
a
,
..
}
=>
{}
//~ ERROR numeric fields in struct patterns are unstable
}
}
src/test/run-pass-fulldeps/empty-struct-braces-derive.rs
浏览文件 @
ab5ba049
...
...
@@ -10,7 +10,6 @@
// `#[derive(Trait)]` works for empty structs/variants with braces or parens.
#![feature(relaxed_adts)]
#![feature(rustc_private)]
extern
crate
serialize
as
rustc_serialize
;
...
...
src/test/run-pass/auxiliary/empty-struct.rs
浏览文件 @
ab5ba049
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(relaxed_adts)]
pub
struct
XEmpty1
{}
pub
struct
XEmpty2
;
pub
struct
XEmpty7
();
...
...
src/test/run-pass/empty-struct-braces.rs
浏览文件 @
ab5ba049
...
...
@@ -13,8 +13,6 @@
// aux-build:empty-struct.rs
#![feature(relaxed_adts)]
extern
crate
empty_struct
;
use
empty_struct
::
*
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录