diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2024-10-17 12:59:40 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2024-10-19 11:09:24 -0700 |
| commit | e1d6164607d63df552ce2adf900c2c4cbf7f5ce3 (patch) | |
| tree | d9f1a1a28e4efd7618cec0440ddee05b59ee3dee | |
| parent | 6a834b4df8a45fafea84761b6e25ccdf75cec007 (diff) | |
| download | rust-e1d6164607d63df552ce2adf900c2c4cbf7f5ce3.tar.gz rust-e1d6164607d63df552ce2adf900c2c4cbf7f5ce3.zip | |
rust-analyzer: Nest `LayoutCalculatorError` in `hir_ty::LayoutError`
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-ty/src/layout.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index 4cdc0db46a1..bce6a80b5b0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -72,6 +72,8 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx #[derive(Debug, PartialEq, Eq, Clone)] pub enum LayoutError { + // FIXME: Remove variants that duplicate LayoutCalculatorError's variants after sync + BadCalc(LayoutCalculatorError<()>), EmptyUnion, HasErrorConst, HasErrorType, @@ -90,6 +92,7 @@ impl std::error::Error for LayoutError {} impl fmt::Display for LayoutError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + LayoutError::BadCalc(err) => err.fallback_fmt(f), LayoutError::EmptyUnion => write!(f, "type is an union with no fields"), LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"), LayoutError::HasErrorType => write!(f, "type contains an error"), @@ -114,11 +117,7 @@ impl fmt::Display for LayoutError { impl<F> From<LayoutCalculatorError<F>> for LayoutError { fn from(err: LayoutCalculatorError<F>) -> Self { - match err { - LayoutCalculatorError::EmptyUnion => LayoutError::EmptyUnion, - LayoutCalculatorError::UnexpectedUnsized(_) => LayoutError::UnexpectedUnsized, - LayoutCalculatorError::SizeOverflow => LayoutError::SizeOverflow, - } + LayoutError::BadCalc(err.without_payload()) } } |
