mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
internal: Revert castable expectation and simplify
This commit is contained in:
parent
8f5deb4ff2
commit
79492cb8ae
5 changed files with 88 additions and 31 deletions
|
@ -219,6 +219,7 @@ struct InternedStandardTypes {
|
|||
unknown: Ty,
|
||||
bool_: Ty,
|
||||
unit: Ty,
|
||||
never: Ty,
|
||||
}
|
||||
|
||||
impl Default for InternedStandardTypes {
|
||||
|
@ -227,6 +228,7 @@ impl Default for InternedStandardTypes {
|
|||
unknown: TyKind::Error.intern(Interner),
|
||||
bool_: TyKind::Scalar(Scalar::Bool).intern(Interner),
|
||||
unit: TyKind::Tuple(0, Substitution::empty(Interner)).intern(Interner),
|
||||
never: TyKind::Never.intern(Interner),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1024,6 +1026,7 @@ impl<'a> InferenceContext<'a> {
|
|||
pub(crate) enum Expectation {
|
||||
None,
|
||||
HasType(Ty),
|
||||
#[allow(dead_code)]
|
||||
Castable(Ty),
|
||||
RValueLikeUnsized(Ty),
|
||||
}
|
||||
|
@ -1102,6 +1105,10 @@ impl Expectation {
|
|||
}
|
||||
}
|
||||
|
||||
fn coercion_target_type(&self, table: &mut unify::InferenceTable<'_>) -> Ty {
|
||||
self.only_has_type(table).unwrap_or_else(|| table.new_type_var())
|
||||
}
|
||||
|
||||
/// Comment copied from rustc:
|
||||
/// Disregard "castable to" expectations because they
|
||||
/// can lead us astray. Consider for example `if cond
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue