Skip to content

Commit 9bc6e11

Browse files
add non-test-case for suggesting const on functions accessing union fields
1 parent 66590ba commit 9bc6e11

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/ui/missing_const_for_fn/cant_be_const.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,12 @@ impl Issue10617 {
157157
self.0
158158
}
159159
}
160+
161+
union U {
162+
f: u32,
163+
}
164+
165+
// Do not lint because accessing union fields from const functions is unstable
166+
fn h(u: U) -> u32 {
167+
unsafe { u.f }
168+
}

0 commit comments

Comments
 (0)