Skip to content

syntax: Make codemap::get_filemap() return an Option #33839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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