rustc: move some functions in middle::ty working on Ty to methods.
This commit is contained in:
parent
aa03871a6e
commit
59935f70e0
37 changed files with 433 additions and 477 deletions
|
@ -66,8 +66,8 @@ impl<'tcx> CastTy<'tcx> {
|
|||
ty::TyInt(_) => Some(CastTy::Int(IntTy::I)),
|
||||
ty::TyUint(u) => Some(CastTy::Int(IntTy::U(u))),
|
||||
ty::TyFloat(_) => Some(CastTy::Float),
|
||||
ty::TyEnum(..) if ty::type_is_c_like_enum(
|
||||
tcx, t) => Some(CastTy::Int(IntTy::CEnum)),
|
||||
ty::TyEnum(..) if t.is_c_like_enum(tcx) =>
|
||||
Some(CastTy::Int(IntTy::CEnum)),
|
||||
ty::TyRawPtr(ref mt) => Some(CastTy::Ptr(mt)),
|
||||
ty::TyRef(_, ref mt) => Some(CastTy::RPtr(mt)),
|
||||
ty::TyBareFn(..) => Some(CastTy::FnPtr),
|
||||
|
|
|
@ -411,14 +411,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
func_or_rcvr: &ast::Expr,
|
||||
args: I) -> CFGIndex {
|
||||
let method_call = ty::MethodCall::expr(call_expr.id);
|
||||
let return_ty = ty::ty_fn_ret(match self.tcx.method_map.borrow().get(&method_call) {
|
||||
let fn_ty = match self.tcx.method_map.borrow().get(&method_call) {
|
||||
Some(method) => method.ty,
|
||||
None => ty::expr_ty_adjusted(self.tcx, func_or_rcvr)
|
||||
});
|
||||
};
|
||||
|
||||
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
|
||||
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
|
||||
if return_ty.diverges() {
|
||||
if fn_ty.fn_ret().diverges() {
|
||||
self.add_unreachable_node()
|
||||
} else {
|
||||
ret
|
||||
|
|
|
@ -656,7 +656,9 @@ fn is_useful(cx: &MatchCheckCtxt,
|
|||
let left_ty = ty::pat_ty(cx.tcx, &*real_pat);
|
||||
|
||||
match real_pat.node {
|
||||
ast::PatIdent(ast::BindByRef(..), _, _) => ty::deref(left_ty, false).unwrap().ty,
|
||||
ast::PatIdent(ast::BindByRef(..), _, _) => {
|
||||
left_ty.builtin_deref(false).unwrap().ty
|
||||
}
|
||||
_ => left_ty,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -821,7 +821,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
|
||||
// the method call infrastructure should have
|
||||
// replaced all late-bound regions with variables:
|
||||
let self_ty = ty::ty_fn_sig(method_ty).input(0);
|
||||
let self_ty = method_ty.fn_sig().input(0);
|
||||
let self_ty = ty::no_late_bound_regions(self.tcx(), &self_ty).unwrap();
|
||||
|
||||
let (m, r) = match self_ty.sty {
|
||||
|
|
|
@ -1137,9 +1137,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
}
|
||||
|
||||
ast::ExprCall(ref f, ref args) => {
|
||||
let diverges = !self.ir.tcx.is_method_call(expr.id) && {
|
||||
ty::ty_fn_ret(ty::expr_ty_adjusted(self.ir.tcx, &**f)).diverges()
|
||||
};
|
||||
let diverges = !self.ir.tcx.is_method_call(expr.id) &&
|
||||
ty::expr_ty_adjusted(self.ir.tcx, &**f).fn_ret().diverges();
|
||||
let succ = if diverges {
|
||||
self.s.exit_ln
|
||||
} else {
|
||||
|
@ -1152,8 +1151,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
ast::ExprMethodCall(_, _, ref args) => {
|
||||
let method_call = ty::MethodCall::expr(expr.id);
|
||||
let method_ty = self.ir.tcx.method_map.borrow().get(&method_call).unwrap().ty;
|
||||
let diverges = ty::ty_fn_ret(method_ty).diverges();
|
||||
let succ = if diverges {
|
||||
let succ = if method_ty.fn_ret().diverges() {
|
||||
self.s.exit_ln
|
||||
} else {
|
||||
succ
|
||||
|
@ -1500,8 +1498,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
match fn_ty.sty {
|
||||
ty::TyClosure(closure_def_id, substs) =>
|
||||
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
|
||||
_ =>
|
||||
ty::ty_fn_ret(fn_ty),
|
||||
_ => fn_ty.fn_ret()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1523,7 +1520,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
ty::FnConverging(t_ret)
|
||||
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() => {
|
||||
|
||||
if ty::type_is_nil(t_ret) {
|
||||
if t_ret.is_nil() {
|
||||
// for nil return types, it is ok to not return a value expl.
|
||||
} else {
|
||||
let ends_with_stmt = match body.expr {
|
||||
|
|
|
@ -426,7 +426,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
// a bind-by-ref means that the base_ty will be the type of the ident itself,
|
||||
// but what we want here is the type of the underlying value being borrowed.
|
||||
// So peel off one-level, turning the &T into T.
|
||||
match ty::deref(base_ty, false) {
|
||||
match base_ty.builtin_deref(false) {
|
||||
Some(t) => t.ty,
|
||||
None => { return Err(()); }
|
||||
}
|
||||
|
@ -928,13 +928,13 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
Some(method_ty) => {
|
||||
let ref_ty =
|
||||
ty::no_late_bound_regions(
|
||||
self.tcx(), &ty::ty_fn_ret(method_ty)).unwrap().unwrap();
|
||||
self.tcx(), &method_ty.fn_ret()).unwrap().unwrap();
|
||||
self.cat_rvalue_node(node.id(), node.span(), ref_ty)
|
||||
}
|
||||
None => base_cmt
|
||||
};
|
||||
let base_cmt_ty = base_cmt.ty;
|
||||
match ty::deref(base_cmt_ty, true) {
|
||||
match base_cmt_ty.builtin_deref(true) {
|
||||
Some(mt) => {
|
||||
let ret = self.cat_deref_common(node, base_cmt, deref_cnt,
|
||||
mt.ty,
|
||||
|
@ -1023,11 +1023,11 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
base_cmt = self.cat_rvalue_node(elt.id(), elt.span(), ref_ty);
|
||||
|
||||
// FIXME(#20649) -- why are we using the `self_ty` as the element type...?
|
||||
let self_ty = ty::ty_fn_sig(method_ty).input(0);
|
||||
let self_ty = method_ty.fn_sig().input(0);
|
||||
ty::no_late_bound_regions(self.tcx(), &self_ty).unwrap()
|
||||
}
|
||||
None => {
|
||||
match ty::array_element_ty(self.tcx(), base_cmt.ty) {
|
||||
match base_cmt.ty.builtin_index() {
|
||||
Some(ty) => ty,
|
||||
None => {
|
||||
return Err(());
|
||||
|
@ -1081,7 +1081,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
span:elt.span(),
|
||||
cat:cat_deref(base_cmt.clone(), 0, ptr),
|
||||
mutbl:m,
|
||||
ty: match ty::deref(base_cmt.ty, false) {
|
||||
ty: match base_cmt.ty.builtin_deref(false) {
|
||||
Some(mt) => mt.ty,
|
||||
None => self.tcx().sess.bug("Found non-derefable type")
|
||||
},
|
||||
|
@ -1375,7 +1375,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
// types are generated by method resolution and always have
|
||||
// all late-bound regions fully instantiated, so we just want
|
||||
// to skip past the binder.
|
||||
ty::no_late_bound_regions(self.tcx(), &ty::ty_fn_ret(method_ty))
|
||||
ty::no_late_bound_regions(self.tcx(), &method_ty.fn_ret())
|
||||
.unwrap()
|
||||
.unwrap() // overloaded ops do not diverge, either
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
|
||||
let mut supertraits: Option<Vec<ty::PolyTraitRef<'tcx>>> = None;
|
||||
let mut error = false;
|
||||
ty::maybe_walk_ty(ty, |ty| {
|
||||
ty.maybe_walk(|ty| {
|
||||
match ty.sty {
|
||||
ty::TyParam(ref param_ty) => {
|
||||
if param_ty.space == SelfSpace {
|
||||
|
|
|
@ -773,7 +773,7 @@ fn confirm_fn_pointer_candidate<'cx,'tcx>(
|
|||
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
|
||||
{
|
||||
let fn_type = selcx.infcx().shallow_resolve(fn_type);
|
||||
let sig = ty::ty_fn_sig(fn_type);
|
||||
let sig = fn_type.fn_sig();
|
||||
confirm_callable_candidate(selcx, obligation, sig, util::TupleArgumentsFlag::Yes)
|
||||
}
|
||||
|
||||
|
|
|
@ -540,7 +540,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// terms of `Fn` etc, but we could probably make this more
|
||||
// precise still.
|
||||
let input_types = stack.fresh_trait_ref.0.input_types();
|
||||
let unbound_input_types = input_types.iter().any(|&t| ty::type_is_fresh(t));
|
||||
let unbound_input_types = input_types.iter().any(|ty| ty.is_fresh());
|
||||
if
|
||||
unbound_input_types &&
|
||||
(self.intercrate ||
|
||||
|
@ -2334,7 +2334,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
// ok to skip binder; it is reintroduced below
|
||||
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
|
||||
let sig = ty::ty_fn_sig(self_ty);
|
||||
let sig = self_ty.fn_sig();
|
||||
let trait_ref =
|
||||
util::closure_trait_ref_and_return_type(self.tcx(),
|
||||
obligation.predicate.def_id(),
|
||||
|
@ -2536,7 +2536,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
return Err(Unimplemented);
|
||||
};
|
||||
let mut ty_params = vec![];
|
||||
ty::walk_ty(field, |ty| {
|
||||
for ty in field.walk() {
|
||||
if let ty::TyParam(p) = ty.sty {
|
||||
assert!(p.space == TypeSpace);
|
||||
let idx = p.idx as usize;
|
||||
|
@ -2544,7 +2544,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty_params.push(idx);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if ty_params.is_empty() {
|
||||
return Err(Unimplemented);
|
||||
}
|
||||
|
|
|
@ -3541,28 +3541,20 @@ impl<'tcx> TyS<'tcx> {
|
|||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_ty<'tcx, F>(ty_root: Ty<'tcx>, mut f: F)
|
||||
where F: FnMut(Ty<'tcx>),
|
||||
{
|
||||
for ty in ty_root.walk() {
|
||||
f(ty);
|
||||
}
|
||||
}
|
||||
|
||||
/// Walks `ty` and any types appearing within `ty`, invoking the
|
||||
/// callback `f` on each type. If the callback returns false, then the
|
||||
/// children of the current type are ignored.
|
||||
///
|
||||
/// Note: prefer `ty.walk()` where possible.
|
||||
pub fn maybe_walk_ty<'tcx,F>(ty_root: Ty<'tcx>, mut f: F)
|
||||
where F : FnMut(Ty<'tcx>) -> bool
|
||||
{
|
||||
let mut walker = ty_root.walk();
|
||||
while let Some(ty) = walker.next() {
|
||||
if !f(ty) {
|
||||
walker.skip_current_subtree();
|
||||
/// Walks `ty` and any types appearing within `ty`, invoking the
|
||||
/// callback `f` on each type. If the callback returns false, then the
|
||||
/// children of the current type are ignored.
|
||||
///
|
||||
/// Note: prefer `ty.walk()` where possible.
|
||||
pub fn maybe_walk<F>(&'tcx self, mut f: F)
|
||||
where F : FnMut(Ty<'tcx>) -> bool
|
||||
{
|
||||
let mut walker = self.walk();
|
||||
while let Some(ty) = walker.next() {
|
||||
if !f(ty) {
|
||||
walker.skip_current_subtree();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3613,128 +3605,126 @@ impl<'tcx> ItemSubsts<'tcx> {
|
|||
}
|
||||
|
||||
// Type utilities
|
||||
|
||||
pub fn type_is_nil(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyTuple(ref tys) => tys.is_empty(),
|
||||
_ => false
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
pub fn is_nil(&self) -> bool {
|
||||
match self.sty {
|
||||
TyTuple(ref tys) => tys.is_empty(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_ty_var(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyInfer(TyVar(_)) => true,
|
||||
_ => false
|
||||
pub fn is_ty_var(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(TyVar(_)) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_bool(ty: Ty) -> bool { ty.sty == TyBool }
|
||||
pub fn is_bool(&self) -> bool { self.sty == TyBool }
|
||||
|
||||
pub fn type_is_self(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyParam(ref p) => p.space == subst::SelfSpace,
|
||||
_ => false
|
||||
pub fn is_self(&self) -> bool {
|
||||
match self.sty {
|
||||
TyParam(ref p) => p.space == subst::SelfSpace,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn type_is_slice(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyRawPtr(mt) | TyRef(_, mt) => match mt.ty.sty {
|
||||
TySlice(_) | TyStr => true,
|
||||
fn is_slice(&self) -> bool {
|
||||
match self.sty {
|
||||
TyRawPtr(mt) | TyRef(_, mt) => match mt.ty.sty {
|
||||
TySlice(_) | TyStr => true,
|
||||
_ => false,
|
||||
},
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_structural(&self) -> bool {
|
||||
match self.sty {
|
||||
TyStruct(..) | TyTuple(_) | TyEnum(..) |
|
||||
TyArray(..) | TyClosure(..) => true,
|
||||
_ => self.is_slice() | self.is_trait()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_simd(&self, cx: &ctxt) -> bool {
|
||||
match self.sty {
|
||||
TyStruct(did, _) => lookup_simd(cx, did),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sequence_element_type(&self, cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => ty,
|
||||
TyStr => mk_mach_uint(cx, ast::TyU8),
|
||||
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
||||
self)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_type(&self, cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyStruct(did, substs) => {
|
||||
let fields = lookup_struct_fields(cx, did);
|
||||
lookup_field_type(cx, did, fields[0].id, substs)
|
||||
}
|
||||
_ => panic!("simd_type called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_size(&self, cx: &ctxt) -> usize {
|
||||
match self.sty {
|
||||
TyStruct(did, _) => {
|
||||
let fields = lookup_struct_fields(cx, did);
|
||||
fields.len()
|
||||
}
|
||||
_ => panic!("simd_size called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_region_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
TyRef(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_unsafe_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
TyRawPtr(_) => return true,
|
||||
_ => return false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_unique(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBox(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
A scalar type is one that denotes an atomic datum, with no sub-components.
|
||||
(A TyRawPtr is scalar because it represents a non-managed pointer, so its
|
||||
contents are abstract to rustc.)
|
||||
*/
|
||||
pub fn is_scalar(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBool | TyChar | TyInt(_) | TyFloat(_) | TyUint(_) |
|
||||
TyInfer(IntVar(_)) | TyInfer(FloatVar(_)) |
|
||||
TyBareFn(..) | TyRawPtr(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if this type is a floating point type and false otherwise.
|
||||
pub fn is_floating_point(&self) -> bool {
|
||||
match self.sty {
|
||||
TyFloat(_) |
|
||||
TyInfer(FloatVar(_)) => true,
|
||||
_ => false,
|
||||
},
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_structural(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyStruct(..) | TyTuple(_) | TyEnum(..) |
|
||||
TyArray(..) | TyClosure(..) => true,
|
||||
_ => type_is_slice(ty) | type_is_trait(ty)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_simd(cx: &ctxt, ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyStruct(did, _) => lookup_simd(cx, did),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => ty,
|
||||
TyStr => mk_mach_uint(cx, ast::TyU8),
|
||||
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
||||
ty)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
TyStruct(did, substs) => {
|
||||
let fields = lookup_struct_fields(cx, did);
|
||||
lookup_field_type(cx, did, fields[0].id, substs)
|
||||
}
|
||||
_ => panic!("simd_type called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_size(cx: &ctxt, ty: Ty) -> usize {
|
||||
match ty.sty {
|
||||
TyStruct(did, _) => {
|
||||
let fields = lookup_struct_fields(cx, did);
|
||||
fields.len()
|
||||
}
|
||||
_ => panic!("simd_size called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_region_ptr(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyRef(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_unsafe_ptr(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyRawPtr(_) => return true,
|
||||
_ => return false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_unique(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyBox(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
A scalar type is one that denotes an atomic datum, with no sub-components.
|
||||
(A TyRawPtr is scalar because it represents a non-managed pointer, so its
|
||||
contents are abstract to rustc.)
|
||||
*/
|
||||
pub fn type_is_scalar(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyBool | TyChar | TyInt(_) | TyFloat(_) | TyUint(_) |
|
||||
TyInfer(IntVar(_)) | TyInfer(FloatVar(_)) |
|
||||
TyBareFn(..) | TyRawPtr(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if this type is a floating point type and false otherwise.
|
||||
pub fn type_is_floating_point(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyFloat(_) |
|
||||
TyInfer(FloatVar(_)) =>
|
||||
true,
|
||||
|
||||
_ =>
|
||||
false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4508,141 +4498,124 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||
r
|
||||
}
|
||||
|
||||
pub fn type_is_trait(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyTrait(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_integral(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyInfer(IntVar(_)) | TyInt(_) | TyUint(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_fresh(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyInfer(FreshTy(_)) => true,
|
||||
TyInfer(FreshIntTy(_)) => true,
|
||||
TyInfer(FreshFloatTy(_)) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_uint(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyInfer(IntVar(_)) | TyUint(ast::TyUs) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_char(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyChar => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_bare_fn(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyBareFn(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_bare_fn_item(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyBareFn(Some(_), _) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_fp(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyInfer(FloatVar(_)) | TyFloat(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_numeric(ty: Ty) -> bool {
|
||||
return type_is_integral(ty) || type_is_fp(ty);
|
||||
}
|
||||
|
||||
pub fn type_is_signed(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyInt(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_is_machine(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyInt(ast::TyIs) | TyUint(ast::TyUs) => false,
|
||||
TyInt(..) | TyUint(..) | TyFloat(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
// Whether a type is enum like, that is an enum type with only nullary
|
||||
// constructors
|
||||
pub fn type_is_c_like_enum(cx: &ctxt, ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
TyEnum(did, _) => {
|
||||
let variants = enum_variants(cx, did);
|
||||
if variants.is_empty() {
|
||||
false
|
||||
} else {
|
||||
variants.iter().all(|v| v.args.is_empty())
|
||||
}
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
pub fn is_trait(&self) -> bool {
|
||||
match self.sty {
|
||||
TyTrait(..) => true,
|
||||
_ => false
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the type and mutability of *ty.
|
||||
//
|
||||
// The parameter `explicit` indicates if this is an *explicit* dereference.
|
||||
// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
|
||||
pub fn deref<'tcx>(ty: Ty<'tcx>, explicit: bool) -> Option<mt<'tcx>> {
|
||||
match ty.sty {
|
||||
TyBox(ty) => {
|
||||
Some(mt {
|
||||
ty: ty,
|
||||
mutbl: ast::MutImmutable,
|
||||
})
|
||||
},
|
||||
TyRef(_, mt) => Some(mt),
|
||||
TyRawPtr(mt) if explicit => Some(mt),
|
||||
_ => None
|
||||
pub fn is_integral(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(IntVar(_)) | TyInt(_) | TyUint(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_content<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
TyBox(ty) => ty,
|
||||
TyRef(_, mt) | TyRawPtr(mt) => mt.ty,
|
||||
_ => ty
|
||||
pub fn is_fresh(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(FreshTy(_)) => true,
|
||||
TyInfer(FreshIntTy(_)) => true,
|
||||
TyInfer(FreshFloatTy(_)) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the type of ty[i]
|
||||
pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
||||
match ty.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
||||
_ => None
|
||||
pub fn is_uint(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(IntVar(_)) | TyUint(ast::TyUs) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the type of elements contained within an 'array-like' type.
|
||||
// This is exactly the same as the above, except it supports strings,
|
||||
// which can't actually be indexed.
|
||||
pub fn array_element_ty<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
||||
match ty.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
||||
TyStr => Some(tcx.types.u8),
|
||||
_ => None
|
||||
pub fn is_char(&self) -> bool {
|
||||
match self.sty {
|
||||
TyChar => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_bare_fn(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBareFn(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_bare_fn_item(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBareFn(Some(_), _) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_fp(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(FloatVar(_)) | TyFloat(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_numeric(&self) -> bool {
|
||||
self.is_integral() || self.is_fp()
|
||||
}
|
||||
|
||||
pub fn is_signed(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInt(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_machine(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInt(ast::TyIs) | TyUint(ast::TyUs) => false,
|
||||
TyInt(..) | TyUint(..) | TyFloat(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
// Whether a type is enum like, that is an enum type with only nullary
|
||||
// constructors
|
||||
pub fn is_c_like_enum(&self, cx: &ctxt) -> bool {
|
||||
match self.sty {
|
||||
TyEnum(did, _) => {
|
||||
let variants = enum_variants(cx, did);
|
||||
if variants.is_empty() {
|
||||
false
|
||||
} else {
|
||||
variants.iter().all(|v| v.args.is_empty())
|
||||
}
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the type and mutability of *ty.
|
||||
//
|
||||
// The parameter `explicit` indicates if this is an *explicit* dereference.
|
||||
// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
|
||||
pub fn builtin_deref(&self, explicit: bool) -> Option<mt<'tcx>> {
|
||||
match self.sty {
|
||||
TyBox(ty) => {
|
||||
Some(mt {
|
||||
ty: ty,
|
||||
mutbl: ast::MutImmutable,
|
||||
})
|
||||
},
|
||||
TyRef(_, mt) => Some(mt),
|
||||
TyRawPtr(mt) if explicit => Some(mt),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the type of ty[i]
|
||||
pub fn builtin_index(&self) -> Option<Ty<'tcx>> {
|
||||
match self.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4725,53 +4698,39 @@ pub fn node_id_item_substs<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> ItemSubsts
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fn_is_variadic(fty: Ty) -> bool {
|
||||
match fty.sty {
|
||||
TyBareFn(_, ref f) => f.sig.0.variadic,
|
||||
ref s => {
|
||||
panic!("fn_is_variadic() called on non-fn type: {:?}", s)
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
pub fn fn_sig(&self) -> &'tcx PolyFnSig<'tcx> {
|
||||
match self.sty {
|
||||
TyBareFn(_, ref f) => &f.sig,
|
||||
_ => panic!("Ty::fn_sig() called on non-fn type: {:?}", self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> &'tcx PolyFnSig<'tcx> {
|
||||
match fty.sty {
|
||||
TyBareFn(_, ref f) => &f.sig,
|
||||
ref s => {
|
||||
panic!("ty_fn_sig() called on non-fn type: {:?}", s)
|
||||
/// Returns the ABI of the given function.
|
||||
pub fn fn_abi(&self) -> abi::Abi {
|
||||
match self.sty {
|
||||
TyBareFn(_, ref f) => f.abi,
|
||||
_ => panic!("Ty::fn_abi() called on non-fn type"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the ABI of the given function.
|
||||
pub fn ty_fn_abi(fty: Ty) -> abi::Abi {
|
||||
match fty.sty {
|
||||
TyBareFn(_, ref f) => f.abi,
|
||||
_ => panic!("ty_fn_abi() called on non-fn type"),
|
||||
// Type accessors for substructures of types
|
||||
pub fn fn_args(&self) -> ty::Binder<Vec<Ty<'tcx>>> {
|
||||
self.fn_sig().inputs()
|
||||
}
|
||||
}
|
||||
|
||||
// Type accessors for substructures of types
|
||||
pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> ty::Binder<Vec<Ty<'tcx>>> {
|
||||
ty_fn_sig(fty).inputs()
|
||||
}
|
||||
pub fn fn_ret(&self) -> Binder<FnOutput<'tcx>> {
|
||||
self.fn_sig().output()
|
||||
}
|
||||
|
||||
pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> Binder<FnOutput<'tcx>> {
|
||||
match fty.sty {
|
||||
TyBareFn(_, ref f) => f.sig.output(),
|
||||
ref s => {
|
||||
panic!("ty_fn_ret() called on non-fn type: {:?}", s)
|
||||
pub fn is_fn(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBareFn(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_fn_ty(fty: Ty) -> bool {
|
||||
match fty.sty {
|
||||
TyBareFn(..) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ty_region(tcx: &ctxt,
|
||||
span: Span,
|
||||
ty: Ty) -> Region {
|
||||
|
@ -4935,12 +4894,12 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
|
|||
// regions fully instantiated and coverge.
|
||||
let fn_ret =
|
||||
ty::no_late_bound_regions(cx,
|
||||
&ty_fn_ret(method_ty)).unwrap();
|
||||
&method_ty.fn_ret()).unwrap();
|
||||
adjusted_ty = fn_ret.unwrap();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
match deref(adjusted_ty, true) {
|
||||
match adjusted_ty.builtin_deref(true) {
|
||||
Some(mt) => { adjusted_ty = mt.ty; }
|
||||
None => {
|
||||
cx.sess.span_bug(
|
||||
|
@ -5578,7 +5537,7 @@ impl<'tcx> VariantInfo<'tcx> {
|
|||
let arg_tys = if !args.is_empty() {
|
||||
// the regions in the argument types come from the
|
||||
// enum def'n, and hence will all be early bound
|
||||
ty::no_late_bound_regions(cx, &ty_fn_args(ctor_ty)).unwrap()
|
||||
ty::no_late_bound_regions(cx, &ctor_ty.fn_args()).unwrap()
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
@ -6595,7 +6554,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
|
|||
helper(tcx, output, svh, state);
|
||||
}
|
||||
};
|
||||
maybe_walk_ty(ty, |ty| {
|
||||
ty.maybe_walk(|ty| {
|
||||
match ty.sty {
|
||||
TyBool => byte!(2),
|
||||
TyChar => byte!(3),
|
||||
|
@ -6939,7 +6898,7 @@ pub enum ExplicitSelfCategory {
|
|||
/// types, nor does it resolve fictitious types.
|
||||
pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
|
||||
ty: Ty) {
|
||||
walk_ty(ty, |ty| {
|
||||
for ty in ty.walk() {
|
||||
match ty.sty {
|
||||
TyRef(region, _) => {
|
||||
accumulator.push(*region)
|
||||
|
@ -6972,7 +6931,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
|
|||
TyError => {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn accum_substs(accumulator: &mut Vec<Region>, substs: &Substs) {
|
||||
match substs.regions {
|
||||
|
|
|
@ -51,7 +51,7 @@ fn fn_sig(f: &mut fmt::Formatter,
|
|||
|
||||
match output {
|
||||
ty::FnConverging(ty) => {
|
||||
if !ty::type_is_nil(ty) {
|
||||
if !ty.is_nil() {
|
||||
try!(write!(f, " -> {}", ty));
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -662,7 +662,12 @@ fn bind_subslice_pat(bcx: Block,
|
|||
offset_right: usize) -> ValueRef {
|
||||
let _icx = push_ctxt("match::bind_subslice_pat");
|
||||
let vec_ty = node_id_type(bcx, pat_id);
|
||||
let unit_ty = ty::sequence_element_type(bcx.tcx(), ty::type_content(vec_ty));
|
||||
let vec_ty_contents = match vec_ty.sty {
|
||||
ty::TyBox(ty) => ty,
|
||||
ty::TyRef(_, mt) | ty::TyRawPtr(mt) => mt.ty,
|
||||
_ => vec_ty
|
||||
};
|
||||
let unit_ty = vec_ty_contents.sequence_element_type(bcx.tcx());
|
||||
let vec_datum = match_datum(val, vec_ty);
|
||||
let (base, len) = vec_datum.get_vec_base_and_len(bcx);
|
||||
|
||||
|
@ -836,7 +841,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
let _icx = push_ctxt("compare_values");
|
||||
if ty::type_is_scalar(rhs_t) {
|
||||
if rhs_t.is_scalar() {
|
||||
let cmp = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq, debug_loc);
|
||||
return Result::new(cx, cmp);
|
||||
}
|
||||
|
@ -1140,7 +1145,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
match opts[0] {
|
||||
ConstantValue(..) | ConstantRange(..) => {
|
||||
test_val = load_if_immediate(bcx, val, left_ty);
|
||||
kind = if ty::type_is_integral(left_ty) {
|
||||
kind = if left_ty.is_integral() {
|
||||
Switch
|
||||
} else {
|
||||
Compare
|
||||
|
|
|
@ -262,7 +262,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
|
|||
attrs.arg(idx, llvm::DereferenceableAttribute(llsz));
|
||||
} else {
|
||||
attrs.arg(idx, llvm::NonNullAttribute);
|
||||
if ty::type_is_trait(inner) {
|
||||
if inner.is_trait() {
|
||||
attrs.arg(idx + 1, llvm::NonNullAttribute);
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
|
|||
attrs.arg(idx, llvm::DereferenceableAttribute(llsz));
|
||||
} else {
|
||||
attrs.arg(idx, llvm::NonNullAttribute);
|
||||
if ty::type_is_trait(mt.ty) {
|
||||
if mt.ty.is_trait() {
|
||||
attrs.arg(idx + 1, llvm::NonNullAttribute);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ use middle::cfg;
|
|||
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
|
||||
use middle::weak_lang_items;
|
||||
use middle::subst::Substs;
|
||||
use middle::ty::{self, Ty, ClosureTyper, type_is_simd, simd_size, HasTypeFlags};
|
||||
use middle::ty::{self, Ty, ClosureTyper, HasTypeFlags};
|
||||
use rustc::ast_map;
|
||||
use session::config::{self, NoDebugInfo};
|
||||
use session::Session;
|
||||
|
@ -443,11 +443,11 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
}
|
||||
ty::TyArray(_, n) => {
|
||||
let (base, len) = tvec::get_fixed_base_and_len(cx, data_ptr, n);
|
||||
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
|
||||
let unit_ty = t.sequence_element_type(cx.tcx());
|
||||
cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);
|
||||
}
|
||||
ty::TySlice(_) | ty::TyStr => {
|
||||
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
|
||||
let unit_ty = t.sequence_element_type(cx.tcx());
|
||||
cx = tvec::iter_vec_raw(cx, data_ptr, unit_ty, info.unwrap(), f);
|
||||
}
|
||||
ty::TyTuple(ref args) => {
|
||||
|
@ -626,9 +626,9 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
|
|||
let zero = C_integral(Type::uint_from_ty(cx.ccx(), t), 0, false);
|
||||
(ICmp(cx, llvm::IntEQ, rhs, zero, debug_loc), false)
|
||||
}
|
||||
ty::TyStruct(_, _) if type_is_simd(cx.tcx(), rhs_t) => {
|
||||
ty::TyStruct(_, _) if rhs_t.is_simd(cx.tcx()) => {
|
||||
let mut res = C_bool(cx.ccx(), false);
|
||||
for i in 0 .. simd_size(cx.tcx(), rhs_t) {
|
||||
for i in 0 .. rhs_t.simd_size(cx.tcx()) {
|
||||
res = Or(cx, res,
|
||||
IsNull(cx,
|
||||
ExtractElement(cx, rhs, C_int(cx.ccx(), i as i64))), debug_loc);
|
||||
|
@ -805,13 +805,13 @@ pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
let val = if ty::type_is_bool(t) {
|
||||
let val = if t.is_bool() {
|
||||
LoadRangeAssert(cx, ptr, 0, 2, llvm::False)
|
||||
} else if ty::type_is_char(t) {
|
||||
} else if t.is_char() {
|
||||
// a char is a Unicode codepoint, and so takes values from 0
|
||||
// to 0x10FFFF inclusive only.
|
||||
LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, llvm::False)
|
||||
} else if (ty::type_is_region_ptr(t) || ty::type_is_unique(t))
|
||||
} else if (t.is_region_ptr() || t.is_unique())
|
||||
&& !common::type_is_fat_ptr(cx.tcx(), t) {
|
||||
LoadNonNull(cx, ptr)
|
||||
} else {
|
||||
|
@ -839,7 +839,7 @@ pub fn store_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, dst: ValueRef, t
|
|||
}
|
||||
|
||||
pub fn from_arg_ty(bcx: Block, val: ValueRef, ty: Ty) -> ValueRef {
|
||||
if ty::type_is_bool(ty) {
|
||||
if ty.is_bool() {
|
||||
ZExt(bcx, val, Type::i8(bcx.ccx()))
|
||||
} else {
|
||||
val
|
||||
|
@ -847,7 +847,7 @@ pub fn from_arg_ty(bcx: Block, val: ValueRef, ty: Ty) -> ValueRef {
|
|||
}
|
||||
|
||||
pub fn to_arg_ty(bcx: Block, val: ValueRef, ty: Ty) -> ValueRef {
|
||||
if ty::type_is_bool(ty) {
|
||||
if ty.is_bool() {
|
||||
Trunc(bcx, val, Type::i1(bcx.ccx()))
|
||||
} else {
|
||||
val
|
||||
|
@ -953,7 +953,7 @@ pub fn memcpy_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
t: Ty<'tcx>) {
|
||||
let _icx = push_ctxt("memcpy_ty");
|
||||
let ccx = bcx.ccx();
|
||||
if ty::type_is_structural(t) {
|
||||
if t.is_structural() {
|
||||
let llty = type_of::type_of(ccx, t);
|
||||
let llsz = llsize_of(ccx, llty);
|
||||
let llalign = type_of::align_of(ccx, t);
|
||||
|
@ -1669,8 +1669,8 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
debug!("trans_fn(param_substs={:?})", param_substs);
|
||||
let _icx = push_ctxt("trans_fn");
|
||||
let fn_ty = ty::node_id_to_type(ccx.tcx(), id);
|
||||
let output_type = ty::erase_late_bound_regions(ccx.tcx(), &ty::ty_fn_ret(fn_ty));
|
||||
let abi = ty::ty_fn_abi(fn_ty);
|
||||
let output_type = ty::erase_late_bound_regions(ccx.tcx(), &fn_ty.fn_ret());
|
||||
let abi = fn_ty.fn_abi();
|
||||
trans_closure(ccx, decl, body, llfndecl, param_substs, id, attrs, output_type, abi,
|
||||
closure::ClosureEnv::NotClosure);
|
||||
}
|
||||
|
@ -1800,7 +1800,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
|
|||
|
||||
let arg_tys =
|
||||
ty::erase_late_bound_regions(
|
||||
ccx.tcx(), &ty::ty_fn_args(ctor_ty));
|
||||
ccx.tcx(), &ctor_ty.fn_args());
|
||||
|
||||
let arg_datums = create_datums_for_fn_args(bcx, &arg_tys[..]);
|
||||
|
||||
|
@ -2334,7 +2334,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
unsafe {
|
||||
// boolean SSA values are i1, but they have to be stored in i8 slots,
|
||||
// otherwise some LLVM optimization passes don't work as expected
|
||||
let llty = if ty::type_is_bool(ty) {
|
||||
let llty = if ty.is_bool() {
|
||||
llvm::LLVMInt8TypeInContext(ccx.llcx())
|
||||
} else {
|
||||
llvm::LLVMTypeOf(v)
|
||||
|
|
|
@ -917,7 +917,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
|
|||
{
|
||||
let args =
|
||||
ty::erase_late_bound_regions(
|
||||
bcx.tcx(), &ty::ty_fn_args(fn_ty));
|
||||
bcx.tcx(), &fn_ty.fn_args());
|
||||
|
||||
// Translate the `self` argument first.
|
||||
if !ignore_self {
|
||||
|
@ -978,7 +978,7 @@ fn trans_overloaded_call_args<'blk, 'tcx>(
|
|||
ignore_self: bool)
|
||||
-> Block<'blk, 'tcx> {
|
||||
// Translate the `self` argument first.
|
||||
let arg_tys = ty::erase_late_bound_regions(bcx.tcx(), &ty::ty_fn_args(fn_ty));
|
||||
let arg_tys = ty::erase_late_bound_regions(bcx.tcx(), &fn_ty.fn_args());
|
||||
if !ignore_self {
|
||||
let arg_datum = unpack_datum!(bcx, expr::trans(bcx, arg_exprs[0]));
|
||||
bcx = trans_arg_datum(bcx,
|
||||
|
@ -1024,8 +1024,8 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
debug!("trans_args(abi={})", abi);
|
||||
|
||||
let _icx = push_ctxt("trans_args");
|
||||
let arg_tys = ty::erase_late_bound_regions(cx.tcx(), &ty::ty_fn_args(fn_ty));
|
||||
let variadic = ty::fn_is_variadic(fn_ty);
|
||||
let arg_tys = ty::erase_late_bound_regions(cx.tcx(), &fn_ty.fn_args());
|
||||
let variadic = fn_ty.fn_sig().0.variadic;
|
||||
|
||||
let mut bcx = cx;
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ pub fn type_needs_unwind_cleanup<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<
|
|||
}
|
||||
|
||||
let mut needs_unwind_cleanup = false;
|
||||
ty::maybe_walk_ty(ty, |ty| {
|
||||
ty.maybe_walk(|ty| {
|
||||
needs_unwind_cleanup |= match ty.sty {
|
||||
ty::TyBool | ty::TyInt(_) | ty::TyUint(_) |
|
||||
ty::TyFloat(_) | ty::TyTuple(_) | ty::TyRawPtr(_) => false,
|
||||
|
@ -234,10 +234,10 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
|
|||
use trans::type_of::sizing_type_of;
|
||||
|
||||
let tcx = ccx.tcx();
|
||||
let simple = ty::type_is_scalar(ty) ||
|
||||
ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) ||
|
||||
let simple = ty.is_scalar() ||
|
||||
ty.is_unique() || ty.is_region_ptr() ||
|
||||
type_is_newtype_immediate(ccx, ty) ||
|
||||
ty::type_is_simd(tcx, ty);
|
||||
ty.is_simd(tcx);
|
||||
if simple && !type_is_fat_ptr(tcx, ty) {
|
||||
return true;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ pub fn type_is_zero_size<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
|
|||
/// zero-size, but not all zero-size types use a `void` return type (in order to aid with C ABI
|
||||
/// compatibility).
|
||||
pub fn return_type_is_void(ccx: &CrateContext, ty: Ty) -> bool {
|
||||
ty::type_is_nil(ty) || ty::type_is_empty(ccx.tcx(), ty)
|
||||
ty.is_nil() || ty::type_is_empty(ccx.tcx(), ty)
|
||||
}
|
||||
|
||||
/// Generates a unique symbol based off the name given. This is used to create
|
||||
|
|
|
@ -149,7 +149,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
v: ValueRef,
|
||||
ty: Ty<'tcx>)
|
||||
-> (ValueRef, Ty<'tcx>) {
|
||||
match ty::deref(ty, true) {
|
||||
match ty.builtin_deref(true) {
|
||||
Some(mt) => {
|
||||
if type_is_sized(cx.tcx(), mt.ty) {
|
||||
(const_deref_ptr(cx, v), mt.ty)
|
||||
|
@ -323,7 +323,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
param_substs,
|
||||
&target);
|
||||
|
||||
let pointee_ty = ty::deref(ty, true)
|
||||
let pointee_ty = ty.builtin_deref(true)
|
||||
.expect("consts: unsizing got non-pointer type").ty;
|
||||
let (base, old_info) = if !type_is_sized(cx.tcx(), pointee_ty) {
|
||||
// Normally, the source is a thin pointer and we are
|
||||
|
@ -338,7 +338,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
(llconst, None)
|
||||
};
|
||||
|
||||
let unsized_ty = ty::deref(target, true)
|
||||
let unsized_ty = target.builtin_deref(true)
|
||||
.expect("consts: unsizing got non-pointer target type").ty;
|
||||
let ptr_ty = type_of::in_memory_type_of(cx, unsized_ty).ptr_to();
|
||||
let base = ptrcast(base, ptr_ty);
|
||||
|
@ -499,14 +499,14 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
debug!("const_expr_unadjusted: te1={}, ty={:?}",
|
||||
cx.tn().val_to_string(te1),
|
||||
ty);
|
||||
let is_simd = ty::type_is_simd(cx.tcx(), ty);
|
||||
let is_simd = ty.is_simd(cx.tcx());
|
||||
let intype = if is_simd {
|
||||
ty::simd_type(cx.tcx(), ty)
|
||||
ty.simd_type(cx.tcx())
|
||||
} else {
|
||||
ty
|
||||
};
|
||||
let is_float = ty::type_is_fp(intype);
|
||||
let signed = ty::type_is_signed(intype);
|
||||
let is_float = intype.is_fp();
|
||||
let signed = intype.is_signed();
|
||||
|
||||
let (te2, _) = const_expr(cx, &**e2, param_substs, fn_args);
|
||||
|
||||
|
@ -572,7 +572,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
check_unary_expr_validity(cx, e, ty, te);
|
||||
|
||||
let is_float = ty::type_is_fp(ty);
|
||||
let is_float = ty.is_fp();
|
||||
match u {
|
||||
ast::UnUniq | ast::UnDeref => {
|
||||
const_deref(cx, te, ty).0
|
||||
|
@ -660,7 +660,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
if type_is_fat_ptr(cx.tcx(), t_expr) {
|
||||
// Fat pointer casts.
|
||||
let t_cast_inner = ty::deref(t_cast, true).expect("cast to non-pointer").ty;
|
||||
let t_cast_inner = t_cast.builtin_deref(true).expect("cast to non-pointer").ty;
|
||||
let ptr_ty = type_of::in_memory_type_of(cx, t_cast_inner).ptr_to();
|
||||
let addr = ptrcast(const_get_elt(cx, v, &[abi::FAT_PTR_ADDR as u32]),
|
||||
ptr_ty);
|
||||
|
@ -681,11 +681,11 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
llvm::LLVMConstIntCast(iv, llty.to_ref(), s)
|
||||
}
|
||||
(CastTy::Int(_), CastTy::Int(_)) => {
|
||||
let s = ty::type_is_signed(t_expr) as Bool;
|
||||
let s = t_expr.is_signed() as Bool;
|
||||
llvm::LLVMConstIntCast(v, llty.to_ref(), s)
|
||||
}
|
||||
(CastTy::Int(_), CastTy::Float) => {
|
||||
if ty::type_is_signed(t_expr) {
|
||||
if t_expr.is_signed() {
|
||||
llvm::LLVMConstSIToFP(v, llty.to_ref())
|
||||
} else {
|
||||
llvm::LLVMConstUIToFP(v, llty.to_ref())
|
||||
|
@ -781,7 +781,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
if ty::type_is_simd(cx.tcx(), ety) {
|
||||
if ety.is_simd(cx.tcx()) {
|
||||
C_vector(&cs[..])
|
||||
} else {
|
||||
adt::trans_const(cx, &*repr, discr, &cs[..])
|
||||
|
@ -789,7 +789,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
})
|
||||
}
|
||||
ast::ExprVec(ref es) => {
|
||||
let unit_ty = ty::sequence_element_type(cx.tcx(), ety);
|
||||
let unit_ty = ety.sequence_element_type(cx.tcx());
|
||||
let llunitty = type_of::type_of(cx, unit_ty);
|
||||
let vs = es.iter().map(|e| const_expr(cx, &**e, param_substs, fn_args).0)
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -801,7 +801,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
ast::ExprRepeat(ref elem, ref count) => {
|
||||
let unit_ty = ty::sequence_element_type(cx.tcx(), ety);
|
||||
let unit_ty = ety.sequence_element_type(cx.tcx());
|
||||
let llunitty = type_of::type_of(cx, unit_ty);
|
||||
let n = ty::eval_repeat_count(cx.tcx(), count);
|
||||
let unit_val = const_expr(cx, &**elem, param_substs, fn_args).0;
|
||||
|
@ -875,7 +875,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
const_fn_call(cx, ExprId(callee.id), did, &arg_vals, param_substs)
|
||||
}
|
||||
def::DefStruct(_) => {
|
||||
if ty::type_is_simd(cx.tcx(), ety) {
|
||||
if ety.is_simd(cx.tcx()) {
|
||||
C_vector(&arg_vals[..])
|
||||
} else {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
|
|
|
@ -640,7 +640,7 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> {
|
|||
}
|
||||
|
||||
pub fn to_llbool<'blk>(self, bcx: Block<'blk, 'tcx>) -> ValueRef {
|
||||
assert!(ty::type_is_bool(self.ty));
|
||||
assert!(self.ty.is_bool());
|
||||
self.to_llscalarish(bcx)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1192,7 +1192,7 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
struct_llvm_type,
|
||||
StructMDF(StructMemberDescriptionFactory {
|
||||
fields: fields,
|
||||
is_simd: ty::type_is_simd(cx.tcx(), struct_type),
|
||||
is_simd: struct_type.is_simd(cx.tcx()),
|
||||
span: span,
|
||||
})
|
||||
)
|
||||
|
|
|
@ -416,7 +416,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let return_type = monomorphize::apply_param_substs(cx.tcx(),
|
||||
param_substs,
|
||||
&return_type);
|
||||
if ty::type_is_nil(return_type) {
|
||||
if return_type.is_nil() {
|
||||
signature.push(ptr::null_mut())
|
||||
} else {
|
||||
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
|
||||
|
|
|
@ -144,7 +144,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
output.push(')');
|
||||
|
||||
match sig.output {
|
||||
ty::FnConverging(result_type) if ty::type_is_nil(result_type) => {}
|
||||
ty::FnConverging(result_type) if result_type.is_nil() => {}
|
||||
ty::FnConverging(result_type) => {
|
||||
output.push_str(" -> ");
|
||||
push_debuginfo_type_name(cx, result_type, true, output);
|
||||
|
|
|
@ -252,7 +252,7 @@ pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let llty = type_of::type_of(bcx.ccx(), const_ty);
|
||||
// HACK(eddyb) get around issues with lifetime intrinsics.
|
||||
let scratch = alloca_no_lifetime(bcx, llty, "const");
|
||||
let lldest = if !ty::type_is_structural(const_ty) {
|
||||
let lldest = if !const_ty.is_structural() {
|
||||
// Cast pointer to slot, because constants have different types.
|
||||
PointerCast(bcx, scratch, val_ty(global))
|
||||
} else {
|
||||
|
@ -790,8 +790,8 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
let ref_ty = // invoked methods have LB regions instantiated:
|
||||
ty::no_late_bound_regions(
|
||||
bcx.tcx(), &ty::ty_fn_ret(method_ty)).unwrap().unwrap();
|
||||
let elt_ty = match ty::deref(ref_ty, true) {
|
||||
bcx.tcx(), &method_ty.fn_ret()).unwrap().unwrap();
|
||||
let elt_ty = match ref_ty.builtin_deref(true) {
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(index_expr.span,
|
||||
"index method didn't return a \
|
||||
|
@ -835,7 +835,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
ccx.int_type());
|
||||
let ix_val = {
|
||||
if ix_size < int_size {
|
||||
if ty::type_is_signed(expr_ty(bcx, idx)) {
|
||||
if expr_ty(bcx, idx).is_signed() {
|
||||
SExt(bcx, ix_val, ccx.int_type())
|
||||
} else { ZExt(bcx, ix_val, ccx.int_type()) }
|
||||
} else if ix_size > int_size {
|
||||
|
@ -845,7 +845,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
};
|
||||
|
||||
let unit_ty = ty::sequence_element_type(bcx.tcx(), base_datum.ty);
|
||||
let unit_ty = base_datum.ty.sequence_element_type(bcx.tcx());
|
||||
|
||||
let (base, len) = base_datum.get_vec_base_and_len(bcx);
|
||||
|
||||
|
@ -1490,7 +1490,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
// panic occur before the ADT as a whole is ready.
|
||||
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
|
||||
|
||||
if ty::type_is_simd(bcx.tcx(), ty) {
|
||||
if ty.is_simd(bcx.tcx()) {
|
||||
// Issue 23112: The original logic appeared vulnerable to same
|
||||
// order-of-eval bug. But, SIMD values are tuple-structs;
|
||||
// i.e. functional record update (FRU) syntax is unavailable.
|
||||
|
@ -1626,11 +1626,11 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
|
||||
let val = datum.to_llscalarish(bcx);
|
||||
let (bcx, llneg) = {
|
||||
if ty::type_is_fp(un_ty) {
|
||||
if un_ty.is_fp() {
|
||||
let result = FNeg(bcx, val, debug_loc);
|
||||
(bcx, result)
|
||||
} else {
|
||||
let is_signed = ty::type_is_signed(un_ty);
|
||||
let is_signed = un_ty.is_signed();
|
||||
let result = Neg(bcx, val, debug_loc);
|
||||
let bcx = if bcx.ccx().check_overflow() && is_signed {
|
||||
let (llty, min) = base::llty_and_min_for_signed_ty(bcx, un_ty);
|
||||
|
@ -1735,14 +1735,14 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let _icx = push_ctxt("trans_eager_binop");
|
||||
|
||||
let tcx = bcx.tcx();
|
||||
let is_simd = ty::type_is_simd(tcx, lhs_t);
|
||||
let is_simd = lhs_t.is_simd(tcx);
|
||||
let intype = if is_simd {
|
||||
ty::simd_type(tcx, lhs_t)
|
||||
lhs_t.simd_type(tcx)
|
||||
} else {
|
||||
lhs_t
|
||||
};
|
||||
let is_float = ty::type_is_fp(intype);
|
||||
let is_signed = ty::type_is_signed(intype);
|
||||
let is_float = intype.is_fp();
|
||||
let is_signed = intype.is_signed();
|
||||
let info = expr_info(binop_expr);
|
||||
|
||||
let binop_debug_loc = binop_expr.debug_loc();
|
||||
|
@ -1999,7 +1999,7 @@ pub fn cast_is_noop<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
return true;
|
||||
}
|
||||
|
||||
match (ty::deref(t_in, true), ty::deref(t_out, true)) {
|
||||
match (t_in.builtin_deref(true), t_out.builtin_deref(true)) {
|
||||
(Some(ty::mt{ ty: t_in, .. }), Some(ty::mt{ ty: t_out, .. })) => {
|
||||
t_in == t_out
|
||||
}
|
||||
|
@ -2108,7 +2108,7 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
ll_t_in = val_ty(discr);
|
||||
(discr, adt::is_discr_signed(&*repr))
|
||||
} else {
|
||||
(datum.to_llscalarish(bcx), ty::type_is_signed(t_in))
|
||||
(datum.to_llscalarish(bcx), t_in.is_signed())
|
||||
};
|
||||
|
||||
let newval = match (r_t_in, r_t_out) {
|
||||
|
@ -2242,7 +2242,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
let ref_ty = // invoked methods have their LB regions instantiated
|
||||
ty::no_late_bound_regions(
|
||||
ccx.tcx(), &ty::ty_fn_ret(method_ty)).unwrap().unwrap();
|
||||
ccx.tcx(), &method_ty.fn_ret()).unwrap().unwrap();
|
||||
let scratch = rvalue_scratch_datum(bcx, ref_ty, "overloaded_deref");
|
||||
|
||||
unpack_result!(bcx, trans_overloaded_op(bcx, expr, method_call,
|
||||
|
@ -2545,13 +2545,13 @@ fn build_unchecked_rshift<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// #1877, #10183: Ensure that input is always valid
|
||||
let rhs = shift_mask_rhs(bcx, rhs, binop_debug_loc);
|
||||
let tcx = bcx.tcx();
|
||||
let is_simd = ty::type_is_simd(tcx, lhs_t);
|
||||
let is_simd = lhs_t.is_simd(tcx);
|
||||
let intype = if is_simd {
|
||||
ty::simd_type(tcx, lhs_t)
|
||||
lhs_t.simd_type(tcx)
|
||||
} else {
|
||||
lhs_t
|
||||
};
|
||||
let is_signed = ty::type_is_signed(intype);
|
||||
let is_signed = intype.is_signed();
|
||||
if is_signed {
|
||||
AShr(bcx, lhs, rhs, binop_debug_loc)
|
||||
} else {
|
||||
|
|
|
@ -324,7 +324,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let llarg_foreign = if foreign_indirect {
|
||||
llarg_rust
|
||||
} else {
|
||||
if ty::type_is_bool(passed_arg_tys[i]) {
|
||||
if passed_arg_tys[i].is_bool() {
|
||||
let val = LoadRangeAssert(bcx, llarg_rust, 0, 2, llvm::False);
|
||||
Trunc(bcx, val, Type::i1(bcx.ccx()))
|
||||
} else {
|
||||
|
@ -450,7 +450,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
|
||||
if !tcx.sess.features.borrow().simd_ffi {
|
||||
let check = |ast_ty: &ast::Ty, ty: ty::Ty| {
|
||||
if ty::type_is_simd(tcx, ty) {
|
||||
if ty.is_simd(tcx) {
|
||||
tcx.sess.span_err(ast_ty.span,
|
||||
&format!("use of SIMD type `{}` in FFI is highly experimental and \
|
||||
may result in invalid code",
|
||||
|
@ -777,7 +777,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
// pointer). It makes adapting types easier, since we can
|
||||
// always just bitcast pointers.
|
||||
if !foreign_indirect {
|
||||
llforeign_arg = if ty::type_is_bool(rust_ty) {
|
||||
llforeign_arg = if rust_ty.is_bool() {
|
||||
let lltemp = builder.alloca(Type::bool(ccx), "");
|
||||
builder.store(builder.zext(llforeign_arg, Type::bool(ccx)), lltemp);
|
||||
lltemp
|
||||
|
@ -799,7 +799,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let llrust_arg = if rust_indirect || type_is_fat_ptr(ccx.tcx(), rust_ty) {
|
||||
llforeign_arg
|
||||
} else {
|
||||
if ty::type_is_bool(rust_ty) {
|
||||
if rust_ty.is_bool() {
|
||||
let tmp = builder.load_range_assert(llforeign_arg, 0, 2, llvm::False);
|
||||
builder.trunc(tmp, Type::i1(ccx))
|
||||
} else if type_of::type_of(ccx, rust_ty).is_aggregate() {
|
||||
|
|
|
@ -392,7 +392,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
|
|||
let ccx = bcx.ccx();
|
||||
// First get the size of all statically known fields.
|
||||
// Don't use type_of::sizing_type_of because that expects t to be sized.
|
||||
assert!(!ty::type_is_simd(bcx.tcx(), t));
|
||||
assert!(!t.is_simd(bcx.tcx()));
|
||||
let repr = adt::represent_type(ccx, t);
|
||||
let sizing_type = adt::sizing_type_of(ccx, &*repr, true);
|
||||
let sized_size = C_uint(ccx, llsize_of_alloc(ccx, sizing_type));
|
||||
|
@ -426,7 +426,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
|
|||
(Load(bcx, size_ptr), Load(bcx, align_ptr))
|
||||
}
|
||||
ty::TySlice(_) | ty::TyStr => {
|
||||
let unit_ty = ty::sequence_element_type(bcx.tcx(), t);
|
||||
let unit_ty = t.sequence_element_type(bcx.tcx());
|
||||
// The info in this case is the length of the str, so the size is that
|
||||
// times the unit size.
|
||||
let llunit_ty = sizing_type_of(bcx.ccx(), unit_ty);
|
||||
|
|
|
@ -253,7 +253,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
fn vec_types_from_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, vec_expr: &ast::Expr)
|
||||
-> VecTypes<'tcx> {
|
||||
let vec_ty = node_id_type(bcx, vec_expr.id);
|
||||
vec_types(bcx, ty::sequence_element_type(bcx.tcx(), vec_ty))
|
||||
vec_types(bcx, vec_ty.sequence_element_type(bcx.tcx()))
|
||||
}
|
||||
|
||||
fn vec_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, unit_ty: Ty<'tcx>)
|
||||
|
|
|
@ -222,9 +222,9 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
|||
}
|
||||
|
||||
ty::TyStruct(..) => {
|
||||
if ty::type_is_simd(cx.tcx(), t) {
|
||||
let llet = type_of(cx, ty::simd_type(cx.tcx(), t));
|
||||
let n = ty::simd_size(cx.tcx(), t) as u64;
|
||||
if t.is_simd(cx.tcx()) {
|
||||
let llet = type_of(cx, t.simd_type(cx.tcx()));
|
||||
let n = t.simd_size(cx.tcx()) as u64;
|
||||
ensure_array_fits_in_address_space(cx, llet, n, t);
|
||||
Type::vector(&llet, n)
|
||||
} else {
|
||||
|
@ -245,7 +245,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
|||
}
|
||||
|
||||
pub fn foreign_arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
|
||||
if ty::type_is_bool(t) {
|
||||
if t.is_bool() {
|
||||
Type::i1(cx)
|
||||
} else {
|
||||
type_of(cx, t)
|
||||
|
@ -253,7 +253,7 @@ pub fn foreign_arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -
|
|||
}
|
||||
|
||||
pub fn arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
|
||||
if ty::type_is_bool(t) {
|
||||
if t.is_bool() {
|
||||
Type::i1(cx)
|
||||
} else if type_is_immediate(cx, t) && type_of(cx, t).is_aggregate() {
|
||||
// We want to pass small aggregates as immediate values, but using an aggregate LLVM type
|
||||
|
@ -402,9 +402,9 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
adt::type_of(cx, &*repr)
|
||||
}
|
||||
ty::TyStruct(did, ref substs) => {
|
||||
if ty::type_is_simd(cx.tcx(), t) {
|
||||
let llet = in_memory_type_of(cx, ty::simd_type(cx.tcx(), t));
|
||||
let n = ty::simd_size(cx.tcx(), t) as u64;
|
||||
if t.is_simd(cx.tcx()) {
|
||||
let llet = in_memory_type_of(cx, t.simd_type(cx.tcx()));
|
||||
let n = t.simd_size(cx.tcx()) as u64;
|
||||
ensure_array_fits_in_address_space(cx, llet, n, t);
|
||||
Type::vector(&llet, n)
|
||||
} else {
|
||||
|
@ -434,7 +434,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
// If this was an enum or struct, fill in the type now.
|
||||
match t.sty {
|
||||
ty::TyEnum(..) | ty::TyStruct(..) | ty::TyClosure(..)
|
||||
if !ty::type_is_simd(cx.tcx(), t) => {
|
||||
if !t.is_simd(cx.tcx()) => {
|
||||
let repr = adt::represent_type(cx, t);
|
||||
adt::finish_type_of(cx, &*repr, &mut llty);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let rhs_ty = fcx.expr_ty(end);
|
||||
|
||||
// Check that both end-points are of numeric or char type.
|
||||
let numeric_or_char = |t| ty::type_is_numeric(t) || ty::type_is_char(t);
|
||||
let numeric_or_char = |ty: Ty| ty.is_numeric() || ty.is_char();
|
||||
let lhs_compat = numeric_or_char(lhs_ty);
|
||||
let rhs_compat = numeric_or_char(rhs_ty);
|
||||
|
||||
|
@ -303,8 +303,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
|
||||
ty::mk_slice(tcx, tcx.mk_region(region), ty::mt {
|
||||
ty: inner_ty,
|
||||
mutbl: ty::deref(expected_ty, true).map(|mt| mt.mutbl)
|
||||
.unwrap_or(ast::MutImmutable)
|
||||
mutbl: expected_ty.builtin_deref(true).map(|mt| mt.mutbl)
|
||||
.unwrap_or(ast::MutImmutable)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
@ -321,7 +321,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
}
|
||||
if let Some(ref slice) = *slice {
|
||||
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
|
||||
let mutbl = ty::deref(expected_ty, true)
|
||||
let mutbl = expected_ty.builtin_deref(true)
|
||||
.map_or(ast::MutImmutable, |mt| mt.mutbl);
|
||||
|
||||
let slice_ty = ty::mk_slice(tcx, tcx.mk_region(region), ty::mt {
|
||||
|
@ -411,7 +411,7 @@ pub fn check_dereferencable<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let tcx = pcx.fcx.ccx.tcx;
|
||||
if pat_is_binding(&tcx.def_map, inner) {
|
||||
let expected = fcx.infcx().shallow_resolve(expected);
|
||||
ty::deref(expected, true).map_or(true, |mt| match mt.ty.sty {
|
||||
expected.builtin_deref(true).map_or(true, |mt| match mt.ty.sty {
|
||||
ty::TyTrait(_) => {
|
||||
// This is "x = SomeTrait" being reduced from
|
||||
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
|
||||
|
@ -633,8 +633,8 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
|
||||
let ctor_scheme = ty::lookup_item_type(tcx, enum_def);
|
||||
let ctor_predicates = ty::lookup_predicates(tcx, enum_def);
|
||||
let path_scheme = if ty::is_fn_ty(ctor_scheme.ty) {
|
||||
let fn_ret = ty::no_late_bound_regions(tcx, &ty::ty_fn_ret(ctor_scheme.ty)).unwrap();
|
||||
let path_scheme = if ctor_scheme.ty.is_fn() {
|
||||
let fn_ret = ty::no_late_bound_regions(tcx, &ctor_scheme.ty.fn_ret()).unwrap();
|
||||
ty::TypeScheme {
|
||||
ty: fn_ret.unwrap(),
|
||||
generics: ctor_scheme.generics,
|
||||
|
|
|
@ -360,7 +360,7 @@ impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> {
|
|||
// refactor it.)
|
||||
let method_sig =
|
||||
ty::no_late_bound_regions(fcx.tcx(),
|
||||
ty::ty_fn_sig(method_callee.ty)).unwrap();
|
||||
method_callee.ty.fn_sig()).unwrap();
|
||||
|
||||
debug!("attempt_resolution: method_callee={:?}",
|
||||
method_callee);
|
||||
|
|
|
@ -169,7 +169,7 @@ impl<'tcx> CastCheck<'tcx> {
|
|||
fn trivial_cast_lint<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) {
|
||||
let t_cast = self.cast_ty;
|
||||
let t_expr = self.expr_ty;
|
||||
if ty::type_is_numeric(t_cast) && ty::type_is_numeric(t_expr) {
|
||||
if t_cast.is_numeric() && t_expr.is_numeric() {
|
||||
fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_NUMERIC_CASTS,
|
||||
self.expr.id,
|
||||
self.span,
|
||||
|
|
|
@ -536,8 +536,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
|||
}
|
||||
Some(ty::AutoPtr(_, _)) => {
|
||||
(adr.autoderefs, adr.unsize.map(|target| {
|
||||
ty::deref(target, false)
|
||||
.expect("fixup: AutoPtr is not &T").ty
|
||||
target.builtin_deref(false)
|
||||
.expect("fixup: AutoPtr is not &T").ty
|
||||
}))
|
||||
}
|
||||
Some(_) => {
|
||||
|
|
|
@ -229,7 +229,7 @@ impl<'tcx> Expectation<'tcx> {
|
|||
match *self {
|
||||
ExpectHasType(ety) => {
|
||||
let ety = fcx.infcx().shallow_resolve(ety);
|
||||
if !ty::type_is_ty_var(ety) {
|
||||
if !ety.is_ty_var() {
|
||||
ExpectHasType(ety)
|
||||
} else {
|
||||
NoExpectation
|
||||
|
@ -1146,7 +1146,7 @@ fn report_cast_to_unsized_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
ast::MutMutable => "mut ",
|
||||
ast::MutImmutable => ""
|
||||
};
|
||||
if ty::type_is_trait(t_cast) {
|
||||
if t_cast.is_trait() {
|
||||
match fcx.tcx().sess.codemap().span_to_snippet(t_span) {
|
||||
Ok(s) => {
|
||||
fcx.tcx().sess.span_suggestion(t_span,
|
||||
|
@ -1948,7 +1948,7 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
UnresolvedTypeAction::Ignore => {
|
||||
// We can continue even when the type cannot be resolved
|
||||
// (i.e. it is an inference variable) because `ty::deref`
|
||||
// (i.e. it is an inference variable) because `Ty::builtin_deref`
|
||||
// and `try_overloaded_deref` both simply return `None`
|
||||
// in such a case without producing spurious errors.
|
||||
fcx.resolve_type_vars_if_possible(t)
|
||||
|
@ -1964,7 +1964,7 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
// Otherwise, deref if type is derefable:
|
||||
let mt = match ty::deref(resolved_t, false) {
|
||||
let mt = match resolved_t.builtin_deref(false) {
|
||||
Some(mt) => Some(mt),
|
||||
None => {
|
||||
let method_call =
|
||||
|
@ -2045,7 +2045,7 @@ fn make_overloaded_lvalue_return_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
Some(method) => {
|
||||
// extract method method return type, which will be &T;
|
||||
// all LB regions should have been instantiated during method lookup
|
||||
let ret_ty = ty::ty_fn_ret(method.ty);
|
||||
let ret_ty = method.ty.fn_ret();
|
||||
let ret_ty = ty::no_late_bound_regions(fcx.tcx(), &ret_ty).unwrap().unwrap();
|
||||
|
||||
if let Some(method_call) = method_call {
|
||||
|
@ -2053,7 +2053,7 @@ fn make_overloaded_lvalue_return_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
// method returns &T, but the type as visible to user is T, so deref
|
||||
ty::deref(ret_ty, true)
|
||||
ret_ty.builtin_deref(true)
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
|
@ -2125,7 +2125,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let input_ty = fcx.infcx().next_ty_var();
|
||||
|
||||
// First, try built-in indexing.
|
||||
match (ty::index(adjusted_ty), &index_ty.sty) {
|
||||
match (adjusted_ty.builtin_index(), &index_ty.sty) {
|
||||
(Some(ty), &ty::TyUint(ast::TyUs)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => {
|
||||
debug!("try_index_step: success, using built-in indexing");
|
||||
// If we had `[T; N]`, we should've caught it before unsizing to `[T]`.
|
||||
|
@ -3160,7 +3160,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
ast::UnDeref => {
|
||||
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
|
||||
oprnd_t = match ty::deref(oprnd_t, true) {
|
||||
oprnd_t = match oprnd_t.builtin_deref(true) {
|
||||
Some(mt) => mt.ty,
|
||||
None => match try_overloaded_deref(fcx, expr.span,
|
||||
Some(MethodCall::expr(expr.id)),
|
||||
|
@ -3179,8 +3179,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
ast::UnNot => {
|
||||
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
|
||||
oprnd_t);
|
||||
if !(ty::type_is_integral(oprnd_t) ||
|
||||
oprnd_t.sty == ty::TyBool) {
|
||||
if !(oprnd_t.is_integral() || oprnd_t.sty == ty::TyBool) {
|
||||
oprnd_t = op::check_user_unop(fcx, "!", "not",
|
||||
tcx.lang_items.not_trait(),
|
||||
expr, &**oprnd, oprnd_t, unop);
|
||||
|
@ -3189,8 +3188,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
ast::UnNeg => {
|
||||
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
|
||||
oprnd_t);
|
||||
if !(ty::type_is_integral(oprnd_t) ||
|
||||
ty::type_is_fp(oprnd_t)) {
|
||||
if !(oprnd_t.is_integral() || oprnd_t.is_fp()) {
|
||||
oprnd_t = op::check_user_unop(fcx, "-", "neg",
|
||||
tcx.lang_items.neg_trait(),
|
||||
expr, &**oprnd, oprnd_t, unop);
|
||||
|
@ -4201,7 +4199,7 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
|
|||
span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous");
|
||||
return;
|
||||
}
|
||||
if !ty::type_is_machine(e) {
|
||||
if !e.is_machine() {
|
||||
span_err!(tcx.sess, sp, E0077,
|
||||
"SIMD vector element type should be machine type");
|
||||
return;
|
||||
|
@ -4870,11 +4868,11 @@ fn structurally_resolve_type_or_else<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
{
|
||||
let mut ty = fcx.resolve_type_vars_if_possible(ty);
|
||||
|
||||
if ty::type_is_ty_var(ty) {
|
||||
if ty.is_ty_var() {
|
||||
let alternative = f();
|
||||
|
||||
// If not, error.
|
||||
if ty::type_is_ty_var(alternative) || alternative.references_error() {
|
||||
if alternative.is_ty_var() || alternative.references_error() {
|
||||
fcx.type_error_message(sp, |_actual| {
|
||||
"the type of this value must be known in this context".to_string()
|
||||
}, ty, None);
|
||||
|
@ -4933,15 +4931,12 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
if tps.is_empty() { return; }
|
||||
let mut tps_used: Vec<_> = repeat(false).take(tps.len()).collect();
|
||||
|
||||
ty::walk_ty(ty, |t| {
|
||||
match t.sty {
|
||||
ty::TyParam(ParamTy {idx, ..}) => {
|
||||
debug!("Found use of ty param num {}", idx);
|
||||
tps_used[idx as usize] = true;
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
});
|
||||
for leaf_ty in ty.walk() {
|
||||
if let ty::TyParam(ParamTy {idx, ..}) = leaf_ty.sty {
|
||||
debug!("Found use of ty param num {}", idx);
|
||||
tps_used[idx as usize] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (i, b) in tps_used.iter().enumerate() {
|
||||
if !*b {
|
||||
|
|
|
@ -86,7 +86,7 @@ pub fn check_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// traits, because their return type is not bool. Perhaps this
|
||||
// should change, but for now if LHS is SIMD we go down a
|
||||
// different path that bypassess all traits.
|
||||
if ty::type_is_simd(fcx.tcx(), lhs_ty) {
|
||||
if lhs_ty.is_simd(fcx.tcx()) {
|
||||
check_expr_coercable_to_type(fcx, rhs_expr, lhs_ty);
|
||||
let rhs_ty = fcx.resolve_type_vars_if_possible(fcx.expr_ty(lhs_expr));
|
||||
let return_ty = enforce_builtin_binop_types(fcx, lhs_expr, lhs_ty, rhs_expr, rhs_ty, op);
|
||||
|
@ -122,8 +122,7 @@ pub fn check_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// can't pin this down to a specific impl.
|
||||
let rhs_ty = fcx.resolve_type_vars_if_possible(rhs_ty);
|
||||
if
|
||||
!ty::type_is_ty_var(lhs_ty) &&
|
||||
!ty::type_is_ty_var(rhs_ty) &&
|
||||
!lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() &&
|
||||
is_builtin_binop(fcx.tcx(), lhs_ty, rhs_ty, op)
|
||||
{
|
||||
let builtin_return_ty =
|
||||
|
@ -157,7 +156,7 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
BinOpCategory::Shift => {
|
||||
// For integers, the shift amount can be of any integral
|
||||
// type. For simd, the type must match exactly.
|
||||
if ty::type_is_simd(tcx, lhs_ty) {
|
||||
if lhs_ty.is_simd(tcx) {
|
||||
demand::suptype(fcx, rhs_expr.span, lhs_ty, rhs_ty);
|
||||
}
|
||||
|
||||
|
@ -177,12 +176,12 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
demand::suptype(fcx, rhs_expr.span, lhs_ty, rhs_ty);
|
||||
|
||||
// if this is simd, result is same as lhs, else bool
|
||||
if ty::type_is_simd(tcx, lhs_ty) {
|
||||
let unit_ty = ty::simd_type(tcx, lhs_ty);
|
||||
if lhs_ty.is_simd(tcx) {
|
||||
let unit_ty = lhs_ty.simd_type(tcx);
|
||||
debug!("enforce_builtin_binop_types: lhs_ty={:?} unit_ty={:?}",
|
||||
lhs_ty,
|
||||
unit_ty);
|
||||
if !ty::type_is_integral(unit_ty) {
|
||||
if !unit_ty.is_integral() {
|
||||
tcx.sess.span_err(
|
||||
lhs_expr.span,
|
||||
&format!("binary comparison operation `{}` not supported \
|
||||
|
@ -335,7 +334,7 @@ fn lookup_op_method<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
|
|||
|
||||
// extract return type for method; all late bound regions
|
||||
// should have been instantiated by now
|
||||
let ret_ty = ty::ty_fn_ret(method_ty);
|
||||
let ret_ty = method_ty.fn_ret();
|
||||
Ok(ty::no_late_bound_regions(fcx.tcx(), &ret_ty).unwrap().unwrap())
|
||||
}
|
||||
None => {
|
||||
|
@ -429,29 +428,29 @@ fn is_builtin_binop<'tcx>(cx: &ty::ctxt<'tcx>,
|
|||
|
||||
BinOpCategory::Shift => {
|
||||
lhs.references_error() || rhs.references_error() ||
|
||||
ty::type_is_integral(lhs) && ty::type_is_integral(rhs) ||
|
||||
ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs)
|
||||
lhs.is_integral() && rhs.is_integral() ||
|
||||
lhs.is_simd(cx) && rhs.is_simd(cx)
|
||||
}
|
||||
|
||||
BinOpCategory::Math => {
|
||||
lhs.references_error() || rhs.references_error() ||
|
||||
ty::type_is_integral(lhs) && ty::type_is_integral(rhs) ||
|
||||
ty::type_is_floating_point(lhs) && ty::type_is_floating_point(rhs) ||
|
||||
ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs)
|
||||
lhs.is_integral() && rhs.is_integral() ||
|
||||
lhs.is_floating_point() && rhs.is_floating_point() ||
|
||||
lhs.is_simd(cx) && rhs.is_simd(cx)
|
||||
}
|
||||
|
||||
BinOpCategory::Bitwise => {
|
||||
lhs.references_error() || rhs.references_error() ||
|
||||
ty::type_is_integral(lhs) && ty::type_is_integral(rhs) ||
|
||||
ty::type_is_floating_point(lhs) && ty::type_is_floating_point(rhs) ||
|
||||
ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs) ||
|
||||
ty::type_is_bool(lhs) && ty::type_is_bool(rhs)
|
||||
lhs.is_integral() && rhs.is_integral() ||
|
||||
lhs.is_floating_point() && rhs.is_floating_point() ||
|
||||
lhs.is_simd(cx) && rhs.is_simd(cx) ||
|
||||
lhs.is_bool() && rhs.is_bool()
|
||||
}
|
||||
|
||||
BinOpCategory::Comparison => {
|
||||
lhs.references_error() || rhs.references_error() ||
|
||||
ty::type_is_scalar(lhs) && ty::type_is_scalar(rhs) ||
|
||||
ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs)
|
||||
lhs.is_scalar() && rhs.is_scalar() ||
|
||||
lhs.is_simd(cx) && rhs.is_simd(cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -662,7 +662,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
|
|||
constrain_call(rcx, expr, Some(&**base),
|
||||
None::<ast::Expr>.iter(), true);
|
||||
let fn_ret = // late-bound regions in overloaded method calls are instantiated
|
||||
ty::no_late_bound_regions(rcx.tcx(), &ty::ty_fn_ret(method.ty)).unwrap();
|
||||
ty::no_late_bound_regions(rcx.tcx(), &method.ty.fn_ret()).unwrap();
|
||||
fn_ret.unwrap()
|
||||
}
|
||||
None => rcx.resolve_node_type(base.id)
|
||||
|
@ -891,7 +891,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
|
|||
|
||||
// Treat overloaded autoderefs as if an AutoRef adjustment
|
||||
// was applied on the base type, as that is always the case.
|
||||
let fn_sig = ty::ty_fn_sig(method.ty);
|
||||
let fn_sig = method.ty.fn_sig();
|
||||
let fn_sig = // late-bound regions should have been instantiated
|
||||
ty::no_late_bound_regions(rcx.tcx(), fn_sig).unwrap();
|
||||
let self_ty = fn_sig.inputs[0];
|
||||
|
@ -937,7 +937,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
|
|||
r_deref_expr, *r_ptr);
|
||||
}
|
||||
|
||||
match ty::deref(derefd_ty, true) {
|
||||
match derefd_ty.builtin_deref(true) {
|
||||
Some(mt) => derefd_ty = mt.ty,
|
||||
/* if this type can't be dereferenced, then there's already an error
|
||||
in the session saying so. Just bail out for now */
|
||||
|
|
|
@ -661,7 +661,7 @@ fn enum_variants<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// enum def'n, and hence will all be early bound
|
||||
let arg_tys =
|
||||
ty::no_late_bound_regions(
|
||||
fcx.tcx(), &ty::ty_fn_args(ctor_ty)).unwrap();
|
||||
fcx.tcx(), &ctor_ty.fn_args()).unwrap();
|
||||
AdtVariant {
|
||||
fields: args.iter().enumerate().map(|(index, arg)| {
|
||||
let arg_ty = arg_tys[index];
|
||||
|
|
|
@ -95,7 +95,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
let rhs_ty = self.fcx.node_ty(rhs.id);
|
||||
let rhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&rhs_ty);
|
||||
|
||||
if ty::type_is_scalar(lhs_ty) && ty::type_is_scalar(rhs_ty) {
|
||||
if lhs_ty.is_scalar() && rhs_ty.is_scalar() {
|
||||
self.fcx.inh.method_map.borrow_mut().remove(&MethodCall::expr(e.id));
|
||||
|
||||
// weird but true: the by-ref binops put an
|
||||
|
|
|
@ -1882,16 +1882,15 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
|||
let ty = ast_ty_to_ty(&ccx.icx(&()), &ExplicitRscope, &**path);
|
||||
let cur_idx = index;
|
||||
|
||||
ty::walk_ty(ty, |t| {
|
||||
match t.sty {
|
||||
ty::TyParam(p) => if p.idx > cur_idx {
|
||||
for leaf_ty in ty.walk() {
|
||||
if let ty::TyParam(p) = leaf_ty.sty {
|
||||
if p.idx > cur_idx {
|
||||
span_err!(tcx.sess, path.span, E0128,
|
||||
"type parameters with a default cannot use \
|
||||
forward declared identifiers");
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Some(ty)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ pub enum Parameter {
|
|||
/// by `ty` (see RFC 447).
|
||||
pub fn parameters_for_type<'tcx>(ty: Ty<'tcx>) -> Vec<Parameter> {
|
||||
let mut result = vec![];
|
||||
ty::maybe_walk_ty(ty, |t| {
|
||||
ty.maybe_walk(|t| {
|
||||
if let ty::TyProjection(..) = t.sty {
|
||||
false // projections are not injective.
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue