Skip to content

Commit 20b02ef

Browse files
Separate between normal evaluated consts and type-system consts
Type system consts (consts that participate in the type system, e.g. const generic params) have special properties: they must have strict equality independent of the user. For example, unions are not possible there. Therefore they are stored as a `ValTree`, a very simple representation that is good, mostly, for comparing things. General consts can be anything (almost) - arbitrary bytes, even uninit bytes. They are stored like all consts previously were (in the type-system's `Const`), with bytes memory, in a new type called `Allocation` (named borrowed from rustc, although it isn't exactly accurate because in r-a it can represent multiple allocations). The trigger for this change was a new requirement from rustc_type_ir, that type-system `Const` will be able to represent as a `ValTree`.
1 parent 2880f88 commit 20b02ef

19 files changed

Lines changed: 1381 additions & 425 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ object = { version = "0.36.7", default-features = false, features = [
127127
"macho",
128128
"pe",
129129
] }
130-
postcard = {version = "1.1.3", features = ["alloc"]}
130+
postcard = { version = "1.1.3", features = ["alloc"] }
131131
process-wrap = { version = "8.2.1", features = ["std"] }
132132
pulldown-cmark-to-cmark = "10.0.4"
133133
pulldown-cmark = { version = "0.9.6", default-features = false }
@@ -186,7 +186,10 @@ hashbrown = { version = "0.14.*", features = [
186186
elided_lifetimes_in_paths = "warn"
187187
explicit_outlives_requirements = "warn"
188188
unsafe_op_in_unsafe_fn = "warn"
189-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)', "cfg(no_salsa_async_drops)"] }
189+
unexpected_cfgs = { level = "warn", check-cfg = [
190+
'cfg(bootstrap)',
191+
"cfg(no_salsa_async_drops)",
192+
] }
190193
unused_extern_crates = "warn"
191194
unused_lifetimes = "warn"
192195
unreachable_pub = "warn"

crates/hir-def/src/hir.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::fmt;
2121
use hir_expand::{MacroDefId, name::Name};
2222
use intern::Symbol;
2323
use la_arena::Idx;
24-
use rustc_apfloat::ieee::{Half as f16, Quad as f128};
24+
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
2525
use syntax::ast;
2626
use type_ref::TypeRefId;
2727

@@ -94,19 +94,19 @@ impl FloatTypeWrapper {
9494
Self(sym)
9595
}
9696

97-
pub fn to_f128(&self) -> f128 {
97+
pub fn to_f128(&self) -> Quad {
9898
self.0.as_str().parse().unwrap_or_default()
9999
}
100100

101-
pub fn to_f64(&self) -> f64 {
101+
pub fn to_f64(&self) -> Double {
102102
self.0.as_str().parse().unwrap_or_default()
103103
}
104104

105-
pub fn to_f32(&self) -> f32 {
105+
pub fn to_f32(&self) -> Single {
106106
self.0.as_str().parse().unwrap_or_default()
107107
}
108108

109-
pub fn to_f16(&self) -> f16 {
109+
pub fn to_f16(&self) -> Half {
110110
self.0.as_str().parse().unwrap_or_default()
111111
}
112112
}

0 commit comments

Comments
 (0)