E0094#
Warning name: unknown_intrinsic
The #intrinsic attribute names an intrinsic
that the compiler does not recognize. The compiler ignores the attribute and
uses the ordinary function body instead. This warning is enabled by default.
Erroneous example#
The name below is deliberately fictitious. The function still returns 42 for
the input 41, but its attribute produces a warning:
///|
#intrinsic("%not_a_real_intrinsic")
pub fn add_one(value : Int32) -> Int32 {
value + 1
}
///|
test {
assert_eq(add_one(41), 42)
}
Suggestion#
Remove the attribute and keep the ordinary implementation. Intrinsics are not a stable API and are not recommended for application code.
///|
pub fn add_one(value : Int32) -> Int32 {
value + 1
}
///|
test {
assert_eq(add_one(41), 42)
}
This differs from E4070: a declaration such as
fn f(x : Int32) -> Int32 = "%not_a_real_intrinsic" has no ordinary function
body to fall back to, so an unknown intrinsic is an error rather than a warning.