rustc: remove fmt::{Debug,Display} from ty::TyKind.
This commit is contained in:
parent
0b3ab4018b
commit
01fa283d6f
22 changed files with 73 additions and 71 deletions
|
@ -786,7 +786,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
// FnMut | copied -> &'env mut | upvar -> &'env mut -> &'up bk
|
// FnMut | copied -> &'env mut | upvar -> &'env mut -> &'up bk
|
||||||
// FnOnce | copied | upvar -> &'up bk
|
// FnOnce | copied | upvar -> &'up bk
|
||||||
|
|
||||||
let kind = match self.node_ty(fn_hir_id)?.sty {
|
let ty = self.node_ty(fn_hir_id)?;
|
||||||
|
let kind = match ty.sty {
|
||||||
ty::Generator(..) => ty::ClosureKind::FnOnce,
|
ty::Generator(..) => ty::ClosureKind::FnOnce,
|
||||||
ty::Closure(closure_def_id, closure_substs) => {
|
ty::Closure(closure_def_id, closure_substs) => {
|
||||||
match self.infcx {
|
match self.infcx {
|
||||||
|
@ -803,7 +804,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
.closure_kind(closure_def_id, self.tcx.global_tcx()),
|
.closure_kind(closure_def_id, self.tcx.global_tcx()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref t => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", t),
|
_ => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", ty),
|
||||||
};
|
};
|
||||||
|
|
||||||
let closure_expr_def_id = self.tcx.hir().local_def_id(fn_node_id);
|
let closure_expr_def_id = self.tcx.hir().local_def_id(fn_node_id);
|
||||||
|
@ -1064,7 +1065,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
let bk = ty::BorrowKind::from_mutbl(mutbl);
|
let bk = ty::BorrowKind::from_mutbl(mutbl);
|
||||||
BorrowedPtr(bk, r)
|
BorrowedPtr(bk, r)
|
||||||
}
|
}
|
||||||
ref ty => bug!("unexpected type in cat_deref: {:?}", ty)
|
_ => bug!("unexpected type in cat_deref: {:?}", base_cmt.ty)
|
||||||
};
|
};
|
||||||
let ret = cmt_ {
|
let ret = cmt_ {
|
||||||
hir_id: node.hir_id(),
|
hir_id: node.hir_id(),
|
||||||
|
@ -1279,11 +1280,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
self.tcx.adt_def(enum_def).variant_with_id(def_id).fields.len())
|
self.tcx.adt_def(enum_def).variant_with_id(def_id).fields.len())
|
||||||
}
|
}
|
||||||
Def::StructCtor(_, CtorKind::Fn) | Def::SelfCtor(..) => {
|
Def::StructCtor(_, CtorKind::Fn) | Def::SelfCtor(..) => {
|
||||||
match self.pat_ty_unadjusted(&pat)?.sty {
|
let ty = self.pat_ty_unadjusted(&pat)?;
|
||||||
|
match ty.sty {
|
||||||
ty::Adt(adt_def, _) => {
|
ty::Adt(adt_def, _) => {
|
||||||
(cmt, adt_def.non_enum_variant().fields.len())
|
(cmt, adt_def.non_enum_variant().fields.len())
|
||||||
}
|
}
|
||||||
ref ty => {
|
_ => {
|
||||||
span_bug!(pat.span,
|
span_bug!(pat.span,
|
||||||
"tuple struct pattern unexpected type {:?}", ty);
|
"tuple struct pattern unexpected type {:?}", ty);
|
||||||
}
|
}
|
||||||
|
@ -1334,9 +1336,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
PatKind::Tuple(ref subpats, ddpos) => {
|
PatKind::Tuple(ref subpats, ddpos) => {
|
||||||
// (p1, ..., pN)
|
// (p1, ..., pN)
|
||||||
let expected_len = match self.pat_ty_unadjusted(&pat)?.sty {
|
let ty = self.pat_ty_unadjusted(&pat)?;
|
||||||
|
let expected_len = match ty.sty {
|
||||||
ty::Tuple(ref tys) => tys.len(),
|
ty::Tuple(ref tys) => tys.len(),
|
||||||
ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
|
_ => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
|
||||||
};
|
};
|
||||||
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {
|
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {
|
||||||
let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2)
|
let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2)
|
||||||
|
|
|
@ -854,10 +854,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
_ => vec![ArgKind::empty()],
|
_ => vec![ArgKind::empty()],
|
||||||
};
|
};
|
||||||
|
|
||||||
let expected = match expected_trait_ref.skip_binder().substs.type_at(1).sty {
|
let expected_ty = expected_trait_ref.skip_binder().substs.type_at(1);
|
||||||
|
let expected = match expected_ty.sty {
|
||||||
ty::Tuple(ref tys) => tys.iter()
|
ty::Tuple(ref tys) => tys.iter()
|
||||||
.map(|t| ArgKind::from_expected_ty(t, Some(span))).collect(),
|
.map(|t| ArgKind::from_expected_ty(t, Some(span))).collect(),
|
||||||
ref sty => vec![ArgKind::Arg("_".to_owned(), sty.to_string())],
|
_ => vec![ArgKind::Arg("_".to_owned(), expected_ty.to_string())],
|
||||||
};
|
};
|
||||||
|
|
||||||
if found.len() == expected.len() {
|
if found.len() == expected.len() {
|
||||||
|
@ -1686,10 +1687,10 @@ impl ArgKind {
|
||||||
ty::Tuple(ref tys) => ArgKind::Tuple(
|
ty::Tuple(ref tys) => ArgKind::Tuple(
|
||||||
span,
|
span,
|
||||||
tys.iter()
|
tys.iter()
|
||||||
.map(|ty| ("_".to_owned(), ty.sty.to_string()))
|
.map(|ty| ("_".to_owned(), ty.to_string()))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
),
|
),
|
||||||
_ => ArgKind::Arg("_".to_owned(), t.sty.to_string()),
|
_ => ArgKind::Arg("_".to_owned(), t.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,10 +351,8 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
||||||
where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
||||||
{
|
{
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
let a_sty = &a.sty;
|
debug!("super_relate_tys: a={:?} b={:?}", a, b);
|
||||||
let b_sty = &b.sty;
|
match (&a.sty, &b.sty) {
|
||||||
debug!("super_relate_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty);
|
|
||||||
match (a_sty, b_sty) {
|
|
||||||
(&ty::Infer(_), _) |
|
(&ty::Infer(_), _) |
|
||||||
(_, &ty::Infer(_)) =>
|
(_, &ty::Infer(_)) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl BoundRegion {
|
||||||
|
|
||||||
/// N.B., if you change this, you'll probably want to change the corresponding
|
/// N.B., if you change this, you'll probably want to change the corresponding
|
||||||
/// AST structure in `libsyntax/ast.rs` as well.
|
/// AST structure in `libsyntax/ast.rs` as well.
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug,
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
|
||||||
RustcEncodable, RustcDecodable, HashStable)]
|
RustcEncodable, RustcDecodable, HashStable)]
|
||||||
pub enum TyKind<'tcx> {
|
pub enum TyKind<'tcx> {
|
||||||
/// The primitive boolean type. Written as `bool`.
|
/// The primitive boolean type. Written as `bool`.
|
||||||
|
@ -383,9 +383,10 @@ impl<'tcx> ClosureSubsts<'tcx> {
|
||||||
///
|
///
|
||||||
/// If you have an inference context, use `infcx.closure_sig()`.
|
/// If you have an inference context, use `infcx.closure_sig()`.
|
||||||
pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
|
pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
|
||||||
match self.closure_sig_ty(def_id, tcx).sty {
|
let ty = self.closure_sig_ty(def_id, tcx);
|
||||||
|
match ty.sty {
|
||||||
ty::FnPtr(sig) => sig,
|
ty::FnPtr(sig) => sig,
|
||||||
ref t => bug!("closure_sig_ty is not a fn-ptr: {:?}", t),
|
_ => bug!("closure_sig_ty is not a fn-ptr: {:?}", ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1124,9 +1124,9 @@ define_print! {
|
||||||
}
|
}
|
||||||
|
|
||||||
define_print! {
|
define_print! {
|
||||||
('tcx) ty::TyKind<'tcx>, (self, f, cx) {
|
('tcx) ty::TyS<'tcx>, (self, f, cx) {
|
||||||
display {
|
display {
|
||||||
match *self {
|
match self.sty {
|
||||||
Bool => write!(f, "bool"),
|
Bool => write!(f, "bool"),
|
||||||
Char => write!(f, "char"),
|
Char => write!(f, "char"),
|
||||||
Int(t) => write!(f, "{}", t.ty_to_string()),
|
Int(t) => write!(f, "{}", t.ty_to_string()),
|
||||||
|
@ -1376,16 +1376,8 @@ define_print! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_print! {
|
|
||||||
('tcx) ty::TyS<'tcx>, (self, f, cx) {
|
|
||||||
display {
|
|
||||||
self.sty.print(f, cx)
|
|
||||||
}
|
|
||||||
debug {
|
debug {
|
||||||
self.sty.print_display(f, cx)
|
self.print_display(f, cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,8 +513,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
|
|
||||||
},
|
},
|
||||||
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => {
|
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => {
|
||||||
let sty = &arg_tys[0].sty;
|
match float_type_width(arg_tys[0]) {
|
||||||
match float_type_width(sty) {
|
|
||||||
Some(_width) =>
|
Some(_width) =>
|
||||||
match name {
|
match name {
|
||||||
"fadd_fast" => self.fadd_fast(args[0].immediate(), args[1].immediate()),
|
"fadd_fast" => self.fadd_fast(args[0].immediate(), args[1].immediate()),
|
||||||
|
@ -528,7 +527,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
span_invalid_monomorphization_error(
|
span_invalid_monomorphization_error(
|
||||||
tcx.sess, span,
|
tcx.sess, span,
|
||||||
&format!("invalid monomorphization of `{}` intrinsic: \
|
&format!("invalid monomorphization of `{}` intrinsic: \
|
||||||
expected basic float type, found `{}`", name, sty));
|
expected basic float type, found `{}`", name, arg_tys[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1473,8 +1472,8 @@ fn generic_simd_intrinsic(
|
||||||
require!(false, "expected element type `{}` of second argument `{}` \
|
require!(false, "expected element type `{}` of second argument `{}` \
|
||||||
to be a pointer to the element type `{}` of the first \
|
to be a pointer to the element type `{}` of the first \
|
||||||
argument `{}`, found `{}` != `*_ {}`",
|
argument `{}`, found `{}` != `*_ {}`",
|
||||||
arg_tys[1].simd_type(tcx).sty, arg_tys[1], in_elem, in_ty,
|
arg_tys[1].simd_type(tcx), arg_tys[1], in_elem, in_ty,
|
||||||
arg_tys[1].simd_type(tcx).sty, in_elem);
|
arg_tys[1].simd_type(tcx), in_elem);
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1488,7 +1487,7 @@ fn generic_simd_intrinsic(
|
||||||
_ => {
|
_ => {
|
||||||
require!(false, "expected element type `{}` of third argument `{}` \
|
require!(false, "expected element type `{}` of third argument `{}` \
|
||||||
to be a signed integer type",
|
to be a signed integer type",
|
||||||
arg_tys[2].simd_type(tcx).sty, arg_tys[2]);
|
arg_tys[2].simd_type(tcx), arg_tys[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1573,8 +1572,8 @@ fn generic_simd_intrinsic(
|
||||||
require!(false, "expected element type `{}` of second argument `{}` \
|
require!(false, "expected element type `{}` of second argument `{}` \
|
||||||
to be a pointer to the element type `{}` of the first \
|
to be a pointer to the element type `{}` of the first \
|
||||||
argument `{}`, found `{}` != `*mut {}`",
|
argument `{}`, found `{}` != `*mut {}`",
|
||||||
arg_tys[1].simd_type(tcx).sty, arg_tys[1], in_elem, in_ty,
|
arg_tys[1].simd_type(tcx), arg_tys[1], in_elem, in_ty,
|
||||||
arg_tys[1].simd_type(tcx).sty, in_elem);
|
arg_tys[1].simd_type(tcx), in_elem);
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1588,7 +1587,7 @@ fn generic_simd_intrinsic(
|
||||||
_ => {
|
_ => {
|
||||||
require!(false, "expected element type `{}` of third argument `{}` \
|
require!(false, "expected element type `{}` of third argument `{}` \
|
||||||
to be a signed integer type",
|
to be a signed integer type",
|
||||||
arg_tys[2].simd_type(tcx).sty, arg_tys[2]);
|
arg_tys[2].simd_type(tcx), arg_tys[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1954,10 +1953,10 @@ fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, boo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the width of a float TypeVariant
|
// Returns the width of a float Ty
|
||||||
// Returns None if the type is not a float
|
// Returns None if the type is not a float
|
||||||
fn float_type_width<'tcx>(sty: &ty::TyKind<'tcx>) -> Option<u64> {
|
fn float_type_width(ty: Ty) -> Option<u64> {
|
||||||
match *sty {
|
match ty.sty {
|
||||||
ty::Float(t) => Some(t.bit_width() as u64),
|
ty::Float(t) => Some(t.bit_width() as u64),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let field_ty = c.ty.builtin_index().unwrap();
|
let field_ty = c.ty.builtin_index().unwrap();
|
||||||
let fields = match c.ty.sty {
|
let fields = match c.ty.sty {
|
||||||
ty::Array(_, n) => n.unwrap_usize(bx.tcx()),
|
ty::Array(_, n) => n.unwrap_usize(bx.tcx()),
|
||||||
ref other => bug!("invalid simd shuffle type: {}", other),
|
_ => bug!("invalid simd shuffle type: {}", c.ty),
|
||||||
};
|
};
|
||||||
let values: Vec<_> = (0..fields).map(|field| {
|
let values: Vec<_> = (0..fields).map(|field| {
|
||||||
let field = const_field(
|
let field = const_field(
|
||||||
|
|
|
@ -148,7 +148,7 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
|
||||||
match tail.sty {
|
match tail.sty {
|
||||||
ty::Foreign(..) => false,
|
ty::Foreign(..) => false,
|
||||||
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
|
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
|
||||||
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
|
_ => bug!("unexpected unsized tail: {:?}", tail),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1799,7 +1799,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
||||||
// (https://github.com/rust-lang/rfcs/pull/1546)
|
// (https://github.com/rust-lang/rfcs/pull/1546)
|
||||||
bug!(
|
bug!(
|
||||||
"End-user description not implemented for field access on `{:?}`",
|
"End-user description not implemented for field access on `{:?}`",
|
||||||
ty.sty
|
ty
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -955,7 +955,8 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
let user_provided_types = cx.tables.user_provided_types();
|
let user_provided_types = cx.tables.user_provided_types();
|
||||||
let user_provided_type = user_provided_types.get(expr.hir_id).map(|u_ty| *u_ty);
|
let user_provided_type = user_provided_types.get(expr.hir_id).map(|u_ty| *u_ty);
|
||||||
debug!("convert_path_expr: user_provided_type={:?}", user_provided_type);
|
debug!("convert_path_expr: user_provided_type={:?}", user_provided_type);
|
||||||
match cx.tables().node_type(expr.hir_id).sty {
|
let ty = cx.tables().node_type(expr.hir_id);
|
||||||
|
match ty.sty {
|
||||||
// A unit struct/variant which is used as a value.
|
// A unit struct/variant which is used as a value.
|
||||||
// We return a completely different ExprKind here to account for this special case.
|
// We return a completely different ExprKind here to account for this special case.
|
||||||
ty::Adt(adt_def, substs) => {
|
ty::Adt(adt_def, substs) => {
|
||||||
|
@ -968,7 +969,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
base: None,
|
base: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref sty => bug!("unexpected sty: {:?}", sty),
|
_ => bug!("unexpected ty: {:?}", ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -529,11 +529,11 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||||
ty::Error => { // Avoid ICE
|
ty::Error => { // Avoid ICE
|
||||||
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
||||||
}
|
}
|
||||||
ref sty =>
|
_ =>
|
||||||
span_bug!(
|
span_bug!(
|
||||||
pat.span,
|
pat.span,
|
||||||
"unexpanded type for vector pattern: {:?}",
|
"unexpanded type for vector pattern: {:?}",
|
||||||
sty),
|
ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||||
ty::Error => { // Avoid ICE (#50577)
|
ty::Error => { // Avoid ICE (#50577)
|
||||||
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
||||||
}
|
}
|
||||||
ref sty => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", sty),
|
_ => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
_ => span_bug!(pat.span,
|
_ => span_bug!(pat.span,
|
||||||
"tuple struct pattern not applied to an ADT {:?}",
|
"tuple struct pattern not applied to an ADT {:?}",
|
||||||
ty.sty),
|
ty),
|
||||||
};
|
};
|
||||||
let variant_def = adt_def.variant_of_def(def);
|
let variant_def = adt_def.variant_of_def(def);
|
||||||
|
|
||||||
|
@ -744,7 +744,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||||
ty::Error => { // Avoid ICE (#50585)
|
ty::Error => { // Avoid ICE (#50585)
|
||||||
return PatternKind::Wild;
|
return PatternKind::Wild;
|
||||||
}
|
}
|
||||||
_ => bug!("inappropriate type for def: {:?}", ty.sty),
|
_ => bug!("inappropriate type for def: {:?}", ty),
|
||||||
};
|
};
|
||||||
PatternKind::Variant {
|
PatternKind::Variant {
|
||||||
adt_def,
|
adt_def,
|
||||||
|
|
|
@ -16,7 +16,8 @@ crate trait UserAnnotatedTyHelpers<'gcx: 'tcx, 'tcx> {
|
||||||
let user_provided_types = self.tables().user_provided_types();
|
let user_provided_types = self.tables().user_provided_types();
|
||||||
let mut user_ty = *user_provided_types.get(hir_id)?;
|
let mut user_ty = *user_provided_types.get(hir_id)?;
|
||||||
debug!("user_subts_applied_to_ty_of_hir_id: user_ty={:?}", user_ty);
|
debug!("user_subts_applied_to_ty_of_hir_id: user_ty={:?}", user_ty);
|
||||||
match &self.tables().node_type(hir_id).sty {
|
let ty = self.tables().node_type(hir_id);
|
||||||
|
match ty.sty {
|
||||||
ty::Adt(adt_def, ..) => {
|
ty::Adt(adt_def, ..) => {
|
||||||
if let UserType::TypeOf(ref mut did, _) = &mut user_ty.value {
|
if let UserType::TypeOf(ref mut did, _) = &mut user_ty.value {
|
||||||
*did = adt_def.did;
|
*did = adt_def.did;
|
||||||
|
@ -24,8 +25,11 @@ crate trait UserAnnotatedTyHelpers<'gcx: 'tcx, 'tcx> {
|
||||||
Some(user_ty)
|
Some(user_ty)
|
||||||
}
|
}
|
||||||
ty::FnDef(..) => Some(user_ty),
|
ty::FnDef(..) => Some(user_ty),
|
||||||
sty =>
|
_ => bug!(
|
||||||
bug!("sty: {:?} should not have user provided type {:?} recorded ", sty, user_ty),
|
"ty: {:?} should not have user provided type {:?} recorded ",
|
||||||
|
ty,
|
||||||
|
user_ty
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
||||||
let fn_ptr = self.memory.create_fn_alloc(instance?).with_default_tag();
|
let fn_ptr = self.memory.create_fn_alloc(instance?).with_default_tag();
|
||||||
self.write_scalar(Scalar::Ptr(fn_ptr.into()), dest)?;
|
self.write_scalar(Scalar::Ptr(fn_ptr.into()), dest)?;
|
||||||
}
|
}
|
||||||
ref other => bug!("reify fn pointer on {:?}", other),
|
_ => bug!("reify fn pointer on {:?}", src.layout.ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
||||||
// No change to value
|
// No change to value
|
||||||
self.write_immediate(*src, dest)?;
|
self.write_immediate(*src, dest)?;
|
||||||
}
|
}
|
||||||
ref other => bug!("fn to unsafe fn cast on {:?}", other),
|
_ => bug!("fn to unsafe fn cast on {:?}", dest.layout.ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
||||||
let val = Immediate::Scalar(Scalar::Ptr(fn_ptr.into()).into());
|
let val = Immediate::Scalar(Scalar::Ptr(fn_ptr.into()).into());
|
||||||
self.write_immediate(val, dest)?;
|
self.write_immediate(val, dest)?;
|
||||||
}
|
}
|
||||||
ref other => bug!("closure fn pointer on {:?}", other),
|
_ => bug!("closure fn pointer on {:?}", src.layout.ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,7 +336,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
||||||
|
|
||||||
let layout = val.layout;
|
let layout = val.layout;
|
||||||
let val = val.to_scalar()?;
|
let val = val.to_scalar()?;
|
||||||
trace!("Running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty.sty);
|
trace!("Running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty);
|
||||||
|
|
||||||
match layout.ty.sty {
|
match layout.ty.sty {
|
||||||
ty::Bool => {
|
ty::Bool => {
|
||||||
|
|
|
@ -354,7 +354,7 @@ where
|
||||||
ty::Ref(_, _, mutbl) => Some(mutbl),
|
ty::Ref(_, _, mutbl) => Some(mutbl),
|
||||||
ty::Adt(def, _) if def.is_box() => Some(hir::MutMutable),
|
ty::Adt(def, _) if def.is_box() => Some(hir::MutMutable),
|
||||||
ty::RawPtr(_) => None,
|
ty::RawPtr(_) => None,
|
||||||
_ => bug!("Unexpected pointer type {}", val.layout.ty.sty),
|
_ => bug!("Unexpected pointer type {}", val.layout.ty),
|
||||||
};
|
};
|
||||||
place.mplace.ptr = M::tag_dereference(self, place, mutbl)?;
|
place.mplace.ptr = M::tag_dereference(self, place, mutbl)?;
|
||||||
Ok(place)
|
Ok(place)
|
||||||
|
|
|
@ -836,7 +836,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
match tail.sty {
|
match tail.sty {
|
||||||
ty::Foreign(..) => false,
|
ty::Foreign(..) => false,
|
||||||
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
|
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
|
||||||
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
|
_ => bug!("unexpected unsized tail: {:?}", tail),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if type_has_metadata(inner_source) {
|
if type_has_metadata(inner_source) {
|
||||||
|
|
|
@ -959,7 +959,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||||
/// removing the dummy `Self` type (`TRAIT_OBJECT_DUMMY_SELF`).
|
/// removing the dummy `Self` type (`TRAIT_OBJECT_DUMMY_SELF`).
|
||||||
fn trait_ref_to_existential(&self, trait_ref: ty::TraitRef<'tcx>)
|
fn trait_ref_to_existential(&self, trait_ref: ty::TraitRef<'tcx>)
|
||||||
-> ty::ExistentialTraitRef<'tcx> {
|
-> ty::ExistentialTraitRef<'tcx> {
|
||||||
assert_eq!(trait_ref.self_ty().sty, TRAIT_OBJECT_DUMMY_SELF);
|
if trait_ref.self_ty().sty != TRAIT_OBJECT_DUMMY_SELF {
|
||||||
|
bug!("trait_ref_to_existential called on {:?} with non-dummy Self", trait_ref);
|
||||||
|
}
|
||||||
ty::ExistentialTraitRef::erase_self_ty(self.tcx(), trait_ref)
|
ty::ExistentialTraitRef::erase_self_ty(self.tcx(), trait_ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// See the examples in `run-pass/match-defbm*.rs`.
|
// See the examples in `run-pass/match-defbm*.rs`.
|
||||||
let mut pat_adjustments = vec![];
|
let mut pat_adjustments = vec![];
|
||||||
while let ty::Ref(_, inner_ty, inner_mutability) = exp_ty.sty {
|
while let ty::Ref(_, inner_ty, inner_mutability) = exp_ty.sty {
|
||||||
debug!("inspecting {:?} with type {:?}", exp_ty, exp_ty.sty);
|
debug!("inspecting {:?}", exp_ty);
|
||||||
|
|
||||||
debug!("current discriminant is Ref, inserting implicit deref");
|
debug!("current discriminant is Ref, inserting implicit deref");
|
||||||
// Preserve the reference type. We'll need it later during HAIR lowering.
|
// Preserve the reference type. We'll need it later during HAIR lowering.
|
||||||
|
@ -894,7 +894,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
subpats.len() < variant.fields.len() && ddpos.is_some() {
|
subpats.len() < variant.fields.len() && ddpos.is_some() {
|
||||||
let substs = match pat_ty.sty {
|
let substs = match pat_ty.sty {
|
||||||
ty::Adt(_, substs) => substs,
|
ty::Adt(_, substs) => substs,
|
||||||
ref ty => bug!("unexpected pattern type {:?}", ty),
|
_ => bug!("unexpected pattern type {:?}", pat_ty),
|
||||||
};
|
};
|
||||||
for (i, subpat) in subpats.iter().enumerate_and_adjust(variant.fields.len(), ddpos) {
|
for (i, subpat) in subpats.iter().enumerate_and_adjust(variant.fields.len(), ddpos) {
|
||||||
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
|
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
|
||||||
|
|
|
@ -3885,7 +3885,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
ty::Adt(adt, substs) => {
|
ty::Adt(adt, substs) => {
|
||||||
Some((adt.variant_of_def(def), adt.did, substs))
|
Some((adt.variant_of_def(def), adt.did, substs))
|
||||||
}
|
}
|
||||||
_ => bug!("unexpected type: {:?}", ty.sty)
|
_ => bug!("unexpected type: {:?}", ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) |
|
Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) |
|
||||||
|
@ -5226,8 +5226,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.node);
|
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.node);
|
||||||
let sp = ty.span;
|
let sp = ty.span;
|
||||||
let ty = AstConv::ast_ty_to_ty(self, ty);
|
let ty = AstConv::ast_ty_to_ty(self, ty);
|
||||||
debug!("suggest_missing_return_type: return type sty {:?}", ty.sty);
|
debug!("suggest_missing_return_type: return type {:?}", ty);
|
||||||
debug!("suggest_missing_return_type: expected type sty {:?}", ty.sty);
|
debug!("suggest_missing_return_type: expected type {:?}", ty);
|
||||||
if ty.sty == expected.sty {
|
if ty.sty == expected.sty {
|
||||||
err.span_label(sp, format!("expected `{}` because of return type",
|
err.span_label(sp, format!("expected `{}` because of return type",
|
||||||
expected));
|
expected));
|
||||||
|
|
|
@ -93,19 +93,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Extract the type of the closure.
|
// Extract the type of the closure.
|
||||||
let (closure_def_id, substs) = match self.node_ty(closure_hir_id).sty {
|
let ty = self.node_ty(closure_hir_id);
|
||||||
|
let (closure_def_id, substs) = match ty.sty {
|
||||||
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)),
|
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)),
|
||||||
ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)),
|
ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)),
|
||||||
ty::Error => {
|
ty::Error => {
|
||||||
// #51714: skip analysis when we have already encountered type errors
|
// #51714: skip analysis when we have already encountered type errors
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ref t => {
|
_ => {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
"type of closure expr {:?} is not a closure {:?}",
|
"type of closure expr {:?} is not a closure {:?}",
|
||||||
closure_hir_id,
|
closure_hir_id,
|
||||||
t
|
ty
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -618,7 +618,7 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>(
|
||||||
span: Span,
|
span: Span,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) -> Vec<ty::Predicate<'tcx>> {
|
) -> Vec<ty::Predicate<'tcx>> {
|
||||||
trace!("check_existential_types: {:?}, {:?}", ty, ty.sty);
|
trace!("check_existential_types: {:?}", ty);
|
||||||
let mut substituted_predicates = Vec::new();
|
let mut substituted_predicates = Vec::new();
|
||||||
ty.fold_with(&mut ty::fold::BottomUpFolder {
|
ty.fold_with(&mut ty::fold::BottomUpFolder {
|
||||||
tcx: fcx.tcx,
|
tcx: fcx.tcx,
|
||||||
|
|
|
@ -472,7 +472,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
|
||||||
instantiated_ty.fold_with(&mut BottomUpFolder {
|
instantiated_ty.fold_with(&mut BottomUpFolder {
|
||||||
tcx: self.tcx().global_tcx(),
|
tcx: self.tcx().global_tcx(),
|
||||||
fldop: |ty| {
|
fldop: |ty| {
|
||||||
trace!("checking type {:?}: {:#?}", ty, ty.sty);
|
trace!("checking type {:?}", ty);
|
||||||
// find a type parameter
|
// find a type parameter
|
||||||
if let ty::Param(..) = ty.sty {
|
if let ty::Param(..) = ty.sty {
|
||||||
// look it up in the substitution list
|
// look it up in the substitution list
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue