@@ -846,18 +846,20 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
846846 remaining_lib_features. remove ( & Symbol :: intern ( "libc" ) ) ;
847847 remaining_lib_features. remove ( & Symbol :: intern ( "test" ) ) ;
848848
849- for ( feature, stable) in tcx. lib_features ( ) . to_vec ( ) {
850- if let Some ( since) = stable {
851- if let Some ( span) = remaining_lib_features. get ( & feature) {
852- // Warn if the user has enabled an already-stable lib feature.
853- unnecessary_stable_feature_lint ( tcx, * span, feature, since) ;
849+ if !remaining_lib_features. is_empty ( ) {
850+ for ( feature, stable) in tcx. lib_features ( ) . to_vec ( ) {
851+ if let Some ( since) = stable {
852+ if let Some ( span) = remaining_lib_features. get ( & feature) {
853+ // Warn if the user has enabled an already-stable lib feature.
854+ unnecessary_stable_feature_lint ( tcx, * span, feature, since) ;
855+ }
854856 }
857+ remaining_lib_features. remove ( & feature) ;
855858 }
856- remaining_lib_features. remove ( & feature) ;
857- }
858859
859- for ( feature, span) in remaining_lib_features {
860- struct_span_err ! ( tcx. sess, span, E0635 , "unknown feature `{}`" , feature) . emit ( ) ;
860+ for ( feature, span) in remaining_lib_features {
861+ struct_span_err ! ( tcx. sess, span, E0635 , "unknown feature `{}`" , feature) . emit ( ) ;
862+ }
861863 }
862864
863865 // FIXME(#44232): the `used_features` table no longer exists, so we
0 commit comments