@@ -33,13 +33,12 @@ use lint::{LintPass, LateLintPass, EarlyLintPass, EarlyContext};
33
33
use rustc:: util:: nodemap:: FxHashSet ;
34
34
35
35
use syntax:: tokenstream:: { TokenTree , TokenStream } ;
36
- use syntax:: ast;
36
+ use syntax:: ast:: { self , Expr } ;
37
37
use syntax:: ptr:: P ;
38
- use syntax:: ast:: Expr ;
39
38
use syntax:: attr:: { self , HasAttrs , AttributeTemplate } ;
40
39
use syntax:: source_map:: Spanned ;
41
40
use syntax:: edition:: Edition ;
42
- use syntax:: feature_gate:: { AttributeGate , AttributeType } ;
41
+ use syntax:: feature_gate:: { self , AttributeGate , AttributeType } ;
43
42
use syntax:: feature_gate:: { Stability , deprecated_attributes} ;
44
43
use syntax_pos:: { BytePos , Span , SyntaxContext } ;
45
44
use syntax:: symbol:: { Symbol , kw, sym} ;
@@ -1831,3 +1830,35 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
1831
1830
}
1832
1831
}
1833
1832
}
1833
+
1834
+ declare_lint ! {
1835
+ pub INCOMPLETE_FEATURES ,
1836
+ Warn ,
1837
+ "incomplete features that may function improperly in some or all cases"
1838
+ }
1839
+
1840
+ declare_lint_pass ! (
1841
+ /// Check for used feature gates in `INCOMPLETE_FEATURES` in `feature_gate.rs`.
1842
+ IncompleteFeatures => [ INCOMPLETE_FEATURES ]
1843
+ ) ;
1844
+
1845
+ impl EarlyLintPass for IncompleteFeatures {
1846
+ fn check_crate ( & mut self , cx : & EarlyContext < ' _ > , _: & ast:: Crate ) {
1847
+ let features = cx. sess . features_untracked ( ) ;
1848
+ features. declared_lang_features
1849
+ . iter ( ) . map ( |( name, span, _) | ( name, span) )
1850
+ . chain ( features. declared_lib_features . iter ( ) . map ( |( name, span) | ( name, span) ) )
1851
+ . filter ( |( name, _) | feature_gate:: INCOMPLETE_FEATURES . iter ( ) . any ( |f| name == & f) )
1852
+ . for_each ( |( name, & span) | {
1853
+ cx. struct_span_lint (
1854
+ INCOMPLETE_FEATURES ,
1855
+ span,
1856
+ & format ! (
1857
+ "the feature `{}` is incomplete and may cause the compiler to crash" ,
1858
+ name,
1859
+ )
1860
+ )
1861
+ . emit ( ) ;
1862
+ } ) ;
1863
+ }
1864
+ }
0 commit comments