remove PredicatePolarity
and BoundConstness
relate impls
Also removes `TypeError::ConstnessMismatch`. It is unused.
This commit is contained in:
parent
196fdf144f
commit
00266eeaa5
3 changed files with 11 additions and 40 deletions
|
@ -35,9 +35,6 @@ impl<'tcx> TypeError<'tcx> {
|
||||||
TypeError::CyclicTy(_) => "cyclic type of infinite size".into(),
|
TypeError::CyclicTy(_) => "cyclic type of infinite size".into(),
|
||||||
TypeError::CyclicConst(_) => "encountered a self-referencing constant".into(),
|
TypeError::CyclicConst(_) => "encountered a self-referencing constant".into(),
|
||||||
TypeError::Mismatch => "types differ".into(),
|
TypeError::Mismatch => "types differ".into(),
|
||||||
TypeError::ConstnessMismatch(values) => {
|
|
||||||
format!("expected {} bound, found {} bound", values.expected, values.found).into()
|
|
||||||
}
|
|
||||||
TypeError::PolarityMismatch(values) => {
|
TypeError::PolarityMismatch(values) => {
|
||||||
format!("expected {} polarity, found {} polarity", values.expected, values.found)
|
format!("expected {} polarity, found {} polarity", values.expected, values.found)
|
||||||
.into()
|
.into()
|
||||||
|
|
|
@ -27,8 +27,7 @@ impl<T> ExpectedFound<T> {
|
||||||
#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
|
#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
|
||||||
pub enum TypeError<I: Interner> {
|
pub enum TypeError<I: Interner> {
|
||||||
Mismatch,
|
Mismatch,
|
||||||
ConstnessMismatch(ExpectedFound<ty::BoundConstness>),
|
PolarityMismatch(#[type_visitable(ignore)] ExpectedFound<ty::PredicatePolarity>),
|
||||||
PolarityMismatch(ExpectedFound<ty::PredicatePolarity>),
|
|
||||||
SafetyMismatch(#[type_visitable(ignore)] ExpectedFound<I::Safety>),
|
SafetyMismatch(#[type_visitable(ignore)] ExpectedFound<I::Safety>),
|
||||||
AbiMismatch(#[type_visitable(ignore)] ExpectedFound<I::Abi>),
|
AbiMismatch(#[type_visitable(ignore)] ExpectedFound<I::Abi>),
|
||||||
Mutability,
|
Mutability,
|
||||||
|
@ -73,9 +72,9 @@ impl<I: Interner> TypeError<I> {
|
||||||
pub fn must_include_note(self) -> bool {
|
pub fn must_include_note(self) -> bool {
|
||||||
use self::TypeError::*;
|
use self::TypeError::*;
|
||||||
match self {
|
match self {
|
||||||
CyclicTy(_) | CyclicConst(_) | SafetyMismatch(_) | ConstnessMismatch(_)
|
CyclicTy(_) | CyclicConst(_) | SafetyMismatch(_) | PolarityMismatch(_) | Mismatch
|
||||||
| PolarityMismatch(_) | Mismatch | AbiMismatch(_) | FixedArraySize(_)
|
| AbiMismatch(_) | FixedArraySize(_) | ArgumentSorts(..) | Sorts(_)
|
||||||
| ArgumentSorts(..) | Sorts(_) | VariadicMismatch(_) | TargetFeatureCast(_) => false,
|
| VariadicMismatch(_) | TargetFeatureCast(_) => false,
|
||||||
|
|
||||||
Mutability
|
Mutability
|
||||||
| ArgumentMutability(_)
|
| ArgumentMutability(_)
|
||||||
|
|
|
@ -223,20 +223,6 @@ impl<I: Interner> Relate<I> for ty::FnSig<I> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: Interner> Relate<I> for ty::BoundConstness {
|
|
||||||
fn relate<R: TypeRelation<I>>(
|
|
||||||
_relation: &mut R,
|
|
||||||
a: ty::BoundConstness,
|
|
||||||
b: ty::BoundConstness,
|
|
||||||
) -> RelateResult<I, ty::BoundConstness> {
|
|
||||||
if a != b {
|
|
||||||
Err(TypeError::ConstnessMismatch(ExpectedFound::new(true, a, b)))
|
|
||||||
} else {
|
|
||||||
Ok(a)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I: Interner> Relate<I> for ty::AliasTy<I> {
|
impl<I: Interner> Relate<I> for ty::AliasTy<I> {
|
||||||
fn relate<R: TypeRelation<I>>(
|
fn relate<R: TypeRelation<I>>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
|
@ -664,29 +650,18 @@ impl<I: Interner, T: Relate<I>> Relate<I> for ty::Binder<I, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: Interner> Relate<I> for ty::PredicatePolarity {
|
|
||||||
fn relate<R: TypeRelation<I>>(
|
|
||||||
_relation: &mut R,
|
|
||||||
a: ty::PredicatePolarity,
|
|
||||||
b: ty::PredicatePolarity,
|
|
||||||
) -> RelateResult<I, ty::PredicatePolarity> {
|
|
||||||
if a != b {
|
|
||||||
Err(TypeError::PolarityMismatch(ExpectedFound::new(true, a, b)))
|
|
||||||
} else {
|
|
||||||
Ok(a)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I: Interner> Relate<I> for ty::TraitPredicate<I> {
|
impl<I: Interner> Relate<I> for ty::TraitPredicate<I> {
|
||||||
fn relate<R: TypeRelation<I>>(
|
fn relate<R: TypeRelation<I>>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: ty::TraitPredicate<I>,
|
a: ty::TraitPredicate<I>,
|
||||||
b: ty::TraitPredicate<I>,
|
b: ty::TraitPredicate<I>,
|
||||||
) -> RelateResult<I, ty::TraitPredicate<I>> {
|
) -> RelateResult<I, ty::TraitPredicate<I>> {
|
||||||
Ok(ty::TraitPredicate {
|
let trait_ref = relation.relate(a.trait_ref, b.trait_ref)?;
|
||||||
trait_ref: relation.relate(a.trait_ref, b.trait_ref)?,
|
if a.polarity != b.polarity {
|
||||||
polarity: relation.relate(a.polarity, b.polarity)?,
|
return Err(TypeError::PolarityMismatch(ExpectedFound::new(
|
||||||
})
|
true, a.polarity, b.polarity,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
Ok(ty::TraitPredicate { trait_ref, polarity: a.polarity })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue