Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fd46c78f
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,发现更多精彩内容 >>
提交
fd46c78f
编写于
12月 31, 2015
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add an --output option for specifying an error emitter
上级
acfccc51
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
135 addition
and
81 deletion
+135
-81
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+5
-4
src/librustc/session/config.rs
src/librustc/session/config.rs
+74
-36
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+24
-10
src/librustc/session/search_paths.rs
src/librustc/session/search_paths.rs
+3
-4
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+12
-11
src/librustc_trans/back/linker.rs
src/librustc_trans/back/linker.rs
+2
-2
src/librustc_trans/back/write.rs
src/librustc_trans/back/write.rs
+9
-9
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/base.rs
+1
-1
src/librustc_trans/trans/debuginfo/metadata.rs
src/librustc_trans/trans/debuginfo/metadata.rs
+1
-1
src/librustc_trans/trans/debuginfo/mod.rs
src/librustc_trans/trans/debuginfo/mod.rs
+2
-2
src/libsyntax/errors/emitter.rs
src/libsyntax/errors/emitter.rs
+1
-1
src/libsyntax/errors/mod.rs
src/libsyntax/errors/mod.rs
+1
-0
未找到文件。
src/librustc/lint/context.rs
浏览文件 @
fd46c78f
...
...
@@ -28,7 +28,7 @@
use
dep_graph
::
DepNode
;
use
middle
::
privacy
::
AccessLevels
;
use
middle
::
ty
;
use
session
::{
early_error
,
Session
};
use
session
::{
config
,
early_error
,
Session
};
use
lint
::{
Level
,
LevelSource
,
Lint
,
LintId
,
LintArray
,
LintPass
};
use
lint
::{
EarlyLintPass
,
EarlyLintPassObject
,
LateLintPass
,
LateLintPassObject
};
use
lint
::{
Default
,
CommandLine
,
Node
,
Allow
,
Warn
,
Deny
,
Forbid
};
...
...
@@ -37,11 +37,12 @@
use
std
::
cell
::
RefCell
;
use
std
::
cmp
;
use
std
::
default
::
Default
as
StdDefault
;
use
std
::
mem
;
use
syntax
::
ast_util
::{
self
,
IdVisitingOperation
};
use
syntax
::
attr
::{
self
,
AttrMetaMethods
};
use
syntax
::
codemap
::
Span
;
use
syntax
::
errors
::
{
self
,
DiagnosticBuilder
}
;
use
syntax
::
errors
::
DiagnosticBuilder
;
use
syntax
::
parse
::
token
::
InternedString
;
use
syntax
::
ast
;
use
syntax
::
attr
::
ThinAttributesExt
;
...
...
@@ -168,7 +169,7 @@ fn push_pass<P: LintPass + ?Sized + 'static>(&mut self,
match
(
sess
,
from_plugin
)
{
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(
None
,
_
)
=>
early_error
(
errors
::
ColorConfig
::
Auto
,
&
msg
[
..
]),
(
None
,
_
)
=>
early_error
(
config
::
ErrorOutputType
::
default
()
,
&
msg
[
..
]),
(
Some
(
sess
),
false
)
=>
sess
.bug
(
&
msg
[
..
]),
// A duplicate name from a plugin is a user error.
...
...
@@ -192,7 +193,7 @@ pub fn register_group(&mut self, sess: Option<&Session>,
match
(
sess
,
from_plugin
)
{
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(
None
,
_
)
=>
early_error
(
errors
::
ColorConfig
::
Auto
,
&
msg
[
..
]),
(
None
,
_
)
=>
early_error
(
config
::
ErrorOutputType
::
default
()
,
&
msg
[
..
]),
(
Some
(
sess
),
false
)
=>
sess
.bug
(
&
msg
[
..
]),
// A duplicate name from a plugin is a user error.
...
...
src/librustc/session/config.rs
浏览文件 @
fd46c78f
...
...
@@ -14,7 +14,6 @@
pub
use
self
::
EntryFnType
::
*
;
pub
use
self
::
CrateType
::
*
;
pub
use
self
::
Passes
::
*
;
pub
use
self
::
OptLevel
::
*
;
pub
use
self
::
DebugInfoLevel
::
*
;
use
session
::{
early_error
,
early_warn
,
Session
};
...
...
@@ -71,6 +70,18 @@ pub enum OutputType {
DepInfo
,
}
#[derive(Clone,
Copy,
Debug,
PartialEq,
Eq)]
pub
enum
ErrorOutputType
{
Tty
(
ColorConfig
),
Json
,
}
impl
Default
for
ErrorOutputType
{
fn
default
()
->
ErrorOutputType
{
ErrorOutputType
::
Tty
(
ColorConfig
::
Auto
)
}
}
impl
OutputType
{
fn
is_compatible_with_codegen_units_and_single_output_file
(
&
self
)
->
bool
{
match
*
self
{
...
...
@@ -124,6 +135,7 @@ pub struct Options {
pub
test
:
bool
,
pub
parse_only
:
bool
,
pub
no_trans
:
bool
,
pub
output
:
ErrorOutputType
,
pub
treat_err_as_bug
:
bool
,
pub
incremental_compilation
:
bool
,
pub
dump_dep_graph
:
bool
,
...
...
@@ -131,7 +143,6 @@ pub struct Options {
pub
debugging_opts
:
DebuggingOptions
,
pub
prints
:
Vec
<
PrintRequest
>
,
pub
cg
:
CodegenOptions
,
pub
color
:
ColorConfig
,
pub
externs
:
HashMap
<
String
,
Vec
<
String
>>
,
pub
crate_name
:
Option
<
String
>
,
/// An optional name to use as the crate for std during std injection,
...
...
@@ -221,7 +232,7 @@ pub fn basic_options() -> Options {
Options
{
crate_types
:
Vec
::
new
(),
gc
:
false
,
optimize
:
No
,
optimize
:
OptLevel
::
No
,
debuginfo
:
NoDebugInfo
,
lint_opts
:
Vec
::
new
(),
lint_cap
:
None
,
...
...
@@ -241,7 +252,12 @@ pub fn basic_options() -> Options {
debugging_opts
:
basic_debugging_options
(),
prints
:
Vec
::
new
(),
cg
:
basic_codegen_options
(),
<<<<<<<
HEAD
color
:
ColorConfig
::
Auto
,
=======
output
:
ErrorOutputType
::
default
(),
show_span
:
None
,
>>>>>>>
Add
an
--
output
option
for
specifying
an
error
emitter
externs
:
HashMap
::
new
(),
crate_name
:
None
,
alt_std_name
:
None
,
...
...
@@ -308,7 +324,7 @@ pub fn $defaultfn() -> $struct_name {
$struct_name
{
$
(
$opt
:
$init
),
*
}
}
pub
fn
$buildfn
(
matches
:
&
getopts
::
Matches
,
color
:
ColorConfig
)
->
$struct_name
pub
fn
$buildfn
(
matches
:
&
getopts
::
Matches
,
output
:
ErrorOutputType
)
->
$struct_name
{
let
mut
op
=
$defaultfn
();
for
option
in
matches
.opt_strs
(
$prefix
)
{
...
...
@@ -322,17 +338,17 @@ pub fn $buildfn(matches: &getopts::Matches, color: ColorConfig) -> $struct_name
if
!
setter
(
&
mut
op
,
value
)
{
match
(
value
,
opt_type_desc
)
{
(
Some
(
..
),
None
)
=>
{
early_error
(
color
,
&
format!
(
"{} option `{}` takes no
\
early_error
(
output
,
&
format!
(
"{} option `{}` takes no
\
value"
,
$outputname
,
key
))
}
(
None
,
Some
(
type_desc
))
=>
{
early_error
(
color
,
&
format!
(
"{0} option `{1}` requires
\
early_error
(
output
,
&
format!
(
"{0} option `{1}` requires
\
{2} ({3} {1}=<value>)"
,
$outputname
,
key
,
type_desc
,
$prefix
))
}
(
Some
(
value
),
Some
(
type_desc
))
=>
{
early_error
(
color
,
&
format!
(
"incorrect value `{}` for {}
\
early_error
(
output
,
&
format!
(
"incorrect value `{}` for {}
\
option `{}` - {} was expected"
,
value
,
$outputname
,
key
,
type_desc
))
...
...
@@ -344,7 +360,7 @@ pub fn $buildfn(matches: &getopts::Matches, color: ColorConfig) -> $struct_name
break
;
}
if
!
found
{
early_error
(
color
,
&
format!
(
"unknown {} option: `{}`"
,
early_error
(
output
,
&
format!
(
"unknown {} option: `{}`"
,
$outputname
,
key
));
}
}
...
...
@@ -863,6 +879,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"NAME=PATH"
),
opt
::
opt
(
""
,
"sysroot"
,
"Override the system root"
,
"PATH"
),
opt
::
multi
(
"Z"
,
""
,
"Set internal debugging options"
,
"FLAG"
),
opt
::
opt_u
(
""
,
"output"
,
"How errors and other mesasges are produced"
,
"tty|json"
),
opt
::
opt
(
""
,
"color"
,
"Configure coloring of output:
auto = colorize, if output goes to a tty (default);
always = always colorize output;
...
...
@@ -905,15 +922,36 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
None
=>
ColorConfig
::
Auto
,
Some
(
arg
)
=>
{
early_error
(
ColorConfig
::
Auto
,
&
format!
(
"argument for --color must be auto, always
\
or never (instead was `{}`)"
,
arg
))
early_error
(
ErrorOutputType
::
default
(),
&
format!
(
"argument for --color must be auto,
\
always
or never (instead was `{}`)"
,
arg
))
}
};
// We need the opts_present check because the driver will send us Matches
// with only stable options if no unstable options are used. Since output is
// unstable, it will not be present. We have to use opts_present not
// opt_present because the latter will panic.
let
output
=
if
matches
.opts_present
(
&
[
"output"
.to_owned
()])
{
match
matches
.opt_str
(
"output"
)
.as_ref
()
.map
(|
s
|
&
s
[
..
])
{
Some
(
"tty"
)
=>
ErrorOutputType
::
Tty
(
color
),
Some
(
"json"
)
=>
ErrorOutputType
::
Json
,
None
=>
ErrorOutputType
::
default
(),
Some
(
arg
)
=>
{
early_error
(
ErrorOutputType
::
default
(),
&
format!
(
"argument for --output must be tty or
\
json (instead was `{}`)"
,
arg
))
}
}
}
else
{
ErrorOutputType
::
default
()
};
let
unparsed_crate_types
=
matches
.opt_strs
(
"crate-type"
);
let
crate_types
=
parse_crate_types_from_list
(
unparsed_crate_types
)
.unwrap_or_else
(|
e
|
early_error
(
color
,
&
e
[
..
]));
.unwrap_or_else
(|
e
|
early_error
(
output
,
&
e
[
..
]));
let
mut
lint_opts
=
vec!
();
let
mut
describe_lints
=
false
;
...
...
@@ -930,11 +968,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let
lint_cap
=
matches
.opt_str
(
"cap-lints"
)
.map
(|
cap
|
{
lint
::
Level
::
from_str
(
&
cap
)
.unwrap_or_else
(||
{
early_error
(
color
,
&
format!
(
"unknown lint level: `{}`"
,
cap
))
early_error
(
output
,
&
format!
(
"unknown lint level: `{}`"
,
cap
))
})
});
let
debugging_opts
=
build_debugging_options
(
matches
,
color
);
let
debugging_opts
=
build_debugging_options
(
matches
,
output
);
let
parse_only
=
debugging_opts
.parse_only
;
let
no_trans
=
debugging_opts
.no_trans
;
...
...
@@ -960,7 +998,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
"link"
=>
OutputType
::
Exe
,
"dep-info"
=>
OutputType
::
DepInfo
,
part
=>
{
early_error
(
color
,
&
format!
(
"unknown emission type: `{}`"
,
early_error
(
output
,
&
format!
(
"unknown emission type: `{}`"
,
part
))
}
};
...
...
@@ -973,7 +1011,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
output_types
.insert
(
OutputType
::
Exe
,
None
);
}
let
mut
cg
=
build_codegen_options
(
matches
,
color
);
let
mut
cg
=
build_codegen_options
(
matches
,
output
);
// Issue #30063: if user requests llvm-related output to one
// particular path, disable codegen-units.
...
...
@@ -985,11 +1023,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
})
.collect
();
if
!
incompatible
.is_empty
()
{
for
ot
in
&
incompatible
{
early_warn
(
color
,
&
format!
(
"--emit={} with -o incompatible with
\
early_warn
(
output
,
&
format!
(
"--emit={} with -o incompatible with
\
-C codegen-units=N for N > 1"
,
ot
.shorthand
()));
}
early_warn
(
color
,
"resetting to default -C codegen-units=1"
);
early_warn
(
output
,
"resetting to default -C codegen-units=1"
);
cg
.codegen_units
=
1
;
}
}
...
...
@@ -1002,29 +1040,29 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let
opt_level
=
{
if
matches
.opt_present
(
"O"
)
{
if
cg
.opt_level
.is_some
()
{
early_error
(
color
,
"-O and -C opt-level both provided"
);
early_error
(
output
,
"-O and -C opt-level both provided"
);
}
Default
OptLevel
::
Default
}
else
{
match
cg
.opt_level
{
None
=>
No
,
Some
(
0
)
=>
No
,
Some
(
1
)
=>
Less
,
Some
(
2
)
=>
Default
,
Some
(
3
)
=>
Aggressive
,
None
=>
OptLevel
::
No
,
Some
(
0
)
=>
OptLevel
::
No
,
Some
(
1
)
=>
OptLevel
::
Less
,
Some
(
2
)
=>
OptLevel
::
Default
,
Some
(
3
)
=>
OptLevel
::
Aggressive
,
Some
(
arg
)
=>
{
early_error
(
color
,
&
format!
(
"optimization level needs to be
\
early_error
(
output
,
&
format!
(
"optimization level needs to be
\
between 0-3 (instead was `{}`)"
,
arg
));
}
}
}
};
let
debug_assertions
=
cg
.debug_assertions
.unwrap_or
(
opt_level
==
No
);
let
debug_assertions
=
cg
.debug_assertions
.unwrap_or
(
opt_level
==
OptLevel
::
No
);
let
gc
=
debugging_opts
.gc
;
let
debuginfo
=
if
matches
.opt_present
(
"g"
)
{
if
cg
.debuginfo
.is_some
()
{
early_error
(
color
,
"-g and -C debuginfo both provided"
);
early_error
(
output
,
"-g and -C debuginfo both provided"
);
}
FullDebugInfo
}
else
{
...
...
@@ -1033,7 +1071,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
Some
(
1
)
=>
LimitedDebugInfo
,
Some
(
2
)
=>
FullDebugInfo
,
Some
(
arg
)
=>
{
early_error
(
color
,
&
format!
(
"debug info level needs to be between
\
early_error
(
output
,
&
format!
(
"debug info level needs to be between
\
0-2 (instead was `{}`)"
,
arg
));
}
...
...
@@ -1042,7 +1080,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let
mut
search_paths
=
SearchPaths
::
new
();
for
s
in
&
matches
.opt_strs
(
"L"
)
{
search_paths
.add_path
(
&
s
[
..
],
color
);
search_paths
.add_path
(
&
s
[
..
],
output
);
}
let
libs
=
matches
.opt_strs
(
"l"
)
.into_iter
()
.map
(|
s
|
{
...
...
@@ -1054,7 +1092,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
(
Some
(
name
),
"framework"
)
=>
(
name
,
cstore
::
NativeFramework
),
(
Some
(
name
),
"static"
)
=>
(
name
,
cstore
::
NativeStatic
),
(
_
,
s
)
=>
{
early_error
(
color
,
&
format!
(
"unknown library kind `{}`, expected
\
early_error
(
output
,
&
format!
(
"unknown library kind `{}`, expected
\
one of dylib, framework, or static"
,
s
));
}
...
...
@@ -1071,13 +1109,13 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
"file-names"
=>
PrintRequest
::
FileNames
,
"sysroot"
=>
PrintRequest
::
Sysroot
,
req
=>
{
early_error
(
color
,
&
format!
(
"unknown print request `{}`"
,
req
))
early_error
(
output
,
&
format!
(
"unknown print request `{}`"
,
req
))
}
}
})
.collect
::
<
Vec
<
_
>>
();
if
!
cg
.remark
.is_empty
()
&&
debuginfo
==
NoDebugInfo
{
early_warn
(
color
,
"-C remark will not show source locations without
\
early_warn
(
output
,
"-C remark will not show source locations without
\
--debuginfo"
);
}
...
...
@@ -1086,11 +1124,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let
mut
parts
=
arg
.splitn
(
2
,
'='
);
let
name
=
match
parts
.next
()
{
Some
(
s
)
=>
s
,
None
=>
early_error
(
color
,
"--extern value must not be empty"
),
None
=>
early_error
(
output
,
"--extern value must not be empty"
),
};
let
location
=
match
parts
.next
()
{
Some
(
s
)
=>
s
,
None
=>
early_error
(
color
,
"--extern value must be of the format `foo=bar`"
),
None
=>
early_error
(
output
,
"--extern value must be of the format `foo=bar`"
),
};
externs
.entry
(
name
.to_string
())
.or_insert
(
vec!
[])
.push
(
location
.to_string
());
...
...
@@ -1121,7 +1159,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
debugging_opts
:
debugging_opts
,
prints
:
prints
,
cg
:
cg
,
color
:
color
,
output
:
output
,
externs
:
externs
,
crate_name
:
crate_name
,
alt_std_name
:
None
,
...
...
src/librustc/session/mod.rs
浏览文件 @
fd46c78f
...
...
@@ -17,7 +17,8 @@
use
syntax
::
ast
::{
NodeId
,
NodeIdAssigner
,
Name
};
use
syntax
::
codemap
::
Span
;
use
syntax
::
errors
::{
self
,
DiagnosticBuilder
};
use
syntax
::
errors
::
emitter
::{
Emitter
,
BasicEmitter
};
use
syntax
::
errors
::
emitter
::{
Emitter
,
BasicEmitter
,
EmitterWriter
};
use
syntax
::
errors
::
json
::
JsonEmitter
;
use
syntax
::
diagnostics
;
use
syntax
::
feature_gate
;
use
syntax
::
parse
;
...
...
@@ -405,12 +406,19 @@ pub fn build_session(sopts: config::Options,
let
treat_err_as_bug
=
sopts
.treat_err_as_bug
;
let
codemap
=
Rc
::
new
(
codemap
::
CodeMap
::
new
());
let
emitter
:
Box
<
Emitter
>
=
match
sopts
.output
{
config
::
ErrorOutputType
::
Tty
(
color_config
)
=>
{
Box
::
new
(
EmitterWriter
::
stderr
(
color_config
,
Some
(
registry
),
codemap
.clone
()))
}
config
::
ErrorOutputType
::
Json
=>
{
Box
::
new
(
JsonEmitter
::
stderr
(
Some
(
registry
),
codemap
.clone
()))
}
};
let
diagnostic_handler
=
errors
::
Handler
::
new
(
sopts
.color
,
Some
(
registry
),
can_print_warnings
,
treat_err_as_bug
,
codemap
.clone
());
errors
::
Handler
::
with_emitter
(
can_print_warnings
,
treat_err_as_bug
,
emitter
);
build_session_
(
sopts
,
local_crate_source_file
,
diagnostic_handler
,
codemap
,
cstore
)
}
...
...
@@ -473,13 +481,19 @@ pub fn build_session_(sopts: config::Options,
sess
}
pub
fn
early_error
(
color
:
errors
::
ColorConfig
,
msg
:
&
str
)
->
!
{
let
mut
emitter
=
BasicEmitter
::
stderr
(
color
);
pub
fn
early_error
(
output
:
config
::
ErrorOutputType
,
msg
:
&
str
)
->
!
{
let
mut
emitter
:
Box
<
Emitter
>
=
match
output
{
config
::
ErrorOutputType
::
Tty
(
color_config
)
=>
Box
::
new
(
BasicEmitter
::
stderr
(
color_config
)),
config
::
ErrorOutputType
::
Json
=>
Box
::
new
(
JsonEmitter
::
basic
()),
};
emitter
.emit
(
None
,
msg
,
None
,
errors
::
Level
::
Fatal
);
panic!
(
errors
::
FatalError
);
}
pub
fn
early_warn
(
color
:
errors
::
ColorConfig
,
msg
:
&
str
)
{
let
mut
emitter
=
BasicEmitter
::
stderr
(
color
);
pub
fn
early_warn
(
output
:
config
::
ErrorOutputType
,
msg
:
&
str
)
{
let
mut
emitter
:
Box
<
Emitter
>
=
match
output
{
config
::
ErrorOutputType
::
Tty
(
color_config
)
=>
Box
::
new
(
BasicEmitter
::
stderr
(
color_config
)),
config
::
ErrorOutputType
::
Json
=>
Box
::
new
(
JsonEmitter
::
basic
()),
};
emitter
.emit
(
None
,
msg
,
None
,
errors
::
Level
::
Warning
);
}
src/librustc/session/search_paths.rs
浏览文件 @
fd46c78f
...
...
@@ -10,8 +10,7 @@
use
std
::
slice
;
use
std
::
path
::{
Path
,
PathBuf
};
use
session
::
early_error
;
use
syntax
::
errors
;
use
session
::{
early_error
,
config
};
#[derive(Clone,
Debug)]
pub
struct
SearchPaths
{
...
...
@@ -38,7 +37,7 @@ pub fn new() -> SearchPaths {
SearchPaths
{
paths
:
Vec
::
new
()
}
}
pub
fn
add_path
(
&
mut
self
,
path
:
&
str
,
color
:
errors
::
ColorConfig
)
{
pub
fn
add_path
(
&
mut
self
,
path
:
&
str
,
output
:
config
::
ErrorOutputType
)
{
let
(
kind
,
path
)
=
if
path
.starts_with
(
"native="
)
{
(
PathKind
::
Native
,
&
path
[
"native="
.len
()
..
])
}
else
if
path
.starts_with
(
"crate="
)
{
...
...
@@ -53,7 +52,7 @@ pub fn add_path(&mut self, path: &str, color: errors::ColorConfig) {
(
PathKind
::
All
,
path
)
};
if
path
.is_empty
()
{
early_error
(
color
,
"empty search path given via `-L`"
);
early_error
(
output
,
"empty search path given via `-L`"
);
}
self
.paths
.push
((
kind
,
PathBuf
::
from
(
path
)));
}
...
...
src/librustc_driver/lib.rs
浏览文件 @
fd46c78f
...
...
@@ -62,7 +62,7 @@
use
rustc_trans
::
back
::
link
;
use
rustc_trans
::
save
;
use
rustc
::
session
::{
config
,
Session
,
build_session
};
use
rustc
::
session
::
config
::{
Input
,
PrintRequest
,
OutputType
};
use
rustc
::
session
::
config
::{
Input
,
PrintRequest
,
OutputType
,
ErrorOutputType
};
use
rustc
::
middle
::
cstore
::
CrateStore
;
use
rustc
::
lint
::
Lint
;
use
rustc
::
lint
;
...
...
@@ -72,6 +72,7 @@
use
std
::
cmp
::
max
;
use
std
::
cmp
::
Ordering
::
Equal
;
use
std
::
default
::
Default
;
use
std
::
env
;
use
std
::
io
::{
self
,
Read
,
Write
};
use
std
::
iter
::
repeat
;
...
...
@@ -126,7 +127,7 @@ pub fn run_compiler<'a>(args: &[String], callbacks: &mut CompilerCalls<'a>) {
let
descriptions
=
diagnostics_registry
();
do_or_return!
(
callbacks
.early_callback
(
&
matches
,
&
descriptions
,
sopts
.
color
));
do_or_return!
(
callbacks
.early_callback
(
&
matches
,
&
descriptions
,
sopts
.
output
));
let
(
odir
,
ofile
)
=
make_output
(
&
matches
);
let
(
input
,
input_file_path
)
=
match
make_input
(
&
matches
.free
)
{
...
...
@@ -214,7 +215,7 @@ pub trait CompilerCalls<'a> {
fn
early_callback
(
&
mut
self
,
_
:
&
getopts
::
Matches
,
_
:
&
diagnostics
::
registry
::
Registry
,
_
:
errors
::
ColorConfig
)
_
:
ErrorOutputType
)
->
Compilation
{
Compilation
::
Continue
}
...
...
@@ -290,7 +291,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
fn
early_callback
(
&
mut
self
,
matches
:
&
getopts
::
Matches
,
descriptions
:
&
diagnostics
::
registry
::
Registry
,
color
:
errors
::
ColorConfig
)
output
:
ErrorOutputType
)
->
Compilation
{
match
matches
.opt_str
(
"explain"
)
{
Some
(
ref
code
)
=>
{
...
...
@@ -305,7 +306,7 @@ fn early_callback(&mut self,
print!
(
"{}"
,
&
description
[
1
..
]);
}
None
=>
{
early_error
(
color
,
&
format!
(
"no extended information for {}"
,
code
));
early_error
(
output
,
&
format!
(
"no extended information for {}"
,
code
));
}
}
return
Compilation
::
Stop
;
...
...
@@ -339,10 +340,10 @@ fn no_input(&mut self,
if
should_stop
==
Compilation
::
Stop
{
return
None
;
}
early_error
(
sopts
.
color
,
"no input filename given"
);
early_error
(
sopts
.
output
,
"no input filename given"
);
}
1
=>
panic!
(
"make_input should have provided valid inputs"
),
_
=>
early_error
(
sopts
.
color
,
"multiple input filenames provided"
),
_
=>
early_error
(
sopts
.
output
,
"multiple input filenames provided"
),
}
None
...
...
@@ -432,7 +433,7 @@ pub fn list_metadata(sess: &Session, matches: &getopts::Matches, input: &Input)
println!
(
"{}"
,
String
::
from_utf8
(
v
)
.unwrap
());
}
&
Input
::
Str
(
_
)
=>
{
early_error
(
sess
.opts.color
,
"cannot list metadata for stdin"
);
early_error
(
ErrorOutputType
::
default
()
,
"cannot list metadata for stdin"
);
}
}
return
Compilation
::
Stop
;
...
...
@@ -459,7 +460,7 @@ fn print_crate_info(sess: &Session,
PrintRequest
::
CrateName
=>
{
let
input
=
match
input
{
Some
(
input
)
=>
input
,
None
=>
early_error
(
sess
.opts.color
,
"no input file provided"
),
None
=>
early_error
(
ErrorOutputType
::
default
()
,
"no input file provided"
),
};
let
attrs
=
attrs
.as_ref
()
.unwrap
();
let
t_outputs
=
driver
::
build_output_filenames
(
input
,
odir
,
ofile
,
attrs
,
sess
);
...
...
@@ -752,7 +753,7 @@ fn parse_all_options(args: &Vec<String>) -> getopts::Matches {
&
opt
.opt_group.short_name
};
if
m
.opt_present
(
opt_name
)
{
early_error
(
errors
::
ColorConfig
::
Auto
,
early_error
(
ErrorOutputType
::
default
()
,
&
format!
(
"use of unstable option '{}' requires -Z
\
unstable-options"
,
opt_name
));
...
...
@@ -761,7 +762,7 @@ fn parse_all_options(args: &Vec<String>) -> getopts::Matches {
}
m
}
Err
(
f
)
=>
early_error
(
errors
::
ColorConfig
::
Auto
,
&
f
.to_string
()),
Err
(
f
)
=>
early_error
(
ErrorOutputType
::
default
()
,
&
f
.to_string
()),
}
}
...
...
src/librustc_trans/back/linker.rs
浏览文件 @
fd46c78f
...
...
@@ -149,8 +149,8 @@ fn optimize(&mut self) {
// GNU-style linkers support optimization with -O. GNU ld doesn't
// need a numeric argument, but other linkers do.
if
self
.sess.opts.optimize
==
config
::
Default
||
self
.sess.opts.optimize
==
config
::
Aggressive
{
if
self
.sess.opts.optimize
==
config
::
OptLevel
::
Default
||
self
.sess.opts.optimize
==
config
::
OptLevel
::
Aggressive
{
self
.cmd
.arg
(
"-Wl,-O1"
);
}
}
...
...
src/librustc_trans/back/write.rs
浏览文件 @
fd46c78f
...
...
@@ -144,10 +144,10 @@ fn target_feature(sess: &Session) -> String {
fn
get_llvm_opt_level
(
optimize
:
config
::
OptLevel
)
->
llvm
::
CodeGenOptLevel
{
match
optimize
{
config
::
No
=>
llvm
::
CodeGenLevelNone
,
config
::
Less
=>
llvm
::
CodeGenLevelLess
,
config
::
Default
=>
llvm
::
CodeGenLevelDefault
,
config
::
Aggressive
=>
llvm
::
CodeGenLevelAggressive
,
config
::
OptLevel
::
No
=>
llvm
::
CodeGenLevelNone
,
config
::
OptLevel
::
Less
=>
llvm
::
CodeGenLevelLess
,
config
::
OptLevel
::
Default
=>
llvm
::
CodeGenLevelDefault
,
config
::
OptLevel
::
Aggressive
=>
llvm
::
CodeGenLevelAggressive
,
}
}
...
...
@@ -303,13 +303,13 @@ fn set_flags(&mut self, sess: &Session, trans: &CrateTranslation) {
// slp vectorization at O3. Otherwise configure other optimization aspects
// of this pass manager builder.
self
.vectorize_loop
=
!
sess
.opts.cg.no_vectorize_loops
&&
(
sess
.opts.optimize
==
config
::
Default
||
sess
.opts.optimize
==
config
::
Aggressive
);
(
sess
.opts.optimize
==
config
::
OptLevel
::
Default
||
sess
.opts.optimize
==
config
::
OptLevel
::
Aggressive
);
self
.vectorize_slp
=
!
sess
.opts.cg.no_vectorize_slp
&&
sess
.opts.optimize
==
config
::
Aggressive
;
sess
.opts.optimize
==
config
::
OptLevel
::
Aggressive
;
self
.merge_functions
=
sess
.opts.optimize
==
config
::
Default
||
sess
.opts.optimize
==
config
::
Aggressive
;
self
.merge_functions
=
sess
.opts.optimize
==
config
::
OptLevel
::
Default
||
sess
.opts.optimize
==
config
::
OptLevel
::
Aggressive
;
}
}
...
...
src/librustc_trans/trans/base.rs
浏览文件 @
fd46c78f
...
...
@@ -1163,7 +1163,7 @@ fn core_lifetime_emit<'blk, 'tcx, F>(ccx: &'blk CrateContext<'blk, 'tcx>,
emit
:
F
)
where
F
:
FnOnce
(
&
'blk
CrateContext
<
'blk
,
'tcx
>
,
machine
::
llsize
,
ValueRef
)
{
if
ccx
.sess
()
.opts.optimize
==
config
::
No
{
if
ccx
.sess
()
.opts.optimize
==
config
::
OptLevel
::
No
{
return
;
}
...
...
src/librustc_trans/trans/debuginfo/metadata.rs
浏览文件 @
fd46c78f
...
...
@@ -1020,7 +1020,7 @@ pub fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
compile_unit_name
,
work_dir
.as_ptr
(),
producer
.as_ptr
(),
cx
.sess
()
.opts.optimize
!=
config
::
No
,
cx
.sess
()
.opts.optimize
!=
config
::
OptLevel
::
No
,
flags
.as_ptr
()
as
*
const
_
,
0
,
split_name
.as_ptr
()
as
*
const
_
)
...
...
src/librustc_trans/trans/debuginfo/mod.rs
浏览文件 @
fd46c78f
...
...
@@ -383,7 +383,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
true
,
scope_line
as
c_uint
,
FlagPrototyped
as
c_uint
,
cx
.sess
()
.opts.optimize
!=
config
::
No
,
cx
.sess
()
.opts.optimize
!=
config
::
OptLevel
::
No
,
llfn
,
template_parameters
,
ptr
::
null_mut
())
...
...
@@ -596,7 +596,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
file_metadata
,
loc
.line
as
c_uint
,
type_metadata
,
cx
.sess
()
.opts.optimize
!=
config
::
No
,
cx
.sess
()
.opts.optimize
!=
config
::
OptLevel
::
No
,
0
,
address_operations
.as_ptr
(),
address_operations
.len
()
as
c_uint
,
...
...
src/libsyntax/errors/emitter.rs
浏览文件 @
fd46c78f
...
...
@@ -43,7 +43,7 @@ fn emit_struct(&mut self, db: &DiagnosticBuilder) {
/// maximum number of lines we will print for each error; arbitrary.
const
MAX_LINES
:
usize
=
6
;
#[derive(Clone,
Copy)]
#[derive(Clone,
Copy
,
Debug,
PartialEq,
Eq
)]
pub
enum
ColorConfig
{
Auto
,
Always
,
...
...
src/libsyntax/errors/mod.rs
浏览文件 @
fd46c78f
...
...
@@ -276,6 +276,7 @@ pub struct Handler {
}
impl
Handler
{
// TODO remove
pub
fn
new
(
color_config
:
ColorConfig
,
registry
:
Option
<
diagnostics
::
registry
::
Registry
>
,
can_emit_warnings
:
bool
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录