aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-04-06 13:42:34 +0100
committerLukas Wirth <[email protected]>2021-04-06 13:42:34 +0100
commita43409fa4313938be21c8650eb2f523fefdcb508 (patch)
tree74127486a51a5886bfebce09f7db6c0a57c098d6 /crates
parentffdb2da49d08384368fbc50d4f60a8dfd2ab70ee (diff)
Panic when creating a HirDisplayWrapper with DisplayTarget::SourceCode
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/display.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 4af2bcf7a..9e6bbcdf1 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -51,6 +51,10 @@ pub trait HirDisplay {
51 where 51 where
52 Self: Sized, 52 Self: Sized,
53 { 53 {
54 assert!(
55 !matches!(display_target, DisplayTarget::SourceCode { .. }),
56 "HirDisplayWrapper cannot fail with DisplaySourceCodeError, use HirDisplay::hir_fmt directly instead"
57 );
54 HirDisplayWrapper { db, t: self, max_size, omit_verbose_types, display_target } 58 HirDisplayWrapper { db, t: self, max_size, omit_verbose_types, display_target }
55 } 59 }
56 60
@@ -235,7 +239,7 @@ where
235 Err(HirDisplayError::FmtError) => Err(fmt::Error), 239 Err(HirDisplayError::FmtError) => Err(fmt::Error),
236 Err(HirDisplayError::DisplaySourceCodeError(_)) => { 240 Err(HirDisplayError::DisplaySourceCodeError(_)) => {
237 // This should never happen 241 // This should never happen
238 panic!("HirDisplay failed when calling Display::fmt!") 242 panic!("HirDisplay::hir_fmt failed with DisplaySourceCodeError when calling Display::fmt!")
239 } 243 }
240 } 244 }
241 } 245 }