@@ -89,6 +89,7 @@ declare_lint_pass! {
89
89
RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX ,
90
90
RUST_2021_PRELUDE_COLLISIONS ,
91
91
RUST_2024_INCOMPATIBLE_PAT ,
92
+ RUST_2024_PRELUDE_COLLISIONS ,
92
93
SELF_CONSTRUCTOR_FROM_OUTER_ITEM ,
93
94
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS ,
94
95
SINGLE_USE_LIFETIMES ,
@@ -3841,6 +3842,46 @@ declare_lint! {
3841
3842
} ;
3842
3843
}
3843
3844
3845
+ declare_lint ! {
3846
+ /// The `rust_2024_prelude_collisions` lint detects the usage of trait methods which are ambiguous
3847
+ /// with traits added to the prelude in future editions.
3848
+ ///
3849
+ /// ### Example
3850
+ ///
3851
+ /// ```rust,edition2021,compile_fail
3852
+ /// #![deny(rust_2024_prelude_collisions)]
3853
+ /// trait Meow {
3854
+ /// fn poll(&self) {}
3855
+ /// }
3856
+ /// impl<T> Meow for T {}
3857
+ ///
3858
+ /// fn main() {
3859
+ /// core::pin::pin!(async {}).poll();
3860
+ /// // ^^^^^^^^
3861
+ /// // This call to try_into matches both Future::poll and Meow::poll as
3862
+ /// // `Future` has been added to the Rust prelude in 2024 edition.
3863
+ /// }
3864
+ /// ```
3865
+ ///
3866
+ /// {{produces}}
3867
+ ///
3868
+ /// ### Explanation
3869
+ ///
3870
+ /// Rust 2024, introduces two new additions to the standard library's prelude,
3871
+ /// `Future` and `IntoFuture`. This results in an ambiguity as to which method/function
3872
+ /// to call when an existing `poll`/`into_future` method is called via dot-call syntax or
3873
+ /// a `poll`/`into_future` associated function is called directly on a type.
3874
+ ///
3875
+ pub RUST_2024_PRELUDE_COLLISIONS ,
3876
+ Allow ,
3877
+ "detects the usage of trait methods which are ambiguous with traits added to the \
3878
+ prelude in future editions",
3879
+ @future_incompatible = FutureIncompatibleInfo {
3880
+ reason: FutureIncompatibilityReason :: EditionError ( Edition :: Edition2024 ) ,
3881
+ reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html>" ,
3882
+ } ;
3883
+ }
3884
+
3844
3885
declare_lint ! {
3845
3886
/// The `rust_2021_prefixes_incompatible_syntax` lint detects identifiers that will be parsed as a
3846
3887
/// prefix instead in Rust 2021.
0 commit comments