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
]
@@ -5196,3 +5197,50 @@ declare_lint! {
5196
5197
Warn,
5197
5198
r#"detects when a function annotated with `#[inline(always)]` and `#[target_feature(enable = "..")]` is inlined into a caller without the required target feature"#,
5198
5199
}
5200
+
5201
+
declare_lint!{
5202
+
/// The `varargs_without_pattern` lint detects when `...` is used as an argument to a
5203
+
/// non-foreign function without any pattern being specified.
5204
+
///
5205
+
/// ### Example
5206
+
///
5207
+
/// ```rust
5208
+
/// // Using `...` in non-foreign function definitions is unstable, however stability is
5209
+
/// // currently only checked after attributes are expanded, so using `#[cfg(false)]` here will
5210
+
/// // allow this to compile on stable Rust.
5211
+
/// #[cfg(false)]
5212
+
/// fn foo(...) {
5213
+
///
5214
+
/// }
5215
+
/// ```
5216
+
///
5217
+
/// {{produces}}
5218
+
///
5219
+
/// ### Explanation
5220
+
///
5221
+
/// Patterns are currently required for all non-`...` arguments in function definitions (with
5222
+
/// some exceptions in the 2015 edition). Requiring `...` arguments to have patterns in
5223
+
/// non-foreign function definitions makes the language more consistent, and removes a source of
5224
+
/// confusion for the unstable C variadic feature. `...` arguments without a pattern are already
5225
+
/// stable and widely used in foreign function definitions; this lint only affects non-foreign
5226
+
/// function definitions.
5227
+
///
5228
+
/// Using `...` (C varargs) in a non-foreign function definition is currently unstable. However,
5229
+
/// stability checking for the `...` syntax in non-foreign function definitions is currently
5230
+
/// implemented after attributes have been expanded, meaning that if the attribute removes the
5231
+
/// use of the unstable syntax (e.g. `#[cfg(false)]`, or a procedural macro), the code will
5232
+
/// compile on stable Rust; this is the only situation where this lint affects code that
5233
+
/// compiles on stable Rust.
5234
+
///
5235
+
/// This is a [future-incompatible] lint to transition this to a hard error in the future.
0 commit comments