Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
87d93167
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,发现更多精彩内容 >>
提交
87d93167
编写于
3月 21, 2013
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #5457 : pcwalton/rust/xcpsm, r=pcwalton
r? @catamorphism
上级
56d288d0
5726fd45
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
17 deletion
+46
-17
src/librustc/metadata/csearch.rs
src/librustc/metadata/csearch.rs
+4
-4
src/librustc/metadata/decoder.rs
src/librustc/metadata/decoder.rs
+12
-9
src/librustc/middle/privacy.rs
src/librustc/middle/privacy.rs
+11
-4
src/test/auxiliary/xc_private_method_lib.rs
src/test/auxiliary/xc_private_method_lib.rs
+10
-0
src/test/compile-fail/xc-private-method.rs
src/test/compile-fail/xc-private-method.rs
+9
-0
未找到文件。
src/librustc/metadata/csearch.rs
浏览文件 @
87d93167
...
@@ -229,11 +229,11 @@ pub fn struct_dtor(cstore: @mut cstore::CStore, def: ast::def_id)
...
@@ -229,11 +229,11 @@ pub fn struct_dtor(cstore: @mut cstore::CStore, def: ast::def_id)
decoder
::
struct_dtor
(
cdata
,
def
.node
)
decoder
::
struct_dtor
(
cdata
,
def
.node
)
}
}
pub
fn
get_
method
_visibility
(
cstore
:
@
mut
cstore
::
CStore
,
pub
fn
get_
item
_visibility
(
cstore
:
@
mut
cstore
::
CStore
,
def_id
:
ast
::
def_id
)
def_id
:
ast
::
def_id
)
->
ast
::
visibility
{
->
ast
::
visibility
{
let
cdata
=
cstore
::
get_crate_data
(
cstore
,
def_id
.crate
);
let
cdata
=
cstore
::
get_crate_data
(
cstore
,
def_id
.crate
);
decoder
::
get_
method
_visibility
(
cdata
,
def_id
.node
)
decoder
::
get_
item
_visibility
(
cdata
,
def_id
.node
)
}
}
pub
fn
get_link_args_for_crate
(
cstore
:
@
mut
cstore
::
CStore
,
pub
fn
get_link_args_for_crate
(
cstore
:
@
mut
cstore
::
CStore
,
...
...
src/librustc/metadata/decoder.rs
浏览文件 @
87d93167
...
@@ -145,13 +145,16 @@ fn item_family(item: ebml::Doc) -> Family {
...
@@ -145,13 +145,16 @@ fn item_family(item: ebml::Doc) -> Family {
}
}
fn
item_visibility
(
item
:
ebml
::
Doc
)
->
ast
::
visibility
{
fn
item_visibility
(
item
:
ebml
::
Doc
)
->
ast
::
visibility
{
let
visibility
=
reader
::
get_doc
(
item
,
tag_items_data_item_visibility
);
match
reader
::
maybe_get_doc
(
item
,
tag_items_data_item_visibility
)
{
debug!
(
"item visibility for %?"
,
item_family
(
item
));
None
=>
ast
::
public
,
match
reader
::
doc_as_u8
(
visibility
)
as
char
{
Some
(
visibility_doc
)
=>
{
'y'
=>
ast
::
public
,
match
reader
::
doc_as_u8
(
visibility_doc
)
as
char
{
'n'
=>
ast
::
private
,
'y'
=>
ast
::
public
,
'i'
=>
ast
::
inherited
,
'n'
=>
ast
::
private
,
_
=>
fail
!
(
~
"unknown visibility character"
),
'i'
=>
ast
::
inherited
,
_
=>
fail
!
(
~
"unknown visibility character"
)
}
}
}
}
}
}
...
@@ -909,8 +912,8 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id)
...
@@ -909,8 +912,8 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id)
result
result
}
}
pub
fn
get_
method
_visibility
(
cdata
:
cmd
,
id
:
ast
::
node_id
)
pub
fn
get_
item
_visibility
(
cdata
:
cmd
,
id
:
ast
::
node_id
)
->
ast
::
visibility
{
->
ast
::
visibility
{
item_visibility
(
lookup_item
(
id
,
cdata
.data
))
item_visibility
(
lookup_item
(
id
,
cdata
.data
))
}
}
...
...
src/librustc/middle/privacy.rs
浏览文件 @
87d93167
...
@@ -265,8 +265,7 @@ pub fn check_crate(tcx: ty::ctxt,
...
@@ -265,8 +265,7 @@ pub fn check_crate(tcx: ty::ctxt,
}
}
}
else
{
}
else
{
let
visibility
=
let
visibility
=
csearch
::
get_method_visibility
(
tcx
.sess.cstore
,
csearch
::
get_item_visibility
(
tcx
.sess.cstore
,
method_id
);
method_id
);
if
visibility
!=
public
{
if
visibility
!=
public
{
tcx
.sess
.span_err
(
span
,
tcx
.sess
.span_err
(
span
,
fmt!
(
"method `%s` is private"
,
fmt!
(
"method `%s` is private"
,
...
@@ -298,8 +297,16 @@ pub fn check_crate(tcx: ty::ctxt,
...
@@ -298,8 +297,16 @@ pub fn check_crate(tcx: ty::ctxt,
.idents
.idents
.last
())));
.last
())));
}
}
}
else
{
}
else
if
csearch
::
get_item_visibility
(
tcx
.sess.cstore
,
// XXX: Check privacy in external crates.
def_id
)
!=
public
{
tcx
.sess
.span_err
(
span
,
fmt!
(
"function `%s` is private"
,
*
tcx
.sess
.parse_sess
.interner
.get
(
copy
*
path
.idents
.last
())));
}
}
}
}
_
=>
{}
_
=>
{}
...
...
src/test/auxiliary/xc_private_method_lib.rs
0 → 100644
浏览文件 @
87d93167
#[crate_type=
"lib"
]
;
pub
struct
Foo
{
x
:
int
}
impl
Foo
{
fn
new
()
->
Foo
{
Foo
{
x
:
1
}
}
}
src/test/compile-fail/xc-private-method.rs
0 → 100644
浏览文件 @
87d93167
// xfail-fast
// aux-build:xc_private_method_lib.rs
extern
mod
xc_private_method_lib
;
fn
main
()
{
let
_
=
xc_private_method_lib
::
Foo
::
new
();
//~ ERROR function `new` is private
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录