File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -620,7 +620,30 @@ impl Features {
620
620
) -> CargoResult < ( ) > {
621
621
let nightly_features_allowed = self . nightly_features_allowed ;
622
622
let Some ( ( slot, feature) ) = self . status ( feature_name) else {
623
- bail ! ( "unknown cargo feature `{}`" , feature_name)
623
+ let mut msg = format ! (
624
+ "feature `{feature_name}` is not a valid unstable feature for Cargo.toml\n \n "
625
+ ) ;
626
+
627
+ if feature_name. contains ( '_' ) {
628
+ let _ = writeln ! ( msg, "Feature names must use '-' instead of '_'." ) ;
629
+ } else {
630
+ let underscore_name = feature_name. replace ( '-' , "_" ) ;
631
+ if CliUnstable :: help ( )
632
+ . iter ( )
633
+ . any ( |( option, _) | * option == underscore_name)
634
+ {
635
+ let _ = writeln ! (
636
+ msg,
637
+ "This feature can be enabled via -Z{feature_name} or the `[unstable]` section in config.toml."
638
+ ) ;
639
+ }
640
+ }
641
+
642
+ let _ = writeln ! (
643
+ msg,
644
+ "See https://doc.rust-lang.org/cargo/reference/unstable.html for more information."
645
+ ) ;
646
+ bail ! ( msg)
624
647
} ;
625
648
626
649
if * slot {
Original file line number Diff line number Diff line change @@ -173,8 +173,9 @@ fn unknown_feature() {
173
173
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
174
174
175
175
Caused by:
176
- unknown cargo feature `foo`
176
+ feature `foo` is not a valid unstable feature for Cargo.toml
177
177
178
+ See https://doc.rust-lang.org/cargo/reference/unstable.html for more information.
178
179
"# ] ] )
179
180
. run ( ) ;
180
181
}
You can’t perform that action at this time.
0 commit comments