Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
aebd94fd
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
aebd94fd
编写于
2月 12, 2017
作者:
E
est31
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stabilize field init shorthand
Closes #37340.
上级
025c328b
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
5 addition
and
45 deletion
+5
-45
src/doc/book/src/structs.md
src/doc/book/src/structs.md
+0
-2
src/doc/reference.md
src/doc/reference.md
+0
-1
src/librustc/lib.rs
src/librustc/lib.rs
+1
-1
src/librustc_incremental/lib.rs
src/librustc_incremental/lib.rs
+1
-1
src/librustc_typeck/lib.rs
src/librustc_typeck/lib.rs
+1
-1
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+2
-7
src/test/compile-fail/feature-gate-field-init-shorthand.rs
src/test/compile-fail/feature-gate-field-init-shorthand.rs
+0
-24
src/test/compile-fail/struct-fields-shorthand-unresolved.rs
src/test/compile-fail/struct-fields-shorthand-unresolved.rs
+0
-2
src/test/compile-fail/struct-fields-shorthand.rs
src/test/compile-fail/struct-fields-shorthand.rs
+0
-2
src/test/parse-fail/struct-field-numeric-shorthand.rs
src/test/parse-fail/struct-field-numeric-shorthand.rs
+0
-2
src/test/run-pass/struct-field-shorthand.rs
src/test/run-pass/struct-field-shorthand.rs
+0
-2
未找到文件。
src/doc/book/src/structs.md
浏览文件 @
aebd94fd
...
...
@@ -122,8 +122,6 @@ fields of the data structure are initialized with variables of the same
names as the fields.
```
#![feature(field_init_shorthand)]
#[derive(Debug)]
struct Person<'a> {
name: &'a str,
...
...
src/doc/reference.md
浏览文件 @
aebd94fd
...
...
@@ -2825,7 +2825,6 @@ This allows a compact syntax with less duplication.
Example:
```
# #![feature(field_init_shorthand)]
# struct Point3d { x: i32, y: i32, z: i32 }
# let x = 0;
# let y_value = 0;
...
...
src/librustc/lib.rs
浏览文件 @
aebd94fd
...
...
@@ -29,7 +29,7 @@
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![
feature(field_init_shorthand
)]
#![
cfg_attr(stage0,feature(field_init_shorthand)
)]
#![feature(i128_type)]
#![feature(libc)]
#![feature(loop_break_value)]
...
...
src/librustc_incremental/lib.rs
浏览文件 @
aebd94fd
...
...
@@ -24,7 +24,7 @@
#![feature(rand)]
#![feature(core_intrinsics)]
#![feature(conservative_impl_trait)]
#![
feature(field_init_shorthand
)]
#![
cfg_attr(stage0,feature(field_init_shorthand)
)]
#![feature(pub_restricted)]
extern
crate
graphviz
;
...
...
src/librustc_typeck/lib.rs
浏览文件 @
aebd94fd
...
...
@@ -77,7 +77,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
#![
feature(field_init_shorthand
)]
#![
cfg_attr(stage0,feature(field_init_shorthand)
)]
#![feature(loop_break_value)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
aebd94fd
...
...
@@ -288,9 +288,6 @@ pub fn new() -> Features {
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
(
active
,
generic_param_attrs
,
"1.11.0"
,
Some
(
34761
)),
// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions.
(
active
,
field_init_shorthand
,
"1.14.0"
,
Some
(
37340
)),
// The #![windows_subsystem] attribute
(
active
,
windows_subsystem
,
"1.14.0"
,
Some
(
37499
)),
...
...
@@ -385,6 +382,8 @@ pub fn new() -> Features {
(
accepted
,
more_struct_aliases
,
"1.16.0"
,
Some
(
37544
)),
// elide `'static` lifetimes in `static`s and `const`s
(
accepted
,
static_in_const
,
"1.17.0"
,
Some
(
35897
)),
// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions.
(
accepted
,
field_init_shorthand
,
"1.17.0"
,
Some
(
37340
)),
);
// (changing above list without updating src/doc/reference.md makes @cmr sad)
...
...
@@ -1233,10 +1232,6 @@ fn visit_expr(&mut self, e: &'a ast::Expr) {
}
ast
::
ExprKind
::
Struct
(
_
,
ref
fields
,
_
)
=>
{
for
field
in
fields
{
if
field
.is_shorthand
{
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
,
...
...
src/test/compile-fail/feature-gate-field-init-shorthand.rs
已删除
100644 → 0
浏览文件 @
025c328b
// 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
Foo
{
x
:
i32
,
y
:
bool
,
z
:
i32
}
fn
main
()
{
let
(
x
,
y
,
z
)
=
(
1
,
true
,
2
);
let
_
=
Foo
{
x
,
//~ ERROR struct field shorthands are unstable
y
:
y
,
z
//~ ERROR struct field shorthands are unstable
};
}
src/test/compile-fail/struct-fields-shorthand-unresolved.rs
浏览文件 @
aebd94fd
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(field_init_shorthand)]
struct
Foo
{
x
:
i32
,
y
:
i32
...
...
src/test/compile-fail/struct-fields-shorthand.rs
浏览文件 @
aebd94fd
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(field_init_shorthand)]
struct
Foo
{
x
:
i32
,
y
:
i32
...
...
src/test/parse-fail/struct-field-numeric-shorthand.rs
浏览文件 @
aebd94fd
...
...
@@ -10,8 +10,6 @@
// compile-flags: -Z parse-only
#![feature(field_init_shorthand)]
struct
Rgb
(
u8
,
u8
,
u8
);
fn
main
()
{
...
...
src/test/run-pass/struct-field-shorthand.rs
浏览文件 @
aebd94fd
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(field_init_shorthand)]
struct
Foo
{
x
:
i32
,
y
:
bool
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录