Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 00266ee

Browse files
committed
remove PredicatePolarity and BoundConstness relate impls
Also removes `TypeError::ConstnessMismatch`. It is unused.
1 parent 196fdf1 commit 00266ee

File tree

3 files changed

+11
-40
lines changed

3 files changed

+11
-40
lines changed

‎compiler/rustc_middle/src/ty/error.rs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ impl<'tcx> TypeError<'tcx> {
3535
TypeError::CyclicTy(_) => "cyclic type of infinite size".into(),
3636
TypeError::CyclicConst(_) => "encountered a self-referencing constant".into(),
3737
TypeError::Mismatch => "types differ".into(),
38-
TypeError::ConstnessMismatch(values) => {
39-
format!("expected {} bound, found {} bound", values.expected, values.found).into()
40-
}
4138
TypeError::PolarityMismatch(values) => {
4239
format!("expected {} polarity, found {} polarity", values.expected, values.found)
4340
.into()

‎compiler/rustc_type_ir/src/error.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ impl<T> ExpectedFound<T> {
2727
#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
2828
pub enum TypeError<I: Interner> {
2929
Mismatch,
30-
ConstnessMismatch(ExpectedFound<ty::BoundConstness>),
31-
PolarityMismatch(ExpectedFound<ty::PredicatePolarity>),
30+
PolarityMismatch(#[type_visitable(ignore)] ExpectedFound<ty::PredicatePolarity>),
3231
SafetyMismatch(#[type_visitable(ignore)] ExpectedFound<I::Safety>),
3332
AbiMismatch(#[type_visitable(ignore)] ExpectedFound<I::Abi>),
3433
Mutability,
@@ -73,9 +72,9 @@ impl<I: Interner> TypeError<I> {
7372
pub fn must_include_note(self) -> bool {
7473
use self::TypeError::*;
7574
match self {
76-
CyclicTy(_) | CyclicConst(_) | SafetyMismatch(_) | ConstnessMismatch(_)
77-
| PolarityMismatch(_) | Mismatch | AbiMismatch(_) | FixedArraySize(_)
78-
| ArgumentSorts(..) | Sorts(_) | VariadicMismatch(_) | TargetFeatureCast(_) => false,
75+
CyclicTy(_) | CyclicConst(_) | SafetyMismatch(_) | PolarityMismatch(_) | Mismatch
76+
| AbiMismatch(_) | FixedArraySize(_) | ArgumentSorts(..) | Sorts(_)
77+
| VariadicMismatch(_) | TargetFeatureCast(_) => false,
7978

8079
Mutability
8180
| ArgumentMutability(_)

‎compiler/rustc_type_ir/src/relate.rs‎

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,6 @@ impl<I: Interner> Relate<I> for ty::FnSig<I> {
223223
}
224224
}
225225

226-
impl<I: Interner> Relate<I> for ty::BoundConstness {
227-
fn relate<R: TypeRelation<I>>(
228-
_relation: &mut R,
229-
a: ty::BoundConstness,
230-
b: ty::BoundConstness,
231-
) -> RelateResult<I, ty::BoundConstness> {
232-
if a != b {
233-
Err(TypeError::ConstnessMismatch(ExpectedFound::new(true, a, b)))
234-
} else {
235-
Ok(a)
236-
}
237-
}
238-
}
239-
240226
impl<I: Interner> Relate<I> for ty::AliasTy<I> {
241227
fn relate<R: TypeRelation<I>>(
242228
relation: &mut R,
@@ -664,29 +650,18 @@ impl<I: Interner, T: Relate<I>> Relate<I> for ty::Binder<I, T> {
664650
}
665651
}
666652

667-
impl<I: Interner> Relate<I> for ty::PredicatePolarity {
668-
fn relate<R: TypeRelation<I>>(
669-
_relation: &mut R,
670-
a: ty::PredicatePolarity,
671-
b: ty::PredicatePolarity,
672-
) -> RelateResult<I, ty::PredicatePolarity> {
673-
if a != b {
674-
Err(TypeError::PolarityMismatch(ExpectedFound::new(true, a, b)))
675-
} else {
676-
Ok(a)
677-
}
678-
}
679-
}
680-
681653
impl<I: Interner> Relate<I> for ty::TraitPredicate<I> {
682654
fn relate<R: TypeRelation<I>>(
683655
relation: &mut R,
684656
a: ty::TraitPredicate<I>,
685657
b: ty::TraitPredicate<I>,
686658
) -> RelateResult<I, ty::TraitPredicate<I>> {
687-
Ok(ty::TraitPredicate {
688-
trait_ref: relation.relate(a.trait_ref, b.trait_ref)?,
689-
polarity: relation.relate(a.polarity, b.polarity)?,
690-
})
659+
let trait_ref = relation.relate(a.trait_ref, b.trait_ref)?;
660+
if a.polarity != b.polarity {
661+
return Err(TypeError::PolarityMismatch(ExpectedFound::new(
662+
true, a.polarity, b.polarity,
663+
)));
664+
}
665+
Ok(ty::TraitPredicate { trait_ref, polarity: a.polarity })
691666
}
692667
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /