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 d677a2d

Browse files
Further simplifications
1 parent 560c6cc commit d677a2d

File tree

3 files changed

+5
-36
lines changed

3 files changed

+5
-36
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<T> ExpectedFound<T> {
3232
pub enum TypeError<'tcx> {
3333
Mismatch,
3434
ConstnessMismatch(ExpectedFound<ty::BoundConstness>),
35-
PolarityMismatch(ExpectedFound<ty::ImplPolarity>),
35+
PolarityMismatch(ExpectedFound<ty::PredicatePolarity>),
3636
UnsafetyMismatch(ExpectedFound<hir::Unsafety>),
3737
AbiMismatch(ExpectedFound<abi::Abi>),
3838
Mutability,

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,6 @@ pub enum ImplPolarity {
280280
Reservation,
281281
}
282282

283-
impl ImplPolarity {
284-
/// Flips polarity by turning `Positive` into `Negative` and `Negative` into `Positive`.
285-
pub fn flip(&self) -> Option<ImplPolarity> {
286-
match self {
287-
ImplPolarity::Positive => Some(ImplPolarity::Negative),
288-
ImplPolarity::Negative => Some(ImplPolarity::Positive),
289-
ImplPolarity::Reservation => None,
290-
}
291-
}
292-
}
293-
294283
impl fmt::Display for ImplPolarity {
295284
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
296285
match self {
@@ -301,15 +290,9 @@ impl fmt::Display for ImplPolarity {
301290
}
302291
}
303292

304-
impl From<PredicatePolarity> for ImplPolarity {
305-
fn from(value: PredicatePolarity) -> Self {
306-
match value {
307-
PredicatePolarity::Positive => ImplPolarity::Positive,
308-
PredicatePolarity::Negative => ImplPolarity::Negative,
309-
}
310-
}
311-
}
312-
293+
/// Polarity for a trait predicate. May either be negative or positive.
294+
/// Distinguished from [`ImplPolarity`] since we never compute goals with
295+
/// "reservation" level.
313296
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable, Debug)]
314297
#[derive(TypeFoldable, TypeVisitable)]
315298
pub enum PredicatePolarity {

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -769,27 +769,13 @@ impl<'tcx> Relate<'tcx> for GenericArg<'tcx> {
769769
}
770770
}
771771

772-
impl<'tcx> Relate<'tcx> for ty::ImplPolarity {
773-
fn relate<R: TypeRelation<'tcx>>(
774-
_relation: &mut R,
775-
a: ty::ImplPolarity,
776-
b: ty::ImplPolarity,
777-
) -> RelateResult<'tcx, ty::ImplPolarity> {
778-
if a != b { Err(TypeError::PolarityMismatch(expected_found(a, b))) } else { Ok(a) }
779-
}
780-
}
781-
782772
impl<'tcx> Relate<'tcx> for ty::PredicatePolarity {
783773
fn relate<R: TypeRelation<'tcx>>(
784774
_relation: &mut R,
785775
a: ty::PredicatePolarity,
786776
b: ty::PredicatePolarity,
787777
) -> RelateResult<'tcx, ty::PredicatePolarity> {
788-
if a != b {
789-
Err(TypeError::PolarityMismatch(expected_found(a.into(), b.into())))
790-
} else {
791-
Ok(a)
792-
}
778+
if a != b { Err(TypeError::PolarityMismatch(expected_found(a, b))) } else { Ok(a) }
793779
}
794780
}
795781

0 commit comments

Comments
(0)

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