Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
39504719
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,发现更多精彩内容 >>
提交
39504719
编写于
2月 24, 2014
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve: Don't use @RefCell in trait_map, nothing modifies its entries.
上级
9d553261
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
26 deletion
+7
-26
src/librustc/middle/resolve.rs
src/librustc/middle/resolve.rs
+3
-3
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/method.rs
+4
-23
未找到文件。
src/librustc/middle/resolve.rs
浏览文件 @
39504719
...
...
@@ -46,7 +46,7 @@ struct binding_info {
type
BindingMap
=
HashMap
<
Name
,
binding_info
>
;
// Trait method resolution
pub
type
TraitMap
=
HashMap
<
NodeId
,
@
RefCell
<~
[
DefId
]
>
>
;
pub
type
TraitMap
=
HashMap
<
NodeId
,
~
[
DefId
]
>
;
// This is the replacement export map. It maps a module to all of the exports
// within.
...
...
@@ -5255,14 +5255,14 @@ fn record_candidate_traits_for_expr_if_necessary(&mut self, expr: &Expr) {
// the field name so that we can do some nice error reporting
// later on in typeck.
let
traits
=
self
.search_for_traits_containing_method
(
ident
);
self
.trait_map
.insert
(
expr
.id
,
@
RefCell
::
new
(
traits
)
);
self
.trait_map
.insert
(
expr
.id
,
traits
);
}
ExprMethodCall
(
_
,
ident
,
_
,
_
)
=>
{
debug!
(
"(recording candidate traits for expr) recording
\
traits for {}"
,
expr
.id
);
let
traits
=
self
.search_for_traits_containing_method
(
ident
);
self
.trait_map
.insert
(
expr
.id
,
@
RefCell
::
new
(
traits
)
);
self
.trait_map
.insert
(
expr
.id
,
traits
);
}
_
=>
{
// Nothing to do.
...
...
src/librustc/middle/typeck/check/method.rs
浏览文件 @
39504719
...
...
@@ -81,7 +81,6 @@ trait `ToStr` imported, and I call `to_str()` on a value of type `T`,
use
middle
::
subst
::
Subst
;
use
middle
::
resolve
;
use
middle
::
ty
::
*
;
use
middle
::
ty
;
use
middle
::
typeck
::
astconv
::
AstConv
;
...
...
@@ -396,28 +395,10 @@ fn push_extension_candidates(&self) {
// If the method being called is associated with a trait, then
// find all the impls of that trait. Each of those are
// candidates.
let
trait_map
:
&
resolve
::
TraitMap
=
&
self
.fcx.ccx.trait_map
;
let
opt_applicable_traits
=
trait_map
.find
(
&
self
.expr.id
);
for
applicable_traits
in
opt_applicable_traits
.iter
()
{
let
applicable_traits
=
applicable_traits
.borrow
();
for
trait_did
in
applicable_traits
.get
()
.iter
()
{
ty
::
populate_implementations_for_trait_if_necessary
(
self
.tcx
(),
*
trait_did
);
// Look for explicit implementations.
let
trait_impls
=
self
.tcx
()
.trait_impls
.borrow
();
let
opt_impl_infos
=
trait_impls
.get
()
.find
(
trait_did
);
for
impl_infos
in
opt_impl_infos
.iter
()
{
let
impl_infos
=
impl_infos
.borrow
();
for
impl_info
in
impl_infos
.get
()
.iter
()
{
let
mut
extension_candidates
=
self
.extension_candidates
.borrow_mut
();
self
.push_candidates_from_impl
(
extension_candidates
.get
(),
*
impl_info
);
}
}
let
opt_applicable_traits
=
self
.fcx.ccx.trait_map
.find
(
&
self
.expr.id
);
for
applicable_traits
in
opt_applicable_traits
.move_iter
()
{
for
trait_did
in
applicable_traits
.iter
()
{
self
.push_extension_candidate
(
*
trait_did
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录