E0554 Feature on Stable Rust Fix
Written November 27, 2026 · Tested with Rust 1.99.1 · 27 min read
- The error: a feature attribute on the stable channel
- The form it usually arrives in: benchmarks
- First fix: remove the attribute when nothing unstable is used
- Second fix: rewrite the gated code on stable APIs
Written November 27, 2026
Tested with Rust 1.99.1
What this guide is
E0554 is the error for a #![feature] attribute compiled on the stable release channel. Unstable features of the compiler and the standard library are switched on with a crate-root attribute such as #![feature(test)], and that switch exists only on nightly releases: a stable or beta compiler refuses the attribute itself, before it looks at what the feature would have enabled. The refusal is total — it does not matter whether the named feature is real, whether the code below actually uses anything unstable, or whether the attribute was copied in from a nightly example and forgotten. On stable, the attribute is the fault. Two name histories qualify that totality, and both are covered below: a feature that has already stabilized still draws E0554, but with the compiler's own remove-the-attribute help attached, and a feature that has been removed draws a different error, E0557, instead.
That makes the repairs a question about what the attribute is doing in the crate. If the code uses nothing unstable — the common case, an attribute left over from an example or a template — the repair is to delete it. If the code genuinely uses a feature-gated construct, the repair is to rewrite that construct on stable APIs, and this guide works the standard example end to end: a #[bench] benchmark, which needs #![feature(test)], rewritten as an ordinary timing loop over std::time::Instant. If the feature has no stable equivalent and the project can accept nightly's lack of guarantees, the repair is to build with a nightly release instead. The sections below take the shapes in order: the plain error, the benchmark form it usually arrives in, the two deletion and rewrite fixes, the same error under other feature names with their different warnings, the stabilized and removed name histories, what RUSTC_BOOTSTRAP=1 actually does on this compiler, the misplaced-attribute cases — which are warnings or a different, uncoded error, not E0554 — and the unknown-feature case, which is E0554 and E0635 together.
The error: a feature attribute on the stable channel
The smallest program that draws this error names one real, currently unstable feature and does nothing with it:
#![feature(test)]
fn main() {
println!("hi");
}
$ rustc --edition 2021 main.rs -o main.bin
error[E0554]: `#![feature]` may not be used on the stable release channel
--> main.rs:1:1
|
1 | #![feature(test)]
| ^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0554`.
The diagnostic is short and worth reading literally. The span covers the whole attribute, line 1, and nothing else in the file is mentioned: the main function below is ordinary stable code, and it is never reached as a question. For a currently unstable name there is no help line and no note — the compiler offers no edit, because no edit to the attribute's contents can satisfy it. Shortening the list, correcting the spelling, or naming a different still-unstable feature all leave a #![feature] attribute on a stable compiler, and that is the whole fault. (A name that has already stabilized is the one exception to the no-help shape, and it is covered in its own section below.) Note also what the error is not about: the program uses nothing from the test feature — no benchmark, no unstable API — and it fails identically. E0554 checks the channel the compiler was released on, not the code the feature would have unlocked.
The form it usually arrives in: benchmarks
In real code this attribute most often arrives attached to the unstable benchmark harness. A file that defines a benchmark with test::Bencher needs #![feature(test)] and extern crate test;, and compiled with the stable compiler it fails at the attribute, on line 1, before the benchmark is considered:
#![feature(test)]
extern crate test;
use test::Bencher;
#[bench]
fn bench_sum(b: &mut Bencher) {
b.iter(|| (1..=100).sum::<i32>());
}
fn main() {}
$ rustc --edition 2021 main.rs -o main.bin
error[E0554]: `#![feature]` may not be used on the stable release channel
--> main.rs:1:1
|
1 | #![feature(test)]
| ^^^^^^^^^^^^^^^^^
warning: unused import: `test::Bencher`
--> main.rs:5:5
|
5 | use test::Bencher;
| ^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0554`.
The warning that follows the error is a consequence of the build mode, not a second fault: this compile runs without --test, so the #[bench] function is not part of the binary being built and its Bencher import reads as unused. The fault to repair is the one on line 1. Everything unstable in this file hangs off that attribute — extern crate test and #[bench] are exactly what the test feature gates — so this is the shape where deleting the attribute alone is not enough: the benchmark itself has to be rewritten, which the second fix below does.
First fix: remove the attribute when nothing unstable is used
If no code in the crate uses a feature-gated construct, the attribute is dead weight — pasted from an example, left behind after the gated code was removed, or carried in by a template — and the repair is the deletion. The first program in this guide, with its first line removed, is:
fn main() {
println!("hi");
}
$ rustc --edition 2021 main.rs -o main.bin
$ ./main.bin
hi
The program prints hi and exits with status 0. The check before taking this fix is a search of the crate for what the named feature gates: for test, that is extern crate test, #[bench], and Bencher; for other features, the unstable items the feature's chapter in the Unstable Book describes. If the search finds nothing, the attribute was enabling nothing, and deleting it changes no behavior — the same code compiles, because it was always stable code. This is also the fix when the attribute names a feature the code once used and no longer does, which is how most stray attributes get there.
Second fix: rewrite the gated code on stable APIs
When the gated code is real, the repair is to express it with stable constructs and then remove the attribute. The benchmark above measures how long summing the integers 1 to 100 takes, by handing the closure to Bencher::iter, which runs it repeatedly under the test harness. The stable equivalent does the repetition itself and times it with std::time::Instant, which is stable:
use std::time::Instant;
fn main() {
let start = Instant::now();
let mut total = 0i32;
for _ in 0..1000 {
total += (1..=100).sum::<i32>();
}
let elapsed = start.elapsed();
std::hint::black_box(elapsed);
println!("{}", total);
}
$ rustc --edition 2021 main.rs -o main.bin
$ ./main.bin
5050000
The program prints 5050000 and exits with status 0. The correspondence is one to one: Bencher::iter's repeated execution becomes the explicit for loop's 1000 repetitions, accumulating into total so the work is real and its result printable — 1000 repetitions of a sum that is 5050 each time. The harness's timing becomes Instant::now() before the loop and elapsed() after it; the elapsed value is passed through std::hint::black_box so the timing code is used and kept. What this rewrite does not reproduce is the harness itself — the statistical reporting and the cargo bench integration are the unstable part, and on stable the measurement is yours: the loop count, the timing, and what you print. That trade is the general shape of this fix for any feature: find what the gated construct does, do it with the stable API that covers the need — most long-unstable features have a stable neighbour, because the common cases are what got stabilized — and accept that the convenience layer on top is what stays nightly-only.
Other names, same error: the warnings around it differ
The attribute's contents do not change the error, but they can add warnings that are worth telling apart from it. The official page for this error uses lang_items as its example, and that name draws an additional warning because the feature is internal to the compiler and the standard library:
#![feature(lang_items)]
fn main() {}
$ rustc --edition 2021 main.rs -o main.bin
error[E0554]: `#![feature]` may not be used on the stable release channel
--> main.rs:1:1
|
1 | #![feature(lang_items)]
| ^^^^^^^^^^^^^^^^^^^^^^^
warning: the feature `lang_items` is internal to the compiler or standard library
--> main.rs:1:12
|
1 | #![feature(lang_items)]
| ^^^^^^^^^^
|
= note: using it is strongly discouraged
= note: `#[warn(internal_features)]` on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0554`.
A feature that is known but unfinished draws a different warning. generic_const_exprs is a real feature in this compiler, and naming it prints the same E0554 with an incomplete-features warning that names its tracking issue:
#![feature(generic_const_exprs)]
fn main() {
println!("hi");
}
$ rustc --edition 2021 main.rs -o main.bin
error[E0554]: `#![feature]` may not be used on the stable release channel
--> main.rs:1:1
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> main.rs:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0554`.
In both printings the order is the same — the error first, the warning after, and the closing line counting both — and the warning is information about the feature, not part of the fault. On a nightly compiler those warnings are the ones that matter; on stable they are decoration around an error that would be identical if the attribute named nothing remarkable at all. Reading order follows from that: repair the channel problem first, and let the warnings tell you, in advance, what moving to nightly would put you next to — an internal feature, an incomplete one, or neither.
Two more name histories: stabilized draws E0554 with help, removed draws E0557
A feature name has a history, and two of the histories change the printing. The first is a feature that has already stabilized. let_else has been stable since Rust 1.65.0, so the code it gates needs no attribute at all on this compiler — but a leftover attribute naming it still draws E0554, because the channel forbids the attribute itself. What changes is everything around the error: the span now carries a help, and a stable_features warning follows:
#![feature(let_else)]
fn main() {
println!("hi");
}
$ rustc --edition 2021 main.rs -o main.bin
error[E0554]: `#![feature]` may not be used on the stable release channel
--> main.rs:1:1
|
1 | #![feature(let_else)]
| ^^^^^^^^^^^^^^^^^^^^^ help: remove the attribute
|
= help: the feature `let_else` has been stable since `1.65.0` and no longer requires an attribute to enable
warning: the feature `let_else` has been stable since 1.65.0 and no longer requires an attribute to enable
--> main.rs:1:12
|
1 | #![feature(let_else)]
| ^^^^^^^^
|
= note: `#[warn(stable_features)]` on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0554`.
This is the one E0554 that supplies its own edit. The repair is the first fix in this guide with nothing to search for: the feature is stable, so the gated construct is ordinary code, and deleting the attribute is the whole repair. A program that uses let-else, with the attribute gone, compiles and runs as written:
fn main() {
let Some(x) = Some(3) else { return };
println!("{}", x);
}
$ rustc --edition 2021 main.rs -o main.bin
$ ./main.bin
3
The second history is a feature that has been removed. const_fn was removed in Rust 1.54.0 and split into finer-grained feature gates, and naming it draws a different error altogether — E0557, feature has been removed — with no E0554 beside it and no E0635 either, on the plain stable channel:
#![feature(const_fn)]
fn main() {
println!("hi");
}
$ rustc --edition 2021 main.rs -o main.bin
error[E0557]: feature has been removed
--> main.rs:1:12
|
1 | #![feature(const_fn)]
| ^^^^^^^^ feature has been removed
|
= note: removed in 1.54.0; see <https://github.com/rust-lang/rust/pull/85109> for more information
= note: split into finer-grained feature gates
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0557`.
The span is on the name alone, at column 12, like E0635's — but the fault is the opposite of unknown: the compiler knows this name's whole history and is reporting its end. There is no channel question to repair, because no channel offers the feature. The repair is to delete the attribute and rewrite whatever it gated under the finer-grained gates the note names, on nightly, or on stable APIs where those gates have themselves stabilized.
When the feature is genuinely needed: nightly, and what RUSTC_BOOTSTRAP does
One shortcut circulates for this error, and its behavior is exact, so it is worth stating plainly rather than from reputation. Setting the environment variable RUSTC_BOOTSTRAP=1 tells the stable compiler to act as if it were a nightly one for feature purposes, and the first program in this guide then compiles on stable:
#![feature(test)]
fn main() {
println!("hi");
}
$ RUSTC_BOOTSTRAP=1 rustc --edition 2021 main.rs -o main.bin
warning: feature `test` is declared but not used
--> main.rs:1:12
|
1 | #![feature(test)]
| ^^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: 1 warning emitted
$ ./main.bin
hi
The program prints hi and exits with status 0. Two details in that printing are the tell that the attribute is now being honoured rather than refused: the error is gone, and in its place is the unused_features warning — the compiler now tracks the declared feature and reports that this program declares test without using it, a warning that can only exist once the feature system is switched on. The variable exists for bootstrapping the compiler itself — nightly is built with beta, and beta with stable, and both builds need unstable features from a compiler that would otherwise refuse them — and using it opts the build out of the stability guarantee that is the point of the stable channel: the features it unlocks can change or disappear, exactly as on nightly, but without nightly's release process around them. It is a way to run nightly semantics on a stable binary, not a way to make a feature stable, and a project that ships built this way has taken the nightly risk while keeping the stable label. The repairs above — delete, rewrite, or use an actual nightly toolchain — are the ones that state honestly which channel the code is on.
What the variable does not do is rescue a name that does not exist. With RUSTC_BOOTSTRAP=1 set, an unknown feature name fails on its own, as the next section's case shows in isolation.
Look-alike: an unknown feature name is E0635, and on stable it arrives on top of E0554
A feature name that this compiler does not know — misspelled, invented, or renamed since the code was written — is a different fault from the channel fault, with its own code, E0635. A name whose feature has been removed is not this case either: it draws E0557 alone, as the two-histories section earlier in this guide shows. On the stable channel the two faults are reported together, channel first:
#![feature(nonexistent_rust_feature)]
fn main() {}
$ rustc --edition 2021 main.rs -o main.bin
error[E0554]: `#![feature]` may not be used on the stable release channel
--> main.rs:1:1
|
1 | #![feature(nonexistent_rust_feature)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0635]: unknown feature `nonexistent_rust_feature`
--> main.rs:1:12
|
1 | #![feature(nonexistent_rust_feature)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0554, E0635.
For more information about an error, try `rustc --explain E0554`.
The spans separate the two faults precisely. E0554 underlines the whole attribute, as always; E0635 underlines only the name, starting at column 12, because the name is its subject. The closing line counts 2 previous errors, and the footer changes shape — "Some errors have detailed explanations: E0554, E0635" — whenever both codes are present. The same pairing appears when one bad name rides in a list with a good one: #![feature(test, nonexistent_rust_feature)] prints E0554 over the whole attribute and E0635 over the bad name alone, at its own column. So a misspelling on stable is never a pure E0635, and fixing the spelling does not clear the build — it removes the second error and leaves the first.
The isolation experiment is the bootstrap variable from the previous section. With RUSTC_BOOTSTRAP=1, the channel fault is switched off, and the same program fails with E0635 alone:
#![feature(nonexistent_rust_feature)]
fn main() {}
$ RUSTC_BOOTSTRAP=1 rustc --edition 2021 main.rs -o main.bin
error[E0635]: unknown feature `nonexistent_rust_feature`
--> main.rs:1:12
|
1 | #![feature(nonexistent_rust_feature)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0635`.
One error, the footer back to its single-code form, and the span still on the name only. That is the cleanest statement of the split: E0635 is about whether the name exists in this compiler, E0554 is about whether any name may be used on this channel, and each fires independently of the other. The repairs are correspondingly separate — a name that draws E0635 is repaired by correcting it to a feature this compiler knows, or by removing the attribute if the name is a leftover for code that no longer needs it; neither repair touches the channel fault underneath. A name whose feature has since stabilized does not draw E0635 at all — the name is known — and is the E0554-with-help case covered earlier.
Misplaced attributes: warnings, an ignored attribute, and one uncoded error
The feature attribute is an inner attribute, and it belongs in exactly one place: the crate root, at the top of the root file. Every other placement behaves differently from E0554, and two of the three are not errors at all. Written inside a function, it is a warning, and the program compiles and runs:
fn main() {
#![feature(test)]
println!("hi");
}
$ rustc --edition 2021 main.rs -o main.bin
warning: the `#![feature]` attribute can only be used at the crate root
--> main.rs:2:5
|
2 | #![feature(test)]
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_attributes)]` (part of `#[warn(unused)]`) on by default
warning: 1 warning emitted
$ ./main.bin
hi
The program prints hi and exits with status 0. The warning's wording is the whole story: the attribute "can only be used at the crate root", it is filed under unused_attributes, and it is ignored — no feature is enabled, and no E0554 is raised, because a stable compiler never evaluates an attribute that is not in the position where attributes take effect. The identical warning, word for word, is what an inner #![feature] inside a module draws:
mod m {
#![feature(test)]
pub fn f() {}
}
fn main() {
m::f();
}
$ rustc --edition 2021 main.rs -o main.bin
warning: the `#![feature]` attribute can only be used at the crate root
--> main.rs:2:5
|
2 | #![feature(test)]
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_attributes)]` (part of `#[warn(unused)]`) on by default
warning: 1 warning emitted
$ ./main.bin
That program prints nothing — its main calls an empty function — and exits with status 0. A module is an enclosing item an inner attribute can annotate, so the placement is grammatical; it is simply not the crate root, and the attribute does nothing there. The practical consequence cuts against intuition: code that appears to enable a feature inside a module or a function enables nothing, so if the gated code then fails, it fails with whatever error the missing feature produces downstream, not with anything pointing at this line — the only pointer is this warning.
Written as an outer attribute, with #[feature] instead of #![feature], the compiler names the confusion directly:
#[feature(test)]
fn main() {
println!("hi");
}
$ rustc --edition 2021 main.rs -o main.bin
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![feature]`
--> main.rs:1:1
|
1 | #[feature(test)]
| ^^^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this function
--> main.rs:2:1
|
2 | / fn main() {
3 | | println!("hi");
4 | | }
| |_^
= note: `#[warn(unused_attributes)]` (part of `#[warn(unused)]`) on by default
warning: 1 warning emitted
$ ./main.bin
hi
Again a warning only, the program prints hi and exits with status 0, and again nothing is enabled: as written, the attribute is applied to the function that follows it, a position where feature has no effect. The warning even supplies the edit — add the exclamation mark — but taking that edit in this position only converts this warning into the crate-root warning above; the attribute has to move to the top of the file, not just gain its !.
The one placement that is a hard error is the crate root itself, in the wrong position within it. An inner attribute that appears after an item, rather than before any item, is not permitted at all:
fn main() {
println!("hi");
}
#![feature(test)]
$ rustc --edition 2021 main.rs -o main.bin
error: an inner attribute is not permitted in this context
--> main.rs:5:1
|
5 | #![feature(test)]
| ^^^^^^^^^^^^^^^^^
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
= note: outer attributes, like `#[test]`, annotate the item following them
error: aborting due to 1 previous error
This error carries no code — the header has no E number, and there is no "For more information" footer, because it is not part of the numbered error index. Its notes state the general rule it enforces: inner attributes annotate the enclosing item and are found at the beginning of source files. The repair is positional — move the attribute above the first item, to the very top of the file — and it is important to be clear about what that repair buys on the stable channel: the identical program with the attribute moved to the top is the first program in this guide, and it fails with E0554. Moving a misplaced attribute to the crate root converts a position error or a silent no-op into the channel error; it never converts any of them into a working stable build. Position and channel are two separate gates, and a stable build has to pass the channel gate by having no effective #![feature] attribute at all.
The exact rule: feature attributes are nightly-only, and they live at the crate root
The official page for E0554 states the rule in its first lines: feature attributes are only allowed on the nightly release channel, and stable or beta compilers will not comply. Its erroneous example is #![feature(lang_items)], the form reproduced above with its internal-features warning, and its stated remedy is to use a nightly release of the compiler, with the warning that the feature may be removed or altered in the future. The page carries no note retiring or replacing this code; E0554 is the current code for this fault.
The two halves of the rule come from two different places. The channel half is the release model: the Reference's index of built-in attributes lists feature in one line — used to enable unstable or experimental compiler features, with details deferred to the Unstable Book — and The Unstable Book describes its own contents the same way from the other side: each chapter is organized by a feature flag, and using an unstable feature of Rust requires a flag of the form #![feature(...)] naming it. Unstable means nightly-only by construction, so the attribute that carries the flag inherits the restriction. The position half is the attribute system itself: the Reference describes an inner attribute as applying to the form it is declared within — for a source file, the crate — which is why the effective place for #![feature] is the top of the crate root, why the same attribute inside a function or module is an unused attribute rather than a misplaced feature, and why one stranded after an item is refused as not permitted in that context. E0554 fires only when both halves meet: an attribute that is in effect, naming features a nightly compiler could switch on, compiled by a compiler whose channel forbids it. Two name histories bend the edges of that statement without breaking it: a name that has already stabilized still draws E0554, because the attribute itself is what the channel forbids, but with the compiler's own remove-the-attribute help attached; a name that has been removed draws E0557 instead, because there is no longer a feature for the attribute to name.
The fixes, ranked
- First, remove the attribute, when the crate uses nothing the named feature gates. Search for the gated constructs —
extern crate testand#[bench]fortest, the feature's Unstable Book chapter for others — and if the search is empty, the deletion is the whole fix and no behavior changes. - Second, rewrite the gated code on stable APIs, when the code is real but its need is covered by stable constructs, as the benchmark is covered by an explicit loop timed with
std::time::Instant. The attribute is then removed as in the first fix, and the crate is stable in fact, not just in label. - Third, move the project to a nightly release, when the feature has no stable equivalent and the work cannot wait for stabilization. This is the official page's own remedy, taken with its warning: the feature may be removed or altered, and the project now tracks nightly.
- Never as a fix:
RUSTC_BOOTSTRAP=1, which makes the stable compiler behave as nightly for feature purposes while keeping the stable label. It demonstrates that the channel is the only fault — and it is the right diagnostic for exactly that — but a build shipped under it carries nightly's instability without nightly's name.
Which fix for which cause
- A crate-root
#![feature(test)]over code that contains no benchmark and no other unstable construct: E0554 alone, span over the whole attribute. Delete the attribute. - A crate-root
#![feature(test)]withextern crate test;and a#[bench]function: E0554, followed in a non---testbuild by an unused-import warning forBencherthat is a consequence of the build mode. Rewrite the benchmark as a stable timing loop, or move the project to nightly if it must stay acargo benchbenchmark. - A crate-root attribute naming
lang_items: E0554 plus aninternal_featureswarning — the feature is internal to the compiler or standard library and its use is strongly discouraged on any channel. The code needs restructuring, not a channel change. - A crate-root attribute naming an unfinished feature such as
generic_const_exprs: E0554 plus anincomplete_featureswarning naming the tracking issue. On nightly the same warning remains; the feature may not be safe to use and may crash the compiler. - A crate-root attribute naming a feature that has already stabilized, such as
let_else: E0554 with a remove-the-attribute help on the span and astable_featureswarning. Delete the attribute — the code is already stable; this is the first fix with the compiler itself supplying the edit. - A crate-root attribute naming a removed feature, such as
const_fn: E0557 alone, no E0554 and no E0635, with a note naming the removal release and the finer-grained gates it was split into. Delete the attribute, and rewrite any gated code under those gates on nightly or on stable APIs. - An attribute naming a feature this compiler does not know, alone or inside a list: E0554 over the whole attribute plus E0635 over the bad name, 2 previous errors. Correct or remove the name to clear E0635; the channel fault remains until the attribute itself goes or the channel changes.
- The same unknown name compiled with
RUSTC_BOOTSTRAP=1: E0635 alone, 1 previous error — the isolation that proves the two codes are independent faults. - A valid program compiled with
RUSTC_BOOTSTRAP=1and a crate-root#![feature(test)]: no error, anunused_featureswarning if the feature goes unused, and the program runs. The channel check is bypassed, not satisfied. - A
#![feature]inside a function body or a module: no error — anunused_attributeswarning, "can only be used at the crate root", the attribute ignored, the program running with nothing enabled. Move it to the top of the root file if it was meant to take effect, and then treat it as the crate-root case. - An outer
#[feature]on a function or another item: no error — a warning that a crate-level attribute should be an inner attribute, with a note that as written it applies to the following item. Add the!and move it to the top of the file, in that order of importance. - An inner
#![feature]at the crate root but after an item: the uncoded error "an inner attribute is not permitted in this context", no E number and no explain footer. Move it above the first item — which, on stable, converts it into E0554.
Checklist
- Read the span first. For a currently unstable name, E0554 underlines the whole attribute on line 1 and offers no help and no edit, because the fault is the compiler's channel, not the attribute's contents. A stabilized name is the exception: the same underline carries a remove-the-attribute help, and deleting the attribute is the whole fix.
- Count the errors. One error is the channel fault alone; two errors with an E0635 underlining a single name mean the name is also unknown to this compiler — a separate fault with a separate repair, which survives every channel fix.
- Note the warnings without mistaking them for the fault.
internal_featuresandincomplete_featureswarnings describe the named feature and appear alongside E0554, and astable_featureswarning marks a name that has already stabilized; theunused_featureswarning appears only when the feature system is actually on, which on a stable binary meansRUSTC_BOOTSTRAPis set. - Search before deleting. The attribute is safe to remove exactly when nothing in the crate uses what it gates; for
testthat means noextern crate test, no#[bench], noBencher. - Check the position before the channel. An attribute inside a function or module, or written without its
!, is ignored with a warning and enables nothing; one placed after an item is an uncoded position error. Neither is E0554, and moving the attribute to the top of the file turns both into the crate-root case. - A name that draws E0557 alone has been removed from the compiler: delete the attribute, and rewrite the gated code under the finer-grained gates the note names, or on stable APIs.
- Decide the channel question honestly. Delete or rewrite for stable, use a nightly toolchain for nightly code, and do not ship a stable-labeled build that only compiles because
RUSTC_BOOTSTRAPwas set.
Related guides on this site
- Unknown Feature E0635 Fix
- E0658 Unstable Feature Fix
- E0091 Unused Type Parameter Fix
- E0084 Unsupported Representation Fix
Sources
- Rust Compiler Error Index, E0554 — for feature attributes being allowed only on the nightly release channel while stable and beta compilers will not comply, for the erroneous example
#![feature(lang_items)], and for using a nightly release, with the warning that the feature may be removed or altered, as the remedy. - Rust Compiler Error Index, E0635 — for the
#![feature]attribute specifying an unknown feature, and for the erroneous example#![feature(nonexistent_rust_feature)]. - The Rust Unstable Book, The Unstable Book — for each chapter being organized by a feature flag, and for using an unstable feature of Rust requiring a flag of the form
#![feature(...)]. - The Rust Reference, Attributes — for an inner attribute applying to the form it is declared within, for an outer attribute applying to the form that follows it, and for the
featureattribute being used to enable unstable or experimental compiler features.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.