Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
004533ea
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,发现更多精彩内容 >>
提交
004533ea
编写于
11月 28, 2014
作者:
M
Murarth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix rustc panic on second compile_input
上级
29e928f2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
98 addition
and
0 deletion
+98
-0
src/librustc_trans/driver/driver.rs
src/librustc_trans/driver/driver.rs
+6
-0
src/libsyntax/ext/mtwt.rs
src/libsyntax/ext/mtwt.rs
+10
-0
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+6
-0
src/libsyntax/util/interner.rs
src/libsyntax/util/interner.rs
+5
-0
src/test/run-make/issue-19371/Makefile
src/test/run-make/issue-19371/Makefile
+9
-0
src/test/run-make/issue-19371/foo.rs
src/test/run-make/issue-19371/foo.rs
+62
-0
未找到文件。
src/librustc_trans/driver/driver.rs
浏览文件 @
004533ea
...
...
@@ -51,6 +51,12 @@ pub fn compile_input(sess: Session,
outdir
:
&
Option
<
Path
>
,
output
:
&
Option
<
Path
>
,
addl_plugins
:
Option
<
Plugins
>
)
{
// These may be left in an incoherent state after a previous compile.
// `clear_tables` and `get_ident_interner().clear()` can be used to free
// memory, but they do not restore the initial state.
syntax
::
ext
::
mtwt
::
reset_tables
();
token
::
reset_ident_interner
();
// We need nested scopes here, because the intermediate results can keep
// large chunks of memory alive and we want to free them as soon as
// possible to keep the peak memory usage low
...
...
src/libsyntax/ext/mtwt.rs
浏览文件 @
004533ea
...
...
@@ -136,6 +136,16 @@ pub fn clear_tables() {
with_resolve_table_mut
(|
table
|
*
table
=
HashMap
::
new
());
}
/// Reset the tables to their initial state
pub
fn
reset_tables
()
{
with_sctable
(|
table
|
{
*
table
.table
.borrow_mut
()
=
vec!
(
EmptyCtxt
,
IllegalCtxt
);
*
table
.mark_memo
.borrow_mut
()
=
HashMap
::
new
();
*
table
.rename_memo
.borrow_mut
()
=
HashMap
::
new
();
});
with_resolve_table_mut
(|
table
|
*
table
=
HashMap
::
new
());
}
/// Add a value to the end of a vec, return its index
fn
idx_push
<
T
>
(
vec
:
&
mut
Vec
<
T
>
,
val
:
T
)
->
u32
{
vec
.push
(
val
);
...
...
src/libsyntax/parse/token.rs
浏览文件 @
004533ea
...
...
@@ -564,6 +564,12 @@ pub fn get_ident_interner() -> Rc<IdentInterner> {
KEY
.with
(|
k
|
k
.clone
())
}
/// Reset the ident interner to its initial state.
pub
fn
reset_ident_interner
()
{
let
interner
=
get_ident_interner
();
interner
.reset
(
mk_fresh_ident_interner
());
}
/// Represents a string stored in the task-local interner. Because the
/// interner lives for the life of the task, this can be safely treated as an
/// immortal string, as long as it never crosses between tasks.
...
...
src/libsyntax/util/interner.rs
浏览文件 @
004533ea
...
...
@@ -214,6 +214,11 @@ pub fn clear(&self) {
*
self
.map
.borrow_mut
()
=
HashMap
::
new
();
*
self
.vect
.borrow_mut
()
=
Vec
::
new
();
}
pub
fn
reset
(
&
self
,
other
:
StrInterner
)
{
*
self
.map
.borrow_mut
()
=
other
.map
.into_inner
();
*
self
.vect
.borrow_mut
()
=
other
.vect
.into_inner
();
}
}
#[cfg(test)]
...
...
src/test/run-make/issue-19371/Makefile
0 → 100644
浏览文件 @
004533ea
-include
../tools.mk
# This test ensures that rustc compile_input can be called twice in one task
# without causing a panic.
# The program needs the path to rustc to get sysroot.
all
:
$(RUSTC)
foo.rs
$(
call
RUN,foo
$(TMPDIR)
$(RUSTC)
)
src/test/run-make/issue-19371/foo.rs
0 → 100644
浏览文件 @
004533ea
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern
crate
rustc
;
extern
crate
rustc_trans
;
extern
crate
syntax
;
use
rustc
::
session
::{
build_session
,
Session
};
use
rustc
::
session
::
config
::{
basic_options
,
build_configuration
,
OutputTypeExe
};
use
rustc_trans
::
driver
::
driver
::{
Input
,
StrInput
,
compile_input
};
use
syntax
::
diagnostics
::
registry
::
Registry
;
fn
main
()
{
let
src
=
r#"
fn main() {}
"#
;
let
args
=
std
::
os
::
args
();
if
args
.len
()
<
4
{
panic!
(
"expected rustc path"
);
}
let
tmpdir
=
Path
::
new
(
args
[
1
]
.as_slice
());
let
mut
sysroot
=
Path
::
new
(
args
[
3
]
.as_slice
());
sysroot
.pop
();
sysroot
.pop
();
compile
(
src
.to_string
(),
tmpdir
.join
(
"out"
),
sysroot
.clone
());
compile
(
src
.to_string
(),
tmpdir
.join
(
"out"
),
sysroot
.clone
());
}
fn
basic_sess
(
sysroot
:
Path
)
->
Session
{
let
mut
opts
=
basic_options
();
opts
.output_types
=
vec!
[
OutputTypeExe
];
opts
.maybe_sysroot
=
Some
(
sysroot
);
let
descriptions
=
Registry
::
new
(
&
rustc
::
DIAGNOSTICS
);
let
sess
=
build_session
(
opts
,
None
,
descriptions
);
sess
}
fn
compile
(
code
:
String
,
output
:
Path
,
sysroot
:
Path
)
{
let
sess
=
basic_sess
(
sysroot
);
let
cfg
=
build_configuration
(
&
sess
);
compile_input
(
sess
,
cfg
,
&
StrInput
(
code
),
&
None
,
&
Some
(
output
),
None
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录