diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-12 18:06:36 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-12 18:06:36 +0000 |
commit | a15d19619e097b14b670064a4edc054a4251f479 (patch) | |
tree | 87f60edd15e470fbc342cef28b0674ba1cf71df9 /crates/hir_ty/src | |
parent | 10f633283180d513138d0d969eceba96e3ce9f96 (diff) | |
parent | 69b78edb5e2a40d8665db713d363bd16c835d6cf (diff) |
Merge #6845
6845: Don't HirDisplay unknown types when displaying for source r=Veykril a=Veykril
Was wondering why the add missing impl assist didn't do anything here:

Turns out me forgetting to set the Index::Idx type in the trait causes RA to panic due to it trying to to create an unparsable type in the `make` module.
Now we get this instead which imo is definitely better to have.

Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r-- | crates/hir_ty/src/display.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 0d968cc68..0e827a29e 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -178,6 +178,7 @@ impl DisplayTarget { | |||
178 | #[derive(Debug)] | 178 | #[derive(Debug)] |
179 | pub enum DisplaySourceCodeError { | 179 | pub enum DisplaySourceCodeError { |
180 | PathNotFound, | 180 | PathNotFound, |
181 | UnknownType, | ||
181 | } | 182 | } |
182 | 183 | ||
183 | pub enum HirDisplayError { | 184 | pub enum HirDisplayError { |
@@ -558,7 +559,14 @@ impl HirDisplay for Ty { | |||
558 | } | 559 | } |
559 | }; | 560 | }; |
560 | } | 561 | } |
561 | Ty::Unknown => write!(f, "{{unknown}}")?, | 562 | Ty::Unknown => { |
563 | if f.display_target.is_source_code() { | ||
564 | return Err(HirDisplayError::DisplaySourceCodeError( | ||
565 | DisplaySourceCodeError::UnknownType, | ||
566 | )); | ||
567 | } | ||
568 | write!(f, "{{unknown}}")?; | ||
569 | } | ||
562 | Ty::Infer(..) => write!(f, "_")?, | 570 | Ty::Infer(..) => write!(f, "_")?, |
563 | } | 571 | } |
564 | Ok(()) | 572 | Ok(()) |