@@ -62,6 +62,8 @@ impl GatedSpans {
6262 }
6363}
6464
65+ /// The strenght of a feature gate.
66+ /// Either it is a `Hard` error, or only a `Soft` warning.
6567#[ derive( Debug , Copy , Clone , PartialEq ) ]
6668pub enum GateStrength {
6769 /// A hard error. (Most feature gates should use this.)
@@ -70,6 +72,20 @@ pub enum GateStrength {
7072 Soft ,
7173}
7274
75+ /// Construct a diagnostic for a language feature error due to the given `span`.
76+ /// The `feature`'s `Symbol` is the one you used in `active.rs` and `rustc_span::symbols`.
77+ ///
78+ /// Example usage:
79+ ///
80+ /// ```ignore
81+ /// feature_err(
82+ /// parse_sess,
83+ /// sym::stmt_expr_attributes,
84+ /// attr.span,
85+ /// "attributes on expressions are unstable",
86+ /// )
87+ /// .emit();
88+ /// ```
7389pub fn feature_err < ' a > (
7490 sess : & ' a ParseSess ,
7591 feature : Symbol ,
@@ -79,6 +95,10 @@ pub fn feature_err<'a>(
7995 feature_err_issue ( sess, feature, span, GateIssue :: Language , explain)
8096}
8197
98+ /// Construct a diagnostic for a feature gate error.
99+ ///
100+ /// This variant allows you to control whether it is a library or language feature.
101+ /// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
82102pub fn feature_err_issue < ' a > (
83103 sess : & ' a ParseSess ,
84104 feature : Symbol ,
@@ -89,6 +109,9 @@ pub fn feature_err_issue<'a>(
89109 leveled_feature_err ( sess, feature, span, issue, explain, GateStrength :: Hard )
90110}
91111
112+ /// Construct a diagnostic for a feature gate error / warning.
113+ ///
114+ /// You should typically just use `feature_err` instead.
92115pub fn leveled_feature_err < ' a > (
93116 sess : & ' a ParseSess ,
94117 feature : Symbol ,
0 commit comments