mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Add INTEGER
and FLOAT
flags for type variables
This commit is contained in:
parent
1bfc732b78
commit
b183612610
1 changed files with 9 additions and 1 deletions
|
@ -132,6 +132,8 @@ bitflags::bitflags! {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(crate) struct TypeVariableFlags: u8 {
|
pub(crate) struct TypeVariableFlags: u8 {
|
||||||
const DIVERGING = 1 << 0;
|
const DIVERGING = 1 << 0;
|
||||||
|
const INTEGER = 1 << 1;
|
||||||
|
const FLOAT = 1 << 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +260,14 @@ impl<'a> InferenceTable<'a> {
|
||||||
// Chalk might have created some type variables for its own purposes that we don't know about...
|
// Chalk might have created some type variables for its own purposes that we don't know about...
|
||||||
self.extend_type_variable_table(var.index() as usize);
|
self.extend_type_variable_table(var.index() as usize);
|
||||||
assert_eq!(var.index() as usize, self.type_variable_table.len() - 1);
|
assert_eq!(var.index() as usize, self.type_variable_table.len() - 1);
|
||||||
|
let flags = self.type_variable_table.get_mut(var.index() as usize).unwrap();
|
||||||
if diverging {
|
if diverging {
|
||||||
self.type_variable_table[var.index() as usize] |= TypeVariableFlags::DIVERGING;
|
*flags |= TypeVariableFlags::DIVERGING;
|
||||||
|
}
|
||||||
|
if matches!(kind, TyVariableKind::Integer) {
|
||||||
|
*flags |= TypeVariableFlags::INTEGER;
|
||||||
|
} else if matches!(kind, TyVariableKind::Float) {
|
||||||
|
*flags |= TypeVariableFlags::FLOAT;
|
||||||
}
|
}
|
||||||
var.to_ty_with_kind(Interner, kind)
|
var.to_ty_with_kind(Interner, kind)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue