Skip to content

Commit

Permalink
Rollup merge of #33839 - kamalmarhubi:codemape-get-filemap-option, r=…
Browse files Browse the repository at this point in the history
…nmatsakis

 This is more idiomatic, putting the caller in charge of whether or not
to panic.
  • Loading branch information
Manishearth committed May 27, 2016
2 parents 7905452 + 3bef085 commit 63dfbdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ fn get_source(input: &Input, sess: &Session) -> (Vec<u8>, String) {
let src_name = driver::source_name(input);
let src = sess.codemap()
.get_filemap(&src_name)
.unwrap()
.src
.as_ref()
.unwrap()
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,13 +1191,13 @@ impl CodeMap {
}
}

pub fn get_filemap(&self, filename: &str) -> Rc<FileMap> {
pub fn get_filemap(&self, filename: &str) -> Option<Rc<FileMap>> {
for fm in self.files.borrow().iter() {
if filename == fm.name {
return fm.clone();
return Some(fm.clone());
}
}
panic!("asking for {} which we don't know about", filename);
None
}

/// For a global BytePos compute the local offset within the containing FileMap
Expand Down

0 comments on commit 63dfbdb

Please sign in to comment.