Use derivative for better derive bounds

This commit is contained in:
Nadrieril 2023-12-19 18:09:31 +01:00
parent c1fc1d18cd
commit c6aa16c469
6 changed files with 21 additions and 21 deletions

View file

@ -49,7 +49,7 @@ impl<'a, T: ?Sized> Captures<'a> for T {}
/// Context that provides type information about constructors.
///
/// Most of the crate is parameterized on a type that implements this trait.
pub trait TypeCx: Sized + Clone + fmt::Debug {
pub trait TypeCx: Sized + fmt::Debug {
/// The type of a pattern.
type Ty: Copy + Clone + fmt::Debug; // FIXME: remove Copy
/// The index of an enum variant.
@ -86,7 +86,8 @@ pub trait TypeCx: Sized + Clone + fmt::Debug {
}
/// Context that provides information global to a match.
#[derive(Clone)]
#[derive(derivative::Derivative)]
#[derivative(Clone(bound = ""), Copy(bound = ""))]
pub struct MatchCtxt<'a, 'p, Cx: TypeCx> {
/// The context for type information.
pub tycx: &'a Cx,
@ -94,18 +95,16 @@ pub struct MatchCtxt<'a, 'p, Cx: TypeCx> {
pub wildcard_arena: &'a TypedArena<DeconstructedPat<'p, Cx>>,
}
impl<'a, 'p, Cx: TypeCx> Copy for MatchCtxt<'a, 'p, Cx> {}
/// The arm of a match expression.
#[derive(Clone, Debug)]
#[derive(Debug)]
#[derive(derivative::Derivative)]
#[derivative(Clone(bound = ""), Copy(bound = ""))]
pub struct MatchArm<'p, Cx: TypeCx> {
pub pat: &'p DeconstructedPat<'p, Cx>,
pub has_guard: bool,
pub arm_data: Cx::ArmData,
}
impl<'p, Cx: TypeCx> Copy for MatchArm<'p, Cx> {}
/// The entrypoint for this crate. Computes whether a match is exhaustive and which of its arms are
/// useful, and runs some lints.
#[cfg(feature = "rustc")]