Skip to content

Commit

Permalink
Rename variadic to c_variadic
Browse files Browse the repository at this point in the history
Function signatures with the `variadic` member set are actually
C-variadic functions. Make this a little more explicit by renaming the
`variadic` boolean value, `c_variadic`.
  • Loading branch information
dlrobertson committed Feb 27, 2019
1 parent a618ad6 commit 08bd4ff
Show file tree
Hide file tree
Showing 43 changed files with 119 additions and 119 deletions.
6 changes: 3 additions & 3 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ impl<'a> LoweringContext<'a> {
let decl = FnDecl {
inputs: vec![],
output,
variadic: false
c_variadic: false
};
let body_id = self.record_body(body_expr, Some(&decl));
self.is_generator = prev_is_generator;
Expand Down Expand Up @@ -2118,7 +2118,7 @@ impl<'a> LoweringContext<'a> {
P(hir::FnDecl {
inputs,
output,
variadic: decl.variadic,
c_variadic: decl.c_variadic,
implicit_self: decl.inputs.get(0).map_or(
hir::ImplicitSelfKind::None,
|arg| {
Expand Down Expand Up @@ -3973,7 +3973,7 @@ impl<'a> LoweringContext<'a> {
let outer_decl = FnDecl {
inputs: decl.inputs.clone(),
output: FunctionRetTy::Default(fn_decl_span),
variadic: false,
c_variadic: false,
};
// We need to lower the declaration outside the new scope, because we
// have to conserve the state of being inside a loop condition for the
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ pub struct Arg {
pub struct FnDecl {
pub inputs: HirVec<Ty>,
pub output: FunctionRetTy,
pub variadic: bool,
pub c_variadic: bool,
/// Does the function have an implicit self?
pub implicit_self: ImplicitSelfKind,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ impl<'a> State<'a> {
s.print_type(ty)?;
s.end()
})?;
if decl.variadic {
if decl.c_variadic {
self.s.word(", ...")?;
}
self.pclose()?;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl_stable_hash_for!(enum hir::TyKind {
impl_stable_hash_for!(struct hir::FnDecl {
inputs,
output,
variadic,
c_variadic,
implicit_self
});

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl_stable_hash_for!(struct ty::GenSig<'tcx> {

impl_stable_hash_for!(struct ty::FnSig<'tcx> {
inputs_and_output,
variadic,
c_variadic,
unsafety,
abi
});
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
if let ty::FnSig {
unsafety: hir::Unsafety::Normal,
abi: Abi::Rust,
variadic: false,
c_variadic: false,
..
} = self_ty.fn_sig(self.tcx()).skip_binder()
{
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.mk_fn_sig(
params_iter,
s.output(),
s.variadic,
s.c_variadic,
hir::Unsafety::Normal,
abi::Abi::Rust,
)
Expand Down Expand Up @@ -2779,7 +2779,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn mk_fn_sig<I>(self,
inputs: I,
output: I::Item,
variadic: bool,
c_variadic: bool,
unsafety: hir::Unsafety,
abi: abi::Abi)
-> <I::Item as InternIteratorElement<Ty<'tcx>, ty::FnSig<'tcx>>>::Output
Expand All @@ -2788,7 +2788,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
{
inputs.chain(iter::once(output)).intern_with(|xs| ty::FnSig {
inputs_and_output: self.intern_type_list(xs),
variadic, unsafety, abi
c_variadic, unsafety, abi
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a, 'tcx> Instance<'tcx> {
sig.map_bound(|sig| tcx.mk_fn_sig(
iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()),
sig.output(),
sig.variadic,
sig.c_variadic,
sig.unsafety,
sig.abi
))
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
{
let tcx = relation.tcx();

if a.variadic != b.variadic {
if a.c_variadic != b.c_variadic {
return Err(TypeError::VariadicMismatch(
expected_found(relation, &a.variadic, &b.variadic)));
expected_found(relation, &a.c_variadic, &b.c_variadic)));
}
let unsafety = relation.relate(&a.unsafety, &b.unsafety)?;
let abi = relation.relate(&a.abi, &b.abi)?;
Expand All @@ -171,7 +171,7 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
});
Ok(ty::FnSig {
inputs_and_output: tcx.mk_type_list(inputs_and_output)?,
variadic: a.variadic,
c_variadic: a.c_variadic,
unsafety,
abi,
})
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> {
tcx.lift(&self.inputs_and_output).map(|x| {
ty::FnSig {
inputs_and_output: x,
variadic: self.variadic,
c_variadic: self.c_variadic,
unsafety: self.unsafety,
abi: self.abi,
}
Expand Down Expand Up @@ -832,7 +832,7 @@ BraceStructTypeFoldableImpl! {

BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
inputs_and_output, variadic, unsafety, abi
inputs_and_output, c_variadic, unsafety, abi
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,11 @@ impl<'tcx> PolyGenSig<'tcx> {
///
/// - `inputs`: is the list of arguments and their modes.
/// - `output`: is the return type.
/// - `variadic`: indicates whether this is a C-variadic function.
/// - `c_variadic`: indicates whether this is a C-variadic function.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
pub struct FnSig<'tcx> {
pub inputs_and_output: &'tcx List<Ty<'tcx>>,
pub variadic: bool,
pub c_variadic: bool,
pub unsafety: hir::Unsafety,
pub abi: abi::Abi,
}
Expand Down Expand Up @@ -1016,8 +1016,8 @@ impl<'tcx> PolyFnSig<'tcx> {
pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
self.map_bound_ref(|fn_sig| fn_sig.output())
}
pub fn variadic(&self) -> bool {
self.skip_binder().variadic
pub fn c_variadic(&self) -> bool {
self.skip_binder().c_variadic
}
pub fn unsafety(&self) -> hir::Unsafety {
self.skip_binder().unsafety
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl PrintContext {
fn fn_sig<F: fmt::Write>(&mut self,
f: &mut F,
inputs: &[Ty<'_>],
variadic: bool,
c_variadic: bool,
output: Ty<'_>)
-> fmt::Result {
write!(f, "(")?;
Expand All @@ -370,7 +370,7 @@ impl PrintContext {
for &ty in inputs {
print!(f, self, write(", "), print_display(ty))?;
}
if variadic {
if c_variadic {
write!(f, ", ...")?;
}
}
Expand Down Expand Up @@ -1074,10 +1074,10 @@ define_print! {
}

write!(f, "fn")?;
cx.fn_sig(f, self.inputs(), self.variadic, self.output())
cx.fn_sig(f, self.inputs(), self.c_variadic, self.output())
}
debug {
write!(f, "({:?}; variadic: {})->{:?}", self.inputs(), self.variadic, self.output())
write!(f, "({:?}; c_variadic: {})->{:?}", self.inputs(), self.c_variadic, self.output())
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_codegen_llvm/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {

let mut inputs = sig.inputs();
let extra_args = if sig.abi == RustCall {
assert!(!sig.variadic && extra_args.is_empty());
assert!(!sig.c_variadic && extra_args.is_empty());

match sig.inputs().last().unwrap().sty {
ty::Tuple(ref tupled_arguments) => {
Expand All @@ -435,7 +435,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
}
}
} else {
assert!(sig.variadic || extra_args.is_empty());
assert!(sig.c_variadic || extra_args.is_empty());
extra_args
};

Expand Down Expand Up @@ -531,7 +531,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
// If this is a C-variadic function, this is not the return value,
// and there is one or more fixed arguments; ensure that the `VaList`
// is ignored as an argument.
if sig.variadic {
if sig.c_variadic {
match (last_arg_idx, arg_idx) {
(Some(last_idx), Some(cur_idx)) if last_idx == cur_idx => {
let va_list_did = match cx.tcx.lang_items().va_list() {
Expand Down Expand Up @@ -589,7 +589,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
args: inputs.iter().chain(extra_args).enumerate().map(|(i, ty)| {
arg_of(ty, Some(i))
}).collect(),
variadic: sig.variadic,
c_variadic: sig.c_variadic,
conv,
};
fn_ty.adjust_for_abi(cx, sig.abi);
Expand Down Expand Up @@ -717,7 +717,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
llargument_tys.push(llarg_ty);
}

if self.variadic {
if self.c_variadic {
cx.type_variadic_func(&llargument_tys, llreturn_ty)
} else {
cx.type_func(&llargument_tys, llreturn_ty)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
output.pop();
}

if sig.variadic {
if sig.c_variadic {
if !sig.inputs().is_empty() {
output.push_str(", ...");
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
&mut self,
mut bx: Bx,
) {
if self.fn_ty.variadic {
if self.fn_ty.c_variadic {
if let Some(va_list) = self.va_list_ref {
bx.va_end(va_list.llval);
}
Expand Down Expand Up @@ -507,7 +507,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

// The "spoofed" `VaList` added to a C-variadic functions signature
// should not be included in the `extra_args` calculation.
let extra_args_start_idx = sig.inputs().len() - if sig.variadic { 1 } else { 0 };
let extra_args_start_idx = sig.inputs().len() - if sig.c_variadic { 1 } else { 0 };
let extra_args = &args[extra_args_start_idx..];
let extra_args = extra_args.iter().map(|op_arg| {
let op_ty = op_arg.ty(self.mir, bx.tcx());
Expand Down Expand Up @@ -695,7 +695,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// an "spoofed" `VaList`. This argument is ignored, but we need to
// populate it with a dummy operand so that the users real arguments
// are not overwritten.
let i = if sig.variadic && last_arg_idx.map(|x| x == i).unwrap_or(false) {
let i = if sig.c_variadic && last_arg_idx.map(|x| x == i).unwrap_or(false) {
let layout = match self.cx.tcx().lang_items().va_list() {
Some(did) => bx.cx().layout_of(bx.tcx().type_of(did)),
None => bug!("`va_list` language item required for C-variadics"),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
indirect_operand.store(bx, tmp);
tmp
} else {
if fx.fn_ty.variadic && last_arg_idx.map(|idx| arg_index == idx).unwrap_or(false) {
if fx.fn_ty.c_variadic && last_arg_idx.map(|idx| arg_index == idx).unwrap_or(false) {
let va_list_impl = match arg_decl.ty.ty_adt_def() {
Some(adt) => adt.non_enum_variant(),
None => bug!("`va_list` language item improperly constructed")
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
let def_id = self.cx.tcx.hir().local_def_id(id);
let sig = self.cx.tcx.fn_sig(def_id);
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
let inputs = if sig.variadic {
let inputs = if sig.c_variadic {
// Don't include the spoofed `VaList` in the functions list
// of inputs.
&sig.inputs()[..sig.inputs().len() - 1]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,12 +1604,12 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
debug!("check_call_inputs({:?}, {:?})", sig, args);
// Do not count the `VaList` argument as a "true" argument to
// a C-variadic function.
let inputs = if sig.variadic {
let inputs = if sig.c_variadic {
&sig.inputs()[..sig.inputs().len() - 1]
} else {
&sig.inputs()[..]
};
if args.len() < inputs.len() || (args.len() > inputs.len() && !sig.variadic) {
if args.len() < inputs.len() || (args.len() > inputs.len() && !sig.c_variadic) {
span_mirbug!(self, term, "call to {:?} with wrong # of args", sig);
}
for (n, (fn_arg, op_arg)) in inputs.iter().zip(args).enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/monomorphize/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
output.pop();
}

if sig.variadic {
if sig.c_variadic {
if !sig.inputs().is_empty() {
output.push_str(", ...");
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/abi/call/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
// `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
let vfp = cx.target_spec().llvm_target.ends_with("hf")
&& fty.conv != Conv::ArmAapcs
&& !fty.variadic;
&& !fty.c_variadic;

if !fty.ret.is_ignore() {
classify_ret_ty(cx, &mut fty.ret, vfp);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ pub struct FnType<'a, Ty> {
/// LLVM return type.
pub ret: ArgType<'a, Ty>,

pub variadic: bool,
pub c_variadic: bool,

pub conv: Conv,
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_traits/chalk_context/program_clauses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn assemble_builtin_sized_impls<'tcx>(
let fn_ptr = generic_types::fn_ptr(
tcx,
fn_ptr.inputs_and_output.len(),
fn_ptr.variadic,
fn_ptr.c_variadic,
fn_ptr.unsafety,
fn_ptr.abi
);
Expand Down Expand Up @@ -190,11 +190,11 @@ fn wf_clause_for_raw_ptr<'tcx>(
fn wf_clause_for_fn_ptr<'tcx>(
tcx: ty::TyCtxt<'_, '_, 'tcx>,
arity_and_output: usize,
variadic: bool,
c_variadic: bool,
unsafety: hir::Unsafety,
abi: abi::Abi
) -> Clauses<'tcx> {
let fn_ptr = generic_types::fn_ptr(tcx, arity_and_output, variadic, unsafety, abi);
let fn_ptr = generic_types::fn_ptr(tcx, arity_and_output, c_variadic, unsafety, abi);

let wf_clause = ProgramClause {
goal: DomainGoal::WellFormed(WellFormed::Ty(fn_ptr)),
Expand Down Expand Up @@ -503,7 +503,7 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
wf_clause_for_fn_ptr(
self.infcx.tcx,
fn_ptr.inputs_and_output.len(),
fn_ptr.variadic,
fn_ptr.c_variadic,
fn_ptr.unsafety,
fn_ptr.abi
)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_traits/generic_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ crate fn raw_ptr(tcx: TyCtxt<'_, '_, 'tcx>, mutbl: hir::Mutability) -> Ty<'tcx>
crate fn fn_ptr(
tcx: ty::TyCtxt<'_, '_, 'tcx>,
arity_and_output: usize,
variadic: bool,
c_variadic: bool,
unsafety: hir::Unsafety,
abi: abi::Abi
) -> Ty<'tcx> {
Expand All @@ -37,7 +37,7 @@ crate fn fn_ptr(

let fn_sig = ty::Binder::bind(ty::FnSig {
inputs_and_output,
variadic,
c_variadic,
unsafety,
abi,
});
Expand Down
Loading

0 comments on commit 08bd4ff

Please sign in to comment.