mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
remove PredicatePolarity
and BoundConstness
relate impls
Also removes `TypeError::ConstnessMismatch`. It is unused.
This commit is contained in:
parent
196fdf144f
commit
00266eeaa5
@ -35,9 +35,6 @@ impl<'tcx> TypeError<'tcx> {
|
||||
TypeError::CyclicTy(_) => "cyclic type of infinite size".into(),
|
||||
TypeError::CyclicConst(_) => "encountered a self-referencing constant".into(),
|
||||
TypeError::Mismatch => "types differ".into(),
|
||||
TypeError::ConstnessMismatch(values) => {
|
||||
format!("expected {} bound, found {} bound", values.expected, values.found).into()
|
||||
}
|
||||
TypeError::PolarityMismatch(values) => {
|
||||
format!("expected {} polarity, found {} polarity", values.expected, values.found)
|
||||
.into()
|
||||
|
@ -27,8 +27,7 @@ impl<T> ExpectedFound<T> {
|
||||
#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
|
||||
pub enum TypeError<I: Interner> {
|
||||
Mismatch,
|
||||
ConstnessMismatch(ExpectedFound<ty::BoundConstness>),
|
||||
PolarityMismatch(ExpectedFound<ty::PredicatePolarity>),
|
||||
PolarityMismatch(#[type_visitable(ignore)] ExpectedFound<ty::PredicatePolarity>),
|
||||
SafetyMismatch(#[type_visitable(ignore)] ExpectedFound<I::Safety>),
|
||||
AbiMismatch(#[type_visitable(ignore)] ExpectedFound<I::Abi>),
|
||||
Mutability,
|
||||
@ -73,9 +72,9 @@ impl<I: Interner> TypeError<I> {
|
||||
pub fn must_include_note(self) -> bool {
|
||||
use self::TypeError::*;
|
||||
match self {
|
||||
CyclicTy(_) | CyclicConst(_) | SafetyMismatch(_) | ConstnessMismatch(_)
|
||||
| PolarityMismatch(_) | Mismatch | AbiMismatch(_) | FixedArraySize(_)
|
||||
| ArgumentSorts(..) | Sorts(_) | VariadicMismatch(_) | TargetFeatureCast(_) => false,
|
||||
CyclicTy(_) | CyclicConst(_) | SafetyMismatch(_) | PolarityMismatch(_) | Mismatch
|
||||
| AbiMismatch(_) | FixedArraySize(_) | ArgumentSorts(..) | Sorts(_)
|
||||
| VariadicMismatch(_) | TargetFeatureCast(_) => false,
|
||||
|
||||
Mutability
|
||||
| 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> {
|
||||
fn relate<R: TypeRelation<I>>(
|
||||
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> {
|
||||
fn relate<R: TypeRelation<I>>(
|
||||
relation: &mut R,
|
||||
a: ty::TraitPredicate<I>,
|
||||
b: ty::TraitPredicate<I>,
|
||||
) -> RelateResult<I, ty::TraitPredicate<I>> {
|
||||
Ok(ty::TraitPredicate {
|
||||
trait_ref: relation.relate(a.trait_ref, b.trait_ref)?,
|
||||
polarity: relation.relate(a.polarity, b.polarity)?,
|
||||
})
|
||||
let trait_ref = relation.relate(a.trait_ref, b.trait_ref)?;
|
||||
if a.polarity != b.polarity {
|
||||
return Err(TypeError::PolarityMismatch(ExpectedFound::new(
|
||||
true, a.polarity, b.polarity,
|
||||
)));
|
||||
}
|
||||
Ok(ty::TraitPredicate { trait_ref, polarity: a.polarity })
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user