Address nits
- Remove the ValuePairs glob import - Make DummyPairs -> ValuePairs::Dummy and make it bug more - Fix WC - Make interner return `impl IntoIterator`s
This commit is contained in:
parent
a2fb2ebc17
commit
c8e42065f0
9 changed files with 85 additions and 78 deletions
|
@ -347,7 +347,7 @@ impl<'tcx> ToTrace<'tcx> for Ty<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +359,10 @@ impl<'tcx> ToTrace<'tcx> for ty::Region<'tcx> {
|
|||
a: Self,
|
||||
b: Self,
|
||||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace { cause: cause.clone(), values: Regions(ExpectedFound::new(a_is_expected, a, b)) }
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: ValuePairs::Regions(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,7 +375,7 @@ impl<'tcx> ToTrace<'tcx> for Const<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -388,13 +391,13 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
|
|||
cause: cause.clone(),
|
||||
values: match (a.unpack(), b.unpack()) {
|
||||
(GenericArgKind::Lifetime(a), GenericArgKind::Lifetime(b)) => {
|
||||
Regions(ExpectedFound::new(a_is_expected, a, b))
|
||||
ValuePairs::Regions(ExpectedFound::new(a_is_expected, a, b))
|
||||
}
|
||||
(GenericArgKind::Type(a), GenericArgKind::Type(b)) => {
|
||||
Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
|
||||
ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
|
||||
}
|
||||
(GenericArgKind::Const(a), GenericArgKind::Const(b)) => {
|
||||
Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
|
||||
ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
|
||||
}
|
||||
|
||||
(
|
||||
|
@ -423,7 +426,10 @@ impl<'tcx> ToTrace<'tcx> for ty::Term<'tcx> {
|
|||
a: Self,
|
||||
b: Self,
|
||||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace { cause: cause.clone(), values: Terms(ExpectedFound::new(a_is_expected, a, b)) }
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,7 +442,7 @@ impl<'tcx> ToTrace<'tcx> for ty::TraitRef<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: TraitRefs(ExpectedFound::new(a_is_expected, a, b)),
|
||||
values: ValuePairs::TraitRefs(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +456,7 @@ impl<'tcx> ToTrace<'tcx> for ty::AliasTy<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: Aliases(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
values: ValuePairs::Aliases(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -462,7 +468,10 @@ impl<'tcx> ToTrace<'tcx> for ty::AliasTerm<'tcx> {
|
|||
a: Self,
|
||||
b: Self,
|
||||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace { cause: cause.clone(), values: Aliases(ExpectedFound::new(a_is_expected, a, b)) }
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: ValuePairs::Aliases(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,7 +484,7 @@ impl<'tcx> ToTrace<'tcx> for ty::FnSig<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: PolySigs(ExpectedFound::new(
|
||||
values: ValuePairs::PolySigs(ExpectedFound::new(
|
||||
a_is_expected,
|
||||
ty::Binder::dummy(a),
|
||||
ty::Binder::dummy(b),
|
||||
|
@ -493,7 +502,7 @@ impl<'tcx> ToTrace<'tcx> for ty::PolyFnSig<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: PolySigs(ExpectedFound::new(a_is_expected, a, b)),
|
||||
values: ValuePairs::PolySigs(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -507,7 +516,7 @@ impl<'tcx> ToTrace<'tcx> for ty::PolyExistentialTraitRef<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: ExistentialTraitRef(ExpectedFound::new(a_is_expected, a, b)),
|
||||
values: ValuePairs::ExistentialTraitRef(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +530,7 @@ impl<'tcx> ToTrace<'tcx> for ty::PolyExistentialProjection<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: ExistentialProjection(ExpectedFound::new(a_is_expected, a, b)),
|
||||
values: ValuePairs::ExistentialProjection(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1707,7 +1707,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
ValuePairs::ExistentialProjection(_) => {
|
||||
(false, Mismatch::Fixed("existential projection"))
|
||||
}
|
||||
infer::DummyPair => (false, Mismatch::Fixed("values")),
|
||||
ValuePairs::Dummy => {
|
||||
bug!("do not expect to report a type error from a ValuePairs::Dummy")
|
||||
}
|
||||
};
|
||||
let Some(vals) = self.values_str(values) else {
|
||||
// Derived error. Cancel the emitter.
|
||||
|
@ -2251,12 +2253,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
values: ValuePairs<'tcx>,
|
||||
) -> Option<(DiagStyledString, DiagStyledString, Option<PathBuf>)> {
|
||||
match values {
|
||||
infer::Regions(exp_found) => self.expected_found_str(exp_found),
|
||||
infer::Terms(exp_found) => self.expected_found_str_term(exp_found),
|
||||
infer::Aliases(exp_found) => self.expected_found_str(exp_found),
|
||||
infer::ExistentialTraitRef(exp_found) => self.expected_found_str(exp_found),
|
||||
infer::ExistentialProjection(exp_found) => self.expected_found_str(exp_found),
|
||||
infer::TraitRefs(exp_found) => {
|
||||
ValuePairs::Regions(exp_found) => self.expected_found_str(exp_found),
|
||||
ValuePairs::Terms(exp_found) => self.expected_found_str_term(exp_found),
|
||||
ValuePairs::Aliases(exp_found) => self.expected_found_str(exp_found),
|
||||
ValuePairs::ExistentialTraitRef(exp_found) => self.expected_found_str(exp_found),
|
||||
ValuePairs::ExistentialProjection(exp_found) => self.expected_found_str(exp_found),
|
||||
ValuePairs::TraitRefs(exp_found) => {
|
||||
let pretty_exp_found = ty::error::ExpectedFound {
|
||||
expected: exp_found.expected.print_trait_sugared(),
|
||||
found: exp_found.found.print_trait_sugared(),
|
||||
|
@ -2268,7 +2270,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
ret => ret,
|
||||
}
|
||||
}
|
||||
infer::PolySigs(exp_found) => {
|
||||
ValuePairs::PolySigs(exp_found) => {
|
||||
let exp_found = self.resolve_vars_if_possible(exp_found);
|
||||
if exp_found.references_error() {
|
||||
return None;
|
||||
|
@ -2276,7 +2278,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
let (exp, fnd) = self.cmp_fn_sig(&exp_found.expected, &exp_found.found);
|
||||
Some((exp, fnd, None))
|
||||
}
|
||||
infer::DummyPair => None,
|
||||
ValuePairs::Dummy => {
|
||||
bug!("do not expect to report a type error from a ValuePairs::Dummy")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ pub use rustc_middle::ty::IntVarValue;
|
|||
pub use BoundRegionConversionTime::*;
|
||||
pub use RegionVariableOrigin::*;
|
||||
pub use SubregionOrigin::*;
|
||||
pub use ValuePairs::*;
|
||||
|
||||
use crate::infer::relate::{Relate, RelateResult};
|
||||
use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligation, TraitEngine};
|
||||
|
@ -484,7 +483,7 @@ pub enum ValuePairs<'tcx> {
|
|||
PolySigs(ExpectedFound<ty::PolyFnSig<'tcx>>),
|
||||
ExistentialTraitRef(ExpectedFound<ty::PolyExistentialTraitRef<'tcx>>),
|
||||
ExistentialProjection(ExpectedFound<ty::PolyExistentialProjection<'tcx>>),
|
||||
DummyPair,
|
||||
Dummy,
|
||||
}
|
||||
|
||||
impl<'tcx> ValuePairs<'tcx> {
|
||||
|
@ -1880,7 +1879,7 @@ impl<'tcx> TypeTrace<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1892,7 +1891,7 @@ impl<'tcx> TypeTrace<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: TraitRefs(ExpectedFound::new(a_is_expected, a, b)),
|
||||
values: ValuePairs::TraitRefs(ExpectedFound::new(a_is_expected, a, b)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1904,12 +1903,12 @@ impl<'tcx> TypeTrace<'tcx> {
|
|||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
}
|
||||
}
|
||||
|
||||
fn dummy(cause: &ObligationCause<'tcx>) -> TypeTrace<'tcx> {
|
||||
TypeTrace { cause: cause.clone(), values: ValuePairs::DummyPair }
|
||||
TypeTrace { cause: cause.clone(), values: ValuePairs::Dummy }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue