You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: compiler/rustc_lint_defs/src/builtin.rs
+48Lines changed: 48 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,7 @@ declare_lint_pass! {
142
142
UNUSED_UNSAFE,
143
143
UNUSED_VARIABLES,
144
144
USELESS_DEPRECATED,
145
+
VARARGS_WITHOUT_PATTERN,
145
146
WARNINGS,
146
147
// tidy-alphabetical-end
147
148
]
@@ -5195,3 +5196,50 @@ declare_lint! {
5195
5196
Warn,
5196
5197
r#"detects when a function annotated with `#[inline(always)]` and `#[target_feature(enable = "..")]` is inlined into a caller without the required target feature"#,
5197
5198
}
5199
+
5200
+
declare_lint!{
5201
+
/// The `varargs_without_pattern` lint detects when `...` is used as an argument to a
5202
+
/// non-foreign function without any pattern being specified.
5203
+
///
5204
+
/// ### Example
5205
+
///
5206
+
/// ```rust
5207
+
/// // Using `...` in non-foreign function definitions is unstable, however stability is
5208
+
/// // currently only checked after attributes are expanded, so using `#[cfg(false)]` here will
5209
+
/// // allow this to compile on stable Rust.
5210
+
/// #[cfg(false)]
5211
+
/// fn foo(...) {
5212
+
///
5213
+
/// }
5214
+
/// ```
5215
+
///
5216
+
/// {{produces}}
5217
+
///
5218
+
/// ### Explanation
5219
+
///
5220
+
/// Patterns are currently required for all non-`...` arguments in function definitions (with
5221
+
/// some exceptions in the 2015 edition). Requiring `...` arguments to have patterns in
5222
+
/// non-foreign function definitions makes the language more consistent, and removes a source of
5223
+
/// confusion for the unstable C variadic feature. `...` arguments without a pattern are already
5224
+
/// stable and widely used in foreign function definitions; this lint only affects non-foreign
5225
+
/// function definitions.
5226
+
///
5227
+
/// Using `...` (C varargs) in a non-foreign function definition is currently unstable. However,
5228
+
/// stability checking for the `...` syntax in non-foreign function definitions is currently
5229
+
/// implemented after attributes have been expanded, meaning that if the attribute removes the
5230
+
/// use of the unstable syntax (e.g. `#[cfg(false)]`, or a procedural macro), the code will
5231
+
/// compile on stable Rust; this is the only situation where this lint affects code that
5232
+
/// compiles on stable Rust.
5233
+
///
5234
+
/// This is a [future-incompatible] lint to transition this to a hard error in the future.
0 commit comments