@@ -62,6 +62,8 @@ impl GatedSpans {
62
62
}
63
63
}
64
64
65
+ /// The strenght of a feature gate.
66
+ /// Either it is a `Hard` error, or only a `Soft` warning.
65
67
#[ derive( Debug , Copy , Clone , PartialEq ) ]
66
68
pub enum GateStrength {
67
69
/// A hard error. (Most feature gates should use this.)
@@ -70,6 +72,20 @@ pub enum GateStrength {
70
72
Soft ,
71
73
}
72
74
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
+ /// ```
73
89
pub fn feature_err < ' a > (
74
90
sess : & ' a ParseSess ,
75
91
feature : Symbol ,
@@ -79,6 +95,10 @@ pub fn feature_err<'a>(
79
95
feature_err_issue ( sess, feature, span, GateIssue :: Language , explain)
80
96
}
81
97
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`.
82
102
pub fn feature_err_issue < ' a > (
83
103
sess : & ' a ParseSess ,
84
104
feature : Symbol ,
@@ -89,6 +109,9 @@ pub fn feature_err_issue<'a>(
89
109
leveled_feature_err ( sess, feature, span, issue, explain, GateStrength :: Hard )
90
110
}
91
111
112
+ /// Construct a diagnostic for a feature gate error / warning.
113
+ ///
114
+ /// You should typically just use `feature_err` instead.
92
115
pub fn leveled_feature_err < ' a > (
93
116
sess : & ' a ParseSess ,
94
117
feature : Symbol ,
0 commit comments