Skip to content

Commit 7bc41ce

Browse files
committed
---
yaml --- r: 115165 b: refs/heads/auto c: feb91f3 h: refs/heads/master i: 115163: b798a13 v: v3
1 parent e0d897c commit 7bc41ce

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: dd5365af2c4281f2808ffa35faf6f53411814267
16+
refs/heads/auto: feb91f3216c7a60c9f7da582b3a02551fe73bb40
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/driver/driver.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

branches/auto/src/librustc/driver/mod.rs

Lines changed: 5 additions & 4 deletions
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
_ => {

branches/auto/src/libsyntax/ast_map.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ impl Map {
388388
f(attrs)
389389
}
390390

391-
pub fn span(&self, id: NodeId) -> Span {
392-
match self.find(id) {
391+
pub fn opt_span(&self, id: NodeId) -> Option<Span> {
392+
let sp = match self.find(id) {
393393
Some(NodeItem(item)) => item.span,
394394
Some(NodeForeignItem(foreign_item)) => foreign_item.span,
395395
Some(NodeTraitMethod(trait_method)) => {
@@ -406,8 +406,14 @@ impl Map {
406406
Some(NodePat(pat)) => pat.span,
407407
Some(NodeBlock(block)) => block.span,
408408
Some(NodeStructCtor(_)) => self.expect_item(self.get_parent(id)).span,
409-
_ => fail!("node_span: could not find span for id {}", id),
410-
}
409+
_ => return None,
410+
};
411+
Some(sp)
412+
}
413+
414+
pub fn span(&self, id: NodeId) -> Span {
415+
self.opt_span(id)
416+
.unwrap_or_else(|| fail!("AstMap.span: could not find span for id {}", id))
411417
}
412418

413419
pub fn node_to_str(&self, id: NodeId) -> StrBuf {

0 commit comments

Comments
 (0)