Skip to content

Commit 2b73335

Browse files
committed
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.
2 parents 6c990bf + 3bef085 commit 2b73335

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/librustc_driver/pretty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ fn get_source(input: &Input, sess: &Session) -> (Vec<u8>, String) {
757757
let src_name = driver::source_name(input);
758758
let src = sess.codemap()
759759
.get_filemap(&src_name)
760+
.unwrap()
760761
.src
761762
.as_ref()
762763
.unwrap()

src/libsyntax/codemap.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1191,13 +1191,13 @@ impl CodeMap {
11911191
}
11921192
}
11931193

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

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

0 commit comments

Comments
 (0)