From 50e01d2bc7429d718e0783d75458a6a047ee2b70 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 1 Mar 2021 21:57:39 +0100 Subject: Use chalk_ir::AdtId --- crates/hir_ty/src/diagnostics/expr.rs | 14 ++++++++------ crates/hir_ty/src/diagnostics/match_check.rs | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'crates/hir_ty/src/diagnostics') diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 66a88e2b6..2751cd304 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -2,9 +2,7 @@ use std::sync::Arc; -use hir_def::{ - expr::Statement, path::path, resolver::HasResolver, AdtId, AssocItemId, DefWithBodyId, -}; +use hir_def::{expr::Statement, path::path, resolver::HasResolver, AssocItemId, DefWithBodyId}; use hir_expand::{diagnostics::DiagnosticSink, name}; use rustc_hash::FxHashSet; use syntax::{ast, AstPtr}; @@ -17,7 +15,7 @@ use crate::{ MissingPatFields, RemoveThisSemicolon, }, utils::variant_data, - InferenceResult, Ty, + AdtId, InferenceResult, Ty, }; pub(crate) use hir_def::{ @@ -382,10 +380,14 @@ impl<'a, 'b> ExprValidator<'a, 'b> { }; let (params, required) = match mismatch.expected { - Ty::Adt(AdtId::EnumId(enum_id), ref parameters) if enum_id == core_result_enum => { + Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters) + if enum_id == core_result_enum => + { (parameters, "Ok".to_string()) } - Ty::Adt(AdtId::EnumId(enum_id), ref parameters) if enum_id == core_option_enum => { + Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters) + if enum_id == core_option_enum => + { (parameters, "Some".to_string()) } _ => return, diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs index 86fee0050..04d39c571 100644 --- a/crates/hir_ty/src/diagnostics/match_check.rs +++ b/crates/hir_ty/src/diagnostics/match_check.rs @@ -222,12 +222,12 @@ use hir_def::{ adt::VariantData, body::Body, expr::{Expr, Literal, Pat, PatId}, - AdtId, EnumVariantId, StructId, VariantId, + EnumVariantId, StructId, VariantId, }; use la_arena::Idx; use smallvec::{smallvec, SmallVec}; -use crate::{db::HirDatabase, InferenceResult, Ty}; +use crate::{db::HirDatabase, AdtId, InferenceResult, Ty}; #[derive(Debug, Clone, Copy)] /// Either a pattern from the source code being analyzed, represented as @@ -627,7 +627,7 @@ pub(super) fn is_useful( // - `!` type // In those cases, no match arm is useful. match cx.infer[cx.match_expr].strip_references() { - Ty::Adt(AdtId::EnumId(enum_id), ..) => { + Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ..) => { if cx.db.enum_data(*enum_id).variants.is_empty() { return Ok(Usefulness::NotUseful); } -- cgit v1.2.3