Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f9f5a88b
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,发现更多精彩内容 >>
提交
f9f5a88b
编写于
11月 11, 2019
作者:
V
Vytautas Astrauskas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a callback that allows compiler consumers to override queries.
上级
2a9be46c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
21 addition
and
0 deletion
+21
-0
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+2
-0
src/librustc_interface/interface.rs
src/librustc_interface/interface.rs
+11
-0
src/librustc_interface/passes.rs
src/librustc_interface/passes.rs
+5
-0
src/librustdoc/core.rs
src/librustdoc/core.rs
+1
-0
src/librustdoc/test.rs
src/librustdoc/test.rs
+1
-0
src/test/run-make-fulldeps/issue-19371/foo.rs
src/test/run-make-fulldeps/issue-19371/foo.rs
+1
-0
未找到文件。
src/librustc_driver/lib.rs
浏览文件 @
f9f5a88b
...
...
@@ -181,6 +181,7 @@ pub fn run_compiler(
crate_name
:
None
,
lint_caps
:
Default
::
default
(),
register_lints
:
None
,
override_queries
:
None
,
};
callbacks
.config
(
&
mut
config
);
config
...
...
@@ -259,6 +260,7 @@ pub fn run_compiler(
crate_name
:
None
,
lint_caps
:
Default
::
default
(),
register_lints
:
None
,
override_queries
:
None
,
};
callbacks
.config
(
&
mut
config
);
...
...
src/librustc_interface/interface.rs
浏览文件 @
f9f5a88b
...
...
@@ -12,6 +12,7 @@
use
rustc_data_structures
::
sync
::
Lrc
;
use
rustc_data_structures
::
fx
::{
FxHashSet
,
FxHashMap
};
use
rustc_parse
::
new_parser_from_source_str
;
use
rustc
::
ty
;
use
std
::
path
::
PathBuf
;
use
std
::
result
;
use
std
::
sync
::{
Arc
,
Mutex
};
...
...
@@ -38,6 +39,8 @@ pub struct Compiler {
pub
(
crate
)
queries
:
Queries
,
pub
(
crate
)
crate_name
:
Option
<
String
>
,
pub
(
crate
)
register_lints
:
Option
<
Box
<
dyn
Fn
(
&
Session
,
&
mut
lint
::
LintStore
)
+
Send
+
Sync
>>
,
pub
(
crate
)
override_queries
:
Option
<
fn
(
&
Session
,
&
mut
ty
::
query
::
Providers
<
'_
>
,
&
mut
ty
::
query
::
Providers
<
'_
>
)
>
,
}
impl
Compiler
{
...
...
@@ -131,6 +134,13 @@ pub struct Config {
/// Note that if you find a Some here you probably want to call that function in the new
/// function being registered.
pub
register_lints
:
Option
<
Box
<
dyn
Fn
(
&
Session
,
&
mut
lint
::
LintStore
)
+
Send
+
Sync
>>
,
/// This is a callback from the driver that is called just after we have populated
/// the list of queries.
///
/// The second parameter is local providers and the third parameter is external providers.
pub
override_queries
:
Option
<
fn
(
&
Session
,
&
mut
ty
::
query
::
Providers
<
'_
>
,
&
mut
ty
::
query
::
Providers
<
'_
>
)
>
,
}
pub
fn
run_compiler_in_existing_thread_pool
<
F
,
R
>
(
config
:
Config
,
f
:
F
)
->
R
...
...
@@ -157,6 +167,7 @@ pub fn run_compiler_in_existing_thread_pool<F, R>(config: Config, f: F) -> R
queries
:
Default
::
default
(),
crate_name
:
config
.crate_name
,
register_lints
:
config
.register_lints
,
override_queries
:
config
.override_queries
,
};
let
_
sess_abort_error
=
OnDrop
(||
{
...
...
src/librustc_interface/passes.rs
浏览文件 @
f9f5a88b
...
...
@@ -786,6 +786,7 @@ pub fn create_global_ctxt(
let
codegen_backend
=
compiler
.codegen_backend
()
.clone
();
let
crate_name
=
crate_name
.to_string
();
let
defs
=
mem
::
take
(
&
mut
resolver_outputs
.definitions
);
let
override_queries
=
compiler
.override_queries
;
let
((),
result
)
=
BoxedGlobalCtxt
::
new
(
static
move
||
{
let
sess
=
&*
sess
;
...
...
@@ -810,6 +811,10 @@ pub fn create_global_ctxt(
default_provide_extern
(
&
mut
extern_providers
);
codegen_backend
.provide_extern
(
&
mut
extern_providers
);
if
let
Some
(
callback
)
=
override_queries
{
callback
(
sess
,
&
mut
local_providers
,
&
mut
extern_providers
);
}
let
gcx
=
TyCtxt
::
create_global_ctxt
(
sess
,
lint_store
,
...
...
src/librustdoc/core.rs
浏览文件 @
f9f5a88b
...
...
@@ -335,6 +335,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
crate_name
,
lint_caps
,
register_lints
:
None
,
override_queries
:
None
,
};
interface
::
run_compiler_in_existing_thread_pool
(
config
,
|
compiler
|
{
...
...
src/librustdoc/test.rs
浏览文件 @
f9f5a88b
...
...
@@ -79,6 +79,7 @@ pub fn run(options: Options) -> i32 {
crate_name
:
options
.crate_name
.clone
(),
lint_caps
:
Default
::
default
(),
register_lints
:
None
,
override_queries
:
None
,
};
let
mut
test_args
=
options
.test_args
.clone
();
...
...
src/test/run-make-fulldeps/issue-19371/foo.rs
浏览文件 @
f9f5a88b
...
...
@@ -60,6 +60,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
crate_name
:
None
,
lint_caps
:
Default
::
default
(),
register_lints
:
None
,
override_queries
:
None
,
};
interface
::
run_compiler
(
config
,
|
compiler
|
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录