Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add GlobalAsm as a valid ItemKind to StableMIR #138025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
celinval wants to merge 1 commit into rust-lang:master
base: master
Choose a base branch
Loading
from celinval:issue-0095-global-asm
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
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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

AltStyle によって変換されたページ (->オリジナル) /