<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Target_feature on ErrorVault — Developer Error Code Dictionary</title>
    <link>https://errorvault.dev/tags/target_feature/</link>
    <description>Recent content in Target_feature on ErrorVault — Developer Error Code Dictionary</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 23 Jul 2026 07:56:04 +0800</lastBuildDate>
    <atom:link href="https://errorvault.dev/tags/target_feature/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Fix E0739: #[target_feature] Attribute Not Allowed on Safe Functions</title>
      <link>https://errorvault.dev/rust/rust-e0739-target-feature-attribute-safe-functions/</link>
      <pubDate>Thu, 23 Jul 2026 07:56:04 +0800</pubDate>
      <guid>https://errorvault.dev/rust/rust-e0739-target-feature-attribute-safe-functions/</guid>
      <description>&lt;h2 id=&#34;1-symptoms&#34;&gt;1. Symptoms&lt;/h2&gt;&#xA;&lt;p&gt;When attempting to compile Rust code that uses the &lt;code&gt;#[target_feature]&lt;/code&gt; attribute on a safe function, the compiler produces error E0739 with a clear diagnostic message. The error indicates that the attribute cannot be applied to non-unsafe functions because using CPU-specific features requires unsafe guarantees.&lt;/p&gt;&#xA;&lt;p&gt;The typical compiler output looks like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-mysql&#34; data-lang=&#34;mysql&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;error[E0739]: the &lt;span style=&#34;color:#ff79c6&#34;&gt;`&lt;/span&gt;&lt;span style=&#34;color:#6272a4&#34;&gt;#[target_feature(...)]` attribute is not yet allowed on safe functions&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#ff79c6&#34;&gt;--&amp;gt;&lt;/span&gt; src&lt;span style=&#34;color:#ff79c6&#34;&gt;/&lt;/span&gt;main.rs:&lt;span style=&#34;color:#bd93f9&#34;&gt;10&lt;/span&gt;:&lt;span style=&#34;color:#bd93f9&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#ff79c6&#34;&gt;|&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#bd93f9&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#6272a4&#34;&gt;#[target_feature(sse, sse2)]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#ff79c6&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;/span&gt; attribute was applied &lt;span style=&#34;color:#ff79c6&#34;&gt;to&lt;/span&gt; safe function&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#ff79c6&#34;&gt;|&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#ff79c6&#34;&gt;=&lt;/span&gt; note: &lt;span style=&#34;color:#ff79c6&#34;&gt;require&lt;/span&gt; the function &lt;span style=&#34;color:#ff79c6&#34;&gt;to&lt;/span&gt; be marked &lt;span style=&#34;color:#ff79c6&#34;&gt;`&lt;/span&gt;unsafe&lt;span style=&#34;color:#ff79c6&#34;&gt;`&lt;/span&gt; because &lt;span style=&#34;color:#ff79c6&#34;&gt;using&lt;/span&gt; the target_feature attribute &lt;span style=&#34;color:#ff79c6&#34;&gt;is&lt;/span&gt; unsafe&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In this example, the compiler is telling you that the function at line 10 in &lt;code&gt;src/main.rs&lt;/code&gt; uses the &lt;code&gt;#[target_feature]&lt;/code&gt; attribute but is not marked as &lt;code&gt;unsafe&lt;/code&gt;. The error also appears when using multiple features like &lt;code&gt;#[target_feature(avx, avx2)]&lt;/code&gt; or &lt;code&gt;#[target_feature(simd128)]&lt;/code&gt; on WebAssembly targets.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
