Skip to content

Commit

Permalink
fix(portkit): don't mention a reference type in inline assembly operands
Browse files Browse the repository at this point in the history
Work-around for [rust-lang/rust#96304][1]. Fixes ICE in tests.

[1]: rust-lang/rust#96304
  • Loading branch information
yvt committed May 24, 2022
1 parent 7442395 commit 0bb5ac3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/r3_portkit/src/sym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub macro sym_static {
.dc.a {2}
",
sym Self::$sym_name,
const $crate::sym::mem::align_of::<&'static $ty>().trailing_zeros(),
const $crate::sym::mem::align_of::<*const $ty>().trailing_zeros(),
sym $static,
options(noreturn),
);
Expand All @@ -170,23 +170,23 @@ mod tests {
static S1: u32 = 1;
static S2: u32 = 2;

impl Tr for &'static u8 {
impl Tr for u8 {
sym_static!(
#[sym(p_var)]
fn var() -> &u32 {
&S0
}
);
}
impl Tr for &'static u16 {
impl Tr for u16 {
sym_static!(
#[sym(p_var)]
fn var() -> &u32 {
&S1
}
);
}
impl Tr for &'static u32 {
impl Tr for u32 {
sym_static!(
#[sym(p_var)]
fn var() -> &u32 {
Expand All @@ -197,9 +197,9 @@ mod tests {

#[test]
fn uniqueness() {
let var1 = dbg!(<&'static u8>::var() as *const u32);
let var2 = dbg!(<&'static u16>::var() as *const u32);
let var3 = dbg!(<&'static u32>::var() as *const u32);
let var1 = dbg!(<u8>::var() as *const u32);
let var2 = dbg!(<u16>::var() as *const u32);
let var3 = dbg!(<u32>::var() as *const u32);
assert_ne!(var1, var2);
assert_ne!(var2, var3);
assert_ne!(var1, var3);
Expand Down

0 comments on commit 0bb5ac3

Please sign in to comment.