-
Notifications
You must be signed in to change notification settings - Fork 13.8k
c_variadic
: Add future-incompatibility warning for ...
arguments without a pattern outside of extern
blocks
#143619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
beetrees
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
beetrees:varargs-named
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,7 @@ declare_lint_pass! { | |
UNUSED_UNSAFE, | ||
UNUSED_VARIABLES, | ||
USELESS_DEPRECATED, | ||
VARARGS_WITHOUT_PATTERN, | ||
WARNINGS, | ||
// tidy-alphabetical-end | ||
] | ||
|
@@ -5197,3 +5198,50 @@ declare_lint! { | |
Warn, | ||
r#"detects when a function annotated with `#[inline(always)]` and `#[target_feature(enable = "..")]` is inlined into a caller without the required target feature"#, | ||
} | ||
|
||
declare_lint! { | ||
/// The `varargs_without_pattern` lint detects when `...` is used as an argument to a | ||
/// non-foreign function without any pattern being specified. | ||
/// | ||
/// ### Example | ||
/// | ||
/// ```rust | ||
/// // Using `...` in non-foreign function definitions is unstable, however stability is | ||
/// // currently only checked after attributes are expanded, so using `#[cfg(false)]` here will | ||
/// // allow this to compile on stable Rust. | ||
/// #[cfg(false)] | ||
/// fn foo(...) { | ||
/// | ||
/// } | ||
/// ``` | ||
/// | ||
/// {{produces}} | ||
/// | ||
/// ### Explanation | ||
/// | ||
/// Patterns are currently required for all non-`...` arguments in function definitions (with | ||
/// some exceptions in the 2015 edition). Requiring `...` arguments to have patterns in | ||
/// non-foreign function definitions makes the language more consistent, and removes a source of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. like, with a block here that's "A correct usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
/// confusion for the unstable C variadic feature. `...` arguments without a pattern are already | ||
/// stable and widely used in foreign function definitions; this lint only affects non-foreign | ||
/// function definitions. | ||
/// | ||
/// Using `...` (C varargs) in a non-foreign function definition is currently unstable. However, | ||
/// stability checking for the `...` syntax in non-foreign function definitions is currently | ||
/// implemented after attributes have been expanded, meaning that if the attribute removes the | ||
/// use of the unstable syntax (e.g. `#[cfg(false)]`, or a procedural macro), the code will | ||
/// compile on stable Rust; this is the only situation where this lint affects code that | ||
/// compiles on stable Rust. | ||
/// | ||
/// This is a [future-incompatible] lint to transition this to a hard error in the future. | ||
/// | ||
/// [future-incompatible]: ../index.md#future-incompatible-lints | ||
pub VARARGS_WITHOUT_PATTERN, | ||
Warn, | ||
"detects usage of `...` arguments without a pattern in non-foreign items", | ||
@future_incompatible = FutureIncompatibleInfo { | ||
reason: FutureIncompatibilityReason::FutureReleaseError, | ||
reference: "issue #145544 <https://github.com/rust-lang/rust/issues/145544>", | ||
report_in_deps: false, | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you give an example of a correct usage, with a pattern?