diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-05-27 10:02:45 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-05-27 10:02:45 +0530 |
| commit | 63dfbdbc1bc1ace106a525682f77b3d08af9ad71 (patch) | |
| tree | 7e1af7784abe1ebab1c219d13e1a57439eb91996 | |
| parent | 7905452f083ab5ac3008dfe6727048e70bbeb142 (diff) | |
| parent | 3bef085ea8da749c234fb4afc749810a5b9c6c16 (diff) | |
| download | rust-63dfbdbc1bc1ace106a525682f77b3d08af9ad71.tar.gz rust-63dfbdbc1bc1ace106a525682f77b3d08af9ad71.zip | |
Rollup merge of #33839 - kamalmarhubi:codemape-get-filemap-option, r=nmatsakis
This is more idiomatic, putting the caller in charge of whether or not to panic.
| -rw-r--r-- | src/librustc_driver/pretty.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 8c84e561e31..0a093887c50 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -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() diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index ca8708fdc83..3b13bf2fc50 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -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 |
