@@ -77,7 +77,8 @@ declare_lint_pass! {
7777 PROC_MACRO_BACK_COMPAT ,
7878 PROC_MACRO_DERIVE_RESOLUTION_FALLBACK ,
7979 PUB_USE_OF_PRIVATE_EXTERN_CRATE ,
80- REFINING_IMPL_TRAIT ,
80+ REFINING_IMPL_TRAIT_INTERNAL ,
81+ REFINING_IMPL_TRAIT_REACHABLE ,
8182 RENAMED_AND_REMOVED_LINTS ,
8283 REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS ,
8384 RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES ,
@@ -4320,7 +4321,9 @@ declare_lint! {
43204321
43214322declare_lint ! {
43224323 /// The `refining_impl_trait` lint detects usages of return-position impl
4323- /// traits in trait signatures which are refined by implementations.
4324+ /// traits in trait signatures which are refined by implementations, meaning
4325+ /// the implementation adds information about the return type that is not
4326+ /// present in the trait.
43244327 ///
43254328 /// ### Example
43264329 ///
@@ -4350,13 +4353,58 @@ declare_lint! {
43504353 ///
43514354 /// ### Explanation
43524355 ///
4353- /// Return-position impl trait in traits (RPITITs) desugar to associated types,
4354- /// and callers of methods for types where the implementation is known are
4356+ /// Callers of methods for types where the implementation is known are
43554357 /// able to observe the types written in the impl signature. This may be
4356- /// intended behavior, but may also pose a semver hazard for authors of libraries
4357- /// who do not wish to make stronger guarantees about the types than what is
4358- /// written in the trait signature.
4359- pub REFINING_IMPL_TRAIT ,
4358+ /// intended behavior, but may also lead to implementation details being
4359+ /// revealed unintentionally. In particular, it may pose a semver hazard
4360+ /// for authors of libraries who do not wish to make stronger guarantees
4361+ /// about the types than what is written in the trait signature.
4362+ pub REFINING_IMPL_TRAIT_REACHABLE ,
4363+ Warn ,
4364+ "impl trait in impl method signature does not match trait method signature" ,
4365+ }
4366+
4367+ declare_lint ! {
4368+ /// The `refining_impl_trait` lint detects usages of return-position impl
4369+ /// traits in trait signatures which are refined by implementations, meaning
4370+ /// the implementation adds information about the return type that is not
4371+ /// present in the trait.
4372+ ///
4373+ /// ### Example
4374+ ///
4375+ /// ```rust,compile_fail
4376+ /// #![deny(refining_impl_trait)]
4377+ ///
4378+ /// use std::fmt::Display;
4379+ ///
4380+ /// pub trait AsDisplay {
4381+ /// fn as_display(&self) -> impl Display;
4382+ /// }
4383+ ///
4384+ /// impl<'s> AsDisplay for &'s str {
4385+ /// fn as_display(&self) -> Self {
4386+ /// *self
4387+ /// }
4388+ /// }
4389+ ///
4390+ /// fn main() {
4391+ /// // users can observe that the return type of
4392+ /// // `<&str as AsDisplay>::as_display()` is `&str`.
4393+ /// let x: &str = "".as_display();
4394+ /// }
4395+ /// ```
4396+ ///
4397+ /// {{produces}}
4398+ ///
4399+ /// ### Explanation
4400+ ///
4401+ /// Callers of methods for types where the implementation is known are
4402+ /// able to observe the types written in the impl signature. This may be
4403+ /// intended behavior, but may also lead to implementation details being
4404+ /// revealed unintentionally. In particular, it may pose a semver hazard
4405+ /// for authors of libraries who do not wish to make stronger guarantees
4406+ /// about the types than what is written in the trait signature.
4407+ pub REFINING_IMPL_TRAIT_INTERNAL ,
43604408 Warn ,
43614409 "impl trait in impl method signature does not match trait method signature" ,
43624410}
0 commit comments