1
Fork 0

Fix conversion to StaticDef and add test

This commit is contained in:
Celina G. Val 2023-12-06 21:33:49 -08:00
parent 4c9e842a09
commit 9cb6463af7
3 changed files with 18 additions and 2 deletions

View file

@ -162,7 +162,7 @@ pub trait Context {
fn krate(&self, def_id: DefId) -> Crate;
fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol;
/// Return the number of bytes for a pointer size.
/// Return information about the target machine.
fn target_info(&self) -> MachineInfo;
}

View file

@ -220,7 +220,7 @@ impl TryFrom<CrateItem> for StaticDef {
type Error = crate::Error;
fn try_from(value: CrateItem) -> Result<Self, Self::Error> {
if matches!(value.kind(), ItemKind::Static | ItemKind::Const) {
if matches!(value.kind(), ItemKind::Static) {
Ok(StaticDef(value.0))
} else {
Err(Error::new(format!("Expected a static item, but found: {value:?}")))