Stop using derivative in rustc_pattern_analysis
This commit is contained in:
@@ -218,8 +218,6 @@ impl<'p, Cx: TypeCx> fmt::Debug for DeconstructedPat<'p, Cx> {
|
||||
/// algorithm. Do not use `Wild` to represent a wildcard pattern comping from user input.
|
||||
///
|
||||
/// This is morally `Option<&'p DeconstructedPat>` where `None` is interpreted as a wildcard.
|
||||
#[derive(derivative::Derivative)]
|
||||
#[derivative(Clone(bound = ""), Copy(bound = ""))]
|
||||
pub(crate) enum PatOrWild<'p, Cx: TypeCx> {
|
||||
/// A non-user-provided wildcard, created during specialization.
|
||||
Wild,
|
||||
@@ -227,6 +225,17 @@ pub(crate) enum PatOrWild<'p, Cx: TypeCx> {
|
||||
Pat(&'p DeconstructedPat<'p, Cx>),
|
||||
}
|
||||
|
||||
impl<'p, Cx: TypeCx> Clone for PatOrWild<'p, Cx> {
|
||||
fn clone(&self) -> Self {
|
||||
match self {
|
||||
PatOrWild::Wild => PatOrWild::Wild,
|
||||
PatOrWild::Pat(pat) => PatOrWild::Pat(pat),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, Cx: TypeCx> Copy for PatOrWild<'p, Cx> {}
|
||||
|
||||
impl<'p, Cx: TypeCx> PatOrWild<'p, Cx> {
|
||||
pub(crate) fn as_pat(&self) -> Option<&'p DeconstructedPat<'p, Cx>> {
|
||||
match self {
|
||||
@@ -289,14 +298,28 @@ impl<'p, Cx: TypeCx> fmt::Debug for PatOrWild<'p, Cx> {
|
||||
|
||||
/// Same idea as `DeconstructedPat`, except this is a fictitious pattern built up for diagnostics
|
||||
/// purposes. As such they don't use interning and can be cloned.
|
||||
#[derive(derivative::Derivative)]
|
||||
#[derivative(Debug(bound = ""), Clone(bound = ""))]
|
||||
pub struct WitnessPat<Cx: TypeCx> {
|
||||
ctor: Constructor<Cx>,
|
||||
pub(crate) fields: Vec<WitnessPat<Cx>>,
|
||||
ty: Cx::Ty,
|
||||
}
|
||||
|
||||
impl<Cx: TypeCx> Clone for WitnessPat<Cx> {
|
||||
fn clone(&self) -> Self {
|
||||
Self { ctor: self.ctor.clone(), fields: self.fields.clone(), ty: self.ty.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<Cx: TypeCx> fmt::Debug for WitnessPat<Cx> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("WitnessPat")
|
||||
.field("ctor", &self.ctor)
|
||||
.field("fields", &self.fields)
|
||||
.field("ty", &self.ty)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Cx: TypeCx> WitnessPat<Cx> {
|
||||
pub(crate) fn new(ctor: Constructor<Cx>, fields: Vec<Self>, ty: Cx::Ty) -> Self {
|
||||
Self { ctor, fields, ty }
|
||||
|
||||
Reference in New Issue
Block a user