File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -620,7 +620,32 @@ 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 ! ( "unknown Cargo.toml feature `{feature_name}`\n \n " ) ;
624
+ let mut append_see_docs = true ;
625
+
626
+ if feature_name. contains ( '_' ) {
627
+ let _ = writeln ! ( msg, "Feature names must use '-' instead of '_'." ) ;
628
+ append_see_docs = false ;
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
+ if append_see_docs {
643
+ let _ = writeln ! (
644
+ msg,
645
+ "See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html for more information."
646
+ ) ;
647
+ }
648
+ bail ! ( msg)
624
649
} ;
625
650
626
651
if * slot {
You can’t perform that action at this time.
0 commit comments