Skip to content
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

incompatible_msrv: lint function calls with any argument count #14216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Feb 13, 2025

The lint for function calls was previously restricted to functions taking exactly one argument. This was not documented.

Generalizing the lint to an arbitrary number of arguments in the function call requires special casing some macro expansions from the standard library. Macros such as panic!() or assert_eq!() exist since Rust 1.0.0, but modern stdlib expand those macros into calls to functions introduced in later Rust versions. While it is desirable to lint code inside macros, using MSRV-incompatible functions coming from core in macro expansions has been special-cased to not trigger this lint.

Also, code coming from compiler desugaring may contain function calls (for example, a..=b is now desugared into RangeInclusive::new(a, b). Those should not be linted either as the compiler is allowed to use unstable function calls.

Fix #14212

changelog: [incompatible_msrv]: lint function calls with any argument count

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 13, 2025
@samueltardieu samueltardieu force-pushed the incompatible-msrv-fix branch 2 times, most recently from b04242c to ab08d1a Compare February 15, 2025 07:36
@samueltardieu samueltardieu marked this pull request as ready for review February 15, 2025 07:37
@samueltardieu samueltardieu force-pushed the incompatible-msrv-fix branch 3 times, most recently from 90bc6d3 to efad358 Compare February 15, 2025 07:41
@samueltardieu
Copy link
Contributor Author

r? @llogiq

The lint for function calls was previously restricted to functions taking
exactly one argument. This was not documented.

Generalizing the lint to an arbitrary number of arguments in the function
call requires special casing some macro expansions from the standard
library. Macros such as `panic!()` or `assert_eq!()` exist since Rust
1.0.0, but modern stdlib expand those macros into calls to functions
introduced in later Rust versions. While it is desirable to lint code
inside macros, using MSRV-incompatible functions coming from `core`
in macro expansions has been special-cased to not trigger this lint.

Also, code coming from compiler desugaring may contain function calls
(for example, `a..=b` is now desugared into `RangeInclusive::new(a,
b)`. Those should not be linted either as the compiler is allowed to
use unstable function calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

incompatible_msrv fails to detect std::iter::repeat_n
3 participants