Simplify some redundant names
This commit is contained in:
parent
3799568895
commit
427c55c65c
6 changed files with 19 additions and 23 deletions
|
@ -315,7 +315,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||||
let mut failed = false;
|
let mut failed = false;
|
||||||
|
|
||||||
let elaborated_args = std::iter::zip(*args, &generics.params).map(|(arg, param)| {
|
let elaborated_args = std::iter::zip(*args, &generics.params).map(|(arg, param)| {
|
||||||
if let Some(ty::Dynamic(obj, _, ty::DynKind::Dyn)) = arg.as_type().map(Ty::kind) {
|
if let Some(ty::Dynamic(obj, _, ty::Dyn)) = arg.as_type().map(Ty::kind) {
|
||||||
let default = tcx.object_lifetime_default(param.def_id);
|
let default = tcx.object_lifetime_default(param.def_id);
|
||||||
|
|
||||||
let re_static = tcx.lifetimes.re_static;
|
let re_static = tcx.lifetimes.re_static;
|
||||||
|
@ -339,7 +339,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||||
|
|
||||||
has_dyn = true;
|
has_dyn = true;
|
||||||
|
|
||||||
Ty::new_dynamic(tcx, obj, implied_region, ty::DynKind::Dyn).into()
|
Ty::new_dynamic(tcx, obj, implied_region, ty::Dyn).into()
|
||||||
} else {
|
} else {
|
||||||
arg
|
arg
|
||||||
}
|
}
|
||||||
|
|
|
@ -2348,11 +2348,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
GenericKind::Param(ref p) => format!("the parameter type `{p}`"),
|
GenericKind::Param(ref p) => format!("the parameter type `{p}`"),
|
||||||
GenericKind::Placeholder(ref p) => format!("the placeholder type `{p:?}`"),
|
GenericKind::Placeholder(ref p) => format!("the placeholder type `{p:?}`"),
|
||||||
GenericKind::Alias(ref p) => match p.kind(self.tcx) {
|
GenericKind::Alias(ref p) => match p.kind(self.tcx) {
|
||||||
ty::AliasKind::Projection | ty::AliasKind::Inherent => {
|
ty::Projection | ty::Inherent => {
|
||||||
format!("the associated type `{p}`")
|
format!("the associated type `{p}`")
|
||||||
}
|
}
|
||||||
ty::AliasKind::Weak => format!("the type alias `{p}`"),
|
ty::Weak => format!("the type alias `{p}`"),
|
||||||
ty::AliasKind::Opaque => format!("the opaque type `{p}`"),
|
ty::Opaque => format!("the opaque type `{p}`"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -511,7 +511,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
match a_ty.kind() {
|
match a_ty.kind() {
|
||||||
&ty::Alias(ty::AliasKind::Projection, data) => {
|
&ty::Alias(ty::Projection, data) => {
|
||||||
// FIXME: This does not handle subtyping correctly, we could
|
// FIXME: This does not handle subtyping correctly, we could
|
||||||
// instead create a new inference variable for `a_ty`, emitting
|
// instead create a new inference variable for `a_ty`, emitting
|
||||||
// `Projection(a_ty, a_infer)` and `a_infer <: b_ty`.
|
// `Projection(a_ty, a_infer)` and `a_infer <: b_ty`.
|
||||||
|
@ -523,10 +523,9 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
// The old solver only accepts projection predicates for associated types.
|
// The old solver only accepts projection predicates for associated types.
|
||||||
ty::Alias(
|
ty::Alias(ty::Inherent | ty::Weak | ty::Opaque, _) => {
|
||||||
ty::AliasKind::Inherent | ty::AliasKind::Weak | ty::AliasKind::Opaque,
|
return Err(TypeError::CyclicTy(a_ty));
|
||||||
_,
|
}
|
||||||
) => return Err(TypeError::CyclicTy(a_ty)),
|
|
||||||
_ => bug!("generalizated `{a_ty:?} to infer, not an alias"),
|
_ => bug!("generalizated `{a_ty:?} to infer, not an alias"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ use rustc_span::{Span, Symbol};
|
||||||
use rustc_target::abi::{Abi, Size, WrappingRange};
|
use rustc_target::abi::{Abi, Size, WrappingRange};
|
||||||
use rustc_target::abi::{Integer, TagEncoding, Variants};
|
use rustc_target::abi::{Integer, TagEncoding, Variants};
|
||||||
use rustc_target::spec::abi::Abi as SpecAbi;
|
use rustc_target::spec::abi::Abi as SpecAbi;
|
||||||
use rustc_type_ir::DynKind;
|
|
||||||
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
@ -675,7 +674,7 @@ fn lint_wide_pointer<'tcx>(
|
||||||
}
|
}
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::RawPtr(TypeAndMut { mutbl: _, ty }) => (!ty.is_sized(cx.tcx, cx.param_env))
|
ty::RawPtr(TypeAndMut { mutbl: _, ty }) => (!ty.is_sized(cx.tcx, cx.param_env))
|
||||||
.then(|| (refs, matches!(ty.kind(), ty::Dynamic(_, _, DynKind::Dyn)))),
|
.then(|| (refs, matches!(ty.kind(), ty::Dynamic(_, _, ty::Dyn)))),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1225,7 +1225,7 @@ impl<'tcx> AliasTy<'tcx> {
|
||||||
|
|
||||||
/// Whether this alias type is an opaque.
|
/// Whether this alias type is an opaque.
|
||||||
pub fn is_opaque(self, tcx: TyCtxt<'tcx>) -> bool {
|
pub fn is_opaque(self, tcx: TyCtxt<'tcx>) -> bool {
|
||||||
matches!(self.opt_kind(tcx), Some(ty::AliasKind::Opaque))
|
matches!(self.opt_kind(tcx), Some(ty::Opaque))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FIXME: rename `AliasTy` to `AliasTerm` and always handle
|
/// FIXME: rename `AliasTy` to `AliasTerm` and always handle
|
||||||
|
@ -2745,7 +2745,7 @@ impl<'tcx> Ty<'tcx> {
|
||||||
// Extern types have metadata = ().
|
// Extern types have metadata = ().
|
||||||
| ty::Foreign(..)
|
| ty::Foreign(..)
|
||||||
// `dyn*` has no metadata
|
// `dyn*` has no metadata
|
||||||
| ty::Dynamic(_, _, DynKind::DynStar)
|
| ty::Dynamic(_, _, ty::DynStar)
|
||||||
// If returned by `struct_tail_without_normalization` this is a unit struct
|
// If returned by `struct_tail_without_normalization` this is a unit struct
|
||||||
// without any fields, or not a struct, and therefore is Sized.
|
// without any fields, or not a struct, and therefore is Sized.
|
||||||
| ty::Adt(..)
|
| ty::Adt(..)
|
||||||
|
@ -2754,7 +2754,7 @@ impl<'tcx> Ty<'tcx> {
|
||||||
| ty::Tuple(..) => (tcx.types.unit, false),
|
| ty::Tuple(..) => (tcx.types.unit, false),
|
||||||
|
|
||||||
ty::Str | ty::Slice(_) => (tcx.types.usize, false),
|
ty::Str | ty::Slice(_) => (tcx.types.usize, false),
|
||||||
ty::Dynamic(_, _, DynKind::Dyn) => {
|
ty::Dynamic(_, _, ty::Dyn) => {
|
||||||
let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, None);
|
let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, None);
|
||||||
(tcx.type_of(dyn_metadata).instantiate(tcx, &[tail.into()]), false)
|
(tcx.type_of(dyn_metadata).instantiate(tcx, &[tail.into()]), false)
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,12 +12,11 @@ use crate::rustc_smir::{alloc, Stable, Tables};
|
||||||
impl<'tcx> Stable<'tcx> for ty::AliasKind {
|
impl<'tcx> Stable<'tcx> for ty::AliasKind {
|
||||||
type T = stable_mir::ty::AliasKind;
|
type T = stable_mir::ty::AliasKind;
|
||||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
||||||
use rustc_middle::ty::AliasKind::*;
|
|
||||||
match self {
|
match self {
|
||||||
Projection => stable_mir::ty::AliasKind::Projection,
|
ty::Projection => stable_mir::ty::AliasKind::Projection,
|
||||||
Inherent => stable_mir::ty::AliasKind::Inherent,
|
ty::Inherent => stable_mir::ty::AliasKind::Inherent,
|
||||||
Opaque => stable_mir::ty::AliasKind::Opaque,
|
ty::Opaque => stable_mir::ty::AliasKind::Opaque,
|
||||||
Weak => stable_mir::ty::AliasKind::Weak,
|
ty::Weak => stable_mir::ty::AliasKind::Weak,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,10 +33,9 @@ impl<'tcx> Stable<'tcx> for ty::DynKind {
|
||||||
type T = stable_mir::ty::DynKind;
|
type T = stable_mir::ty::DynKind;
|
||||||
|
|
||||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
||||||
use rustc_middle::ty::DynKind;
|
|
||||||
match self {
|
match self {
|
||||||
DynKind::Dyn => stable_mir::ty::DynKind::Dyn,
|
ty::Dyn => stable_mir::ty::DynKind::Dyn,
|
||||||
DynKind::DynStar => stable_mir::ty::DynKind::DynStar,
|
ty::DynStar => stable_mir::ty::DynKind::DynStar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue