Fix conversion to StaticDef and add test
This commit is contained in:
parent
4c9e842a09
commit
9cb6463af7
3 changed files with 18 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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:?}")))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue