Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2eac09d2
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,发现更多精彩内容 >>
提交
2eac09d2
编写于
8月 30, 2021
作者:
M
Mark Rousskov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use index newtyping for TyVid
上级
1698e3ca
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
26 deletion
+21
-26
compiler/rustc_infer/src/infer/fudge.rs
compiler/rustc_infer/src/infer/fudge.rs
+1
-1
compiler/rustc_infer/src/infer/type_variable.rs
compiler/rustc_infer/src/infer/type_variable.rs
+9
-9
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
...trait_selection/src/traits/error_reporting/suggestions.rs
+2
-2
compiler/rustc_type_ir/src/lib.rs
compiler/rustc_type_ir/src/lib.rs
+8
-13
compiler/rustc_typeck/src/check/method/suggest.rs
compiler/rustc_typeck/src/check/method/suggest.rs
+1
-1
未找到文件。
compiler/rustc_infer/src/infer/fudge.rs
浏览文件 @
2eac09d2
...
...
@@ -187,7 +187,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if
self
.type_vars
.0
.contains
(
&
vid
)
{
// This variable was created during the fudging.
// Recreate it with a fresh variable here.
let
idx
=
(
vid
.
index
-
self
.type_vars
.0
.start.index
)
as
usize
;
let
idx
=
(
vid
.
as_usize
()
-
self
.type_vars
.0
.start
.as_usize
()
)
as
usize
;
let
origin
=
self
.type_vars
.1
[
idx
];
self
.infcx
.next_ty_var
(
origin
)
}
else
{
...
...
compiler/rustc_infer/src/infer/type_variable.rs
浏览文件 @
2eac09d2
...
...
@@ -196,7 +196,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
/// Note that this function does not return care whether
/// `vid` has been unified with something else or not.
pub
fn
var_diverges
(
&
self
,
vid
:
ty
::
TyVid
)
->
Diverging
{
self
.storage.values
.get
(
vid
.index
as
usize
)
.diverging
self
.storage.values
.get
(
vid
.index
()
)
.diverging
}
/// Returns the origin that was given when `vid` was created.
...
...
@@ -204,7 +204,7 @@ pub fn var_diverges(&self, vid: ty::TyVid) -> Diverging {
/// Note that this function does not return care whether
/// `vid` has been unified with something else or not.
pub
fn
var_origin
(
&
self
,
vid
:
ty
::
TyVid
)
->
&
TypeVariableOrigin
{
&
self
.storage.values
.get
(
vid
.
index
as
usize
)
.origin
&
self
.storage.values
.get
(
vid
.
as_usize
()
)
.origin
}
/// Records that `a == b`, depending on `dir`.
...
...
@@ -269,7 +269,7 @@ pub fn new_var(
assert_eq!
(
eq_key
.vid
,
sub_key
);
let
index
=
self
.values
()
.push
(
TypeVariableData
{
origin
,
diverging
});
assert_eq!
(
eq_key
.vid.
index
,
index
as
u32
);
assert_eq!
(
eq_key
.vid
.
as_u32
()
,
index
as
u32
);
debug!
(
"new_var(index={:?}, universe={:?}, diverging={:?}, origin={:?}"
,
...
...
@@ -357,11 +357,11 @@ pub fn vars_since_snapshot(
&
mut
self
,
value_count
:
usize
,
)
->
(
Range
<
TyVid
>
,
Vec
<
TypeVariableOrigin
>
)
{
let
range
=
TyVid
{
index
:
value_count
as
u32
}
..
TyVid
{
index
:
self
.num_vars
()
as
u32
}
;
let
range
=
TyVid
::
from_usize
(
value_count
)
..
TyVid
::
from_usize
(
self
.num_vars
())
;
(
range
.start
..
range
.end
,
(
range
.start.
index
..
range
.end.index
)
.map
(|
index
|
self
.storage.values
.get
(
index
as
usize
)
.origin
)
(
range
.start
.
as_usize
()
..
range
.end
.as_usize
()
)
.map
(|
index
|
self
.storage.values
.get
(
index
)
.origin
)
.collect
(),
)
}
...
...
@@ -371,7 +371,7 @@ pub fn vars_since_snapshot(
pub
fn
unsolved_variables
(
&
mut
self
)
->
Vec
<
ty
::
TyVid
>
{
(
0
..
self
.storage.values
.len
())
.filter_map
(|
i
|
{
let
vid
=
ty
::
TyVid
{
index
:
i
as
u32
}
;
let
vid
=
ty
::
TyVid
::
from_usize
(
i
)
;
match
self
.probe
(
vid
)
{
TypeVariableValue
::
Unknown
{
..
}
=>
Some
(
vid
),
TypeVariableValue
::
Known
{
..
}
=>
None
,
...
...
@@ -424,10 +424,10 @@ impl<'tcx> ut::UnifyKey for TyVidEqKey<'tcx> {
type
Value
=
TypeVariableValue
<
'tcx
>
;
#[inline(always)]
fn
index
(
&
self
)
->
u32
{
self
.vid.
index
self
.vid
.
as_u32
()
}
fn
from_index
(
i
:
u32
)
->
Self
{
TyVidEqKey
::
from
(
ty
::
TyVid
{
index
:
i
}
)
TyVidEqKey
::
from
(
ty
::
TyVid
::
from_u32
(
i
)
)
}
fn
tag
()
->
&
'static
str
{
"TyVidEqKey"
...
...
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
浏览文件 @
2eac09d2
...
...
@@ -1244,7 +1244,7 @@ fn report_closure_arg_mismatch(
let
sig
=
if
let
ty
::
Tuple
(
inputs
)
=
inputs
.kind
()
{
tcx
.mk_fn_sig
(
inputs
.iter
()
.map
(|
k
|
k
.expect_ty
()),
tcx
.mk_ty_infer
(
ty
::
TyVar
(
ty
::
TyVid
{
index
:
0
}
)),
tcx
.mk_ty_infer
(
ty
::
TyVar
(
ty
::
TyVid
::
from_u32
(
0
)
)),
false
,
hir
::
Unsafety
::
Normal
,
abi
::
Abi
::
Rust
,
...
...
@@ -1252,7 +1252,7 @@ fn report_closure_arg_mismatch(
}
else
{
tcx
.mk_fn_sig
(
std
::
iter
::
once
(
inputs
),
tcx
.mk_ty_infer
(
ty
::
TyVar
(
ty
::
TyVid
{
index
:
0
}
)),
tcx
.mk_ty_infer
(
ty
::
TyVar
(
ty
::
TyVid
::
from_u32
(
0
)
)),
false
,
hir
::
Unsafety
::
Normal
,
abi
::
Abi
::
Rust
,
...
...
compiler/rustc_type_ir/src/lib.rs
浏览文件 @
2eac09d2
...
...
@@ -363,10 +363,11 @@ pub enum IntVarValue {
#[derive(Clone,
Copy,
PartialEq,
Eq)]
pub
struct
FloatVarValue
(
pub
FloatTy
);
/// A **ty**pe **v**ariable **ID**.
#[derive(Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Encodable,
Decodable)]
pub
struct
TyVid
{
pub
index
:
u32
,
rustc_index
::
newtype_index!
{
/// A **ty**pe **v**ariable **ID**.
pub
struct
TyVid
{
DEBUG_FORMAT
=
"_#{}t"
}
}
/// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
...
...
@@ -422,10 +423,10 @@ pub enum InferTy {
impl
UnifyKey
for
TyVid
{
type
Value
=
();
fn
index
(
&
self
)
->
u32
{
self
.
index
self
.
as_u32
()
}
fn
from_index
(
i
:
u32
)
->
TyVid
{
TyVid
{
index
:
i
}
TyVid
::
from_u32
(
i
)
}
fn
tag
()
->
&
'static
str
{
"TyVid"
...
...
@@ -558,7 +559,7 @@ impl<CTX> HashStable<CTX> for InferTy {
fn
hash_stable
(
&
self
,
ctx
:
&
mut
CTX
,
hasher
:
&
mut
StableHasher
)
{
use
InferTy
::
*
;
match
self
{
TyVar
(
v
)
=>
v
.
index
.hash_stable
(
ctx
,
hasher
),
TyVar
(
v
)
=>
v
.
as_u32
()
.hash_stable
(
ctx
,
hasher
),
IntVar
(
v
)
=>
v
.index
.hash_stable
(
ctx
,
hasher
),
FloatVar
(
v
)
=>
v
.index
.hash_stable
(
ctx
,
hasher
),
FreshTy
(
v
)
|
FreshIntTy
(
v
)
|
FreshFloatTy
(
v
)
=>
v
.hash_stable
(
ctx
,
hasher
),
...
...
@@ -587,12 +588,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
impl
fmt
::
Debug
for
TyVid
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"_#{}t"
,
self
.index
)
}
}
impl
fmt
::
Debug
for
IntVid
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"_#{}i"
,
self
.index
)
...
...
compiler/rustc_typeck/src/check/method/suggest.rs
浏览文件 @
2eac09d2
...
...
@@ -742,7 +742,7 @@ fn report_function<T: std::fmt::Display>(
let
projection_ty
=
pred
.skip_binder
()
.projection_ty
;
let
substs_with_infer_self
=
tcx
.mk_substs
(
iter
::
once
(
tcx
.mk_ty_var
(
ty
::
TyVid
{
index
:
0
}
)
.into
())
iter
::
once
(
tcx
.mk_ty_var
(
ty
::
TyVid
::
from_u32
(
0
)
)
.into
())
.chain
(
projection_ty
.substs
.iter
()
.skip
(
1
)),
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录