diff options
| author | Kamal Marhubi <kamal@marhubi.com> | 2016-05-24 16:08:01 +0200 |
|---|---|---|
| committer | Kamal Marhubi <kamal@marhubi.com> | 2016-05-24 16:08:01 +0200 |
| commit | 3bef085ea8da749c234fb4afc749810a5b9c6c16 (patch) | |
| tree | d246cb8d1d4e414c1067bdbd466ec96b237c098e /src/libsyntax | |
| parent | dd6e8d45e183861d44ed91a99f0a50403b2776a3 (diff) | |
| download | rust-3bef085ea8da749c234fb4afc749810a5b9c6c16.tar.gz rust-3bef085ea8da749c234fb4afc749810a5b9c6c16.zip | |
syntax: Make codemap::get_filemap() return an Option
This is more idiomatic, putting the caller in charge of whether or not to panic.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 6 |
1 files changed, 3 insertions, 3 deletions
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 |
