Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c8b6d5b2
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,发现更多精彩内容 >>
提交
c8b6d5b2
编写于
7月 13, 2015
作者:
H
Huon Wilson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement `repr(simd)` as an alias for `#[simd]`.
上级
e822a18a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
4 deletion
+48
-4
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+3
-2
src/librustc_trans/trans/adt.rs
src/librustc_trans/trans/adt.rs
+3
-0
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+3
-0
src/libsyntax/attr.rs
src/libsyntax/attr.rs
+4
-1
src/libsyntax/ext/deriving/generic/mod.rs
src/libsyntax/ext/deriving/generic/mod.rs
+1
-1
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+20
-0
src/test/compile-fail/feature-gate-repr-simd.rs
src/test/compile-fail/feature-gate-repr-simd.rs
+14
-0
未找到文件。
src/librustc/middle/ty.rs
浏览文件 @
c8b6d5b2
...
...
@@ -3312,10 +3312,10 @@ fn new(tcx: &ctxt<'tcx>,
variants
:
Vec
<
VariantDefData
<
'tcx
,
'container
>>
)
->
Self
{
let
mut
flags
=
AdtFlags
::
NO_ADT_FLAGS
;
let
attrs
=
tcx
.get_attrs
(
did
);
if
attr
s
.iter
()
.any
(|
item
|
item
.check_name
(
"fundamental"
)
)
{
if
attr
::
contains_name
(
&
attrs
,
"fundamental"
)
{
flags
=
flags
|
AdtFlags
::
IS_FUNDAMENTAL
;
}
if
attrs
.iter
()
.any
(|
item
|
item
.check_name
(
"simd"
)
)
{
if
tcx
.lookup_simd
(
did
)
{
flags
=
flags
|
AdtFlags
::
IS_SIMD
;
}
if
Some
(
did
)
==
tcx
.lang_items
.phantom_data
()
{
...
...
@@ -6116,6 +6116,7 @@ pub fn lookup_packed(&self, did: DefId) -> bool {
/// Determine whether an item is annotated with `#[simd]`
pub
fn
lookup_simd
(
&
self
,
did
:
DefId
)
->
bool
{
self
.has_attr
(
did
,
"simd"
)
||
self
.lookup_repr_hints
(
did
)
.contains
(
&
attr
::
ReprSimd
)
}
/// Obtain the representation annotation for a struct definition.
...
...
src/librustc_trans/trans/adt.rs
浏览文件 @
c8b6d5b2
...
...
@@ -615,6 +615,9 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
attr
::
ReprPacked
=>
{
cx
.tcx
()
.sess
.bug
(
"range_to_inttype: found ReprPacked on an enum"
);
}
attr
::
ReprSimd
=>
{
cx
.tcx
()
.sess
.bug
(
"range_to_inttype: found ReprSimd on an enum"
);
}
}
for
&
ity
in
attempts
{
if
bounds_usable
(
cx
,
ity
,
bounds
)
{
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
c8b6d5b2
...
...
@@ -4421,6 +4421,9 @@ fn do_check<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
"discriminant type specified here"
);
}
}
attr
::
ReprSimd
=>
{
ccx
.tcx.sess
.bug
(
"range_to_inttype: found ReprSimd on an enum"
);
}
attr
::
ReprPacked
=>
{
ccx
.tcx.sess
.bug
(
"range_to_inttype: found ReprPacked on an enum"
);
}
...
...
src/libsyntax/attr.rs
浏览文件 @
c8b6d5b2
...
...
@@ -579,6 +579,7 @@ pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAt
// Can't use "extern" because it's not a lexical identifier.
"C"
=>
Some
(
ReprExtern
),
"packed"
=>
Some
(
ReprPacked
),
"simd"
=>
Some
(
ReprSimd
),
_
=>
match
int_type_of_word
(
&
word
)
{
Some
(
ity
)
=>
Some
(
ReprInt
(
item
.span
,
ity
)),
None
=>
{
...
...
@@ -628,6 +629,7 @@ pub enum ReprAttr {
ReprInt
(
Span
,
IntType
),
ReprExtern
,
ReprPacked
,
ReprSimd
,
}
impl
ReprAttr
{
...
...
@@ -636,7 +638,8 @@ pub fn is_ffi_safe(&self) -> bool {
ReprAny
=>
false
,
ReprInt
(
_
sp
,
ity
)
=>
ity
.is_ffi_safe
(),
ReprExtern
=>
true
,
ReprPacked
=>
false
ReprPacked
=>
false
,
ReprSimd
=>
true
,
}
}
}
...
...
src/libsyntax/ext/deriving/generic/mod.rs
浏览文件 @
c8b6d5b2
...
...
@@ -739,7 +739,7 @@ fn find_repr_type_name(diagnostic: &SpanHandler,
for
a
in
type_attrs
{
for
r
in
&
attr
::
find_repr_attrs
(
diagnostic
,
a
)
{
repr_type_name
=
match
*
r
{
attr
::
ReprAny
|
attr
::
ReprPacked
=>
continue
,
attr
::
ReprAny
|
attr
::
ReprPacked
|
attr
::
ReprSimd
=>
continue
,
attr
::
ReprExtern
=>
"i32"
,
attr
::
ReprInt
(
_
,
attr
::
SignedInt
(
ast
::
TyIs
))
=>
"isize"
,
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
c8b6d5b2
...
...
@@ -177,6 +177,9 @@
// Allows macros to appear in the type position.
(
"type_macros"
,
"1.3.0"
,
Active
),
// allow `repr(simd)`, and importing the various simd intrinsics
(
"simd_basics"
,
"1.3.0"
,
Active
),
];
// (changing above list without updating src/doc/reference.md makes @cmr sad)
...
...
@@ -359,6 +362,7 @@ pub struct Features {
pub
allow_box
:
bool
,
pub
allow_pushpop_unsafe
:
bool
,
pub
simd_ffi
:
bool
,
pub
simd_basics
:
bool
,
pub
unmarked_api
:
bool
,
pub
negate_unsigned
:
bool
,
/// spans of #![feature] attrs for stable language features. for error reporting
...
...
@@ -388,6 +392,7 @@ pub fn new() -> Features {
allow_box
:
false
,
allow_pushpop_unsafe
:
false
,
simd_ffi
:
false
,
simd_basics
:
false
,
unmarked_api
:
false
,
negate_unsigned
:
false
,
declared_stable_lang_features
:
Vec
::
new
(),
...
...
@@ -660,6 +665,20 @@ fn visit_item(&mut self, i: &ast::Item) {
if
attr
::
contains_name
(
&
i
.attrs
[
..
],
"simd"
)
{
self
.gate_feature
(
"simd"
,
i
.span
,
"SIMD types are experimental and possibly buggy"
);
self
.context.span_handler
.span_warn
(
i
.span
,
"the `#[simd]` attribute is deprecated,
\
use `#[repr(simd)]` instead"
);
}
for
attr
in
&
i
.attrs
{
if
attr
.name
()
==
"repr"
{
for
item
in
attr
.meta_item_list
()
.unwrap_or
(
&
[])
{
if
item
.name
()
==
"simd"
{
self
.gate_feature
(
"simd_basics"
,
i
.span
,
"SIMD types are experimental and possibly buggy"
);
}
}
}
}
}
...
...
@@ -892,6 +911,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler,
allow_box
:
cx
.has_feature
(
"box_syntax"
),
allow_pushpop_unsafe
:
cx
.has_feature
(
"pushpop_unsafe"
),
simd_ffi
:
cx
.has_feature
(
"simd_ffi"
),
simd_basics
:
cx
.has_feature
(
"simd_basics"
),
unmarked_api
:
cx
.has_feature
(
"unmarked_api"
),
negate_unsigned
:
cx
.has_feature
(
"negate_unsigned"
),
declared_stable_lang_features
:
accepted_features
,
...
...
src/test/compile-fail/feature-gate-repr-simd.rs
0 → 100644
浏览文件 @
c8b6d5b2
// 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.
#[repr(simd)]
struct
Foo
(
u64
,
u64
);
//~ error: SIMD types are experimental
fn
main
()
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录