Skip to content

incompatible_msrv: lint function calls with any argument count #14216

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

Merged
merged 1 commit into from
Mar 13, 2025

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

@samueltardieu samueltardieu force-pushed the incompatible-msrv-fix branch 2 times, most recently from 3fb9b88 to c3d5f65 Compare February 15, 2025 15:33
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.
@samueltardieu
Copy link
Contributor Author

Rebased

@samueltardieu
Copy link
Contributor Author

r? @Centri3

@rustbot rustbot assigned Centri3 and unassigned llogiq Mar 9, 2025
@Centri3
Copy link
Member

Centri3 commented Mar 9, 2025

Will look tomorrow.
Probably fine to merge this before #14328 but we shouldn't wait for someone to run into it.

Copy link
Member

@Centri3 Centri3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, immediately forgot about this.

@Centri3 Centri3 added this pull request to the merge queue Mar 13, 2025
Merged via the queue into rust-lang:master with commit 18061e2 Mar 13, 2025
11 checks passed
@samueltardieu samueltardieu deleted the incompatible-msrv-fix branch March 14, 2025 07:01
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
5 participants