You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
An unsafe fn used as a value is callable without unsafe #1829
Spec §16.11: an unsafe fn may not coerce to a safe callable type. The coercion check (check_ident, SemaCheck.w) runs only when an extern "C" fn type is expected; an unannotated binding takes the fn's own TY_FN type, and a call through it needs no unsafe:
unsafe fn danger(x: i32) -> i32: x + 1
fn main:
let f = danger
print(f(1))
Expected: an error (the value keeps its unsafety, or the call through it requires unsafe). Actual (with check, v0.15.2.1 and the D75 branch): ok.
Found while implementing D75 variadic definitions (#1678). A ... definition is refused as a value outright there (it has no variadic function-pointer type), so it does not go through this hole; every other unsafe fn does.
Activity
Sema: a function whose call needs unsafe is an unsafe callable as a v…
Spec v7.12: the unsafe callable type is spelled `unsafe fn(A) -> R` /…
Spec v7.12: the unsafe callable type is spelled `unsafe fn(A) -> R` /…
Spec v7.11–v7.13 (D78, D79): SIMD vectors; the unsafe callable type; …