Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
63d6ef65
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,发现更多精彩内容 >>
未验证
提交
63d6ef65
编写于
4月 05, 2020
作者:
A
Aaron Hill
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Query-ify Instance::resolve
上级
853c4774
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
24 addition
and
25 deletion
+24
-25
src/librustc_interface/callbacks.rs
src/librustc_interface/callbacks.rs
+0
-1
src/librustc_middle/query/mod.rs
src/librustc_middle/query/mod.rs
+4
-0
src/librustc_middle/ty/instance.rs
src/librustc_middle/ty/instance.rs
+3
-20
src/librustc_middle/ty/mod.rs
src/librustc_middle/ty/mod.rs
+0
-1
src/librustc_middle/ty/query/keys.rs
src/librustc_middle/ty/query/keys.rs
+11
-0
src/librustc_ty/instance.rs
src/librustc_ty/instance.rs
+5
-3
src/librustc_ty/lib.rs
src/librustc_ty/lib.rs
+1
-0
未找到文件。
src/librustc_interface/callbacks.rs
浏览文件 @
63d6ef65
...
...
@@ -58,5 +58,4 @@ pub fn setup_callbacks() {
rustc_span
::
SPAN_DEBUG
.swap
(
&
(
span_debug
as
fn
(
_
,
&
mut
fmt
::
Formatter
<
'_
>
)
->
_
));
rustc_hir
::
def_id
::
DEF_ID_DEBUG
.swap
(
&
(
def_id_debug
as
fn
(
_
,
&
mut
fmt
::
Formatter
<
'_
>
)
->
_
));
TRACK_DIAGNOSTICS
.swap
(
&
(
track_diagnostic
as
fn
(
&
_
)));
rustc_middle
::
ty
::
RESOLVE_INSTANCE
.swap
(
&
(
rustc_ty
::
instance
::
resolve_instance
as
_
));
}
src/librustc_middle/query/mod.rs
浏览文件 @
63d6ef65
...
...
@@ -1257,5 +1257,9 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
eval_always
desc
{
"looking up enabled feature gates"
}
}
query
resolve_instance
(
key
:
(
ty
::
ParamEnv
<
'tcx
>
,
DefId
,
SubstsRef
<
'tcx
>
))
->
Option
<
ty
::
Instance
<
'tcx
>>
{
desc
{
"resolving instance `{:?}` `{:?}` with {:?}"
,
key
.1
,
key
.2
,
key
.0
}
}
}
}
src/librustc_middle/ty/instance.rs
浏览文件 @
63d6ef65
use
crate
::
middle
::
codegen_fn_attrs
::
CodegenFnAttrFlags
;
use
crate
::
ty
::
print
::{
FmtPrinter
,
Printer
};
use
crate
::
ty
::{
self
,
SubstsRef
,
Ty
,
TyCtxt
,
TypeFoldable
};
use
rustc_data_structures
::
AtomicRef
;
use
rustc_hir
::
def
::
Namespace
;
use
rustc_hir
::
def_id
::{
CrateNum
,
DefId
};
use
rustc_hir
::
lang_items
::
DropInPlaceFnLangItem
;
...
...
@@ -289,7 +288,9 @@ pub fn resolve(
def_id
:
DefId
,
substs
:
SubstsRef
<
'tcx
>
,
)
->
Option
<
Instance
<
'tcx
>>
{
(
*
RESOLVE_INSTANCE
)(
tcx
,
param_env
,
def_id
,
substs
)
// All regions in the result of this query are erased, so it's
// fine to erase all of the input regions.
tcx
.resolve_instance
((
tcx
.erase_regions
(
&
param_env
),
def_id
,
tcx
.erase_regions
(
&
substs
)))
}
pub
fn
resolve_for_fn_ptr
(
...
...
@@ -440,21 +441,3 @@ fn needs_fn_once_adapter_shim(
(
ty
::
ClosureKind
::
FnMut
,
_
)
|
(
ty
::
ClosureKind
::
FnOnce
,
_
)
=>
Err
(()),
}
}
fn
resolve_instance_default
(
_
tcx
:
TyCtxt
<
'tcx
>
,
_
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
_
def_id
:
DefId
,
_
substs
:
SubstsRef
<
'tcx
>
,
)
->
Option
<
Instance
<
'tcx
>>
{
unimplemented!
()
}
pub
static
RESOLVE_INSTANCE
:
AtomicRef
<
for
<
'tcx
>
fn
(
TyCtxt
<
'tcx
>
,
ty
::
ParamEnv
<
'tcx
>
,
DefId
,
SubstsRef
<
'tcx
>
,
)
->
Option
<
Instance
<
'tcx
>>
,
>
=
AtomicRef
::
new
(
&
(
resolve_instance_default
as
_
));
src/librustc_middle/ty/mod.rs
浏览文件 @
63d6ef65
...
...
@@ -81,7 +81,6 @@
CtxtInterners
,
GeneratorInteriorTypeCause
,
GlobalCtxt
,
Lift
,
TypeckTables
,
};
pub
use
self
::
instance
::
RESOLVE_INSTANCE
;
pub
use
self
::
instance
::{
Instance
,
InstanceDef
};
pub
use
self
::
trait_def
::
TraitDef
;
...
...
src/librustc_middle/ty/query/keys.rs
浏览文件 @
63d6ef65
...
...
@@ -296,3 +296,14 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
}
impl
<
'tcx
>
Key
for
(
ty
::
ParamEnv
<
'tcx
>
,
DefId
,
SubstsRef
<
'tcx
>
)
{
type
CacheSelector
=
DefaultCacheSelector
;
fn
query_crate
(
&
self
)
->
CrateNum
{
self
.1
.krate
}
fn
default_span
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
Span
{
tcx
.def_span
(
self
.1
)
}
}
src/librustc_ty/instance.rs
浏览文件 @
63d6ef65
...
...
@@ -11,9 +11,7 @@
pub
fn
resolve_instance
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
def_id
:
DefId
,
substs
:
SubstsRef
<
'tcx
>
,
(
param_env
,
def_id
,
substs
):
(
ty
::
ParamEnv
<
'tcx
>
,
DefId
,
SubstsRef
<
'tcx
>
),
)
->
Option
<
Instance
<
'tcx
>>
{
debug!
(
"resolve(def_id={:?}, substs={:?})"
,
def_id
,
substs
);
let
result
=
if
let
Some
(
trait_def_id
)
=
tcx
.trait_of_item
(
def_id
)
{
...
...
@@ -199,3 +197,7 @@ fn resolve_associated_item<'tcx>(
traits
::
VtableAutoImpl
(
..
)
|
traits
::
VtableParam
(
..
)
|
traits
::
VtableTraitAlias
(
..
)
=>
None
,
}
}
pub
fn
provide
(
providers
:
&
mut
ty
::
query
::
Providers
<
'_
>
)
{
*
providers
=
ty
::
query
::
Providers
{
resolve_instance
,
..*
providers
};
}
src/librustc_ty/lib.rs
浏览文件 @
63d6ef65
...
...
@@ -25,4 +25,5 @@ pub fn provide(providers: &mut Providers<'_>) {
common_traits
::
provide
(
providers
);
needs_drop
::
provide
(
providers
);
ty
::
provide
(
providers
);
instance
::
provide
(
providers
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录