Rust

E0658 Unstable Feature Fix

E0658 is not a bug in your logic - it is a gate. The item you called exists in the standard library, but it has not been stabilized, so the stable compiler refuses it and names the feature and its tracking issue. This guide works five items that draw the error, shows the stable API that does the same job in each case, and separates the one move that makes things worse on stable: adding the feature header itself.

Written November 30, 2026 · Tested with Rust 1.99.1 · 13 min read

By the end of this guide
  • The rule underneath: the gate is on the item, not the idea
  • How to read the diagnostic
  • The first failure: core::ptr::metadata
  • The same error on two iterator methods

Written November 30, 2026

Tested with Rust 1.99.1

What this guide is

Error E0658 is the use of an unstable library feature. The error codes index states it in one line - "An unstable feature was used" - and its erroneous example is one of the failures in this guide: importing std::intrinsics, which the compiler reports as the unstable feature core_intrinsics. Its explanation gives the only two routes past the gate: switch to a nightly version of rustc, or, on nightly, add the corresponding feature header so the item can be used. On the stable channel neither the item nor the header is available, and this guide is about the stable route instead: in each case below, a stabilized API already does the job the unstable item was reached for.

The practical payoff is reading the diagnostic as a pointer rather than a dead end. The header names the feature in backticks, and in most of the programs below a note line gives the tracking issue number and its URL - that issue is where the feature's status and discussion live. What the compiler will not do is suggest the stable alternative, because it does not know which one fits your code. The repairs below are that mapping for the five probed features: ptr_metadata, iterator_try_collect, iter_collect_into, str_as_str, and core_intrinsics.

This guide is about unstable library items used from ordinary code. The neighboring guide on E0554 covers the feature header itself on the stable channel; this one links it only where adding that header is the instinct E0658 provokes, and does not re-teach it.

Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.

The rule underneath: the gate is on the item, not the idea

An unstable feature is an item that has landed in the standard library behind a feature gate while its design is still being settled. The nightly appendix of the Rust Book describes the mechanism: a new feature lands "behind a feature gate" first, and only after nightly users have tried it and the team has discussed it does it move toward stable. Until that move happens, the stable compiler knows the item exists - which is why it can name the feature so precisely - and refuses it anyway.

That is why E0658 is scoped to the exact item, not to the job the item does. Reading a slice's length is a stable, ordinary operation; extracting it through core::ptr::metadata is the gated route to the same fact. Collecting an iterator is stable; collecting through try_collect or into an existing vector through collect_into are the gated routes. In every failing program below, the underlying job compiles on stable once it is expressed through the stabilized API - the gate was never on the idea, only on the spelling.

How to read the diagnostic

The header names the feature: "use of unstable library feature ptr_metadata". The single label underlines the exact call or import that used the item. In four of the five failing programs below, a note follows - "see issue #81513 https://github.com/rust-lang/rust/issues/81513 for more information", with the number changing per feature - and there is no help block proposing a repair. The fifth program, the core_intrinsics import, carries a different note instead of an issue line: it says intrinsics are unlikely to ever be stabilized and should be used through the stabilized interfaces in the rest of the standard library, which is the repair direction stated by the compiler itself.

So the reading order is: take the feature name from the header, take the tracking issue from the note when one is printed, and then look for the stabilized API that does the same job - the fixes section below is that lookup for the probed set.

The first failure: core::ptr::metadata

Extracting a wide pointer's metadata through the free function is gated as ptr_metadata, issue #81513 - the function's own documentation marks it as a nightly-only experimental API under that feature and issue:

Rust
fn main() { let a: [u8; 3] = [1, 2, 3]; let fat: *const [u8] = &a; let m = core::ptr::metadata(fat); println!("{}", m); }
Output
error[E0658]: use of unstable library feature `ptr_metadata`
 --> q1.rs:1:76
  |
1 | fn main() { let a: [u8; 3] = [1, 2, 3]; let fat: *const [u8] = &a; let m = core::ptr::metadata(fat); println!("{}", m); }
  |                                                                            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #81513 <https://github.com/rust-lang/rust/issues/81513> for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.

The pointer itself is an ordinary stable value. Only the extraction function is gated - the repair below reads the same length through the slice pointer's own stable method.

The same error on two iterator methods

Two convenience methods on Iterator are gated under different features and different issues. try_collect, gated as iterator_try_collect, issue #94047, is the fallible collect - here over an iterator holding a single Result:

Rust
fn main() { let r: Result<i32, String> = Ok(1); let v: Vec<i32> = vec![r].into_iter().try_collect().unwrap(); println!("{}", v.len()); }
Output
error[E0658]: use of unstable library feature `iterator_try_collect`
 --> q2.rs:1:87
  |
1 | fn main() { let r: Result<i32, String> = Ok(1); let v: Vec<i32> = vec![r].into_iter().try_collect().unwrap(); println!("{}", v.len()); }
  |                                                                                       ^^^^^^^^^^^
  |
  = note: see issue #94047 <https://github.com/rust-lang/rust/issues/94047> for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.

collect_into, gated as iter_collect_into, issue #94780, collects into a vector that already exists instead of returning a new one:

Rust
fn main() { let mut out: Vec<i32> = Vec::new(); vec![3, 4].into_iter().collect_into(&mut out); println!("{}", out.len()); }
Output
error[E0658]: use of unstable library feature `iter_collect_into`
 --> q3.rs:1:72
  |
1 | fn main() { let mut out: Vec<i32> = Vec::new(); vec![3, 4].into_iter().collect_into(&mut out); println!("{}", out.len()); }
  |                                                                        ^^^^^^^^^^^^
  |
  = note: see issue #94780 <https://github.com/rust-lang/rust/issues/94780> for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.

Same header shape, different feature names: each method carries its own gate and its own tracking issue, so a fix or a status check is always per method, never per trait.

The same error on a string slice and on an import

Calling as_str on a value that is already a string slice is gated as str_as_str, issue #130366:

Rust
fn main() { let s = "a,b,c"; println!("{}", s.as_str().len()); }
Output
error[E0658]: use of unstable library feature `str_as_str`
 --> q4.rs:1:47
  |
1 | fn main() { let s = "a,b,c"; println!("{}", s.as_str().len()); }
  |                                               ^^^^^^
  |
  = note: see issue #130366 <https://github.com/rust-lang/rust/issues/130366> for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.

Here the gated call adds nothing at all - s is already the slice the method would return - which makes its repair the simplest in this guide: delete the call. The import form is the error index's own example. Importing std::intrinsics draws E0658 for core_intrinsics, with the compiler's own note that intrinsics should be reached through stabilized interfaces instead, plus an unused-import warning because nothing in the program uses the import:

Rust
use std::intrinsics; fn main() { println!("hi"); }
Output
warning: unused import: `std::intrinsics`
 --> q5.rs:1:5
  |
1 | use std::intrinsics; fn main() { println!("hi"); }
  |     ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
 --> q5.rs:1:5
  |
1 | use std::intrinsics; fn main() { println!("hi"); }
  |     ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.

Five features, one shape in this guide's probed set: the header names the feature, the label underlines the use, and a note gives either the tracking issue or, for intrinsics, the direction of the stable replacement.

The trap: adding the feature header is E0554

Trap
The explanation for E0658 says that on nightly you add the corresponding feature header. On the stable channel that header is itself an error - E0554, "#![feature] may not be used on the stable release channel":
Rust
#![feature(ptr_metadata)]
fn main() { println!("hi"); }
Output
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> q6.rs:1:1
  |
1 | #![feature(ptr_metadata)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0554`.

So on stable the header does not rescue any of the programs above - it replaces one error with another. That is the whole trap, and it is why the neighboring E0554 guide exists: the header question and the item question are separate errors with separate repairs, and on stable both repairs point the same way, back to stabilized APIs. Switching the project to a nightly toolchain is the other real route, and it is a project decision, not a code fix - nothing in this guide's probed set needs it, because every job below has a stable spelling.

The items that compile: expected gates that are not there

Two items probed for this guide were expected to draw E0658 and did not - on this toolchain they are stable, and the programs compile and run. Taking several disjoint mutable borrows of one array at once, through get_disjoint_mut, compiles:

Rust
fn main() { let mut a: [i32; 4] = [1, 2, 3, 4]; let parts = a.get_disjoint_mut([0, 2]).unwrap(); *parts[0] = 10; println!("{:?}", a); }
Config
[10, 2, 3, 4]

The output is [10, 2, 3, 4]: the write through the first disjoint borrow landed, and the array is otherwise unchanged. And f64::next_up, the next representable float above its argument, compiles:

Rust
fn main() { let x: f64 = 1.5; println!("{}", x.next_up()); }
Output
1.5000000000000002

The output is 1.5000000000000002, the representable value just above 1.5. The lesson is narrow and worth keeping: a feature's status is a fact about a specific toolchain, not about the item's reputation - an item remembered as unstable may have been stabilized since, and the compiler in front of you is the authority. Do not generalize these two programs past what they show: they establish the status of these two items on this toolchain, and say nothing about any other item.

Fixes in reach order

When E0658 appears on stable, stay on stable and re-express the call through the stabilized API, in this order. First, for ptr_metadata, read the metadata through the pointer's own stable methods - for a slice pointer, its length is the len() method the pointer already carries:

Rust
fn main() { let a: [u8; 3] = [1, 2, 3]; let fat: *const [u8] = &a; println!("{}", fat.len()); }
Output
3

The output is 3, the array's length - the same fact metadata would have extracted, read through the stable method instead.

Second, for iterator_try_collect, use the stable collect into a Result collection: collecting an iterator of Result values into a Result<Vec<_>, _> stops at the first error and unwraps to the values when there is none, which is the job try_collect was doing:

Rust
fn main() { let v: Vec<Result<i32, String>> = vec![Ok(1), Ok(2)]; let out: Result<Vec<i32>, String> = v.into_iter().collect(); println!("{}", out.unwrap().len()); }
Output
2

The output is 2, the number of collected values. Third, for iter_collect_into, fill the existing vector with the stable extend, which appends the iterator's items to the vector already in scope:

Rust
fn main() { let mut out: Vec<i32> = Vec::new(); out.extend(vec![3, 4].into_iter()); println!("{}", out.len()); }
Output
2

The output is 2: both items landed in the pre-existing vector, the outcome collect_into was asked for. Fourth, for str_as_str, delete the call and use the slice itself - it already has every method the conversion would have exposed, including len():

Rust
fn main() { let s = "a,b,c"; println!("{}", s.len()); }
Output
5

The output is 5, the byte length of a,b,c. Fifth, for core_intrinsics, drop the import and use the stabilized interface for whatever intrinsic was wanted - in this program nothing used the import at all, so the repair is the import's removal and the program runs as written:

Rust
fn main() { println!("hi"); }
Output
hi

The output is hi. Where disjoint mutable access was the real goal behind a gated spelling, the stable split_at_mut route also compiles - it splits the array into two mutable slices at an index, and writes through both halves land:

Rust
fn main() { let mut a: [i32; 4] = [1, 2, 3, 4]; let (lo, hi) = a.split_at_mut(2); lo[0] = 10; hi[0] = 30; println!("{:?}", a); }
Config
[10, 2, 30, 4]

The output is [10, 2, 30, 4]. Last, if the diagnostic is E0554 instead, the header is the problem, not the item - remove it and apply the repairs above; the E0554 guide covers that error in full.

Decision summary

E0658, "use of unstable library feature", is one shape in this guide's probed set: stable-channel code uses a standard-library item that is still behind a feature gate - core::ptr::metadata, Iterator::try_collect, Iterator::collect_into, as_str on a string slice, or the std::intrinsics import. The diagnostic names the feature in the header, underlines the use, and gives the tracking issue in a note - #81513, #94047, #94780, and #130366 for the first four - while the intrinsics form instead states that intrinsics should be used through stabilized interfaces. The repairs stay on stable: read a slice pointer's length with len(), collect an iterator of results with the stable collect into a Result collection, fill an existing vector with extend, use a string slice directly, and drop the intrinsics import. Adding the #![feature] header on stable is not a repair - it is E0554. And status is per item and per toolchain: get_disjoint_mut and f64::next_up, both probed expecting the gate, compile and run on this toolchain.

Checklist

  • Read the feature name out of the E0658 header and, when a note prints one, the tracking issue out of its note before changing any code - the fix is always for that specific item.
  • Never add a #![feature] header on the stable channel - it draws E0554 and rescues nothing.
  • Replace the gated call with the stabilized API that does the same job: len() for slice metadata, collect into a Result collection for try_collect, extend for collect_into, the slice itself for as_str.
  • Drop a core_intrinsics import and use the stabilized interface the compiler's note points to.
  • Check an item's status on the toolchain in front of you before assuming it is gated - an item remembered as unstable may have been stabilized.
  • Treat switching to nightly as a project decision, not a code fix, and only for an item with no stable spelling.

Sources

  • Rust error codes index, E0658 - an unstable feature was used, the std::intrinsics erroneous example, and the explanation that stable and beta cannot use unstable features, that nightly can, and that on nightly the corresponding feature is added to use the item.
  • Rust error codes index, E0554 - the neighboring error for a #![feature] header used on the stable release channel.
  • core::ptr::metadata - extracts the metadata component of a pointer, marked as a nightly-only experimental API under the ptr_metadata feature, issue #81513.
  • The Rust Book, Appendix G - How Rust is Made and "Nightly Rust" - new features land behind a feature gate, are tried by nightly users, and are discussed before moving toward stable.
  • Iterator - the trait whose method list includes try_collect and collect_into, the two gated iterator methods worked in this guide, and the stable collect used in the try_collect repair; the extend used in the collect_into repair is the collection's own stable Extend method.

Keep Exploring