@@ -91,6 +91,7 @@ declare_lint_pass! {
91
91
RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX ,
92
92
RUST_2021_PRELUDE_COLLISIONS ,
93
93
RUST_2024_INCOMPATIBLE_PAT ,
94
+ RUST_2024_PRELUDE_COLLISIONS ,
94
95
SELF_CONSTRUCTOR_FROM_OUTER_ITEM ,
95
96
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS ,
96
97
SINGLE_USE_LIFETIMES ,
@@ -3750,6 +3751,46 @@ declare_lint! {
3750
3751
} ;
3751
3752
}
3752
3753
3754
+ declare_lint ! {
3755
+ /// The `rust_2024_prelude_collisions` lint detects the usage of trait methods which are ambiguous
3756
+ /// with traits added to the prelude in future editions.
3757
+ ///
3758
+ /// ### Example
3759
+ ///
3760
+ /// ```rust,edition2021,compile_fail
3761
+ /// #![deny(rust_2024_prelude_collisions)]
3762
+ /// trait Meow {
3763
+ /// fn poll(&self) {}
3764
+ /// }
3765
+ /// impl<T> Meow for T {}
3766
+ ///
3767
+ /// fn main() {
3768
+ /// core::pin::pin!(async {}).poll();
3769
+ /// // ^^^^^^
3770
+ /// // This call to try_into matches both Future::poll and Meow::poll as
3771
+ /// // `Future` has been added to the Rust prelude in 2024 edition.
3772
+ /// }
3773
+ /// ```
3774
+ ///
3775
+ /// {{produces}}
3776
+ ///
3777
+ /// ### Explanation
3778
+ ///
3779
+ /// Rust 2024, introduces two new additions to the standard library's prelude:
3780
+ /// `Future` and `IntoFuture`. This results in an ambiguity as to which method/function
3781
+ /// to call when an existing `poll`/`into_future` method is called via dot-call syntax or
3782
+ /// a `poll`/`into_future` associated function is called directly on a type.
3783
+ ///
3784
+ pub RUST_2024_PRELUDE_COLLISIONS ,
3785
+ Allow ,
3786
+ "detects the usage of trait methods which are ambiguous with traits added to the \
3787
+ prelude in future editions",
3788
+ @future_incompatible = FutureIncompatibleInfo {
3789
+ reason: FutureIncompatibilityReason :: EditionError ( Edition :: Edition2024 ) ,
3790
+ reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html>" ,
3791
+ } ;
3792
+ }
3793
+
3753
3794
declare_lint ! {
3754
3795
/// The `rust_2021_prefixes_incompatible_syntax` lint detects identifiers that will be parsed as a
3755
3796
/// prefix instead in Rust 2021.
0 commit comments