Skip to content

Commit 803e92d

Browse files
committed
auto merge of #14326 : huonw/rust/tiny-fixes, r=pnkfelix
The changes to flowgraph make invalid invocations slightly more forgiving by (trying to) provide slightly more information and by avoiding the ICE message.
2 parents 1edb0e5 + feb91f3 commit 803e92d

File tree

7 files changed

+101
-84
lines changed

7 files changed

+101
-84
lines changed

src/librustc/driver/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct Options {
7070
pub gc: bool,
7171
pub optimize: OptLevel,
7272
pub debuginfo: DebugInfoLevel,
73-
pub lint_opts: Vec<(lint::Lint, lint::level)> ,
73+
pub lint_opts: Vec<(lint::Lint, lint::Level)> ,
7474
pub output_types: Vec<back::link::OutputType> ,
7575
// This was mutable for rustpkg, which updates search paths based on the
7676
// parsed code. It remains mutable in case its replacements wants to use
@@ -580,8 +580,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
580580
let no_trans = matches.opt_present("no-trans");
581581
let no_analysis = matches.opt_present("no-analysis");
582582

583-
let lint_levels = [lint::allow, lint::warn,
584-
lint::deny, lint::forbid];
583+
let lint_levels = [lint::Allow, lint::Warn,
584+
lint::Deny, lint::Forbid];
585585
let mut lint_opts = Vec::new();
586586
let lint_dict = lint::get_lint_dict();
587587
for level in lint_levels.iter() {

src/librustc/driver/driver.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
226226
krate = time(time_passes, "prelude injection", krate, |krate|
227227
front::std_inject::maybe_inject_prelude(sess, krate));
228228

229-
let (krate, map) = time(time_passes, "assinging node ids and indexing ast", krate, |krate|
229+
let (krate, map) = time(time_passes, "assigning node ids and indexing ast", krate, |krate|
230230
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
231231

232232
if sess.opts.debugging_opts & config::AST_JSON != 0 {
@@ -653,11 +653,22 @@ pub fn pretty_print_input(sess: Session,
653653
PpmFlowGraph(nodeid) => {
654654
let ast_map = ast_map.expect("--pretty flowgraph missing ast_map");
655655
let node = ast_map.find(nodeid).unwrap_or_else(|| {
656-
fail!("--pretty flowgraph=id couldn't find id: {}", id)
656+
sess.fatal(format_strbuf!("--pretty flowgraph couldn't find id: {}",
657+
nodeid).as_slice())
657658
});
658659
let block = match node {
659660
syntax::ast_map::NodeBlock(block) => block,
660-
_ => fail!("--pretty=flowgraph needs block, got {:?}", node)
661+
_ => {
662+
let message = format_strbuf!("--pretty=flowgraph needs block, got {:?}",
663+
node);
664+
665+
// point to what was found, if there's an
666+
// accessible span.
667+
match ast_map.opt_span(nodeid) {
668+
Some(sp) => sess.span_fatal(sp, message.as_slice()),
669+
None => sess.fatal(message.as_slice())
670+
}
671+
}
661672
};
662673
let analysis = phase_3_run_analysis_passes(sess, &krate, ast_map);
663674
print_flowgraph(analysis, block, out)
@@ -846,4 +857,3 @@ pub fn build_output_filenames(input: &Input,
846857
}
847858
}
848859
}
849-

src/librustc/driver/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,12 @@ pub fn parse_pretty(sess: &Session, name: &str) -> PpMode {
302302
(None, "typed") => PpmTyped,
303303
(None, "expanded,identified") => PpmExpandedIdentified,
304304
(None, "identified") => PpmIdentified,
305-
(Some(s), "flowgraph") => {
306-
match from_str(s) {
305+
(arg, "flowgraph") => {
306+
match arg.and_then(from_str) {
307307
Some(id) => PpmFlowGraph(id),
308-
None => sess.fatal(format!("`pretty flowgraph=<nodeid>` needs \
309-
an integer <nodeid>; got {}", s))
308+
None => sess.fatal(format_strbuf!("`pretty flowgraph=<nodeid>` needs \
309+
an integer <nodeid>; got {}",
310+
arg.unwrap_or("nothing")).as_slice())
310311
}
311312
}
312313
_ => {

src/librustc/middle/dead.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// closely. The idea is that all reachable symbols are live, codes called
1313
// from live codes are live, and everything else is dead.
1414

15-
use middle::lint::{allow, contains_lint, DeadCode};
15+
use middle::lint::{Allow, contains_lint, DeadCode};
1616
use middle::privacy;
1717
use middle::ty;
1818
use middle::typeck;
@@ -195,7 +195,7 @@ impl<'a> Visitor<()> for MarkSymbolVisitor<'a> {
195195
}
196196

197197
fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
198-
contains_lint(attrs, allow, DEAD_CODE_LINT_STR)
198+
contains_lint(attrs, Allow, DEAD_CODE_LINT_STR)
199199
|| attr::contains_name(attrs.as_slice(), "lang")
200200
}
201201

0 commit comments

Comments
 (0)