diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_ty/src/display.rs | 6 |
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 | } |