Auto merge of #132044 - lcnr:no-relate-abi, r=compiler-errors
do not implement `Relate` for "boring" types and update some macros while we're at it. This means we don't have to implement `TypeVisitable` for them. r? `@compiler-errors`
This commit is contained in:
commit
ffd978b7bf
9 changed files with 110 additions and 115 deletions
|
@ -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()
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use std::iter;
|
||||
|
||||
use rustc_hir as hir;
|
||||
use rustc_target::spec::abi;
|
||||
pub use rustc_type_ir::relate::*;
|
||||
|
||||
use crate::ty::error::{ExpectedFound, TypeError};
|
||||
|
@ -121,26 +119,6 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPredicate<
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Relate<TyCtxt<'tcx>> for hir::Safety {
|
||||
fn relate<R: TypeRelation<TyCtxt<'tcx>>>(
|
||||
_relation: &mut R,
|
||||
a: hir::Safety,
|
||||
b: hir::Safety,
|
||||
) -> RelateResult<'tcx, hir::Safety> {
|
||||
if a != b { Err(TypeError::SafetyMismatch(ExpectedFound::new(true, a, b))) } else { Ok(a) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Relate<TyCtxt<'tcx>> for abi::Abi {
|
||||
fn relate<R: TypeRelation<TyCtxt<'tcx>>>(
|
||||
_relation: &mut R,
|
||||
a: abi::Abi,
|
||||
b: abi::Abi,
|
||||
) -> RelateResult<'tcx, abi::Abi> {
|
||||
if a == b { Ok(a) } else { Err(TypeError::AbiMismatch(ExpectedFound::new(true, a, b))) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Relate<TyCtxt<'tcx>> for ty::GenericArgsRef<'tcx> {
|
||||
fn relate<R: TypeRelation<TyCtxt<'tcx>>>(
|
||||
relation: &mut R,
|
||||
|
|
|
@ -264,8 +264,6 @@ TrivialTypeTraversalImpls! {
|
|||
// interners).
|
||||
TrivialTypeTraversalAndLiftImpls! {
|
||||
::rustc_hir::def_id::DefId,
|
||||
::rustc_hir::Safety,
|
||||
::rustc_target::spec::abi::Abi,
|
||||
crate::ty::ClosureKind,
|
||||
crate::ty::ParamConst,
|
||||
crate::ty::ParamTy,
|
||||
|
@ -276,6 +274,11 @@ TrivialTypeTraversalAndLiftImpls! {
|
|||
rustc_target::abi::Size,
|
||||
}
|
||||
|
||||
TrivialLiftImpls! {
|
||||
::rustc_hir::Safety,
|
||||
::rustc_target::spec::abi::Abi,
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Lift implementations
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue