You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exhaustiveness checking could be incorrect in the presence of an incorrectly implemented deref function. This could lead to UB. Some possible solutions:
The compiler adds an implicit _ => unreachable!(), match arm for all sub-patterns which use deref. The match arm would not be generated if the user supplied one. The actual pattern would have _ as a sub-pattern, as required. E.g., when matching a scrutinee with type Option<Rc<bool>>, the generated arm would be equivalent to Some(_) => unreachable!(). Obviously the generated arm should not trigger any unreachable code lints. This is my personally preferred option.
We require the user to have an explicit _ match arm. This is boilerplatey.
Only allow deref in patterns for trusted types, e.g., a subset of std types.
Add a DerefPure trait or similar attribute to indicate to the compiler that a smart pointer is safe to be used with deref patterns. This option would require a lot of work to design, implement, and stabilise such a trait.
The text was updated successfully, but these errors were encountered:
Exhaustiveness checking could be incorrect in the presence of an incorrectly implemented
deref
function. This could lead to UB. Some possible solutions:_ => unreachable!(),
match arm for all sub-patterns which use deref. The match arm would not be generated if the user supplied one. The actual pattern would have_
as a sub-pattern, as required. E.g., when matching a scrutinee with typeOption<Rc<bool>>
, the generated arm would be equivalent toSome(_) => unreachable!()
. Obviously the generated arm should not trigger any unreachable code lints. This is my personally preferred option._
match arm. This is boilerplatey.DerefPure
trait or similar attribute to indicate to the compiler that a smart pointer is safe to be used with deref patterns. This option would require a lot of work to design, implement, and stabilise such a trait.The text was updated successfully, but these errors were encountered: