Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5a5c265e
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,发现更多精彩内容 >>
提交
5a5c265e
编写于
5月 12, 2017
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor common logic into `ParameterEnvironment::and()`
上级
194d4bc1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
19 deletion
+30
-19
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+27
-4
src/librustc/ty/util.rs
src/librustc/ty/util.rs
+3
-15
未找到文件。
src/librustc/ty/mod.rs
浏览文件 @
5a5c265e
...
...
@@ -1259,10 +1259,33 @@ pub struct ParameterEnvironment<'tcx> {
}
impl
<
'tcx
>
ParameterEnvironment
<
'tcx
>
{
pub
fn
and
<
T
>
(
self
,
value
:
T
)
->
ParameterEnvironmentAnd
<
'tcx
,
T
>
{
ParameterEnvironmentAnd
{
param_env
:
self
,
value
:
value
,
/// Creates a suitable environment in which to perform trait
/// queries on the given value. This will either be `self` *or*
/// the empty environment, depending on whether `value` references
/// type parameters that are in scope. (If it doesn't, then any
/// judgements should be completely independent of the context,
/// and hence we can safely use the empty environment so as to
/// enable more sharing across functions.)
///
/// NB: This is a mildly dubious thing to do, in that a function
/// (or other environment) might have wacky where-clauses like
/// `where Box<u32>: Copy`, which are clearly never
/// satisfiable. The code will at present ignore these,
/// effectively, when type-checking the body of said
/// function. This preserves existing behavior in any
/// case. --nmatsakis
pub
fn
and
<
T
:
TypeFoldable
<
'tcx
>>
(
self
,
value
:
T
)
->
ParameterEnvironmentAnd
<
'tcx
,
T
>
{
assert
!
(
!
value
.needs_infer
());
if
value
.has_param_types
()
||
value
.has_self_ty
()
{
ParameterEnvironmentAnd
{
param_env
:
self
,
value
:
value
,
}
}
else
{
ParameterEnvironmentAnd
{
param_env
:
ParameterEnvironment
::
empty
(),
value
:
value
,
}
}
}
}
...
...
src/librustc/ty/util.rs
浏览文件 @
5a5c265e
...
...
@@ -724,11 +724,7 @@ pub fn moves_by_default(&'tcx self,
param_env
:
ParameterEnvironment
<
'tcx
>
,
span
:
Span
)
->
bool
{
if
self
.has_param_types
()
||
self
.has_self_ty
()
{
!
tcx
.at
(
span
)
.is_copy_raw
(
param_env
.and
(
self
))
}
else
{
!
tcx
.is_copy_raw
(
ParameterEnvironment
::
empty
()
.and
(
self
))
}
!
tcx
.at
(
span
)
.is_copy_raw
(
param_env
.and
(
self
))
}
pub
fn
is_sized
(
&
'tcx
self
,
...
...
@@ -736,11 +732,7 @@ pub fn is_sized(&'tcx self,
param_env
:
ParameterEnvironment
<
'tcx
>
,
span
:
Span
)
->
bool
{
if
self
.has_param_types
()
||
self
.has_self_ty
()
{
tcx
.at
(
span
)
.is_sized_raw
(
param_env
.and
(
self
))
}
else
{
tcx
.is_sized_raw
(
ParameterEnvironment
::
empty
()
.and
(
self
))
}
tcx
.at
(
span
)
.is_sized_raw
(
param_env
.and
(
self
))
}
pub
fn
is_freeze
(
&
'tcx
self
,
...
...
@@ -748,11 +740,7 @@ pub fn is_freeze(&'tcx self,
param_env
:
ParameterEnvironment
<
'tcx
>
,
span
:
Span
)
->
bool
{
if
self
.has_param_types
()
||
self
.has_self_ty
()
{
tcx
.at
(
span
)
.is_freeze_raw
(
param_env
.and
(
self
))
}
else
{
tcx
.is_freeze_raw
(
ParameterEnvironment
::
empty
()
.and
(
self
))
}
tcx
.at
(
span
)
.is_freeze_raw
(
param_env
.and
(
self
))
}
/// If `ty.needs_drop(...)` returns `true`, then `ty` is definitely
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录