about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhyd-dev <yd-huang@outlook.com>2021-03-15 20:44:48 +0800
committerhyd-dev <yd-huang@outlook.com>2021-03-15 20:45:45 +0800
commit4709dcd476540621f7fb023ae68b4f916d857278 (patch)
tree8ed43aa72127719b59f0af3ff84db6a7a15887bb
parent176bb6bd38dc73557dc6947077f7239dda7b64ef (diff)
downloadrust-4709dcd476540621f7fb023ae68b4f916d857278.tar.gz
rust-4709dcd476540621f7fb023ae68b4f916d857278.zip
Change the `.unwrap` to `.expect` with a helpful message
-rw-r--r--compiler/rustc_interface/src/interface.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs
index 14bffb54e7a..a1090ee316d 100644
--- a/compiler/rustc_interface/src/interface.rs
+++ b/compiler/rustc_interface/src/interface.rs
@@ -181,7 +181,11 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
     );
 
     if let Some(parse_sess_created) = config.parse_sess_created {
-        parse_sess_created(&mut Lrc::get_mut(&mut sess).unwrap().parse_sess);
+        parse_sess_created(
+            &mut Lrc::get_mut(&mut sess)
+                .expect("create_session() should never share the returned session")
+                .parse_sess,
+        );
     }
 
     let compiler = Compiler {