Track fn type and lifetime parameters in TyFnDef.
This commit is contained in:
parent
b423a0f9ef
commit
ffa0860467
@ -44,7 +44,7 @@ enum RootUnsafeContext {
|
||||
|
||||
fn type_is_unsafe_function(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyFnDef(_, ref f) |
|
||||
ty::TyFnDef(_, _, ref f) |
|
||||
ty::TyFnPtr(ref f) => f.unsafety == hir::Unsafety::Unsafe,
|
||||
_ => false,
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ struct IntrinsicCheckingVisitor<'a, 'tcx: 'a> {
|
||||
impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
|
||||
let intrinsic = match self.tcx.lookup_item_type(def_id).ty.sty {
|
||||
ty::TyFnDef(_, ref bfty) => bfty.abi == RustIntrinsic,
|
||||
ty::TyFnDef(_, _, ref bfty) => bfty.abi == RustIntrinsic,
|
||||
_ => return false
|
||||
};
|
||||
intrinsic && self.tcx.item_name(def_id).as_str() == "transmute"
|
||||
@ -238,7 +238,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
Def::Fn(did) if self.def_id_is_transmute(did) => {
|
||||
let typ = self.tcx.node_id_to_type(expr.id);
|
||||
match typ.sty {
|
||||
ty::TyFnDef(_, ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
|
||||
ty::TyFnDef(_, _, ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
|
||||
if let ty::FnConverging(to) = bare_fn_ty.sig.0.output {
|
||||
let from = bare_fn_ty.sig.0.inputs[0];
|
||||
self.check_transmute(expr.span, from, to, expr.id);
|
||||
|
@ -1286,7 +1286,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
// provide an impl, but only for suitable `fn` pointers
|
||||
ty::TyFnDef(_, &ty::BareFnTy {
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
@ -155,7 +155,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
match *adjustment {
|
||||
AdjustReifyFnPointer => {
|
||||
match self.sty {
|
||||
ty::TyFnDef(_, b) => {
|
||||
ty::TyFnDef(_, _, b) => {
|
||||
cx.mk_ty(ty::TyFnPtr(b))
|
||||
}
|
||||
_ => {
|
||||
|
@ -41,7 +41,6 @@ use std::borrow::Borrow;
|
||||
use std::cell::{Cell, RefCell, Ref};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::rc::Rc;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast::{self, Name, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::parse::token::special_idents;
|
||||
@ -946,30 +945,15 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn mk_fn_def(&self, def_id: DefId,
|
||||
substs: &'tcx Substs<'tcx>,
|
||||
fty: BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyFnDef(def_id, self.mk_bare_fn(fty)))
|
||||
self.mk_ty(TyFnDef(def_id, substs, self.mk_bare_fn(fty)))
|
||||
}
|
||||
|
||||
pub fn mk_fn_ptr(&self, fty: BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyFnPtr(self.mk_bare_fn(fty)))
|
||||
}
|
||||
|
||||
pub fn mk_ctor_fn(&self,
|
||||
def_id: DefId,
|
||||
input_tys: &[Ty<'tcx>],
|
||||
output: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let input_args = input_tys.iter().cloned().collect();
|
||||
self.mk_fn_def(def_id, BareFnTy {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: input_args,
|
||||
output: ty::FnConverging(output),
|
||||
variadic: false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn mk_trait(&self,
|
||||
principal: ty::PolyTraitRef<'tcx>,
|
||||
bounds: ExistentialBounds<'tcx>)
|
||||
|
@ -83,7 +83,7 @@ pub fn simplify_type(tcx: &TyCtxt,
|
||||
ty::TyTuple(ref tys) => {
|
||||
Some(TupleSimplifiedType(tys.len()))
|
||||
}
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => {
|
||||
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => {
|
||||
Some(FunctionSimplifiedType(f.sig.0.inputs.len()))
|
||||
}
|
||||
ty::TyProjection(_) | ty::TyParam(_) => {
|
||||
|
@ -134,7 +134,12 @@ impl FlagComputation {
|
||||
self.add_tys(&ts[..]);
|
||||
}
|
||||
|
||||
&ty::TyFnDef(_, ref f) | &ty::TyFnPtr(ref f) => {
|
||||
&ty::TyFnDef(_, substs, ref f) => {
|
||||
self.add_substs(substs);
|
||||
self.add_fn_sig(&f.sig);
|
||||
}
|
||||
|
||||
&ty::TyFnPtr(ref f) => {
|
||||
self.add_fn_sig(&f.sig);
|
||||
}
|
||||
}
|
||||
|
@ -568,11 +568,13 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
||||
}
|
||||
}
|
||||
|
||||
(&ty::TyFnDef(a_def_id, a_fty), &ty::TyFnDef(b_def_id, b_fty))
|
||||
(&ty::TyFnDef(a_def_id, a_substs, a_fty),
|
||||
&ty::TyFnDef(b_def_id, b_substs, b_fty))
|
||||
if a_def_id == b_def_id =>
|
||||
{
|
||||
let substs = try!(relate_substs(relation, None, a_substs, b_substs));
|
||||
let fty = try!(relation.relate(a_fty, b_fty));
|
||||
Ok(tcx.mk_fn_def(a_def_id, fty))
|
||||
Ok(tcx.mk_fn_def(a_def_id, tcx.mk_substs(substs), fty))
|
||||
}
|
||||
|
||||
(&ty::TyFnPtr(a_fty), &ty::TyFnPtr(b_fty)) =>
|
||||
|
@ -282,9 +282,12 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
}
|
||||
ty::TyTrait(ref trait_ty) => ty::TyTrait(trait_ty.fold_with(folder)),
|
||||
ty::TyTuple(ref ts) => ty::TyTuple(ts.fold_with(folder)),
|
||||
ty::TyFnDef(def_id, ref f) => {
|
||||
ty::TyFnDef(def_id, substs, ref f) => {
|
||||
let substs = substs.fold_with(folder);
|
||||
let bfn = f.fold_with(folder);
|
||||
ty::TyFnDef(def_id, folder.tcx().mk_bare_fn(bfn))
|
||||
ty::TyFnDef(def_id,
|
||||
folder.tcx().mk_substs(substs),
|
||||
folder.tcx().mk_bare_fn(bfn))
|
||||
}
|
||||
ty::TyFnPtr(ref f) => {
|
||||
let bfn = f.fold_with(folder);
|
||||
@ -322,7 +325,10 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
ty::TyEnum(_tid, ref substs) => substs.visit_with(visitor),
|
||||
ty::TyTrait(ref trait_ty) => trait_ty.visit_with(visitor),
|
||||
ty::TyTuple(ref ts) => ts.visit_with(visitor),
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => f.visit_with(visitor),
|
||||
ty::TyFnDef(_, substs, ref f) => {
|
||||
substs.visit_with(visitor) || f.visit_with(visitor)
|
||||
}
|
||||
ty::TyFnPtr(ref f) => f.visit_with(visitor),
|
||||
ty::TyRef(r, ref tm) => r.visit_with(visitor) || tm.visit_with(visitor),
|
||||
ty::TyStruct(_did, ref substs) => substs.visit_with(visitor),
|
||||
ty::TyClosure(_did, ref substs) => substs.visit_with(visitor),
|
||||
|
@ -129,9 +129,7 @@ pub enum TypeVariants<'tcx> {
|
||||
|
||||
/// The anonymous type of a function declaration/definition. Each
|
||||
/// function has a unique type.
|
||||
/// FIXME: Does this need to include substitutions?
|
||||
/// `g::<i32>` and `g::<u32>` should have different types.
|
||||
TyFnDef(DefId, &'tcx BareFnTy<'tcx>),
|
||||
TyFnDef(DefId, &'tcx Substs<'tcx>, &'tcx BareFnTy<'tcx>),
|
||||
|
||||
/// A pointer to a function. Written as `fn() -> i32`.
|
||||
/// FIXME: This is currently also used to represent the callee of a method;
|
||||
@ -1142,7 +1140,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
pub fn fn_sig(&self) -> &'tcx PolyFnSig<'tcx> {
|
||||
match self.sty {
|
||||
TyFnDef(_, ref f) | TyFnPtr(ref f) => &f.sig,
|
||||
TyFnDef(_, _, ref f) | TyFnPtr(ref f) => &f.sig,
|
||||
_ => panic!("Ty::fn_sig() called on non-fn type: {:?}", self)
|
||||
}
|
||||
}
|
||||
@ -1150,7 +1148,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
/// Returns the ABI of the given function.
|
||||
pub fn fn_abi(&self) -> abi::Abi {
|
||||
match self.sty {
|
||||
TyFnDef(_, ref f) | TyFnPtr(ref f) => f.abi,
|
||||
TyFnDef(_, _, ref f) | TyFnPtr(ref f) => f.abi,
|
||||
_ => panic!("Ty::fn_abi() called on non-fn type"),
|
||||
}
|
||||
}
|
||||
|
@ -514,13 +514,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
region(state, *r);
|
||||
mt(state, m);
|
||||
}
|
||||
TyFnDef(def_id, ref b) => {
|
||||
TyFnDef(def_id, _, _) => {
|
||||
byte!(14);
|
||||
hash!(def_id);
|
||||
hash!(b.unsafety);
|
||||
hash!(b.abi);
|
||||
fn_sig(state, &b.sig);
|
||||
return false;
|
||||
}
|
||||
TyFnPtr(ref b) => {
|
||||
byte!(15);
|
||||
|
@ -98,7 +98,11 @@ fn push_subtypes<'tcx>(stack: &mut Vec<Ty<'tcx>>, parent_ty: Ty<'tcx>) {
|
||||
ty::TyTuple(ref ts) => {
|
||||
push_reversed(stack, ts);
|
||||
}
|
||||
ty::TyFnDef(_, ref ft) | ty::TyFnPtr(ref ft) => {
|
||||
ty::TyFnDef(_, substs, ref ft) => {
|
||||
push_reversed(stack, substs.types.as_slice());
|
||||
push_sig_subtypes(stack, &ft.sig);
|
||||
}
|
||||
ty::TyFnPtr(ref ft) => {
|
||||
push_sig_subtypes(stack, &ft.sig);
|
||||
}
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
TyFnDef(def_id, ref bare_fn) => {
|
||||
TyFnDef(def_id, substs, ref bare_fn) => {
|
||||
if bare_fn.unsafety == hir::Unsafety::Unsafe {
|
||||
try!(write!(f, "unsafe "));
|
||||
}
|
||||
|
@ -1065,7 +1065,7 @@ impl LateLintPass for MutableTransmutes {
|
||||
}
|
||||
let typ = cx.tcx.node_id_to_type(expr.id);
|
||||
match typ.sty {
|
||||
ty::TyFnDef(_, ref bare_fn) if bare_fn.abi == RustIntrinsic => {
|
||||
ty::TyFnDef(_, _, ref bare_fn) if bare_fn.abi == RustIntrinsic => {
|
||||
if let ty::FnConverging(to) = bare_fn.sig.0.output {
|
||||
let from = bare_fn.sig.0.inputs[0];
|
||||
return Some((&from.sty, &to.sty));
|
||||
@ -1079,7 +1079,7 @@ impl LateLintPass for MutableTransmutes {
|
||||
|
||||
fn def_id_is_transmute(cx: &LateContext, def_id: DefId) -> bool {
|
||||
match cx.tcx.lookup_item_type(def_id).ty.sty {
|
||||
ty::TyFnDef(_, ref bfty) if bfty.abi == RustIntrinsic => (),
|
||||
ty::TyFnDef(_, _, ref bfty) if bfty.abi == RustIntrinsic => (),
|
||||
_ => return false
|
||||
}
|
||||
cx.tcx.with_path(def_id, |path| match path.last() {
|
||||
|
@ -472,7 +472,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
||||
variant.name,
|
||||
ctor_ty);
|
||||
let field_tys = match ctor_ty.sty {
|
||||
ty::TyFnDef(_, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
|
||||
ref inputs, ..
|
||||
}), ..}) => {
|
||||
// tuple-struct constructors don't have escaping regions
|
||||
@ -988,7 +988,7 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
|
||||
let predicates = doc_predicates(item_doc, tcx, cdata, tag_method_ty_generics);
|
||||
let ity = tcx.lookup_item_type(def_id).ty;
|
||||
let fty = match ity.sty {
|
||||
ty::TyFnDef(_, fty) => fty.clone(),
|
||||
ty::TyFnDef(_, _, fty) => fty.clone(),
|
||||
_ => tcx.sess.bug(&format!(
|
||||
"the type {:?} of the method {:?} is not a function?",
|
||||
ity, name))
|
||||
@ -1582,7 +1582,7 @@ pub fn is_extern_item(cdata: Cmd, id: DefIndex, tcx: &TyCtxt) -> bool {
|
||||
let ty::TypeScheme { generics, ty } = get_type(cdata, id, tcx);
|
||||
let no_generics = generics.types.is_empty();
|
||||
match ty.sty {
|
||||
ty::TyFnDef(_, fn_ty) | ty::TyFnPtr(fn_ty)
|
||||
ty::TyFnDef(_, _, fn_ty) | ty::TyFnPtr(fn_ty)
|
||||
if fn_ty.abi != Abi::Rust => return no_generics,
|
||||
_ => no_generics,
|
||||
}
|
||||
|
@ -380,7 +380,8 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||
}
|
||||
'F' => {
|
||||
let def_id = self.parse_def();
|
||||
return tcx.mk_fn_def(def_id, self.parse_bare_fn_ty());
|
||||
let substs = self.tcx.mk_substs(self.parse_substs());
|
||||
return tcx.mk_fn_def(def_id, substs, self.parse_bare_fn_ty());
|
||||
}
|
||||
'G' => {
|
||||
return tcx.mk_fn_ptr(self.parse_bare_fn_ty());
|
||||
|
@ -135,9 +135,10 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Cursor<Vec<u8>>, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx
|
||||
ty::TyStr => {
|
||||
write!(w, "v");
|
||||
}
|
||||
ty::TyFnDef(def_id, f) => {
|
||||
ty::TyFnDef(def_id, substs, f) => {
|
||||
write!(w, "F");
|
||||
write!(w, "{}|", (cx.ds)(def_id));
|
||||
enc_substs(w, cx, substs);
|
||||
enc_bare_fn_ty(w, cx, f);
|
||||
}
|
||||
ty::TyFnPtr(f) => {
|
||||
|
@ -239,7 +239,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||
}
|
||||
ExprKind::Call { ty, fun, args } => {
|
||||
let diverges = match ty.sty {
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => {
|
||||
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => {
|
||||
f.sig.0.output.diverges()
|
||||
}
|
||||
_ => false
|
||||
|
@ -61,7 +61,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
||||
let method = method_callee(cx, self, ty::MethodCall::expr(self.id));
|
||||
|
||||
let sig = match method.ty.sty {
|
||||
ty::TyFnDef(_, fn_ty) => &fn_ty.sig,
|
||||
ty::TyFnDef(_, _, fn_ty) => &fn_ty.sig,
|
||||
_ => cx.tcx.sess.span_bug(self.span, "type of method is not an fn")
|
||||
};
|
||||
|
||||
|
@ -421,7 +421,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
let func_ty = mir.operand_ty(tcx, func);
|
||||
debug!("check_terminator: call, func_ty={:?}", func_ty);
|
||||
let func_ty = match func_ty.sty {
|
||||
ty::TyFnDef(_, func_ty) | ty::TyFnPtr(func_ty) => func_ty,
|
||||
ty::TyFnDef(_, _, func_ty) | ty::TyFnPtr(func_ty) => func_ty,
|
||||
_ => {
|
||||
span_mirbug!(self, term, "call to non-function {:?}", func_ty);
|
||||
return;
|
||||
|
@ -857,7 +857,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
|
||||
if let Def::Struct(..) = self.tcx.resolve_expr(expr) {
|
||||
let expr_ty = self.tcx.expr_ty(expr);
|
||||
let def = match expr_ty.sty {
|
||||
ty::TyFnDef(_, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
|
||||
output: ty::FnConverging(ty), ..
|
||||
}), ..}) => ty,
|
||||
_ => expr_ty
|
||||
|
@ -131,7 +131,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
|
||||
|
||||
let function_type;
|
||||
let (fn_sig, abi, env_ty) = match fn_type.sty {
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => (&f.sig, f.abi, None),
|
||||
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => (&f.sig, f.abi, None),
|
||||
ty::TyClosure(closure_did, ref substs) => {
|
||||
let infcx = infer::normalizing_infer_ctxt(ccx.tcx(), &ccx.tcx().tables);
|
||||
function_type = infcx.closure_type(closure_did, substs);
|
||||
|
@ -906,7 +906,7 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
-> ValueRef {
|
||||
let name = ccx.sess().cstore.item_symbol(did);
|
||||
match t.sty {
|
||||
ty::TyFnDef(_, ref fn_ty) => {
|
||||
ty::TyFnDef(_, _, ref fn_ty) => {
|
||||
match ccx.sess().target.target.adjust_abi(fn_ty.abi) {
|
||||
Abi::Rust | Abi::RustCall => {
|
||||
get_extern_rust_fn(ccx, t, &name[..], did)
|
||||
@ -2610,7 +2610,7 @@ fn register_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
node_id: ast::NodeId,
|
||||
node_type: Ty<'tcx>)
|
||||
-> ValueRef {
|
||||
if let ty::TyFnDef(_, ref f) = node_type.sty {
|
||||
if let ty::TyFnDef(_, _, ref f) = node_type.sty {
|
||||
if f.abi != Abi::Rust && f.abi != Abi::RustCall {
|
||||
ccx.sess().span_bug(sp,
|
||||
&format!("only the `{}` or `{}` calling conventions are valid \
|
||||
@ -2915,7 +2915,7 @@ fn register_method(ccx: &CrateContext,
|
||||
|
||||
let sym = exported_name(ccx, id, mty, &attrs);
|
||||
|
||||
if let ty::TyFnDef(_, ref f) = mty.sty {
|
||||
if let ty::TyFnDef(_, _, ref f) = mty.sty {
|
||||
let llfn = if f.abi == Abi::Rust || f.abi == Abi::RustCall {
|
||||
register_fn(ccx, span, sym, id, mty)
|
||||
} else {
|
||||
|
@ -157,8 +157,8 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &hir::Expr)
|
||||
}
|
||||
}
|
||||
Def::Fn(did) if match expr_ty.sty {
|
||||
ty::TyFnDef(_, ref f) => f.abi == Abi::RustIntrinsic ||
|
||||
f.abi == Abi::PlatformIntrinsic,
|
||||
ty::TyFnDef(_, _, ref f) => f.abi == Abi::RustIntrinsic ||
|
||||
f.abi == Abi::PlatformIntrinsic,
|
||||
_ => false
|
||||
} => {
|
||||
let substs = common::node_id_substs(bcx.ccx(),
|
||||
@ -290,13 +290,13 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
||||
|
||||
// Construct the "tuply" version of `bare_fn_ty`. It takes two arguments: `self`,
|
||||
// which is the fn pointer, and `args`, which is the arguments tuple.
|
||||
let (opt_def_id, sig) =
|
||||
let (opt_def_id_and_substs, sig) =
|
||||
match bare_fn_ty.sty {
|
||||
ty::TyFnDef(def_id,
|
||||
ty::TyFnDef(def_id, substs,
|
||||
&ty::BareFnTy { unsafety: hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
ref sig }) => {
|
||||
(Some(def_id), sig)
|
||||
(Some((def_id, substs)), sig)
|
||||
}
|
||||
ty::TyFnPtr(&ty::BareFnTy { unsafety: hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
@ -322,8 +322,8 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
||||
variadic: false
|
||||
})
|
||||
};
|
||||
let tuple_fn_ty = match opt_def_id {
|
||||
Some(def_id) => tcx.mk_fn_def(def_id, bare_tuple_fn),
|
||||
let tuple_fn_ty = match opt_def_id_and_substs {
|
||||
Some((def_id, substs)) => tcx.mk_fn_def(def_id, substs, bare_tuple_fn),
|
||||
None => tcx.mk_fn_ptr(bare_tuple_fn),
|
||||
};
|
||||
debug!("tuple_fn_ty: {:?}", tuple_fn_ty);
|
||||
@ -615,7 +615,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||
let mut bcx = callee.bcx;
|
||||
|
||||
let (abi, ret_ty) = match callee.ty.sty {
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => {
|
||||
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => {
|
||||
let sig = bcx.tcx().erase_late_bound_regions(&f.sig);
|
||||
let sig = infer::normalize_associated_type(bcx.tcx(), &sig);
|
||||
(f.abi, sig.output)
|
||||
|
@ -600,7 +600,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||
def_id: DefId)
|
||||
-> bool {
|
||||
if !match ccx.tcx().lookup_item_type(def_id).ty.sty {
|
||||
ty::TyFnDef(def_id, _) => {
|
||||
ty::TyFnDef(def_id, _, _) => {
|
||||
// Some constructors also have type TyFnDef but they are
|
||||
// always instantiated inline and don't result in
|
||||
// translation item. Same for FFI functions.
|
||||
@ -1291,7 +1291,7 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
&trait_data.bounds.projection_bounds,
|
||||
output);
|
||||
},
|
||||
ty::TyFnDef(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) |
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy{ unsafety, abi, ref sig } ) |
|
||||
ty::TyFnPtr(&ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == hir::Unsafety::Unsafe {
|
||||
output.push_str("unsafe ");
|
||||
|
@ -1277,7 +1277,7 @@ pub fn inlined_variant_def<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
debug!("inlined_variant_def: ctor_ty={:?} inlined_vid={:?}", ctor_ty,
|
||||
inlined_vid);
|
||||
let adt_def = match ctor_ty.sty {
|
||||
ty::TyFnDef(_, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
|
||||
output: ty::FnConverging(ty), ..
|
||||
}), ..}) => ty,
|
||||
_ => ctor_ty
|
||||
|
@ -253,7 +253,7 @@ impl<'tcx> TypeMap<'tcx> {
|
||||
principal.substs,
|
||||
&mut unique_type_id);
|
||||
},
|
||||
ty::TyFnDef(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) |
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy{ unsafety, abi, ref sig } ) |
|
||||
ty::TyFnPtr(&ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == hir::Unsafety::Unsafe {
|
||||
unique_type_id.push_str("unsafe ");
|
||||
@ -766,7 +766,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::TyFnDef(_, ref barefnty) | ty::TyFnPtr(ref barefnty) => {
|
||||
ty::TyFnDef(_, _, ref barefnty) | ty::TyFnPtr(ref barefnty) => {
|
||||
let fn_metadata = subroutine_type_metadata(cx,
|
||||
unique_type_id,
|
||||
&barefnty.sig,
|
||||
|
@ -430,7 +430,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let fn_type = monomorphize::apply_param_substs(cx.tcx(), param_substs, &fn_type);
|
||||
|
||||
let (sig, abi) = match fn_type.sty {
|
||||
ty::TyFnDef(_, ref barefnty) | ty::TyFnPtr(ref barefnty) => {
|
||||
ty::TyFnDef(_, _, ref barefnty) | ty::TyFnPtr(ref barefnty) => {
|
||||
let sig = cx.tcx().erase_late_bound_regions(&barefnty.sig);
|
||||
let sig = infer::normalize_associated_type(cx.tcx(), &sig);
|
||||
(sig, barefnty.abi)
|
||||
|
@ -101,7 +101,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
push_item_name(cx, principal.def_id, false, output);
|
||||
push_type_params(cx, principal.substs, output);
|
||||
},
|
||||
ty::TyFnDef(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) |
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy{ unsafety, abi, ref sig } ) |
|
||||
ty::TyFnPtr(&ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == hir::Unsafety::Unsafe {
|
||||
output.push_str("unsafe ");
|
||||
|
@ -106,7 +106,7 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
|
||||
|
||||
let function_type; // placeholder so that the memory ownership works out ok
|
||||
let (sig, abi, env) = match fn_type.sty {
|
||||
ty::TyFnDef(_, f) |
|
||||
ty::TyFnDef(_, _, f) |
|
||||
ty::TyFnPtr(f) => {
|
||||
(&f.sig, f.abi, None)
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ccx.tn().val_to_string(llretptr));
|
||||
|
||||
let (fn_abi, fn_sig) = match callee_ty.sty {
|
||||
ty::TyFnDef(_, ref fn_ty) |
|
||||
ty::TyFnDef(_, _, ref fn_ty) |
|
||||
ty::TyFnPtr(ref fn_ty) => (fn_ty.abi, &fn_ty.sig),
|
||||
_ => ccx.sess().bug("trans_native_call called on non-function type")
|
||||
};
|
||||
@ -502,7 +502,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) {
|
||||
abi => {
|
||||
let ty = ccx.tcx().node_id_to_type(foreign_item.id);
|
||||
match ty.sty {
|
||||
ty::TyFnDef(_, bft) |
|
||||
ty::TyFnDef(_, _, bft) |
|
||||
ty::TyFnPtr(bft) => gate_simd_ffi(ccx.tcx(), &decl, bft),
|
||||
_ => ccx.tcx().sess.span_bug(foreign_item.span,
|
||||
"foreign fn's sty isn't a bare_fn_ty?")
|
||||
@ -554,7 +554,7 @@ pub fn decl_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let tys = foreign_types_for_fn_ty(ccx, t);
|
||||
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
|
||||
let cconv = match t.sty {
|
||||
ty::TyFnDef(_, ref fn_ty) | ty::TyFnPtr(ref fn_ty) => {
|
||||
ty::TyFnDef(_, _, ref fn_ty) | ty::TyFnPtr(ref fn_ty) => {
|
||||
llvm_calling_convention(ccx, fn_ty.abi)
|
||||
}
|
||||
_ => panic!("expected bare fn in decl_rust_fn_with_foreign_abi")
|
||||
@ -576,7 +576,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
|
||||
|
||||
let t = ccx.tcx().node_id_to_type(node_id);
|
||||
let cconv = match t.sty {
|
||||
ty::TyFnDef(_, ref fn_ty) | ty::TyFnPtr(ref fn_ty) => {
|
||||
ty::TyFnDef(_, _, ref fn_ty) | ty::TyFnPtr(ref fn_ty) => {
|
||||
llvm_calling_convention(ccx, fn_ty.abi)
|
||||
}
|
||||
_ => panic!("expected bare fn in register_rust_fn_with_foreign_abi")
|
||||
@ -636,7 +636,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
// Compute the type that the function would have if it were just a
|
||||
// normal Rust function. This will be the type of the wrappee fn.
|
||||
match t.sty {
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f)=> {
|
||||
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f)=> {
|
||||
assert!(f.abi != Abi::Rust);
|
||||
assert!(f.abi != Abi::RustIntrinsic);
|
||||
assert!(f.abi != Abi::PlatformIntrinsic);
|
||||
@ -959,7 +959,7 @@ fn foreign_signature<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
ty: Ty<'tcx>) -> ForeignTypes<'tcx> {
|
||||
let fn_sig = match ty.sty {
|
||||
ty::TyFnDef(_, ref fn_ty) | ty::TyFnPtr(ref fn_ty) => &fn_ty.sig,
|
||||
ty::TyFnDef(_, _, ref fn_ty) | ty::TyFnPtr(ref fn_ty) => &fn_ty.sig,
|
||||
_ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
|
||||
};
|
||||
let fn_sig = ccx.tcx().erase_late_bound_regions(fn_sig);
|
||||
|
@ -259,7 +259,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
traits::VtableObject(ref data) => {
|
||||
let idx = traits::get_vtable_index_of_object_method(bcx.tcx(), data, method_id);
|
||||
if let Some(self_expr) = self_expr {
|
||||
if let ty::TyFnDef(_, ref fty) = monomorphize_type(bcx, method_ty).sty {
|
||||
if let ty::TyFnDef(_, _, ref fty) = monomorphize_type(bcx, method_ty).sty {
|
||||
let ty = opaque_method_ty(bcx.tcx(), fty);
|
||||
return trans_trait_callee(bcx, ty, idx, self_expr, arg_cleanup_scope);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ enum AbiStyle {
|
||||
impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
fn abi_style(&self, fn_ty: Ty<'tcx>) -> AbiStyle {
|
||||
match fn_ty.sty {
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => {
|
||||
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => {
|
||||
// We do not translate intrinsics here (they shouldn’t be functions)
|
||||
assert!(f.abi != Abi::RustIntrinsic && f.abi != Abi::PlatformIntrinsic);
|
||||
|
||||
|
@ -153,7 +153,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// Given a function type and a count of ty params, construct an llvm type
|
||||
pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>) -> Type {
|
||||
match fty.sty {
|
||||
ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => {
|
||||
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => {
|
||||
// FIXME(#19925) once fn item types are
|
||||
// zero-sized, we'll need to do something here
|
||||
if f.abi == Abi::Rust || f.abi == Abi::RustCall {
|
||||
|
@ -225,7 +225,7 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
||||
let error_fn_sig;
|
||||
|
||||
let fn_sig = match callee_ty.sty {
|
||||
ty::TyFnDef(_, &ty::BareFnTy {ref sig, ..}) |
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy {ref sig, ..}) |
|
||||
ty::TyFnPtr(&ty::BareFnTy {ref sig, ..}) => {
|
||||
sig
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||
}
|
||||
|
||||
match a.sty {
|
||||
ty::TyFnDef(_, a_f) => {
|
||||
ty::TyFnDef(_, _, a_f) => {
|
||||
// Function items are coercible to any closure
|
||||
// type; function pointers are not (that would
|
||||
// require double indirection).
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
use astconv::AstConv;
|
||||
use intrinsics;
|
||||
use middle::subst;
|
||||
use middle::subst::{self, Substs};
|
||||
use middle::ty::FnSig;
|
||||
use middle::ty::{self, Ty, TyCtxt};
|
||||
use middle::ty::fold::TypeFolder;
|
||||
@ -34,7 +34,12 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: &TyCtxt<'tcx>, it: &hir::ForeignItem,
|
||||
inputs: Vec<ty::Ty<'tcx>>,
|
||||
output: ty::FnOutput<'tcx>) {
|
||||
let def_id = tcx.map.local_def_id(it.id);
|
||||
let fty = tcx.mk_fn_def(def_id, ty::BareFnTy {
|
||||
let i_ty = tcx.lookup_item_type(def_id);
|
||||
|
||||
let mut substs = Substs::empty();
|
||||
substs.types = i_ty.generics.types.map(|def| tcx.mk_param_from_def(def));
|
||||
|
||||
let fty = tcx.mk_fn_def(def_id, tcx.mk_substs(substs), ty::BareFnTy {
|
||||
unsafety: hir::Unsafety::Unsafe,
|
||||
abi: abi,
|
||||
sig: ty::Binder(FnSig {
|
||||
@ -43,7 +48,6 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: &TyCtxt<'tcx>, it: &hir::ForeignItem,
|
||||
variadic: false,
|
||||
}),
|
||||
});
|
||||
let i_ty = tcx.lookup_item_type(def_id);
|
||||
let i_n_tps = i_ty.generics.types.len(subst::FnSpace);
|
||||
if i_n_tps != n_tps {
|
||||
span_err!(tcx.sess, it.span, E0094,
|
||||
|
@ -434,7 +434,7 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
param_env: ty::ParameterEnvironment<'a, 'tcx>)
|
||||
{
|
||||
match raw_fty.sty {
|
||||
ty::TyFnDef(_, ref fn_ty) => {
|
||||
ty::TyFnDef(_, _, ref fn_ty) => {
|
||||
let tables = RefCell::new(ty::Tables::empty());
|
||||
let inh = Inherited::new(ccx.tcx, &tables, param_env);
|
||||
|
||||
|
@ -255,7 +255,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
let type_scheme = fcx.tcx().lookup_item_type(fcx.tcx().map.local_def_id(item.id));
|
||||
let item_ty = fcx.instantiate_type_scheme(item.span, free_substs, &type_scheme.ty);
|
||||
let bare_fn_ty = match item_ty.sty {
|
||||
ty::TyFnDef(_, ref bare_fn_ty) => bare_fn_ty,
|
||||
ty::TyFnDef(_, _, ref bare_fn_ty) => bare_fn_ty,
|
||||
_ => {
|
||||
this.tcx().sess.span_bug(item.span, "Fn item without fn type");
|
||||
}
|
||||
|
@ -543,6 +543,8 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
sig, untransformed_rcvr_ty);
|
||||
|
||||
let def_id = ccx.tcx.map.local_def_id(id);
|
||||
let substs = ccx.tcx.mk_substs(mk_item_substs(ccx, &ty_generics));
|
||||
|
||||
let ty_method = ty::Method::new(name,
|
||||
ty_generics,
|
||||
ty_generic_predicates,
|
||||
@ -552,7 +554,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
def_id,
|
||||
container);
|
||||
|
||||
let fty = ccx.tcx.mk_fn_def(def_id, ty_method.fty.clone());
|
||||
let fty = ccx.tcx.mk_fn_def(def_id, substs, ty_method.fty.clone());
|
||||
debug!("method {} (id {}) has type {:?}",
|
||||
name, id, fty);
|
||||
ccx.tcx.register_item_type(def_id, TypeScheme {
|
||||
@ -714,17 +716,13 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
tcx.register_item_type(def_id,
|
||||
TypeScheme { generics: ty_generics.clone(),
|
||||
ty: selfty });
|
||||
if let &Some(ref ast_trait_ref) = opt_trait_ref {
|
||||
tcx.impl_trait_refs.borrow_mut().insert(
|
||||
def_id,
|
||||
Some(astconv::instantiate_mono_trait_ref(&ccx.icx(&ty_predicates),
|
||||
&ExplicitRscope,
|
||||
ast_trait_ref,
|
||||
Some(selfty)))
|
||||
);
|
||||
} else {
|
||||
tcx.impl_trait_refs.borrow_mut().insert(def_id, None);
|
||||
}
|
||||
let trait_ref = opt_trait_ref.as_ref().map(|ast_trait_ref| {
|
||||
astconv::instantiate_mono_trait_ref(&ccx.icx(&ty_predicates),
|
||||
&ExplicitRscope,
|
||||
ast_trait_ref,
|
||||
Some(selfty))
|
||||
});
|
||||
tcx.impl_trait_refs.borrow_mut().insert(def_id, trait_ref);
|
||||
|
||||
enforce_impl_params_are_constrained(tcx, generics, &mut ty_predicates, def_id);
|
||||
tcx.predicates.borrow_mut().insert(def_id, ty_predicates.clone());
|
||||
@ -901,7 +899,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
}
|
||||
|
||||
if !struct_def.is_struct() {
|
||||
convert_variant_ctor(tcx, struct_def.id(), variant, scheme, predicates);
|
||||
convert_variant_ctor(ccx, struct_def.id(), variant, scheme, predicates);
|
||||
}
|
||||
},
|
||||
hir::ItemTy(_, ref generics) => {
|
||||
@ -919,11 +917,12 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_variant_ctor<'a, 'tcx>(tcx: &TyCtxt<'tcx>,
|
||||
fn convert_variant_ctor<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
ctor_id: ast::NodeId,
|
||||
variant: ty::VariantDef<'tcx>,
|
||||
scheme: ty::TypeScheme<'tcx>,
|
||||
predicates: ty::GenericPredicates<'tcx>) {
|
||||
let tcx = ccx.tcx;
|
||||
let ctor_ty = match variant.kind() {
|
||||
VariantKind::Unit | VariantKind::Struct => scheme.ty,
|
||||
VariantKind::Tuple => {
|
||||
@ -932,9 +931,17 @@ fn convert_variant_ctor<'a, 'tcx>(tcx: &TyCtxt<'tcx>,
|
||||
.iter()
|
||||
.map(|field| field.unsubst_ty())
|
||||
.collect();
|
||||
tcx.mk_ctor_fn(tcx.map.local_def_id(ctor_id),
|
||||
&inputs[..],
|
||||
scheme.ty)
|
||||
let def_id = tcx.map.local_def_id(ctor_id);
|
||||
let substs = tcx.mk_substs(mk_item_substs(ccx, &scheme.generics));
|
||||
tcx.mk_fn_def(def_id, substs, ty::BareFnTy {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
abi: abi::Abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: inputs,
|
||||
output: ty::FnConverging(scheme.ty),
|
||||
variadic: false
|
||||
})
|
||||
})
|
||||
}
|
||||
};
|
||||
write_ty_to_tcx(tcx, ctor_id, ctor_ty);
|
||||
@ -960,7 +967,7 @@ fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
// Convert the ctor, if any. This also registers the variant as
|
||||
// an item.
|
||||
convert_variant_ctor(
|
||||
ccx.tcx,
|
||||
ccx,
|
||||
variant.node.data.id(),
|
||||
ty_variant,
|
||||
scheme.clone(),
|
||||
@ -1435,7 +1442,9 @@ fn compute_type_scheme_of_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
||||
hir::ItemFn(ref decl, unsafety, _, abi, ref generics, _) => {
|
||||
let ty_generics = ty_generics_for_fn(ccx, generics, &ty::Generics::empty());
|
||||
let tofd = astconv::ty_of_bare_fn(&ccx.icx(generics), unsafety, abi, &decl);
|
||||
let ty = tcx.mk_fn_def(ccx.tcx.map.local_def_id(it.id), tofd);
|
||||
let def_id = ccx.tcx.map.local_def_id(it.id);
|
||||
let substs = tcx.mk_substs(mk_item_substs(ccx, &ty_generics));
|
||||
let ty = tcx.mk_fn_def(def_id, substs, tofd);
|
||||
ty::TypeScheme { ty: ty, generics: ty_generics }
|
||||
}
|
||||
hir::ItemTy(ref t, ref generics) => {
|
||||
@ -2142,7 +2151,8 @@ fn compute_type_scheme_of_foreign_fn_decl<'a, 'tcx>(
|
||||
ty::FnDiverging
|
||||
};
|
||||
|
||||
let t_fn = ccx.tcx.mk_fn_def(id, ty::BareFnTy {
|
||||
let substs = ccx.tcx.mk_substs(mk_item_substs(ccx, &ty_generics));
|
||||
let t_fn = ccx.tcx.mk_fn_def(id, substs, ty::BareFnTy {
|
||||
abi: abi,
|
||||
unsafety: hir::Unsafety::Unsafe,
|
||||
sig: ty::Binder(ty::FnSig {inputs: input_tys,
|
||||
|
@ -103,7 +103,7 @@ use dep_graph::DepNode;
|
||||
use front::map as hir_map;
|
||||
use middle::def::Def;
|
||||
use middle::infer::{self, TypeOrigin};
|
||||
use middle::subst;
|
||||
use middle::subst::Substs;
|
||||
use middle::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
use session::{config, CompileResult};
|
||||
use util::common::time;
|
||||
@ -128,7 +128,7 @@ pub mod coherence;
|
||||
pub mod variance;
|
||||
|
||||
pub struct TypeAndSubsts<'tcx> {
|
||||
pub substs: subst::Substs<'tcx>,
|
||||
pub substs: Substs<'tcx>,
|
||||
pub ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
@ -236,7 +236,8 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
||||
_ => ()
|
||||
}
|
||||
let main_def_id = tcx.map.local_def_id(main_id);
|
||||
let se_ty = tcx.mk_fn_def(main_def_id, ty::BareFnTy {
|
||||
let substs = tcx.mk_substs(Substs::empty());
|
||||
let se_ty = tcx.mk_fn_def(main_def_id, substs, ty::BareFnTy {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
@ -282,7 +283,9 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
||||
_ => ()
|
||||
}
|
||||
|
||||
let se_ty = tcx.mk_fn_def(ccx.tcx.map.local_def_id(start_id), ty::BareFnTy {
|
||||
let start_def_id = ccx.tcx.map.local_def_id(start_id);
|
||||
let substs = tcx.mk_substs(Substs::empty());
|
||||
let se_ty = tcx.mk_fn_def(start_def_id, substs, ty::BareFnTy {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
@ -429,7 +429,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::TyFnDef(_, &ty::BareFnTy { ref sig, .. }) |
|
||||
ty::TyFnDef(_, _, &ty::BareFnTy { ref sig, .. }) |
|
||||
ty::TyFnPtr(&ty::BareFnTy { ref sig, .. }) => {
|
||||
self.add_constraints_from_sig(generics, sig, variance);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ pub fn build_external_trait(cx: &DocContext, tcx: &TyCtxt,
|
||||
fn build_external_function(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Function {
|
||||
let t = tcx.lookup_item_type(did);
|
||||
let (decl, style, abi) = match t.ty.sty {
|
||||
ty::TyFnDef(_, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi),
|
||||
ty::TyFnDef(_, _, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi),
|
||||
_ => panic!("bad function"),
|
||||
};
|
||||
|
||||
|
@ -1663,7 +1663,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
|
||||
mutability: mt.mutbl.clean(cx),
|
||||
type_: box mt.ty.clean(cx),
|
||||
},
|
||||
ty::TyFnDef(_, ref fty) |
|
||||
ty::TyFnDef(_, _, ref fty) |
|
||||
ty::TyFnPtr(ref fty) => BareFunction(box BareFunctionDecl {
|
||||
unsafety: fty.unsafety,
|
||||
generics: Generics {
|
||||
|
Loading…
x
Reference in New Issue
Block a user