Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9292c0bc
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,发现更多精彩内容 >>
提交
9292c0bc
编写于
7月 17, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Properly feature gate all unstable ABIs
上级
06ca016b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
103 addition
and
73 deletion
+103
-73
src/doc/book/closures.md
src/doc/book/closures.md
+1
-0
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+41
-32
src/test/compile-fail/E0045.rs
src/test/compile-fail/E0045.rs
+1
-1
src/test/compile-fail/feature-gate-abi-vectorcall.rs
src/test/compile-fail/feature-gate-abi-vectorcall.rs
+0
-19
src/test/compile-fail/feature-gate-abi.rs
src/test/compile-fail/feature-gate-abi.rs
+60
-0
src/test/compile-fail/feature-gate-rust-call.rs
src/test/compile-fail/feature-gate-rust-call.rs
+0
-21
未找到文件。
src/doc/book/closures.md
浏览文件 @
9292c0bc
...
...
@@ -223,6 +223,7 @@ trait system to overload operators. Calling functions is no different. We have
three separate traits to overload with:
```
rust
# #![feature(unboxed_closures)]
# mod foo {
pub
trait
Fn
<
Args
>
:
FnMut
<
Args
>
{
extern
"rust-call"
fn
call
(
&
self
,
args
:
Args
)
->
Self
::
Output
;
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
9292c0bc
...
...
@@ -800,6 +800,29 @@ struct PostExpansionVisitor<'a> {
}}
}
impl
<
'a
>
PostExpansionVisitor
<
'a
>
{
fn
check_abi
(
&
self
,
abi
:
Abi
,
span
:
Span
)
{
match
abi
{
Abi
::
RustIntrinsic
=>
gate_feature_post!
(
&
self
,
intrinsics
,
span
,
"intrinsics are subject to change"
),
Abi
::
PlatformIntrinsic
=>
{
gate_feature_post!
(
&
self
,
platform_intrinsics
,
span
,
"platform intrinsics are experimental and possibly buggy"
)
},
Abi
::
Vectorcall
=>
{
gate_feature_post!
(
&
self
,
abi_vectorcall
,
span
,
"vectorcall is experimental and subject to change"
)
}
Abi
::
RustCall
=>
{
gate_feature_post!
(
&
self
,
unboxed_closures
,
span
,
"rust-call ABI is subject to change"
);
}
_
=>
{}
}
}
}
impl
<
'a
>
Visitor
for
PostExpansionVisitor
<
'a
>
{
fn
visit_attribute
(
&
mut
self
,
attr
:
&
ast
::
Attribute
)
{
if
!
self
.context.cm
.span_allows_unstable
(
attr
.span
)
{
...
...
@@ -831,21 +854,7 @@ fn visit_item(&mut self, i: &ast::Item) {
across platforms, it is recommended to
\
use `#[link(name =
\"
foo
\"
)]` instead"
)
}
match
foreign_module
.abi
{
Abi
::
RustIntrinsic
=>
gate_feature_post!
(
&
self
,
intrinsics
,
i
.span
,
"intrinsics are subject to change"
),
Abi
::
PlatformIntrinsic
=>
{
gate_feature_post!
(
&
self
,
platform_intrinsics
,
i
.span
,
"platform intrinsics are experimental
\
and possibly buggy"
)
},
Abi
::
Vectorcall
=>
{
gate_feature_post!
(
&
self
,
abi_vectorcall
,
i
.span
,
"vectorcall is experimental and subject to change"
)
}
_
=>
()
}
self
.check_abi
(
foreign_module
.abi
,
i
.span
);
}
ast
::
ItemKind
::
Fn
(
..
)
=>
{
...
...
@@ -928,6 +937,16 @@ fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
visit
::
walk_foreign_item
(
self
,
i
)
}
fn
visit_ty
(
&
mut
self
,
ty
:
&
ast
::
Ty
)
{
match
ty
.node
{
ast
::
TyKind
::
BareFn
(
ref
bare_fn_ty
)
=>
{
self
.check_abi
(
bare_fn_ty
.abi
,
ty
.span
);
}
_
=>
{}
}
visit
::
walk_ty
(
self
,
ty
)
}
fn
visit_expr
(
&
mut
self
,
e
:
&
ast
::
Expr
)
{
match
e
.node
{
ast
::
ExprKind
::
Box
(
_
)
=>
{
...
...
@@ -1015,23 +1034,10 @@ fn visit_fn(&mut self,
}
match
fn_kind
{
FnKind
::
ItemFn
(
_
,
_
,
_
,
_
,
abi
,
_
)
if
abi
==
Abi
::
RustIntrinsic
=>
{
gate_feature_post!
(
&
self
,
intrinsics
,
span
,
"intrinsics are subject to change"
)
}
FnKind
::
ItemFn
(
_
,
_
,
_
,
_
,
abi
,
_
)
|
FnKind
::
Method
(
_
,
&
ast
::
MethodSig
{
abi
,
..
},
_
)
=>
match
abi
{
Abi
::
RustCall
=>
{
gate_feature_post!
(
&
self
,
unboxed_closures
,
span
,
"rust-call ABI is subject to change"
);
},
Abi
::
Vectorcall
=>
{
gate_feature_post!
(
&
self
,
abi_vectorcall
,
span
,
"vectorcall is experimental and subject to change"
);
},
_
=>
{}
},
FnKind
::
Method
(
_
,
&
ast
::
MethodSig
{
abi
,
..
},
_
)
=>
{
self
.check_abi
(
abi
,
span
);
}
_
=>
{}
}
visit
::
walk_fn
(
self
,
fn_kind
,
fn_decl
,
block
,
span
);
...
...
@@ -1044,7 +1050,10 @@ fn visit_trait_item(&mut self, ti: &ast::TraitItem) {
ti
.span
,
"associated constants are experimental"
)
}
ast
::
TraitItemKind
::
Method
(
ref
sig
,
_
)
=>
{
ast
::
TraitItemKind
::
Method
(
ref
sig
,
ref
block
)
=>
{
if
block
.is_none
()
{
self
.check_abi
(
sig
.abi
,
ti
.span
);
}
if
sig
.constness
==
ast
::
Constness
::
Const
{
gate_feature_post!
(
&
self
,
const_fn
,
ti
.span
,
"const fn is unstable"
);
}
...
...
src/test/compile-fail/E0045.rs
浏览文件 @
9292c0bc
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern
"
rust-call
"
{
fn
foo
(
x
:
u8
,
...
);
}
//~ ERROR E0045
extern
"
Rust
"
{
fn
foo
(
x
:
u8
,
...
);
}
//~ ERROR E0045
fn
main
()
{
}
src/test/compile-fail/feature-gate-abi-vectorcall.rs
已删除
100644 → 0
浏览文件 @
06ca016b
// 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.
extern
"vectorcall"
{
//~ ERROR vectorcall is experimental and subject to change
fn
bar
();
}
extern
"vectorcall"
fn
baz
()
{
//~ ERROR vectorcall is experimental and subject to change
}
fn
main
()
{
}
src/test/compile-fail/feature-gate-abi.rs
0 → 100644
浏览文件 @
9292c0bc
// 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.
// Functions
extern
"rust-intrinsic"
fn
f1
()
{}
//~ ERROR intrinsics are subject to change
extern
"platform-intrinsic"
fn
f2
()
{}
//~ ERROR platform intrinsics are experimental
extern
"vectorcall"
fn
f3
()
{}
//~ ERROR vectorcall is experimental and subject to change
extern
"rust-call"
fn
f4
()
{}
//~ ERROR rust-call ABI is subject to change
// Methods in trait definition
trait
Tr
{
extern
"rust-intrinsic"
fn
m1
();
//~ ERROR intrinsics are subject to change
extern
"platform-intrinsic"
fn
m2
();
//~ ERROR platform intrinsics are experimental
extern
"vectorcall"
fn
m3
();
//~ ERROR vectorcall is experimental and subject to change
extern
"rust-call"
fn
m4
();
//~ ERROR rust-call ABI is subject to change
extern
"rust-intrinsic"
fn
dm1
()
{}
//~ ERROR intrinsics are subject to change
extern
"platform-intrinsic"
fn
dm2
()
{}
//~ ERROR platform intrinsics are experimental
extern
"vectorcall"
fn
dm3
()
{}
//~ ERROR vectorcall is experimental and subject to change
extern
"rust-call"
fn
dm4
()
{}
//~ ERROR rust-call ABI is subject to change
}
struct
S
;
// Methods in trait impl
impl
Tr
for
S
{
extern
"rust-intrinsic"
fn
m1
()
{}
//~ ERROR intrinsics are subject to change
extern
"platform-intrinsic"
fn
m2
()
{}
//~ ERROR platform intrinsics are experimental
extern
"vectorcall"
fn
m3
()
{}
//~ ERROR vectorcall is experimental and subject to change
extern
"rust-call"
fn
m4
()
{}
//~ ERROR rust-call ABI is subject to change
}
// Methods in inherent impl
impl
S
{
extern
"rust-intrinsic"
fn
im1
()
{}
//~ ERROR intrinsics are subject to change
extern
"platform-intrinsic"
fn
im2
()
{}
//~ ERROR platform intrinsics are experimental
extern
"vectorcall"
fn
im3
()
{}
//~ ERROR vectorcall is experimental and subject to change
extern
"rust-call"
fn
im4
()
{}
//~ ERROR rust-call ABI is subject to change
}
// Function pointer types
type
A1
=
extern
"rust-intrinsic"
fn
();
//~ ERROR intrinsics are subject to change
type
A2
=
extern
"platform-intrinsic"
fn
();
//~ ERROR platform intrinsics are experimental
type
A3
=
extern
"vectorcall"
fn
();
//~ ERROR vectorcall is experimental and subject to change
type
A4
=
extern
"rust-call"
fn
();
//~ ERROR rust-call ABI is subject to change
// Foreign modules
extern
"rust-intrinsic"
{}
//~ ERROR intrinsics are subject to change
extern
"platform-intrinsic"
{}
//~ ERROR platform intrinsics are experimental
extern
"vectorcall"
{}
//~ ERROR vectorcall is experimental and subject to change
extern
"rust-call"
{}
//~ ERROR rust-call ABI is subject to change
fn
main
()
{}
src/test/compile-fail/feature-gate-rust-call.rs
已删除
100644 → 0
浏览文件 @
06ca016b
// Copyright 2014 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.
extern
"rust-call"
fn
foo
()
{
}
//~ ERROR rust-call ABI is subject to change
trait
Foo
{
extern
"rust-call"
fn
foo
();
}
impl
Foo
for
i32
{
extern
"rust-call"
fn
foo
()
{
}
//~ ERROR rust-call ABI is subject to change
}
fn
main
()
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录