Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3f4a489f
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,发现更多精彩内容 >>
提交
3f4a489f
编写于
1月 29, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_typeck: rename `LvalueOp` to `PlaceOp`.
上级
2c4a75bf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
31 deletion
+31
-31
src/librustc_typeck/check/autoderef.rs
src/librustc_typeck/check/autoderef.rs
+2
-2
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/confirm.rs
+16
-16
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+13
-13
未找到文件。
src/librustc_typeck/check/autoderef.rs
浏览文件 @
3f4a489f
...
...
@@ -10,7 +10,7 @@
use
astconv
::
AstConv
;
use
super
::{
FnCtxt
,
Lvalu
eOp
,
Needs
};
use
super
::{
FnCtxt
,
Plac
eOp
,
Needs
};
use
super
::
method
::
MethodCallee
;
use
rustc
::
infer
::
InferOk
;
...
...
@@ -239,6 +239,6 @@ pub fn try_overloaded_deref(&self,
base_ty
:
Ty
<
'tcx
>
,
needs
:
Needs
)
->
Option
<
InferOk
<
'tcx
,
MethodCallee
<
'tcx
>>>
{
self
.try_overloaded_
lvalue_op
(
span
,
base_ty
,
&
[],
needs
,
Lvalu
eOp
::
Deref
)
self
.try_overloaded_
place_op
(
span
,
base_ty
,
&
[],
needs
,
Plac
eOp
::
Deref
)
}
}
src/librustc_typeck/check/method/confirm.rs
浏览文件 @
3f4a489f
...
...
@@ -11,7 +11,7 @@
use
super
::{
probe
,
MethodCallee
};
use
astconv
::
AstConv
;
use
check
::{
FnCtxt
,
Lvalu
eOp
,
callee
,
Needs
};
use
check
::{
FnCtxt
,
Plac
eOp
,
callee
,
Needs
};
use
hir
::
def_id
::
DefId
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
traits
;
...
...
@@ -438,7 +438,7 @@ fn convert_lvalue_derefs_to_mutable(&self) {
debug!
(
"convert_lvalue_derefs_to_mutable: i={} expr={:?}"
,
i
,
expr
);
// Fix up the autoderefs. Autorefs can only occur immediately preceding
// overloaded
lvalu
e ops, and will be fixed by them in order to get
// overloaded
plac
e ops, and will be fixed by them in order to get
// the correct region.
let
mut
source
=
self
.node_ty
(
expr
.hir_id
);
// Do not mutate adjustments in place, but rather take them,
...
...
@@ -470,28 +470,28 @@ fn convert_lvalue_derefs_to_mutable(&self) {
match
expr
.node
{
hir
::
ExprIndex
(
ref
base_expr
,
ref
index_expr
)
=>
{
let
index_expr_ty
=
self
.node_ty
(
index_expr
.hir_id
);
self
.convert_
lvalu
e_op_to_mutable
(
Lvalu
eOp
::
Index
,
expr
,
base_expr
,
&
[
index_expr_ty
]);
self
.convert_
plac
e_op_to_mutable
(
Plac
eOp
::
Index
,
expr
,
base_expr
,
&
[
index_expr_ty
]);
}
hir
::
ExprUnary
(
hir
::
UnDeref
,
ref
base_expr
)
=>
{
self
.convert_
lvalu
e_op_to_mutable
(
Lvalu
eOp
::
Deref
,
expr
,
base_expr
,
&
[]);
self
.convert_
plac
e_op_to_mutable
(
Plac
eOp
::
Deref
,
expr
,
base_expr
,
&
[]);
}
_
=>
{}
}
}
}
fn
convert_
lvalu
e_op_to_mutable
(
&
self
,
op
:
Lvalu
eOp
,
fn
convert_
plac
e_op_to_mutable
(
&
self
,
op
:
Plac
eOp
,
expr
:
&
hir
::
Expr
,
base_expr
:
&
hir
::
Expr
,
arg_tys
:
&
[
Ty
<
'tcx
>
])
{
debug!
(
"convert_
lvalu
e_op_to_mutable({:?}, {:?}, {:?}, {:?})"
,
debug!
(
"convert_
plac
e_op_to_mutable({:?}, {:?}, {:?}, {:?})"
,
op
,
expr
,
base_expr
,
arg_tys
);
if
!
self
.tables
.borrow
()
.is_method_call
(
expr
)
{
debug!
(
"convert_
lvalu
e_op_to_mutable - builtin, nothing to do"
);
debug!
(
"convert_
plac
e_op_to_mutable - builtin, nothing to do"
);
return
}
...
...
@@ -499,24 +499,24 @@ fn convert_lvalue_op_to_mutable(&self,
.map_or_else
(||
self
.node_ty
(
expr
.hir_id
),
|
adj
|
adj
.target
);
let
base_ty
=
self
.resolve_type_vars_if_possible
(
&
base_ty
);
// Need to deref because overloaded
lvalu
e ops take self by-reference.
// Need to deref because overloaded
plac
e ops take self by-reference.
let
base_ty
=
base_ty
.builtin_deref
(
false
)
.expect
(
"
lvalu
e op takes something that is not a ref"
)
.expect
(
"
plac
e op takes something that is not a ref"
)
.ty
;
let
method
=
self
.try_overloaded_
lvalu
e_op
(
let
method
=
self
.try_overloaded_
plac
e_op
(
expr
.span
,
base_ty
,
arg_tys
,
Needs
::
MutPlace
,
op
);
let
method
=
match
method
{
Some
(
ok
)
=>
self
.register_infer_ok_obligations
(
ok
),
None
=>
return
self
.tcx.sess
.delay_span_bug
(
expr
.span
,
"re-trying op failed"
)
};
debug!
(
"convert_
lvalu
e_op_to_mutable: method={:?}"
,
method
);
debug!
(
"convert_
plac
e_op_to_mutable: method={:?}"
,
method
);
self
.write_method_call
(
expr
.hir_id
,
method
);
let
(
region
,
mutbl
)
=
if
let
ty
::
TyRef
(
r
,
mt
)
=
method
.sig
.inputs
()[
0
]
.sty
{
(
r
,
mt
.mutbl
)
}
else
{
span_bug!
(
expr
.span
,
"input to
lvalu
e op is not a ref?"
);
span_bug!
(
expr
.span
,
"input to
plac
e op is not a ref?"
);
};
// Convert the autoref in the base expr to mutable with the correct
...
...
@@ -529,7 +529,7 @@ fn convert_lvalue_op_to_mutable(&self,
let
mut
source
=
base_expr_ty
;
for
adjustment
in
&
mut
adjustments
[
..
]
{
if
let
Adjust
::
Borrow
(
AutoBorrow
::
Ref
(
..
))
=
adjustment
.kind
{
debug!
(
"convert_
lvalu
e_op_to_mutable: converting autoref {:?}"
,
adjustment
);
debug!
(
"convert_
plac
e_op_to_mutable: converting autoref {:?}"
,
adjustment
);
adjustment
.kind
=
Adjust
::
Borrow
(
AutoBorrow
::
Ref
(
region
,
mutbl
));
adjustment
.target
=
self
.tcx
.mk_ref
(
region
,
ty
::
TypeAndMut
{
ty
:
source
,
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
3f4a489f
...
...
@@ -424,7 +424,7 @@ pub fn recurse(&mut self, blk: &hir::Block) -> UnsafetyState {
}
#[derive(Debug,
Copy,
Clone)]
pub
enum
Lvalu
eOp
{
pub
enum
Plac
eOp
{
Deref
,
Index
}
...
...
@@ -2293,8 +2293,8 @@ fn try_index_step(&self,
// type from the method signature.
// If some lookup succeeded, install method in table
let
input_ty
=
self
.next_ty_var
(
TypeVariableOrigin
::
AutoDeref
(
base_expr
.span
));
let
method
=
self
.try_overloaded_
lvalu
e_op
(
expr
.span
,
self_ty
,
&
[
input_ty
],
needs
,
Lvalu
eOp
::
Index
);
let
method
=
self
.try_overloaded_
plac
e_op
(
expr
.span
,
self_ty
,
&
[
input_ty
],
needs
,
Plac
eOp
::
Index
);
let
result
=
method
.map
(|
ok
|
{
debug!
(
"try_index_step: success, using overloaded indexing"
);
...
...
@@ -2329,36 +2329,36 @@ fn try_index_step(&self,
None
}
fn
resolve_
lvalue_op
(
&
self
,
op
:
Lvalu
eOp
,
is_mut
:
bool
)
->
(
Option
<
DefId
>
,
Symbol
)
{
fn
resolve_
place_op
(
&
self
,
op
:
Plac
eOp
,
is_mut
:
bool
)
->
(
Option
<
DefId
>
,
Symbol
)
{
let
(
tr
,
name
)
=
match
(
op
,
is_mut
)
{
(
Lvalu
eOp
::
Deref
,
false
)
=>
(
Plac
eOp
::
Deref
,
false
)
=>
(
self
.tcx
.lang_items
()
.deref_trait
(),
"deref"
),
(
Lvalu
eOp
::
Deref
,
true
)
=>
(
Plac
eOp
::
Deref
,
true
)
=>
(
self
.tcx
.lang_items
()
.deref_mut_trait
(),
"deref_mut"
),
(
Lvalu
eOp
::
Index
,
false
)
=>
(
Plac
eOp
::
Index
,
false
)
=>
(
self
.tcx
.lang_items
()
.index_trait
(),
"index"
),
(
Lvalu
eOp
::
Index
,
true
)
=>
(
Plac
eOp
::
Index
,
true
)
=>
(
self
.tcx
.lang_items
()
.index_mut_trait
(),
"index_mut"
),
};
(
tr
,
Symbol
::
intern
(
name
))
}
fn
try_overloaded_
lvalu
e_op
(
&
self
,
fn
try_overloaded_
plac
e_op
(
&
self
,
span
:
Span
,
base_ty
:
Ty
<
'tcx
>
,
arg_tys
:
&
[
Ty
<
'tcx
>
],
needs
:
Needs
,
op
:
Lvalu
eOp
)
op
:
Plac
eOp
)
->
Option
<
InferOk
<
'tcx
,
MethodCallee
<
'tcx
>>>
{
debug!
(
"try_overloaded_
lvalu
e_op({:?},{:?},{:?},{:?})"
,
debug!
(
"try_overloaded_
plac
e_op({:?},{:?},{:?},{:?})"
,
span
,
base_ty
,
needs
,
op
);
// Try Mut first, if needed.
let
(
mut_tr
,
mut_op
)
=
self
.resolve_
lvalu
e_op
(
op
,
true
);
let
(
mut_tr
,
mut_op
)
=
self
.resolve_
plac
e_op
(
op
,
true
);
let
method
=
match
(
needs
,
mut_tr
)
{
(
Needs
::
MutPlace
,
Some
(
trait_did
))
=>
{
self
.lookup_method_in_trait
(
span
,
mut_op
,
trait_did
,
base_ty
,
Some
(
arg_tys
))
...
...
@@ -2367,7 +2367,7 @@ fn try_overloaded_lvalue_op(&self,
};
// Otherwise, fall back to the immutable version.
let
(
imm_tr
,
imm_op
)
=
self
.resolve_
lvalu
e_op
(
op
,
false
);
let
(
imm_tr
,
imm_op
)
=
self
.resolve_
plac
e_op
(
op
,
false
);
let
method
=
match
(
method
,
imm_tr
)
{
(
None
,
Some
(
trait_did
))
=>
{
self
.lookup_method_in_trait
(
span
,
imm_op
,
trait_did
,
base_ty
,
Some
(
arg_tys
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录