Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
64d4ed30
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,发现更多精彩内容 >>
提交
64d4ed30
编写于
2月 14, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move ParamEnv methods from `ty/util` to `ty/mod`
上级
6d0f9319
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
44 deletion
+44
-44
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+43
-1
src/librustc/ty/util.rs
src/librustc/ty/util.rs
+1
-43
未找到文件。
src/librustc/ty/mod.rs
浏览文件 @
64d4ed30
...
...
@@ -29,7 +29,7 @@
use
mir
::
interpret
::{
GlobalId
,
Value
,
PrimVal
};
use
mir
::
GeneratorLayout
;
use
session
::
CrateDisambiguator
;
use
traits
;
use
traits
::{
self
,
Reveal
}
;
use
ty
;
use
ty
::
subst
::{
Subst
,
Substs
};
use
ty
::
util
::{
IntTypeExt
,
Discr
};
...
...
@@ -1396,6 +1396,48 @@ pub struct ParamEnv<'tcx> {
}
impl
<
'tcx
>
ParamEnv
<
'tcx
>
{
/// Construct a trait environment suitable for contexts where
/// there are no where clauses in scope. Hidden types (like `impl
/// Trait`) are left hidden, so this is suitable for ordinary
/// type-checking.
pub
fn
empty
()
->
Self
{
Self
::
new
(
ty
::
Slice
::
empty
(),
Reveal
::
UserFacing
,
ty
::
UniverseIndex
::
ROOT
)
}
/// Construct a trait environment with no where clauses in scope
/// where the values of all `impl Trait` and other hidden types
/// are revealed. This is suitable for monomorphized, post-typeck
/// environments like trans or doing optimizations.
///
/// NB. If you want to have predicates in scope, use `ParamEnv::new`,
/// or invoke `param_env.with_reveal_all()`.
pub
fn
reveal_all
()
->
Self
{
Self
::
new
(
ty
::
Slice
::
empty
(),
Reveal
::
All
,
ty
::
UniverseIndex
::
ROOT
)
}
/// Construct a trait environment with the given set of predicates.
pub
fn
new
(
caller_bounds
:
&
'tcx
ty
::
Slice
<
ty
::
Predicate
<
'tcx
>>
,
reveal
:
Reveal
,
universe
:
ty
::
UniverseIndex
)
->
Self
{
ty
::
ParamEnv
{
caller_bounds
,
reveal
,
universe
}
}
/// Returns a new parameter environment with the same clauses, but
/// which "reveals" the true results of projections in all cases
/// (even for associated types that are specializable). This is
/// the desired behavior during trans and certain other special
/// contexts; normally though we want to use `Reveal::UserFacing`,
/// which is the default.
pub
fn
with_reveal_all
(
self
)
->
Self
{
ty
::
ParamEnv
{
reveal
:
Reveal
::
All
,
..
self
}
}
/// Returns this same environment but with no caller bounds.
pub
fn
without_caller_bounds
(
self
)
->
Self
{
ty
::
ParamEnv
{
caller_bounds
:
ty
::
Slice
::
empty
(),
..
self
}
}
/// 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
...
...
src/librustc/ty/util.rs
浏览文件 @
64d4ed30
...
...
@@ -16,7 +16,7 @@
use
hir
;
use
ich
::
NodeIdHashingMode
;
use
middle
::
const_val
::
ConstVal
;
use
traits
::{
self
,
Reveal
}
;
use
traits
;
use
ty
::{
self
,
Ty
,
TyCtxt
,
TypeFoldable
};
use
ty
::
fold
::
TypeVisitor
;
use
ty
::
subst
::{
Subst
,
UnpackedKind
};
...
...
@@ -182,48 +182,6 @@ pub enum Representability {
}
impl
<
'tcx
>
ty
::
ParamEnv
<
'tcx
>
{
/// Construct a trait environment suitable for contexts where
/// there are no where clauses in scope. Hidden types (like `impl
/// Trait`) are left hidden, so this is suitable for ordinary
/// type-checking.
pub
fn
empty
()
->
Self
{
Self
::
new
(
ty
::
Slice
::
empty
(),
Reveal
::
UserFacing
,
ty
::
UniverseIndex
::
ROOT
)
}
/// Construct a trait environment with no where clauses in scope
/// where the values of all `impl Trait` and other hidden types
/// are revealed. This is suitable for monomorphized, post-typeck
/// environments like trans or doing optimizations.
///
/// NB. If you want to have predicates in scope, use `ParamEnv::new`,
/// or invoke `param_env.with_reveal_all()`.
pub
fn
reveal_all
()
->
Self
{
Self
::
new
(
ty
::
Slice
::
empty
(),
Reveal
::
All
,
ty
::
UniverseIndex
::
ROOT
)
}
/// Construct a trait environment with the given set of predicates.
pub
fn
new
(
caller_bounds
:
&
'tcx
ty
::
Slice
<
ty
::
Predicate
<
'tcx
>>
,
reveal
:
Reveal
,
universe
:
ty
::
UniverseIndex
)
->
Self
{
ty
::
ParamEnv
{
caller_bounds
,
reveal
,
universe
}
}
/// Returns a new parameter environment with the same clauses, but
/// which "reveals" the true results of projections in all cases
/// (even for associated types that are specializable). This is
/// the desired behavior during trans and certain other special
/// contexts; normally though we want to use `Reveal::UserFacing`,
/// which is the default.
pub
fn
with_reveal_all
(
self
)
->
Self
{
ty
::
ParamEnv
{
reveal
:
Reveal
::
All
,
..
self
}
}
/// Returns this same environment but with no caller bounds.
pub
fn
without_caller_bounds
(
self
)
->
Self
{
ty
::
ParamEnv
{
caller_bounds
:
ty
::
Slice
::
empty
(),
..
self
}
}
pub
fn
can_type_implement_copy
<
'a
>
(
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
self_type
:
Ty
<
'tcx
>
,
span
:
Span
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录