Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8b38b685
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,发现更多精彩内容 >>
提交
8b38b685
编写于
12月 20, 2020
作者:
N
Nadrieril
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Inline the constructor-specific `split` functions
上级
3141f2d7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
19 addition
and
34 deletion
+19
-34
compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
+19
-34
未找到文件。
compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
浏览文件 @
8b38b685
...
@@ -183,14 +183,6 @@ fn to_pat<'tcx>(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Pat<'tcx> {
...
@@ -183,14 +183,6 @@ fn to_pat<'tcx>(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Pat<'tcx> {
Pat
{
ty
,
span
:
DUMMY_SP
,
kind
:
Box
::
new
(
kind
)
}
Pat
{
ty
,
span
:
DUMMY_SP
,
kind
:
Box
::
new
(
kind
)
}
}
}
/// Split this range, as described at the top of the file.
fn
split
<
'p
,
'tcx
>
(
&
self
,
pcx
:
PatCtxt
<
'_
,
'p
,
'tcx
>
)
->
SmallVec
<
[
Constructor
<
'tcx
>
;
1
]
>
{
let
mut
split_range
=
SplitIntRange
::
new
(
self
.clone
());
let
intranges
=
pcx
.matrix
.head_ctors
(
pcx
.cx
)
.filter_map
(|
ctor
|
ctor
.as_int_range
());
split_range
.split
(
intranges
.cloned
());
split_range
.iter
()
.map
(
IntRange
)
.collect
()
}
/// Lint on likely incorrect range patterns (#63987)
/// Lint on likely incorrect range patterns (#63987)
pub
(
super
)
fn
lint_overlapping_range_endpoints
(
&
self
,
pcx
:
PatCtxt
<
'_
,
'_
,
'_
>
,
hir_id
:
HirId
)
{
pub
(
super
)
fn
lint_overlapping_range_endpoints
(
&
self
,
pcx
:
PatCtxt
<
'_
,
'_
,
'_
>
,
hir_id
:
HirId
)
{
if
self
.is_singleton
()
{
if
self
.is_singleton
()
{
...
@@ -403,19 +395,6 @@ fn arity(self) -> u64 {
...
@@ -403,19 +395,6 @@ fn arity(self) -> u64 {
self
.kind
.arity
()
self
.kind
.arity
()
}
}
/// Split this slice, as described at the top of the file.
fn
split
<
'p
,
'tcx
>
(
self
,
pcx
:
PatCtxt
<
'_
,
'p
,
'tcx
>
)
->
SmallVec
<
[
Constructor
<
'tcx
>
;
1
]
>
{
let
(
self_prefix
,
self_suffix
)
=
match
self
.kind
{
VarLen
(
self_prefix
,
self_suffix
)
=>
(
self_prefix
,
self_suffix
),
_
=>
return
smallvec!
[
Slice
(
self
)],
};
let
mut
split_self
=
SplitVarLenSlice
::
new
(
self_prefix
,
self_suffix
,
self
.array_len
);
let
slices
=
pcx
.matrix
.head_ctors
(
pcx
.cx
)
.filter_map
(|
c
|
c
.as_slice
())
.map
(|
s
|
s
.kind
);
split_self
.split
(
slices
);
split_self
.iter
()
.map
(
Slice
)
.collect
()
}
/// See `Constructor::is_covered_by`
/// See `Constructor::is_covered_by`
fn
is_covered_by
(
self
,
other
:
Self
)
->
bool
{
fn
is_covered_by
(
self
,
other
:
Self
)
->
bool
{
other
.kind
.covers_length
(
self
.arity
())
other
.kind
.covers_length
(
self
.arity
())
...
@@ -680,26 +659,32 @@ pub(super) fn from_pat<'p>(cx: &MatchCheckCtxt<'p, 'tcx>, pat: &'p Pat<'tcx>) ->
...
@@ -680,26 +659,32 @@ pub(super) fn from_pat<'p>(cx: &MatchCheckCtxt<'p, 'tcx>, pat: &'p Pat<'tcx>) ->
debug!
(
"Constructor::split({:#?}, {:#?})"
,
self
,
pcx
.matrix
);
debug!
(
"Constructor::split({:#?}, {:#?})"
,
self
,
pcx
.matrix
);
match
self
{
match
self
{
Wildcard
=>
Constructor
::
split_wildcard
(
pcx
),
Wildcard
=>
{
let
mut
split_wildcard
=
SplitWildcard
::
new
(
pcx
);
split_wildcard
.split
(
pcx
);
split_wildcard
.into_ctors
(
pcx
)
}
// Fast-track if the range is trivial. In particular, we don't do the overlapping
// Fast-track if the range is trivial. In particular, we don't do the overlapping
// ranges check.
// ranges check.
IntRange
(
ctor_range
)
if
!
ctor_range
.is_singleton
()
=>
ctor_range
.split
(
pcx
),
IntRange
(
ctor_range
)
if
!
ctor_range
.is_singleton
()
=>
{
Slice
(
slice
@
Slice
{
kind
:
VarLen
(
..
),
..
})
=>
slice
.split
(
pcx
),
let
mut
split_range
=
SplitIntRange
::
new
(
ctor_range
.clone
());
let
intranges
=
pcx
.matrix
.head_ctors
(
pcx
.cx
)
.filter_map
(|
ctor
|
ctor
.as_int_range
());
split_range
.split
(
intranges
.cloned
());
split_range
.iter
()
.map
(
IntRange
)
.collect
()
}
&
Slice
(
Slice
{
kind
:
VarLen
(
self_prefix
,
self_suffix
),
array_len
})
=>
{
let
mut
split_self
=
SplitVarLenSlice
::
new
(
self_prefix
,
self_suffix
,
array_len
);
let
slices
=
pcx
.matrix
.head_ctors
(
pcx
.cx
)
.filter_map
(|
c
|
c
.as_slice
())
.map
(|
s
|
s
.kind
);
split_self
.split
(
slices
);
split_self
.iter
()
.map
(
Slice
)
.collect
()
}
// Any other constructor can be used unchanged.
// Any other constructor can be used unchanged.
_
=>
smallvec!
[
self
.clone
()],
_
=>
smallvec!
[
self
.clone
()],
}
}
}
}
/// For wildcards, there are two groups of constructors: there are the constructors actually
/// present in the matrix (`head_ctors`), and the constructors not present (`missing_ctors`).
/// Two constructors that are not in the matrix will either both be caught (by a wildcard), or
/// both not be caught. Therefore we can keep the missing constructors grouped together.
fn
split_wildcard
<
'p
>
(
pcx
:
PatCtxt
<
'_
,
'p
,
'tcx
>
)
->
SmallVec
<
[
Self
;
1
]
>
{
let
mut
split_wildcard
=
SplitWildcard
::
new
(
pcx
);
split_wildcard
.split
(
pcx
);
split_wildcard
.into_ctors
(
pcx
)
}
/// Returns whether `self` is covered by `other`, i.e. whether `self` is a subset of `other`.
/// Returns whether `self` is covered by `other`, i.e. whether `self` is a subset of `other`.
/// For the simple cases, this is simply checking for equality. For the "grouped" constructors,
/// For the simple cases, this is simply checking for equality. For the "grouped" constructors,
/// this checks for inclusion.
/// this checks for inclusion.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录