Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
047a8d01
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,发现更多精彩内容 >>
提交
047a8d01
编写于
7月 15, 2017
作者:
N
Niko Matsakis
提交者:
Sean Griffin
3月 01, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
kill custom type inference defaults (these don't really work anyway)
上级
7112d658
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
16 addition
and
31 deletion
+16
-31
src/librustc/infer/mod.rs
src/librustc/infer/mod.rs
+5
-18
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+1
-2
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/confirm.rs
+2
-2
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/mod.rs
+2
-2
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/probe.rs
+2
-2
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+4
-5
未找到文件。
src/librustc/infer/mod.rs
浏览文件 @
047a8d01
...
...
@@ -22,7 +22,7 @@
use
middle
::
region
;
use
middle
::
lang_items
;
use
mir
::
tcx
::
PlaceTy
;
use
ty
::
subst
::
{
Kind
,
Subst
,
Substs
}
;
use
ty
::
subst
::
Substs
;
use
ty
::{
TyVid
,
IntVid
,
FloatVid
};
use
ty
::{
self
,
Ty
,
TyCtxt
};
use
ty
::
error
::{
ExpectedFound
,
TypeError
,
UnconstrainedNumeric
};
...
...
@@ -1093,26 +1093,13 @@ pub fn region_var_for_def(&self,
/// as the substitutions for the default, `(T, U)`.
pub
fn
type_var_for_def
(
&
self
,
span
:
Span
,
def
:
&
ty
::
TypeParameterDef
,
substs
:
&
[
Kind
<
'tcx
>
])
def
:
&
ty
::
TypeParameterDef
)
->
Ty
<
'tcx
>
{
let
default
=
if
def
.has_default
{
let
default
=
self
.tcx
.type_of
(
def
.def_id
);
Some
(
type_variable
::
Default
{
ty
:
default
.subst_spanned
(
self
.tcx
,
substs
,
Some
(
span
)),
origin_span
:
span
,
def_id
:
def
.def_id
})
}
else
{
None
};
let
ty_var_id
=
self
.type_variables
.borrow_mut
()
.new_var
(
false
,
TypeVariableOrigin
::
TypeParameterDefinition
(
span
,
def
.name
),
default
);
None
);
self
.tcx
.mk_var
(
ty_var_id
)
}
...
...
@@ -1125,8 +1112,8 @@ pub fn fresh_substs_for_item(&self,
->
&
'tcx
Substs
<
'tcx
>
{
Substs
::
for_item
(
self
.tcx
,
def_id
,
|
def
,
_
|
{
self
.region_var_for_def
(
span
,
def
)
},
|
def
,
substs
|
{
self
.type_var_for_def
(
span
,
def
,
substs
)
},
|
def
,
_
|
{
self
.type_var_for_def
(
span
,
def
)
})
}
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
047a8d01
...
...
@@ -51,7 +51,6 @@ fn re_infer(&self, span: Span, _def: Option<&ty::RegionParameterDef>)
/// Same as ty_infer, but with a known type parameter definition.
fn
ty_infer_for_def
(
&
self
,
_
def
:
&
ty
::
TypeParameterDef
,
_
substs
:
&
[
Kind
<
'tcx
>
],
span
:
Span
)
->
Ty
<
'tcx
>
{
self
.ty_infer
(
span
)
}
...
...
@@ -261,7 +260,7 @@ fn create_substs_for_ast_path(&self,
}
else
if
infer_types
{
// No type parameters were provided, we can infer all.
let
ty_var
=
if
!
default_needs_object_self
(
def
)
{
self
.ty_infer_for_def
(
def
,
s
ubsts
,
s
pan
)
self
.ty_infer_for_def
(
def
,
span
)
}
else
{
self
.ty_infer
(
span
)
};
...
...
src/librustc_typeck/check/method/confirm.rs
浏览文件 @
047a8d01
...
...
@@ -325,7 +325,7 @@ fn instantiate_method_substs(&mut self,
}
else
{
self
.region_var_for_def
(
self
.span
,
def
)
}
},
|
def
,
cur_substs
|
{
},
|
def
,
_
cur_substs
|
{
let
i
=
def
.index
as
usize
;
if
i
<
parent_substs
.len
()
{
parent_substs
.type_at
(
i
)
...
...
@@ -336,7 +336,7 @@ fn instantiate_method_substs(&mut self,
{
self
.to_ty
(
ast_ty
)
}
else
{
self
.type_var_for_def
(
self
.span
,
def
,
cur_substs
)
self
.type_var_for_def
(
self
.span
,
def
)
}
})
}
...
...
src/librustc_typeck/check/method/mod.rs
浏览文件 @
047a8d01
...
...
@@ -249,13 +249,13 @@ pub fn lookup_method_in_trait(&self,
let
substs
=
Substs
::
for_item
(
self
.tcx
,
trait_def_id
,
|
def
,
_
|
self
.region_var_for_def
(
span
,
def
),
|
def
,
substs
|
{
|
def
,
_
substs
|
{
if
def
.index
==
0
{
self_ty
}
else
if
let
Some
(
ref
input_types
)
=
opt_input_types
{
input_types
[
def
.index
as
usize
-
1
]
}
else
{
self
.type_var_for_def
(
span
,
def
,
substs
)
self
.type_var_for_def
(
span
,
def
)
}
});
...
...
src/librustc_typeck/check/method/probe.rs
浏览文件 @
047a8d01
...
...
@@ -1304,12 +1304,12 @@ fn xform_method_sig(&self,
// `impl_self_ty()` for an explanation.
self
.tcx.types.re_erased
}
},
|
def
,
cur_substs
|
{
},
|
def
,
_
cur_substs
|
{
let
i
=
def
.index
as
usize
;
if
i
<
substs
.len
()
{
substs
.type_at
(
i
)
}
else
{
self
.type_var_for_def
(
self
.span
,
def
,
cur_substs
)
self
.type_var_for_def
(
self
.span
,
def
)
}
});
xform_fn_sig
.subst
(
self
.tcx
,
substs
)
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
047a8d01
...
...
@@ -93,7 +93,7 @@
use
rustc
::
infer
::
anon_types
::
AnonTypeDecl
;
use
rustc
::
infer
::
type_variable
::{
TypeVariableOrigin
};
use
rustc
::
middle
::
region
;
use
rustc
::
ty
::
subst
::{
Kind
,
Subst
,
Substs
};
use
rustc
::
ty
::
subst
::{
Subst
,
Substs
};
use
rustc
::
traits
::{
self
,
FulfillmentContext
,
ObligationCause
,
ObligationCauseCode
};
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
,
Visibility
,
ToPredicate
};
use
rustc
::
ty
::
adjustment
::{
Adjust
,
Adjustment
,
AutoBorrow
,
AutoBorrowMutability
};
...
...
@@ -1692,9 +1692,8 @@ fn ty_infer(&self, span: Span) -> Ty<'tcx> {
fn
ty_infer_for_def
(
&
self
,
ty_param_def
:
&
ty
::
TypeParameterDef
,
substs
:
&
[
Kind
<
'tcx
>
],
span
:
Span
)
->
Ty
<
'tcx
>
{
self
.type_var_for_def
(
span
,
ty_param_def
,
substs
)
self
.type_var_for_def
(
span
,
ty_param_def
)
}
fn
projected_ty_from_poly_trait_ref
(
&
self
,
...
...
@@ -4793,7 +4792,7 @@ pub fn instantiate_value_path(&self,
// Handle Self first, so we can adjust the index to match the AST.
if
has_self
&&
i
==
0
{
return
opt_self_ty
.unwrap_or_else
(||
{
self
.type_var_for_def
(
span
,
def
,
substs
)
self
.type_var_for_def
(
span
,
def
)
});
}
i
-=
has_self
as
usize
;
...
...
@@ -4826,7 +4825,7 @@ pub fn instantiate_value_path(&self,
// This can also be reached in some error cases:
// We prefer to use inference variables instead of
// TyError to let type inference recover somewhat.
self
.type_var_for_def
(
span
,
def
,
substs
)
self
.type_var_for_def
(
span
,
def
)
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录