Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ pub(crate) fn new_item_kind(kind: DefKind) -> ItemKind {
| DefKind::OpaqueTy
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::Impl { .. }
| DefKind::GlobalAsm => {
| DefKind::Impl { .. } => {
unreachable!("Not a valid item kind: {kind:?}");
}
DefKind::Closure | DefKind::AssocFn | DefKind::Fn | DefKind::SyntheticCoroutineBody => {
Expand All @@ -150,6 +149,7 @@ pub(crate) fn new_item_kind(kind: DefKind) -> ItemKind {
DefKind::Const | DefKind::InlineConst | DefKind::AssocConst | DefKind::AnonConst => {
ItemKind::Const
}
DefKind::GlobalAsm => ItemKind::GlobalAsm,
DefKind::Static { .. } => ItemKind::Static,
DefKind::Ctor(_, rustc_hir::def::CtorKind::Const) => ItemKind::Ctor(CtorKind::Const),
DefKind::Ctor(_, rustc_hir::def::CtorKind::Fn) => ItemKind::Ctor(CtorKind::Fn),
Expand Down
1 change: 1 addition & 0 deletions compiler/stable_mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub enum ItemKind {
Static,
Const,
Ctor(CtorKind),
GlobalAsm,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Serialize)]
Expand Down
10 changes: 9 additions & 1 deletion tests/ui-fulldeps/stable-mir/check_item_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ const CRATE_NAME: &str = "input";
/// This function uses the Stable MIR APIs to get information about the test crate.
fn test_item_kind() -> ControlFlow<()> {
let items = stable_mir::all_local_items();
assert_eq!(items.len(), 4);
assert_eq!(items.len(), 5);
// Constructor item.
for item in items {
let expected_kind = match item.name().as_str() {
"Dummy" => ItemKind::Ctor(CtorKind::Fn),
"dummy" => ItemKind::Fn,
"unit" => ItemKind::Fn,
"DUMMY_CONST" => ItemKind::Const,
name if name.contains("global_asm") => ItemKind::GlobalAsm,
name => unreachable!("Unexpected item {name}"),
};
assert_eq!(item.kind(), expected_kind, "Mismatched type for {}", item.name());
Expand Down Expand Up @@ -75,6 +76,13 @@ fn generate_input(path: &str) -> std::io::Result<()> {
pub fn unit() -> DummyUnit {{
DummyUnit
}}

std::arch::global_asm!(".global my_noop",
".text",
"my_noop:",
"ret"
);

"#
)?;
Ok(())
Expand Down
Loading