<p dir="auto">Rustc gives a message that bytes!() is deprecated:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="b.rs:1:33: 1:47 warning: `bytes!` is deprecated, use `b&quot;foo&quot;` literals instead
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!(&quot;foo&quot;); }
                                       ^~~~~~~~~~~~~~
b.rs:1:33: 1:47 help: see http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals for documentation
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!(&quot;foo&quot;); }
                                       ^~~~~~~~~~~~~~
b.rs:1:33: 1:47 help: see https://github.com/rust-lang/rust/blob/master/src/etc/2014-06-rewrite-bytes-macros.py for an automated migration
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!(&quot;foo&quot;); }
                                       ^~~~~~~~~~~~~~
b.rs:1:17: 1:18 warning: unused variable: `x`, #[warn(unused_variables)] on by default
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!(&quot;foo&quot;); }
                       ^"><pre class="notranslate"><code class="notranslate">b.rs:1:33: 1:47 warning: `bytes!` is deprecated, use `b"foo"` literals instead
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!("foo"); }
                                       ^~~~~~~~~~~~~~
b.rs:1:33: 1:47 help: see http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals for documentation
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!("foo"); }
                                       ^~~~~~~~~~~~~~
b.rs:1:33: 1:47 help: see https://github.com/rust-lang/rust/blob/master/src/etc/2014-06-rewrite-bytes-macros.py for an automated migration
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!("foo"); }
                                       ^~~~~~~~~~~~~~
b.rs:1:17: 1:18 warning: unused variable: `x`, #[warn(unused_variables)] on by default
b.rs:1 fn main() { let x: [u8, ..3] = *bytes!("foo"); }
                       ^
</code></pre></div>
<p dir="auto">But the suggested replacement, as implemented by the python script, no longer compiles. Compiling the program resulting from applying the script's generated patch gives the error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="b.rs:1:32: 1:39 error: mismatched types: expected `[u8, ..3]`, found `[u8]` (expected array of 3 elements, found slice)
b.rs:1 fn main() { let x: [u8, ..3] = *b&quot;foo&quot;; }
                                      ^~~~~~~"><pre class="notranslate"><code class="notranslate">b.rs:1:32: 1:39 error: mismatched types: expected `[u8, ..3]`, found `[u8]` (expected array of 3 elements, found slice)
b.rs:1 fn main() { let x: [u8, ..3] = *b"foo"; }
                                      ^~~~~~~
</code></pre></div>
<p dir="auto">The b"foo" syntax should not be suggested as a replacement for bytes!("foo") if it cannot fulfill the same roles. In particular, it seems odd to me that b"foo" syntax results in a less flexible type than bytes!("foo").</p>
<p dir="auto">Note that [u8, ..n] can be converted to &amp;[u8], which can be converted to the DST [u8]--but &amp;[u8], which is what b"foo" produces, cannot be statically converted to [u8, ..n], so the change suggested by the deprecation warning results in loss of generality.</p>
<p dir="auto">Tracking issue for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="44324836" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rfcs/issues/339" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rfcs/pull/339/hovercard" href="https://github.com/rust-lang/rfcs/pull/339">rust-lang/rfcs#339</a></p>
<p dir="auto">Nominating for backcompat-lang</p>