1
Fork 0

Refactor ty::FnSig to privatize all fields

This commit is contained in:
Mark-Simulacrum 2016-11-28 19:35:38 -07:00
parent 09991241fd
commit 1eab19dba8
42 changed files with 238 additions and 272 deletions

View file

@ -178,8 +178,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for ExprVisitor<'a, 'gcx, 'tcx> {
let typ = self.infcx.tcx.tables().node_id_to_type(expr.id); let typ = self.infcx.tcx.tables().node_id_to_type(expr.id);
match typ.sty { 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 => {
let from = bare_fn_ty.sig.0.inputs[0]; let from = bare_fn_ty.sig.skip_binder().inputs()[0];
let to = bare_fn_ty.sig.0.output; let to = bare_fn_ty.sig.skip_binder().output();
self.check_transmute(expr.span, from, to, expr.id); self.check_transmute(expr.span, from, to, expr.id);
} }
_ => { _ => {

View file

@ -241,12 +241,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// The `Self` type is erased, so it should not appear in list of // The `Self` type is erased, so it should not appear in list of
// arguments or return type apart from the receiver. // arguments or return type apart from the receiver.
let ref sig = self.item_type(method.def_id).fn_sig(); let ref sig = self.item_type(method.def_id).fn_sig();
for &input_ty in &sig.0.inputs[1..] { for input_ty in &sig.skip_binder().inputs()[1..] {
if self.contains_illegal_self_type_reference(trait_def_id, input_ty) { if self.contains_illegal_self_type_reference(trait_def_id, input_ty) {
return Some(MethodViolationCode::ReferencesSelf); return Some(MethodViolationCode::ReferencesSelf);
} }
} }
if self.contains_illegal_self_type_reference(trait_def_id, sig.0.output) { if self.contains_illegal_self_type_reference(trait_def_id, sig.output().skip_binder()) {
return Some(MethodViolationCode::ReferencesSelf); return Some(MethodViolationCode::ReferencesSelf);
} }

View file

@ -1368,21 +1368,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
ty::TyFnDef(.., &ty::BareFnTy { ty::TyFnDef(.., &ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
abi: Abi::Rust, abi: Abi::Rust,
sig: ty::Binder(ty::FnSig { ref sig,
inputs: _,
output: _,
variadic: false
})
}) | }) |
ty::TyFnPtr(&ty::BareFnTy { ty::TyFnPtr(&ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
abi: Abi::Rust, abi: Abi::Rust,
sig: ty::Binder(ty::FnSig { ref sig
inputs: _, }) if !sig.variadic() => {
output: _,
variadic: false
})
}) => {
candidates.vec.push(FnPointerCandidate); candidates.vec.push(FnPointerCandidate);
} }

View file

@ -487,14 +487,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
-> ty::Binder<(ty::TraitRef<'tcx>, Ty<'tcx>)> -> ty::Binder<(ty::TraitRef<'tcx>, Ty<'tcx>)>
{ {
let arguments_tuple = match tuple_arguments { let arguments_tuple = match tuple_arguments {
TupleArgumentsFlag::No => sig.0.inputs[0], TupleArgumentsFlag::No => sig.skip_binder().inputs()[0],
TupleArgumentsFlag::Yes => self.intern_tup(&sig.0.inputs[..]), TupleArgumentsFlag::Yes =>
self.intern_tup(sig.skip_binder().inputs()),
}; };
let trait_ref = ty::TraitRef { let trait_ref = ty::TraitRef {
def_id: fn_trait_def_id, def_id: fn_trait_def_id,
substs: self.mk_substs_trait(self_ty, &[arguments_tuple]), substs: self.mk_substs_trait(self_ty, &[arguments_tuple]),
}; };
ty::Binder((trait_ref, sig.0.output)) ty::Binder((trait_ref, sig.skip_binder().output()))
} }
} }

View file

@ -81,7 +81,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
Some(TupleSimplifiedType(tys.len())) 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())) Some(FunctionSimplifiedType(f.sig.skip_binder().inputs().len()))
} }
ty::TyProjection(_) | ty::TyParam(_) => { ty::TyProjection(_) | ty::TyParam(_) => {
if can_simplify_params { if can_simplify_params {

View file

@ -180,8 +180,8 @@ impl FlagComputation {
fn add_fn_sig(&mut self, fn_sig: &ty::PolyFnSig) { fn add_fn_sig(&mut self, fn_sig: &ty::PolyFnSig) {
let mut computation = FlagComputation::new(); let mut computation = FlagComputation::new();
computation.add_tys(&fn_sig.0.inputs); computation.add_tys(fn_sig.skip_binder().inputs());
computation.add_ty(fn_sig.0.output); computation.add_ty(fn_sig.skip_binder().output());
self.add_bound_computation(&computation); self.add_bound_computation(&computation);
} }

View file

@ -180,37 +180,24 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
-> RelateResult<'tcx, ty::FnSig<'tcx>> -> RelateResult<'tcx, ty::FnSig<'tcx>>
where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
{ {
if a.variadic != b.variadic { if a.variadic() != b.variadic() {
return Err(TypeError::VariadicMismatch( return Err(TypeError::VariadicMismatch(
expected_found(relation, &a.variadic, &b.variadic))); expected_found(relation, &a.variadic(), &b.variadic())));
} }
let inputs = relate_arg_vecs(relation, if a.inputs().len() != b.inputs().len() {
&a.inputs, return Err(TypeError::ArgCount);
&b.inputs)?; }
let output = relation.relate(&a.output, &b.output)?;
Ok(ty::FnSig {inputs: inputs, let inputs = a.inputs().iter().zip(b.inputs()).map(|(&a, &b)| {
output: output, relation.relate_with_variance(ty::Contravariant, &a, &b)
variadic: a.variadic}) }).collect::<Result<Vec<_>, _>>()?;
let output = relation.relate(&a.output(), &b.output())?;
Ok(ty::FnSig::new(inputs, output, a.variadic()))
} }
} }
fn relate_arg_vecs<'a, 'gcx, 'tcx, R>(relation: &mut R,
a_args: &[Ty<'tcx>],
b_args: &[Ty<'tcx>])
-> RelateResult<'tcx, Vec<Ty<'tcx>>>
where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
{
if a_args.len() != b_args.len() {
return Err(TypeError::ArgCount);
}
a_args.iter().zip(b_args)
.map(|(a, b)| relation.relate_with_variance(ty::Contravariant, a, b))
.collect()
}
impl<'tcx> Relate<'tcx> for ast::Unsafety { impl<'tcx> Relate<'tcx> for ast::Unsafety {
fn relate<'a, 'gcx, R>(relation: &mut R, fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ast::Unsafety, a: &ast::Unsafety,

View file

@ -232,13 +232,9 @@ impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::AutoBorrow<'a> {
impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> {
type Lifted = ty::FnSig<'tcx>; type Lifted = ty::FnSig<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.inputs[..]).and_then(|inputs| { tcx.lift(self.inputs()).and_then(|inputs| {
tcx.lift(&self.output).map(|output| { tcx.lift(&self.output()).map(|output| {
ty::FnSig { ty::FnSig::new(inputs, output, self.variadic())
inputs: inputs,
output: output,
variadic: self.variadic
}
}) })
}) })
} }
@ -589,9 +585,9 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TypeAndMut<'tcx> {
impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> { impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
ty::FnSig { inputs: self.inputs.fold_with(folder), ty::FnSig::new(self.inputs().to_owned().fold_with(folder),
output: self.output.fold_with(folder), self.output().fold_with(folder),
variadic: self.variadic } self.variadic())
} }
fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
@ -599,7 +595,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
} }
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool { fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.inputs.visit_with(visitor) || self.output.visit_with(visitor) self.inputs().to_owned().visit_with(visitor) || self.output().visit_with(visitor)
} }
} }

View file

@ -563,16 +563,34 @@ pub struct ClosureTy<'tcx> {
/// - `variadic` indicates whether this is a variadic function. (only true for foreign fns) /// - `variadic` indicates whether this is a variadic function. (only true for foreign fns)
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] #[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub struct FnSig<'tcx> { pub struct FnSig<'tcx> {
pub inputs: Vec<Ty<'tcx>>, inputs: Vec<Ty<'tcx>>,
pub output: Ty<'tcx>, output: Ty<'tcx>,
pub variadic: bool variadic: bool
}
impl<'tcx> FnSig<'tcx> {
pub fn new(inputs: Vec<Ty<'tcx>>, output: Ty<'tcx>, variadic: bool) -> Self {
FnSig { inputs: inputs, output: output, variadic: variadic }
}
pub fn inputs(&self) -> &[Ty<'tcx>] {
&self.inputs
}
pub fn output(&self) -> Ty<'tcx> {
self.output
}
pub fn variadic(&self) -> bool {
self.variadic
}
} }
pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>; pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
impl<'tcx> PolyFnSig<'tcx> { impl<'tcx> PolyFnSig<'tcx> {
pub fn inputs(&self) -> ty::Binder<Vec<Ty<'tcx>>> { pub fn inputs<'a>(&'a self) -> Binder<&[Ty<'tcx>]> {
self.map_bound_ref(|fn_sig| fn_sig.inputs.clone()) Binder(self.0.inputs())
} }
pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> { pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> {
self.map_bound_ref(|fn_sig| fn_sig.inputs[index]) self.map_bound_ref(|fn_sig| fn_sig.inputs[index])
@ -1244,7 +1262,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
// Type accessors for substructures of types // Type accessors for substructures of types
pub fn fn_args(&self) -> ty::Binder<Vec<Ty<'tcx>>> { pub fn fn_args(&self) -> ty::Binder<Vec<Ty<'tcx>>> {
self.fn_sig().inputs() ty::Binder(self.fn_sig().inputs().skip_binder().iter().cloned().collect::<Vec<_>>())
} }
pub fn fn_ret(&self) -> Binder<Ty<'tcx>> { pub fn fn_ret(&self) -> Binder<Ty<'tcx>> {

View file

@ -530,7 +530,7 @@ impl<'a, 'gcx, 'tcx, H: Hasher> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tc
self.hash(f.unsafety); self.hash(f.unsafety);
self.hash(f.abi); self.hash(f.abi);
self.hash(f.sig.variadic()); self.hash(f.sig.variadic());
self.hash(f.sig.inputs().skip_binder().len()); self.hash(f.sig.skip_binder().inputs().len());
} }
TyDynamic(ref data, ..) => { TyDynamic(ref data, ..) => {
if let Some(p) = data.principal() { if let Some(p) = data.principal() {

View file

@ -126,6 +126,6 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
} }
fn push_sig_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, sig: &ty::PolyFnSig<'tcx>) { fn push_sig_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, sig: &ty::PolyFnSig<'tcx>) {
stack.push(sig.0.output); stack.push(sig.skip_binder().output());
stack.extend(sig.0.inputs.iter().cloned().rev()); stack.extend(sig.skip_binder().inputs().iter().cloned().rev());
} }

View file

@ -595,7 +595,7 @@ impl<'tcx> fmt::Debug for ty::InstantiatedPredicates<'tcx> {
impl<'tcx> fmt::Display for ty::FnSig<'tcx> { impl<'tcx> fmt::Display for ty::FnSig<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "fn")?; write!(f, "fn")?;
fn_sig(f, &self.inputs, self.variadic, self.output) fn_sig(f, self.inputs(), self.variadic(), self.output())
} }
} }
@ -625,7 +625,7 @@ impl fmt::Debug for ty::RegionVid {
impl<'tcx> fmt::Debug for ty::FnSig<'tcx> { impl<'tcx> fmt::Debug for ty::FnSig<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({:?}; variadic: {})->{:?}", self.inputs, self.variadic, self.output) write!(f, "({:?}; variadic: {})->{:?}", self.inputs(), self.variadic(), self.output())
} }
} }

View file

@ -1084,8 +1084,8 @@ impl LateLintPass for MutableTransmutes {
let typ = cx.tcx.tables().node_id_to_type(expr.id); let typ = cx.tcx.tables().node_id_to_type(expr.id);
match typ.sty { match typ.sty {
ty::TyFnDef(.., ref bare_fn) if bare_fn.abi == RustIntrinsic => { ty::TyFnDef(.., ref bare_fn) if bare_fn.abi == RustIntrinsic => {
let from = bare_fn.sig.0.inputs[0]; let from = bare_fn.sig.skip_binder().inputs()[0];
let to = bare_fn.sig.0.output; let to = bare_fn.sig.skip_binder().output();
return Some((&from.sty, &to.sty)); return Some((&from.sty, &to.sty));
} }
_ => (), _ => (),

View file

@ -603,8 +603,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} }
let sig = cx.erase_late_bound_regions(&bare_fn.sig); let sig = cx.erase_late_bound_regions(&bare_fn.sig);
if !sig.output.is_nil() { if !sig.output().is_nil() {
let r = self.check_type_for_ffi(cache, sig.output); let r = self.check_type_for_ffi(cache, sig.output());
match r { match r {
FfiSafe => {} FfiSafe => {}
_ => { _ => {
@ -612,7 +612,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} }
} }
} }
for arg in sig.inputs { for arg in sig.inputs() {
let r = self.check_type_for_ffi(cache, arg); let r = self.check_type_for_ffi(cache, arg);
match r { match r {
FfiSafe => {} FfiSafe => {}
@ -678,12 +678,12 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
let sig = self.cx.tcx.item_type(def_id).fn_sig(); let sig = self.cx.tcx.item_type(def_id).fn_sig();
let sig = self.cx.tcx.erase_late_bound_regions(&sig); let sig = self.cx.tcx.erase_late_bound_regions(&sig);
for (&input_ty, input_hir) in sig.inputs.iter().zip(&decl.inputs) { for (input_ty, input_hir) in sig.inputs().iter().zip(&decl.inputs) {
self.check_type_for_ffi_and_report_errors(input_hir.ty.span, &input_ty); self.check_type_for_ffi_and_report_errors(input_hir.ty.span, input_ty);
} }
if let hir::Return(ref ret_hir) = decl.output { if let hir::Return(ref ret_hir) = decl.output {
let ret_ty = sig.output; let ret_ty = sig.output();
if !ret_ty.is_nil() { if !ret_ty.is_nil() {
self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty); self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty);
} }

View file

@ -208,7 +208,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
let diverges = match ty.sty { let diverges = match ty.sty {
ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => { ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => {
// FIXME(canndrew): This is_never should probably be an is_uninhabited // FIXME(canndrew): This is_never should probably be an is_uninhabited
f.sig.0.output.is_never() f.sig.skip_binder().output().is_never()
} }
_ => false _ => false
}; };

View file

@ -247,10 +247,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
span_bug!(expr.span, "method call has late-bound regions") span_bug!(expr.span, "method call has late-bound regions")
}); });
assert_eq!(sig.inputs.len(), 2); assert_eq!(sig.inputs().len(), 2);
let tupled_args = Expr { let tupled_args = Expr {
ty: sig.inputs[1], ty: sig.inputs()[1],
temp_lifetime: temp_lifetime, temp_lifetime: temp_lifetime,
span: expr.span, span: expr.span,
kind: ExprKind::Tuple { kind: ExprKind::Tuple {

View file

@ -238,14 +238,14 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
.iter() .iter()
.enumerate() .enumerate()
.map(|(index, arg)| { .map(|(index, arg)| {
(fn_sig.inputs[index], Some(&*arg.pat)) (fn_sig.inputs()[index], Some(&*arg.pat))
}); });
let body = self.tcx.map.expr(body_id); let body = self.tcx.map.expr(body_id);
let arguments = implicit_argument.into_iter().chain(explicit_arguments); let arguments = implicit_argument.into_iter().chain(explicit_arguments);
self.cx(MirSource::Fn(id)).build(|cx| { self.cx(MirSource::Fn(id)).build(|cx| {
build::construct_fn(cx, id, arguments, abi, fn_sig.output, body) build::construct_fn(cx, id, arguments, abi, fn_sig.output(), body)
}); });
intravisit::walk_fn(self, fk, decl, body_id, span, id); intravisit::walk_fn(self, fk, decl, body_id, span, id);

View file

@ -506,15 +506,15 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
match *destination { match *destination {
Some((ref dest, _)) => { Some((ref dest, _)) => {
let dest_ty = dest.ty(mir, tcx).to_ty(tcx); let dest_ty = dest.ty(mir, tcx).to_ty(tcx);
if let Err(terr) = self.sub_types(sig.output, dest_ty) { if let Err(terr) = self.sub_types(sig.output(), dest_ty) {
span_mirbug!(self, term, span_mirbug!(self, term,
"call dest mismatch ({:?} <- {:?}): {:?}", "call dest mismatch ({:?} <- {:?}): {:?}",
dest_ty, sig.output, terr); dest_ty, sig.output(), terr);
} }
}, },
None => { None => {
// FIXME(canndrew): This is_never should probably be an is_uninhabited // FIXME(canndrew): This is_never should probably be an is_uninhabited
if !sig.output.is_never() { if !sig.output().is_never() {
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig); span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
} }
}, },
@ -528,11 +528,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
args: &[Operand<'tcx>]) args: &[Operand<'tcx>])
{ {
debug!("check_call_inputs({:?}, {:?})", sig, args); debug!("check_call_inputs({:?}, {:?})", sig, args);
if args.len() < sig.inputs.len() || if args.len() < sig.inputs().len() ||
(args.len() > sig.inputs.len() && !sig.variadic) { (args.len() > sig.inputs().len() && !sig.variadic()) {
span_mirbug!(self, term, "call to {:?} with wrong # of args", sig); span_mirbug!(self, term, "call to {:?} with wrong # of args", sig);
} }
for (n, (fn_arg, op_arg)) in sig.inputs.iter().zip(args).enumerate() { for (n, (fn_arg, op_arg)) in sig.inputs().iter().zip(args).enumerate() {
let op_arg_ty = op_arg.ty(mir, self.tcx()); let op_arg_ty = op_arg.ty(mir, self.tcx());
if let Err(terr) = self.sub_types(op_arg_ty, fn_arg) { if let Err(terr) = self.sub_types(op_arg_ty, fn_arg) {
span_mirbug!(self, term, "bad arg #{:?} ({:?} <- {:?}): {:?}", span_mirbug!(self, term, "bad arg #{:?} ({:?} <- {:?}): {:?}",
@ -562,12 +562,12 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
// box_free takes a Box as a pointer. Allow for that. // box_free takes a Box as a pointer. Allow for that.
if sig.inputs.len() != 1 { if sig.inputs().len() != 1 {
span_mirbug!(self, term, "box_free should take 1 argument"); span_mirbug!(self, term, "box_free should take 1 argument");
return; return;
} }
let pointee_ty = match sig.inputs[0].sty { let pointee_ty = match sig.inputs()[0].sty {
ty::TyRawPtr(mt) => mt.ty, ty::TyRawPtr(mt) => mt.ty,
_ => { _ => {
span_mirbug!(self, term, "box_free should take a raw ptr"); span_mirbug!(self, term, "box_free should take a raw ptr");

View file

@ -367,13 +367,13 @@ impl FnType {
Cdecl => llvm::CCallConv, Cdecl => llvm::CCallConv,
}; };
let mut inputs = &sig.inputs[..]; let mut inputs = sig.inputs();
let extra_args = if abi == RustCall { let extra_args = if abi == RustCall {
assert!(!sig.variadic && extra_args.is_empty()); assert!(!sig.variadic() && extra_args.is_empty());
match inputs[inputs.len() - 1].sty { match sig.inputs().last().unwrap().sty {
ty::TyTuple(ref tupled_arguments) => { ty::TyTuple(ref tupled_arguments) => {
inputs = &inputs[..inputs.len() - 1]; inputs = &sig.inputs()[0..sig.inputs().len() - 1];
&tupled_arguments[..] &tupled_arguments[..]
} }
_ => { _ => {
@ -382,7 +382,7 @@ impl FnType {
} }
} }
} else { } else {
assert!(sig.variadic || extra_args.is_empty()); assert!(sig.variadic() || extra_args.is_empty());
extra_args extra_args
}; };
@ -428,7 +428,7 @@ impl FnType {
} }
}; };
let ret_ty = sig.output; let ret_ty = sig.output();
let mut ret = arg_of(ret_ty, true); let mut ret = arg_of(ret_ty, true);
if !type_is_fat_ptr(ccx.tcx(), ret_ty) { if !type_is_fat_ptr(ccx.tcx(), ret_ty) {
@ -525,7 +525,7 @@ impl FnType {
FnType { FnType {
args: args, args: args,
ret: ret, ret: ret,
variadic: sig.variadic, variadic: sig.variadic(),
cconv: cconv cconv: cconv
} }
} }
@ -569,7 +569,7 @@ impl FnType {
}; };
// Fat pointers are returned by-value. // Fat pointers are returned by-value.
if !self.ret.is_ignore() { if !self.ret.is_ignore() {
if !type_is_fat_ptr(ccx.tcx(), sig.output) { if !type_is_fat_ptr(ccx.tcx(), sig.output()) {
fixup(&mut self.ret); fixup(&mut self.ret);
} }
} }

View file

@ -1077,8 +1077,8 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let dest_val = adt::MaybeSizedValue::sized(dest); // Can return unsized value let dest_val = adt::MaybeSizedValue::sized(dest); // Can return unsized value
let mut llarg_idx = fcx.fn_ty.ret.is_indirect() as usize; let mut llarg_idx = fcx.fn_ty.ret.is_indirect() as usize;
let mut arg_idx = 0; let mut arg_idx = 0;
for (i, arg_ty) in sig.inputs.into_iter().enumerate() { for (i, arg_ty) in sig.inputs().into_iter().enumerate() {
let lldestptr = adt::trans_field_ptr(bcx, sig.output, dest_val, Disr::from(disr), i); let lldestptr = adt::trans_field_ptr(bcx, sig.output(), dest_val, Disr::from(disr), i);
let arg = &fcx.fn_ty.args[arg_idx]; let arg = &fcx.fn_ty.args[arg_idx];
arg_idx += 1; arg_idx += 1;
let b = &bcx.build(); let b = &bcx.build();
@ -1091,7 +1091,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
arg.store_fn_arg(b, &mut llarg_idx, lldestptr); arg.store_fn_arg(b, &mut llarg_idx, lldestptr);
} }
} }
adt::trans_set_discr(bcx, sig.output, dest, disr); adt::trans_set_discr(bcx, sig.output(), dest, disr);
} }
fcx.finish(bcx, DebugLoc::None); fcx.finish(bcx, DebugLoc::None);

View file

@ -329,7 +329,14 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
// Make a version with the type of by-ref closure. // Make a version with the type of by-ref closure.
let ty::ClosureTy { unsafety, abi, mut sig } = tcx.closure_type(def_id, substs); let ty::ClosureTy { unsafety, abi, mut sig } = tcx.closure_type(def_id, substs);
sig.0.inputs.insert(0, ref_closure_ty); // sig has no self type as of yet sig.0 = ty::FnSig::new({
let mut inputs = sig.0.inputs().to_owned();
inputs.insert(0, ref_closure_ty); // sig has no self type as of yet
inputs
},
sig.0.output(),
sig.0.variadic()
);
let llref_fn_ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy { let llref_fn_ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy {
unsafety: unsafety, unsafety: unsafety,
abi: abi, abi: abi,
@ -342,7 +349,15 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
// Make a version of the closure type with the same arguments, but // Make a version of the closure type with the same arguments, but
// with argument #0 being by value. // with argument #0 being by value.
assert_eq!(abi, Abi::RustCall); assert_eq!(abi, Abi::RustCall);
sig.0.inputs[0] = closure_ty; sig.0 = ty::FnSig::new(
{
let mut inputs = sig.0.inputs().to_owned();
inputs[0] = closure_ty;
inputs
},
sig.0.output(),
sig.0.variadic()
);
let sig = tcx.erase_late_bound_regions_and_normalize(&sig); let sig = tcx.erase_late_bound_regions_and_normalize(&sig);
let fn_ty = FnType::new(ccx, abi, &sig, &[]); let fn_ty = FnType::new(ccx, abi, &sig, &[]);
@ -491,13 +506,12 @@ fn trans_fn_pointer_shim<'a, 'tcx>(
} }
}; };
let sig = tcx.erase_late_bound_regions_and_normalize(sig); let sig = tcx.erase_late_bound_regions_and_normalize(sig);
let tuple_input_ty = tcx.intern_tup(&sig.inputs[..]); let tuple_input_ty = tcx.intern_tup(sig.inputs());
let sig = ty::FnSig { let sig = ty::FnSig::new(
inputs: vec![bare_fn_ty_maybe_ref, vec![bare_fn_ty_maybe_ref, tuple_input_ty],
tuple_input_ty], sig.output(),
output: sig.output, false
variadic: false );
};
let fn_ty = FnType::new(ccx, Abi::RustCall, &sig, &[]); let fn_ty = FnType::new(ccx, Abi::RustCall, &sig, &[]);
let tuple_fn_ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy { let tuple_fn_ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,

View file

@ -418,11 +418,11 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
let ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy { let ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Unsafe, unsafety: hir::Unsafety::Unsafe,
abi: Abi::C, abi: Abi::C,
sig: ty::Binder(ty::FnSig { sig: ty::Binder(ty::FnSig::new(
inputs: vec![tcx.mk_mut_ptr(tcx.types.u8)], vec![tcx.mk_mut_ptr(tcx.types.u8)],
output: tcx.types.never, tcx.types.never,
variadic: false false
}), )),
})); }));
let unwresume = ccx.eh_unwind_resume(); let unwresume = ccx.eh_unwind_resume();
@ -1091,10 +1091,11 @@ pub fn ty_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty::ClosureKind::FnOnce => ty, ty::ClosureKind::FnOnce => ty,
}; };
let sig = sig.map_bound(|sig| ty::FnSig { let sig = sig.map_bound(|sig| ty::FnSig::new(
inputs: iter::once(env_ty).chain(sig.inputs).collect(), iter::once(env_ty).chain(sig.inputs().into_iter().cloned()).collect(),
..sig sig.output(),
}); sig.variadic()
));
Cow::Owned(ty::BareFnTy { unsafety: unsafety, abi: abi, sig: sig }) Cow::Owned(ty::BareFnTy { unsafety: unsafety, abi: abi, sig: sig })
} }
_ => bug!("unexpected type {:?} to ty_fn_sig", ty) _ => bug!("unexpected type {:?} to ty_fn_sig", ty)

View file

@ -390,16 +390,16 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
{ {
let signature = cx.tcx().erase_late_bound_regions(signature); let signature = cx.tcx().erase_late_bound_regions(signature);
let mut signature_metadata: Vec<DIType> = Vec::with_capacity(signature.inputs.len() + 1); let mut signature_metadata: Vec<DIType> = Vec::with_capacity(signature.inputs().len() + 1);
// return type // return type
signature_metadata.push(match signature.output.sty { signature_metadata.push(match signature.output().sty {
ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(), ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(),
_ => type_metadata(cx, signature.output, span) _ => type_metadata(cx, signature.output(), span)
}); });
// regular arguments // regular arguments
for &argument_type in &signature.inputs { for &argument_type in signature.inputs() {
signature_metadata.push(type_metadata(cx, argument_type, span)); signature_metadata.push(type_metadata(cx, argument_type, span));
} }

View file

@ -308,18 +308,18 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return create_DIArray(DIB(cx), &[]); return create_DIArray(DIB(cx), &[]);
} }
let mut signature = Vec::with_capacity(sig.inputs.len() + 1); let mut signature = Vec::with_capacity(sig.inputs().len() + 1);
// Return type -- llvm::DIBuilder wants this at index 0 // Return type -- llvm::DIBuilder wants this at index 0
signature.push(match sig.output.sty { signature.push(match sig.output().sty {
ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(), ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(),
_ => type_metadata(cx, sig.output, syntax_pos::DUMMY_SP) _ => type_metadata(cx, sig.output(), syntax_pos::DUMMY_SP)
}); });
let inputs = if abi == Abi::RustCall { let inputs = if abi == Abi::RustCall {
&sig.inputs[..sig.inputs.len()-1] &sig.inputs()[..sig.inputs().len() - 1]
} else { } else {
&sig.inputs[..] sig.inputs()
}; };
// Arguments types // Arguments types
@ -327,8 +327,8 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
signature.push(type_metadata(cx, argument_type, syntax_pos::DUMMY_SP)); signature.push(type_metadata(cx, argument_type, syntax_pos::DUMMY_SP));
} }
if abi == Abi::RustCall && !sig.inputs.is_empty() { if abi == Abi::RustCall && !sig.inputs().is_empty() {
if let ty::TyTuple(args) = sig.inputs[sig.inputs.len() - 1].sty { if let ty::TyTuple(args) = sig.inputs()[sig.inputs().len() - 1].sty {
for &argument_type in args { for &argument_type in args {
signature.push(type_metadata(cx, argument_type, syntax_pos::DUMMY_SP)); signature.push(type_metadata(cx, argument_type, syntax_pos::DUMMY_SP));
} }

View file

@ -116,8 +116,8 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
output.push_str("fn("); output.push_str("fn(");
let sig = cx.tcx().erase_late_bound_regions_and_normalize(sig); let sig = cx.tcx().erase_late_bound_regions_and_normalize(sig);
if !sig.inputs.is_empty() { if !sig.inputs().is_empty() {
for &parameter_type in &sig.inputs { for &parameter_type in sig.inputs() {
push_debuginfo_type_name(cx, parameter_type, true, output); push_debuginfo_type_name(cx, parameter_type, true, output);
output.push_str(", "); output.push_str(", ");
} }
@ -125,8 +125,8 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
output.pop(); output.pop();
} }
if sig.variadic { if sig.variadic() {
if !sig.inputs.is_empty() { if !sig.inputs().is_empty() {
output.push_str(", ..."); output.push_str(", ...");
} else { } else {
output.push_str("..."); output.push_str("...");
@ -135,9 +135,9 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
output.push(')'); output.push(')');
if !sig.output.is_nil() { if !sig.output().is_nil() {
output.push_str(" -> "); output.push_str(" -> ");
push_debuginfo_type_name(cx, sig.output, true, output); push_debuginfo_type_name(cx, sig.output(), true, output);
} }
}, },
ty::TyClosure(..) => { ty::TyClosure(..) => {

View file

@ -124,7 +124,7 @@ pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
let llfn = declare_raw_fn(ccx, name, fty.cconv, fty.llvm_type(ccx)); let llfn = declare_raw_fn(ccx, name, fty.cconv, fty.llvm_type(ccx));
// FIXME(canndrew): This is_never should really be an is_uninhabited // FIXME(canndrew): This is_never should really be an is_uninhabited
if sig.output.is_never() { if sig.output().is_never() {
llvm::Attribute::NoReturn.apply_llfn(Function, llfn); llvm::Attribute::NoReturn.apply_llfn(Function, llfn);
} }

View file

@ -105,8 +105,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
}; };
let sig = tcx.erase_late_bound_regions_and_normalize(&fty.sig); let sig = tcx.erase_late_bound_regions_and_normalize(&fty.sig);
let arg_tys = sig.inputs; let arg_tys = sig.inputs();
let ret_ty = sig.output; let ret_ty = sig.output();
let name = &*tcx.item_name(def_id).as_str(); let name = &*tcx.item_name(def_id).as_str();
let span = match call_debug_location { let span = match call_debug_location {
@ -674,7 +674,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
// again to find them and extract the arguments // again to find them and extract the arguments
intr.inputs.iter() intr.inputs.iter()
.zip(llargs) .zip(llargs)
.zip(&arg_tys) .zip(arg_tys)
.flat_map(|((t, llarg), ty)| modify_as_needed(bcx, t, ty, *llarg)) .flat_map(|((t, llarg), ty)| modify_as_needed(bcx, t, ty, *llarg))
.collect() .collect()
}; };
@ -1012,11 +1012,7 @@ fn gen_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
trans: &mut for<'b> FnMut(Block<'b, 'tcx>)) trans: &mut for<'b> FnMut(Block<'b, 'tcx>))
-> ValueRef { -> ValueRef {
let ccx = fcx.ccx; let ccx = fcx.ccx;
let sig = ty::FnSig { let sig = ty::FnSig::new(inputs, output, false);
inputs: inputs,
output: output,
variadic: false,
};
let fn_ty = FnType::new(ccx, Abi::Rust, &sig, &[]); let fn_ty = FnType::new(ccx, Abi::Rust, &sig, &[]);
let rust_fn_ty = ccx.tcx().mk_fn_ptr(ccx.tcx().mk_bare_fn(ty::BareFnTy { let rust_fn_ty = ccx.tcx().mk_fn_ptr(ccx.tcx().mk_bare_fn(ty::BareFnTy {
@ -1051,11 +1047,7 @@ fn get_rust_try_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
let fn_ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy { let fn_ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Unsafe, unsafety: hir::Unsafety::Unsafe,
abi: Abi::Rust, abi: Abi::Rust,
sig: ty::Binder(ty::FnSig { sig: ty::Binder(ty::FnSig::new(vec![i8p], tcx.mk_nil(), false)),
inputs: vec![i8p],
output: tcx.mk_nil(),
variadic: false,
}),
})); }));
let output = tcx.types.i32; let output = tcx.types.i32;
let rust_try = gen_fn(fcx, "__rust_try", vec![fn_ty, i8p, i8p], output, trans); let rust_try = gen_fn(fcx, "__rust_try", vec![fn_ty, i8p, i8p], output, trans);
@ -1108,7 +1100,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
let tcx = bcx.tcx(); let tcx = bcx.tcx();
let sig = tcx.erase_late_bound_regions_and_normalize(callee_ty.fn_sig()); let sig = tcx.erase_late_bound_regions_and_normalize(callee_ty.fn_sig());
let arg_tys = sig.inputs; let arg_tys = sig.inputs();
// every intrinsic takes a SIMD vector as its first argument // every intrinsic takes a SIMD vector as its first argument
require_simd!(arg_tys[0], "input"); require_simd!(arg_tys[0], "input");

View file

@ -453,7 +453,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
return; return;
} }
let extra_args = &args[sig.inputs.len()..]; let extra_args = &args[sig.inputs().len()..];
let extra_args = extra_args.iter().map(|op_arg| { let extra_args = extra_args.iter().map(|op_arg| {
let op_ty = op_arg.ty(&self.mir, bcx.tcx()); let op_ty = op_arg.ty(&self.mir, bcx.tcx());
bcx.monomorphize(&op_ty) bcx.monomorphize(&op_ty)
@ -546,7 +546,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
// Make a fake operand for store_return // Make a fake operand for store_return
let op = OperandRef { let op = OperandRef {
val: Ref(dst), val: Ref(dst),
ty: sig.output, ty: sig.output(),
}; };
self.store_return(&bcx, ret_dest, fn_ty.ret, op); self.store_return(&bcx, ret_dest, fn_ty.ret, op);
} }
@ -584,7 +584,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
debug_loc.apply_to_bcx(ret_bcx); debug_loc.apply_to_bcx(ret_bcx);
let op = OperandRef { let op = OperandRef {
val: Immediate(invokeret), val: Immediate(invokeret),
ty: sig.output, ty: sig.output(),
}; };
self.store_return(&ret_bcx, ret_dest, fn_ty.ret, op); self.store_return(&ret_bcx, ret_dest, fn_ty.ret, op);
}); });
@ -595,7 +595,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
if let Some((_, target)) = *destination { if let Some((_, target)) = *destination {
let op = OperandRef { let op = OperandRef {
val: Immediate(llret), val: Immediate(llret),
ty: sig.output, ty: sig.output(),
}; };
self.store_return(&bcx, ret_dest, fn_ty.ret, op); self.store_return(&bcx, ret_dest, fn_ty.ret, op);
funclet_br(self, bcx, target); funclet_br(self, bcx, target);

View file

@ -187,11 +187,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
assert_eq!(dg.ty(), glue::get_drop_glue_type(tcx, dg.ty())); assert_eq!(dg.ty(), glue::get_drop_glue_type(tcx, dg.ty()));
let t = dg.ty(); let t = dg.ty();
let sig = ty::FnSig { let sig = ty::FnSig::new(vec![tcx.mk_mut_ptr(tcx.types.i8)], tcx.mk_nil(), false);
inputs: vec![tcx.mk_mut_ptr(tcx.types.i8)],
output: tcx.mk_nil(),
variadic: false,
};
// Create a FnType for fn(*mut i8) and substitute the real type in // Create a FnType for fn(*mut i8) and substitute the real type in
// later - that prevents FnType from splitting fat pointers up. // later - that prevents FnType from splitting fat pointers up.
@ -480,14 +476,10 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
output.push_str("fn("); output.push_str("fn(");
let ty::FnSig { let sig = self.tcx.erase_late_bound_regions_and_normalize(sig);
inputs: sig_inputs,
output: sig_output,
variadic: sig_variadic
} = self.tcx.erase_late_bound_regions_and_normalize(sig);
if !sig_inputs.is_empty() { if !sig.inputs().is_empty() {
for &parameter_type in &sig_inputs { for &parameter_type in sig.inputs() {
self.push_type_name(parameter_type, output); self.push_type_name(parameter_type, output);
output.push_str(", "); output.push_str(", ");
} }
@ -495,8 +487,8 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
output.pop(); output.pop();
} }
if sig_variadic { if sig.variadic() {
if !sig_inputs.is_empty() { if !sig.inputs().is_empty() {
output.push_str(", ..."); output.push_str(", ...");
} else { } else {
output.push_str("..."); output.push_str("...");
@ -505,9 +497,9 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
output.push(')'); output.push(')');
if !sig_output.is_nil() { if !sig.output().is_nil() {
output.push_str(" -> "); output.push_str(" -> ");
self.push_type_name(sig_output, output); self.push_type_name(sig.output(), output);
} }
}, },
ty::TyClosure(def_id, ref closure_substs) => { ty::TyClosure(def_id, ref closure_substs) => {

View file

@ -1595,7 +1595,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
// checking for here would be considered early bound // checking for here would be considered early bound
// anyway.) // anyway.)
let inputs = bare_fn_ty.sig.inputs(); let inputs = bare_fn_ty.sig.inputs();
let late_bound_in_args = tcx.collect_constrained_late_bound_regions(&inputs); let late_bound_in_args = tcx.collect_constrained_late_bound_regions(
&inputs.map_bound(|i| i.to_owned()));
let output = bare_fn_ty.sig.output(); let output = bare_fn_ty.sig.output();
let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(&output); let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(&output);
for br in late_bound_in_ret.difference(&late_bound_in_args) { for br in late_bound_in_ret.difference(&late_bound_in_args) {
@ -1803,11 +1804,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
self.tcx().mk_bare_fn(ty::BareFnTy { self.tcx().mk_bare_fn(ty::BareFnTy {
unsafety: unsafety, unsafety: unsafety,
abi: abi, abi: abi,
sig: ty::Binder(ty::FnSig { sig: ty::Binder(ty::FnSig::new(input_tys, output_ty, decl.variadic)),
inputs: input_tys,
output: output_ty,
variadic: decl.variadic
}),
}) })
} }
@ -1853,8 +1850,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
let expected_arg_ty = expected_sig.as_ref().and_then(|e| { let expected_arg_ty = expected_sig.as_ref().and_then(|e| {
// no guarantee that the correct number of expected args // no guarantee that the correct number of expected args
// were supplied // were supplied
if i < e.inputs.len() { if i < e.inputs().len() {
Some(e.inputs[i]) Some(e.inputs()[i])
} else { } else {
None None
} }
@ -1862,7 +1859,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
self.ty_of_arg(&rb, a, expected_arg_ty) self.ty_of_arg(&rb, a, expected_arg_ty)
}).collect(); }).collect();
let expected_ret_ty = expected_sig.map(|e| e.output); let expected_ret_ty = expected_sig.map(|e| e.output());
let is_infer = match decl.output { let is_infer = match decl.output {
hir::Return(ref output) if output.node == hir::TyInfer => true, hir::Return(ref output) if output.node == hir::TyInfer => true,
@ -1885,9 +1882,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
ty::ClosureTy { ty::ClosureTy {
unsafety: unsafety, unsafety: unsafety,
abi: abi, abi: abi,
sig: ty::Binder(ty::FnSig {inputs: input_tys, sig: ty::Binder(ty::FnSig::new(input_tys, output_ty, decl.variadic)),
output: output_ty,
variadic: decl.variadic}),
} }
} }

View file

@ -237,11 +237,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// This is the "default" function signature, used in case of error. // This is the "default" function signature, used in case of error.
// In that case, we check each argument against "error" in order to // In that case, we check each argument against "error" in order to
// set up all the node type bindings. // set up all the node type bindings.
error_fn_sig = ty::Binder(ty::FnSig { error_fn_sig = ty::Binder(ty::FnSig::new(
inputs: self.err_args(arg_exprs.len()), self.err_args(arg_exprs.len()),
output: self.tcx.types.err, self.tcx.types.err,
variadic: false, false,
}); ));
(&error_fn_sig, None) (&error_fn_sig, None)
} }
@ -261,17 +261,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let expected_arg_tys = let expected_arg_tys =
self.expected_types_for_fn_args(call_expr.span, self.expected_types_for_fn_args(call_expr.span,
expected, expected,
fn_sig.output, fn_sig.output(),
&fn_sig.inputs); fn_sig.inputs());
self.check_argument_types(call_expr.span, self.check_argument_types(call_expr.span,
&fn_sig.inputs, fn_sig.inputs(),
&expected_arg_tys[..], &expected_arg_tys[..],
arg_exprs, arg_exprs,
fn_sig.variadic, fn_sig.variadic(),
TupleArgumentsFlag::DontTupleArguments, TupleArgumentsFlag::DontTupleArguments,
def_span); def_span);
fn_sig.output fn_sig.output()
} }
fn confirm_deferred_closure_call(&self, fn confirm_deferred_closure_call(&self,
@ -287,18 +287,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let expected_arg_tys = self.expected_types_for_fn_args(call_expr.span, let expected_arg_tys = self.expected_types_for_fn_args(call_expr.span,
expected, expected,
fn_sig.output.clone(), fn_sig.output().clone(),
&fn_sig.inputs); fn_sig.inputs());
self.check_argument_types(call_expr.span, self.check_argument_types(call_expr.span,
&fn_sig.inputs, fn_sig.inputs(),
&expected_arg_tys, &expected_arg_tys,
arg_exprs, arg_exprs,
fn_sig.variadic, fn_sig.variadic(),
TupleArgumentsFlag::TupleArguments, TupleArgumentsFlag::TupleArguments,
None); None);
fn_sig.output fn_sig.output()
} }
fn confirm_overloaded_call(&self, fn confirm_overloaded_call(&self,
@ -365,12 +365,12 @@ impl<'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> for CallResolution<'gcx, 'tc
debug!("attempt_resolution: method_callee={:?}", method_callee); debug!("attempt_resolution: method_callee={:?}", method_callee);
for (&method_arg_ty, &self_arg_ty) in for (method_arg_ty, self_arg_ty) in
method_sig.inputs[1..].iter().zip(&self.fn_sig.inputs) { method_sig.inputs().into_iter().skip(1).zip(self.fn_sig.inputs()) {
fcx.demand_eqtype(self.call_expr.span, self_arg_ty, method_arg_ty); fcx.demand_eqtype(self.call_expr.span, &self_arg_ty, &method_arg_ty);
} }
fcx.demand_eqtype(self.call_expr.span, method_sig.output, self.fn_sig.output); fcx.demand_eqtype(self.call_expr.span, method_sig.output(), self.fn_sig.output());
fcx.write_overloaded_call_method_map(self.call_expr, method_callee); fcx.write_overloaded_call_method_map(self.call_expr, method_callee);
} }

View file

@ -86,7 +86,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// Tuple up the arguments and insert the resulting function type into // Tuple up the arguments and insert the resulting function type into
// the `closures` table. // the `closures` table.
fn_ty.sig.0.inputs = vec![self.tcx.intern_tup(&fn_ty.sig.0.inputs[..])]; fn_ty.sig.0 = ty::FnSig::new(vec![self.tcx.intern_tup(fn_ty.sig.skip_binder().inputs())],
fn_ty.sig.skip_binder().output(),
fn_ty.sig.variadic()
);
debug!("closure for {:?} --> sig={:?} opt_kind={:?}", debug!("closure for {:?} --> sig={:?} opt_kind={:?}",
expr_def_id, expr_def_id,
@ -224,11 +227,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
debug!("deduce_sig_from_projection: ret_param_ty {:?}", debug!("deduce_sig_from_projection: ret_param_ty {:?}",
ret_param_ty); ret_param_ty);
let fn_sig = ty::FnSig { let fn_sig = ty::FnSig::new(input_tys, ret_param_ty, false);
inputs: input_tys,
output: ret_param_ty,
variadic: false,
};
debug!("deduce_sig_from_projection: fn_sig {:?}", fn_sig); debug!("deduce_sig_from_projection: fn_sig {:?}", fn_sig);
Some(fn_sig) Some(fn_sig)

View file

@ -495,8 +495,8 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
_ => bug!("{:?} is not a MethodTraitItem", trait_m), _ => bug!("{:?} is not a MethodTraitItem", trait_m),
}; };
let impl_iter = impl_sig.inputs.iter(); let impl_iter = impl_sig.inputs().iter();
let trait_iter = trait_sig.inputs.iter(); let trait_iter = trait_sig.inputs().iter();
impl_iter.zip(trait_iter) impl_iter.zip(trait_iter)
.zip(impl_m_iter) .zip(impl_m_iter)
.zip(trait_m_iter) .zip(trait_m_iter)
@ -508,7 +508,8 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
}) })
.next() .next()
.unwrap_or_else(|| { .unwrap_or_else(|| {
if infcx.sub_types(false, &cause, impl_sig.output, trait_sig.output) if infcx.sub_types(false, &cause, impl_sig.output(),
trait_sig.output())
.is_err() { .is_err() {
(impl_m_output.span(), Some(trait_m_output.span())) (impl_m_output.span(), Some(trait_m_output.span()))
} else { } else {
@ -681,9 +682,9 @@ fn compare_number_of_method_arguments<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
}; };
let impl_m_fty = m_fty(impl_m); let impl_m_fty = m_fty(impl_m);
let trait_m_fty = m_fty(trait_m); let trait_m_fty = m_fty(trait_m);
if impl_m_fty.sig.0.inputs.len() != trait_m_fty.sig.0.inputs.len() { let trait_number_args = trait_m_fty.sig.inputs().skip_binder().len();
let trait_number_args = trait_m_fty.sig.0.inputs.len(); let impl_number_args = impl_m_fty.sig.inputs().skip_binder().len();
let impl_number_args = impl_m_fty.sig.0.inputs.len(); if trait_number_args != impl_number_args {
let trait_m_node_id = tcx.map.as_local_node_id(trait_m.def_id); let trait_m_node_id = tcx.map.as_local_node_id(trait_m.def_id);
let trait_span = if let Some(trait_id) = trait_m_node_id { let trait_span = if let Some(trait_id) = trait_m_node_id {
match tcx.map.expect_trait_item(trait_id).node { match tcx.map.expect_trait_item(trait_id).node {

View file

@ -42,11 +42,7 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let fty = tcx.mk_fn_def(def_id, substs, tcx.mk_bare_fn(ty::BareFnTy { let fty = tcx.mk_fn_def(def_id, substs, tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Unsafe, unsafety: hir::Unsafety::Unsafe,
abi: abi, abi: abi,
sig: ty::Binder(FnSig { sig: ty::Binder(FnSig::new(inputs, output, false)),
inputs: inputs,
output: output,
variadic: false,
}),
})); }));
let i_n_tps = tcx.item_generics(def_id).types.len(); let i_n_tps = tcx.item_generics(def_id).types.len();
if i_n_tps != n_tps { if i_n_tps != n_tps {
@ -299,11 +295,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
let fn_ty = tcx.mk_bare_fn(ty::BareFnTy { let fn_ty = tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
abi: Abi::Rust, abi: Abi::Rust,
sig: ty::Binder(FnSig { sig: ty::Binder(FnSig::new(vec![mut_u8], tcx.mk_nil(), false)),
inputs: vec![mut_u8],
output: tcx.mk_nil(),
variadic: false,
}),
}); });
(0, vec![tcx.mk_fn_ptr(fn_ty), mut_u8, mut_u8], tcx.types.i32) (0, vec![tcx.mk_fn_ptr(fn_ty), mut_u8, mut_u8], tcx.types.i32)
} }
@ -377,21 +369,21 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
let sig = tcx.item_type(def_id).fn_sig(); let sig = tcx.item_type(def_id).fn_sig();
let sig = tcx.no_late_bound_regions(sig).unwrap(); let sig = tcx.no_late_bound_regions(sig).unwrap();
if intr.inputs.len() != sig.inputs.len() { if intr.inputs.len() != sig.inputs().len() {
span_err!(tcx.sess, it.span, E0444, span_err!(tcx.sess, it.span, E0444,
"platform-specific intrinsic has invalid number of \ "platform-specific intrinsic has invalid number of \
arguments: found {}, expected {}", arguments: found {}, expected {}",
sig.inputs.len(), intr.inputs.len()); sig.inputs().len(), intr.inputs.len());
return return
} }
let input_pairs = intr.inputs.iter().zip(&sig.inputs); let input_pairs = intr.inputs.iter().zip(sig.inputs());
for (i, (expected_arg, arg)) in input_pairs.enumerate() { for (i, (expected_arg, arg)) in input_pairs.enumerate() {
match_intrinsic_type_to_type(ccx, &format!("argument {}", i + 1), it.span, match_intrinsic_type_to_type(ccx, &format!("argument {}", i + 1), it.span,
&mut structural_to_nomimal, expected_arg, arg); &mut structural_to_nomimal, expected_arg, arg);
} }
match_intrinsic_type_to_type(ccx, "return value", it.span, match_intrinsic_type_to_type(ccx, "return value", it.span,
&mut structural_to_nomimal, &mut structural_to_nomimal,
&intr.output, sig.output); &intr.output, sig.output());
return return
} }
None => { None => {

View file

@ -246,7 +246,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
infer::FnCall, infer::FnCall,
&fty.sig).0; &fty.sig).0;
let fn_sig = self.instantiate_type_scheme(span, trait_ref.substs, &fn_sig); let fn_sig = self.instantiate_type_scheme(span, trait_ref.substs, &fn_sig);
let transformed_self_ty = fn_sig.inputs[0]; let transformed_self_ty = fn_sig.inputs()[0];
let method_ty = tcx.mk_fn_def(def_id, trait_ref.substs, let method_ty = tcx.mk_fn_def(def_id, trait_ref.substs,
tcx.mk_bare_fn(ty::BareFnTy { tcx.mk_bare_fn(ty::BareFnTy {
sig: ty::Binder(fn_sig), sig: ty::Binder(fn_sig),

View file

@ -785,18 +785,18 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
// Create the function context. This is either derived from scratch or, // Create the function context. This is either derived from scratch or,
// in the case of function expressions, based on the outer context. // in the case of function expressions, based on the outer context.
let mut fcx = FnCtxt::new(inherited, fn_sig.output, body.id); let mut fcx = FnCtxt::new(inherited, fn_sig.output(), body.id);
*fcx.ps.borrow_mut() = UnsafetyState::function(unsafety, unsafety_id); *fcx.ps.borrow_mut() = UnsafetyState::function(unsafety, unsafety_id);
fcx.require_type_is_sized(fcx.ret_ty, decl.output.span(), traits::ReturnType); fcx.require_type_is_sized(fcx.ret_ty, decl.output.span(), traits::ReturnType);
fcx.ret_ty = fcx.instantiate_anon_types(&fcx.ret_ty); fcx.ret_ty = fcx.instantiate_anon_types(&fcx.ret_ty);
fn_sig.output = fcx.ret_ty; fn_sig = ty::FnSig::new(fn_sig.inputs().to_owned(), fcx.ret_ty, fn_sig.variadic());
{ {
let mut visit = GatherLocalsVisitor { fcx: &fcx, }; let mut visit = GatherLocalsVisitor { fcx: &fcx, };
// Add formal parameters. // Add formal parameters.
for (arg_ty, input) in fn_sig.inputs.iter().zip(&decl.inputs) { for (arg_ty, input) in fn_sig.inputs().iter().zip(&decl.inputs) {
// The type of the argument must be well-formed. // The type of the argument must be well-formed.
// //
// NB -- this is now checked in wfcheck, but that // NB -- this is now checked in wfcheck, but that
@ -2474,13 +2474,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ty::TyFnDef(def_id, .., ref fty) => { ty::TyFnDef(def_id, .., ref fty) => {
// HACK(eddyb) ignore self in the definition (see above). // HACK(eddyb) ignore self in the definition (see above).
let expected_arg_tys = self.expected_types_for_fn_args(sp, expected, let expected_arg_tys = self.expected_types_for_fn_args(sp, expected,
fty.sig.0.output, fty.sig.0.output(),
&fty.sig.0.inputs[1..]); &fty.sig.0.inputs()[1..]);
self.check_argument_types(sp, &fty.sig.0.inputs()[1..], &expected_arg_tys[..],
self.check_argument_types(sp, &fty.sig.0.inputs[1..], &expected_arg_tys[..], args_no_rcvr, fty.sig.0.variadic(), tuple_arguments,
args_no_rcvr, fty.sig.0.variadic, tuple_arguments,
self.tcx.map.span_if_local(def_id)); self.tcx.map.span_if_local(def_id));
fty.sig.0.output fty.sig.0.output()
} }
_ => { _ => {
span_bug!(callee_expr.span, "method without bare fn type"); span_bug!(callee_expr.span, "method without bare fn type");

View file

@ -296,10 +296,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
// //
// FIXME(#27579) return types should not be implied bounds // FIXME(#27579) return types should not be implied bounds
let fn_sig_tys: Vec<_> = let fn_sig_tys: Vec<_> =
fn_sig.inputs.iter() fn_sig.inputs().iter().cloned().chain(Some(fn_sig.output())).collect();
.cloned()
.chain(Some(fn_sig.output))
.collect();
let old_body_id = self.set_body_id(body_id.node_id()); let old_body_id = self.set_body_id(body_id.node_id());
self.relate_free_regions(&fn_sig_tys[..], body_id.node_id(), span); self.relate_free_regions(&fn_sig_tys[..], body_id.node_id(), span);
@ -940,7 +937,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
let fn_sig = method.ty.fn_sig(); let fn_sig = method.ty.fn_sig();
let fn_sig = // late-bound regions should have been instantiated let fn_sig = // late-bound regions should have been instantiated
self.tcx.no_late_bound_regions(fn_sig).unwrap(); self.tcx.no_late_bound_regions(fn_sig).unwrap();
let self_ty = fn_sig.inputs[0]; let self_ty = fn_sig.inputs()[0];
let (m, r) = match self_ty.sty { let (m, r) = match self_ty.sty {
ty::TyRef(r, ref m) => (m.mutbl, r), ty::TyRef(r, ref m) => (m.mutbl, r),
_ => { _ => {
@ -967,8 +964,8 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
self.type_must_outlive(infer::CallRcvr(deref_expr.span), self.type_must_outlive(infer::CallRcvr(deref_expr.span),
self_ty, r_deref_expr); self_ty, r_deref_expr);
self.type_must_outlive(infer::CallReturn(deref_expr.span), self.type_must_outlive(infer::CallReturn(deref_expr.span),
fn_sig.output, r_deref_expr); fn_sig.output(), r_deref_expr);
fn_sig.output fn_sig.output()
} }
None => derefd_ty None => derefd_ty
}; };

View file

@ -449,15 +449,15 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
let fty = fcx.instantiate_type_scheme(span, free_substs, &fty); let fty = fcx.instantiate_type_scheme(span, free_substs, &fty);
let sig = fcx.tcx.liberate_late_bound_regions(free_id_outlive, &fty.sig); let sig = fcx.tcx.liberate_late_bound_regions(free_id_outlive, &fty.sig);
for &input_ty in &sig.inputs { for input_ty in sig.inputs() {
fcx.register_wf_obligation(input_ty, span, self.code.clone()); fcx.register_wf_obligation(&input_ty, span, self.code.clone());
} }
implied_bounds.extend(sig.inputs); implied_bounds.extend(sig.inputs());
fcx.register_wf_obligation(sig.output, span, self.code.clone()); fcx.register_wf_obligation(sig.output(), span, self.code.clone());
// FIXME(#25759) return types should not be implied bounds // FIXME(#25759) return types should not be implied bounds
implied_bounds.push(sig.output); implied_bounds.push(sig.output());
self.check_where_clauses(fcx, span, predicates); self.check_where_clauses(fcx, span, predicates);
} }
@ -487,7 +487,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
debug!("check_method_receiver: sig={:?}", sig); debug!("check_method_receiver: sig={:?}", sig);
let self_arg_ty = sig.inputs[0]; let self_arg_ty = sig.inputs()[0];
let rcvr_ty = match ExplicitSelf::determine(self_ty, self_arg_ty) { let rcvr_ty = match ExplicitSelf::determine(self_ty, self_arg_ty) {
ExplicitSelf::ByValue => self_ty, ExplicitSelf::ByValue => self_ty,
ExplicitSelf::ByReference(region, mutbl) => { ExplicitSelf::ByReference(region, mutbl) => {

View file

@ -930,11 +930,7 @@ fn convert_variant_ctor<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
tcx.mk_fn_def(def_id, substs, tcx.mk_bare_fn(ty::BareFnTy { tcx.mk_fn_def(def_id, substs, tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
abi: abi::Abi::Rust, abi: abi::Abi::Rust,
sig: ty::Binder(ty::FnSig { sig: ty::Binder(ty::FnSig::new(inputs, ty, false))
inputs: inputs,
output: ty,
variadic: false
})
})) }))
} }
}; };
@ -2085,9 +2081,7 @@ fn compute_type_of_foreign_fn_decl<'a, 'tcx>(
ccx.tcx.mk_fn_def(def_id, substs, ccx.tcx.mk_bare_fn(ty::BareFnTy { ccx.tcx.mk_fn_def(def_id, substs, ccx.tcx.mk_bare_fn(ty::BareFnTy {
abi: abi, abi: abi,
unsafety: hir::Unsafety::Unsafe, unsafety: hir::Unsafety::Unsafe,
sig: ty::Binder(ty::FnSig {inputs: input_tys, sig: ty::Binder(ty::FnSig::new(input_tys, output, decl.variadic)),
output: output,
variadic: decl.variadic}),
})) }))
} }

View file

@ -222,11 +222,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
tcx.mk_bare_fn(ty::BareFnTy { tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
abi: Abi::Rust, abi: Abi::Rust,
sig: ty::Binder(ty::FnSig { sig: ty::Binder(ty::FnSig::new(Vec::new(), tcx.mk_nil(), false))
inputs: Vec::new(),
output: tcx.mk_nil(),
variadic: false
})
})); }));
require_same_types( require_same_types(
@ -274,14 +270,14 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
tcx.mk_bare_fn(ty::BareFnTy { tcx.mk_bare_fn(ty::BareFnTy {
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
abi: Abi::Rust, abi: Abi::Rust,
sig: ty::Binder(ty::FnSig { sig: ty::Binder(ty::FnSig::new(
inputs: vec![ vec![
tcx.types.isize, tcx.types.isize,
tcx.mk_imm_ptr(tcx.mk_imm_ptr(tcx.types.u8)) tcx.mk_imm_ptr(tcx.mk_imm_ptr(tcx.types.u8))
], ],
output: tcx.types.isize, tcx.types.isize,
variadic: false, false,
}), )),
})); }));
require_same_types( require_same_types(

View file

@ -467,10 +467,10 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
sig: &ty::PolyFnSig<'tcx>, sig: &ty::PolyFnSig<'tcx>,
variance: VarianceTermPtr<'a>) { variance: VarianceTermPtr<'a>) {
let contra = self.contravariant(variance); let contra = self.contravariant(variance);
for &input in &sig.0.inputs { for &input in sig.0.inputs() {
self.add_constraints_from_ty(generics, input, contra); self.add_constraints_from_ty(generics, input, contra);
} }
self.add_constraints_from_ty(generics, sig.0.output, variance); self.add_constraints_from_ty(generics, sig.0.output(), variance);
} }
/// Adds constraints appropriate for a region appearing in a /// Adds constraints appropriate for a region appearing in a

View file

@ -1152,11 +1152,11 @@ impl<'a, 'tcx> Clean<FnDecl> for (DefId, &'a ty::PolyFnSig<'tcx>) {
cx.tcx.sess.cstore.fn_arg_names(did).into_iter() cx.tcx.sess.cstore.fn_arg_names(did).into_iter()
}.peekable(); }.peekable();
FnDecl { FnDecl {
output: Return(sig.0.output.clean(cx)), output: Return(sig.skip_binder().output().clean(cx)),
attrs: Attributes::default(), attrs: Attributes::default(),
variadic: sig.0.variadic, variadic: sig.skip_binder().variadic,
inputs: Arguments { inputs: Arguments {
values: sig.0.inputs.iter().map(|t| { values: sig.skip_binder().inputs().iter().map(|t| {
Argument { Argument {
type_: t.clean(cx), type_: t.clean(cx),
id: ast::CRATE_NODE_ID, id: ast::CRATE_NODE_ID,