Skip to content

Commit 08bd4ff

Browse files
committed
Rename variadic to c_variadic
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`.
1 parent a618ad6 commit 08bd4ff

File tree

43 files changed

+119
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+119
-119
lines changed

src/librustc/hir/lowering.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ impl<'a> LoweringContext<'a> {
954954
let decl = FnDecl {
955955
inputs: vec![],
956956
output,
957-
variadic: false
957+
c_variadic: false
958958
};
959959
let body_id = self.record_body(body_expr, Some(&decl));
960960
self.is_generator = prev_is_generator;
@@ -2118,7 +2118,7 @@ impl<'a> LoweringContext<'a> {
21182118
P(hir::FnDecl {
21192119
inputs,
21202120
output,
2121-
variadic: decl.variadic,
2121+
c_variadic: decl.c_variadic,
21222122
implicit_self: decl.inputs.get(0).map_or(
21232123
hir::ImplicitSelfKind::None,
21242124
|arg| {
@@ -3973,7 +3973,7 @@ impl<'a> LoweringContext<'a> {
39733973
let outer_decl = FnDecl {
39743974
inputs: decl.inputs.clone(),
39753975
output: FunctionRetTy::Default(fn_decl_span),
3976-
variadic: false,
3976+
c_variadic: false,
39773977
};
39783978
// We need to lower the declaration outside the new scope, because we
39793979
// have to conserve the state of being inside a loop condition for the

src/librustc/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ pub struct Arg {
18681868
pub struct FnDecl {
18691869
pub inputs: HirVec<Ty>,
18701870
pub output: FunctionRetTy,
1871-
pub variadic: bool,
1871+
pub c_variadic: bool,
18721872
/// Does the function have an implicit self?
18731873
pub implicit_self: ImplicitSelfKind,
18741874
}

src/librustc/hir/print.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ impl<'a> State<'a> {
20072007
s.print_type(ty)?;
20082008
s.end()
20092009
})?;
2010-
if decl.variadic {
2010+
if decl.c_variadic {
20112011
self.s.word(", ...")?;
20122012
}
20132013
self.pclose()?;

src/librustc/ich/impls_hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl_stable_hash_for!(enum hir::TyKind {
368368
impl_stable_hash_for!(struct hir::FnDecl {
369369
inputs,
370370
output,
371-
variadic,
371+
c_variadic,
372372
implicit_self
373373
});
374374

src/librustc/ich/impls_ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl_stable_hash_for!(struct ty::GenSig<'tcx> {
232232

233233
impl_stable_hash_for!(struct ty::FnSig<'tcx> {
234234
inputs_and_output,
235-
variadic,
235+
c_variadic,
236236
unsafety,
237237
abi
238238
});

src/librustc/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
19441944
if let ty::FnSig {
19451945
unsafety: hir::Unsafety::Normal,
19461946
abi: Abi::Rust,
1947-
variadic: false,
1947+
c_variadic: false,
19481948
..
19491949
} = self_ty.fn_sig(self.tcx()).skip_binder()
19501950
{

src/librustc/ty/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24532453
self.mk_fn_sig(
24542454
params_iter,
24552455
s.output(),
2456-
s.variadic,
2456+
s.c_variadic,
24572457
hir::Unsafety::Normal,
24582458
abi::Abi::Rust,
24592459
)
@@ -2779,7 +2779,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27792779
pub fn mk_fn_sig<I>(self,
27802780
inputs: I,
27812781
output: I::Item,
2782-
variadic: bool,
2782+
c_variadic: bool,
27832783
unsafety: hir::Unsafety,
27842784
abi: abi::Abi)
27852785
-> <I::Item as InternIteratorElement<Ty<'tcx>, ty::FnSig<'tcx>>>::Output
@@ -2788,7 +2788,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27882788
{
27892789
inputs.chain(iter::once(output)).intern_with(|xs| ty::FnSig {
27902790
inputs_and_output: self.intern_type_list(xs),
2791-
variadic, unsafety, abi
2791+
c_variadic, unsafety, abi
27922792
})
27932793
}
27942794

src/librustc/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, 'tcx> Instance<'tcx> {
6565
sig.map_bound(|sig| tcx.mk_fn_sig(
6666
iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()),
6767
sig.output(),
68-
sig.variadic,
68+
sig.c_variadic,
6969
sig.unsafety,
7070
sig.abi
7171
))

src/librustc/ty/relate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
147147
{
148148
let tcx = relation.tcx();
149149

150-
if a.variadic != b.variadic {
150+
if a.c_variadic != b.c_variadic {
151151
return Err(TypeError::VariadicMismatch(
152-
expected_found(relation, &a.variadic, &b.variadic)));
152+
expected_found(relation, &a.c_variadic, &b.c_variadic)));
153153
}
154154
let unsafety = relation.relate(&a.unsafety, &b.unsafety)?;
155155
let abi = relation.relate(&a.abi, &b.abi)?;
@@ -171,7 +171,7 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
171171
});
172172
Ok(ty::FnSig {
173173
inputs_and_output: tcx.mk_type_list(inputs_and_output)?,
174-
variadic: a.variadic,
174+
c_variadic: a.c_variadic,
175175
unsafety,
176176
abi,
177177
})

src/librustc/ty/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> {
396396
tcx.lift(&self.inputs_and_output).map(|x| {
397397
ty::FnSig {
398398
inputs_and_output: x,
399-
variadic: self.variadic,
399+
c_variadic: self.c_variadic,
400400
unsafety: self.unsafety,
401401
abi: self.abi,
402402
}
@@ -832,7 +832,7 @@ BraceStructTypeFoldableImpl! {
832832

833833
BraceStructTypeFoldableImpl! {
834834
impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
835-
inputs_and_output, variadic, unsafety, abi
835+
inputs_and_output, c_variadic, unsafety, abi
836836
}
837837
}
838838

src/librustc/ty/sty.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -979,11 +979,11 @@ impl<'tcx> PolyGenSig<'tcx> {
979979
///
980980
/// - `inputs`: is the list of arguments and their modes.
981981
/// - `output`: is the return type.
982-
/// - `variadic`: indicates whether this is a C-variadic function.
982+
/// - `c_variadic`: indicates whether this is a C-variadic function.
983983
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
984984
pub struct FnSig<'tcx> {
985985
pub inputs_and_output: &'tcx List<Ty<'tcx>>,
986-
pub variadic: bool,
986+
pub c_variadic: bool,
987987
pub unsafety: hir::Unsafety,
988988
pub abi: abi::Abi,
989989
}
@@ -1016,8 +1016,8 @@ impl<'tcx> PolyFnSig<'tcx> {
10161016
pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
10171017
self.map_bound_ref(|fn_sig| fn_sig.output())
10181018
}
1019-
pub fn variadic(&self) -> bool {
1020-
self.skip_binder().variadic
1019+
pub fn c_variadic(&self) -> bool {
1020+
self.skip_binder().c_variadic
10211021
}
10221022
pub fn unsafety(&self) -> hir::Unsafety {
10231023
self.skip_binder().unsafety

src/librustc/util/ppaux.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl PrintContext {
360360
fn fn_sig<F: fmt::Write>(&mut self,
361361
f: &mut F,
362362
inputs: &[Ty<'_>],
363-
variadic: bool,
363+
c_variadic: bool,
364364
output: Ty<'_>)
365365
-> fmt::Result {
366366
write!(f, "(")?;
@@ -370,7 +370,7 @@ impl PrintContext {
370370
for &ty in inputs {
371371
print!(f, self, write(", "), print_display(ty))?;
372372
}
373-
if variadic {
373+
if c_variadic {
374374
write!(f, ", ...")?;
375375
}
376376
}
@@ -1074,10 +1074,10 @@ define_print! {
10741074
}
10751075

10761076
write!(f, "fn")?;
1077-
cx.fn_sig(f, self.inputs(), self.variadic, self.output())
1077+
cx.fn_sig(f, self.inputs(), self.c_variadic, self.output())
10781078
}
10791079
debug {
1080-
write!(f, "({:?}; variadic: {})->{:?}", self.inputs(), self.variadic, self.output())
1080+
write!(f, "({:?}; c_variadic: {})->{:?}", self.inputs(), self.c_variadic, self.output())
10811081
}
10821082
}
10831083
}

src/librustc_codegen_llvm/abi.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
422422

423423
let mut inputs = sig.inputs();
424424
let extra_args = if sig.abi == RustCall {
425-
assert!(!sig.variadic && extra_args.is_empty());
425+
assert!(!sig.c_variadic && extra_args.is_empty());
426426

427427
match sig.inputs().last().unwrap().sty {
428428
ty::Tuple(ref tupled_arguments) => {
@@ -435,7 +435,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
435435
}
436436
}
437437
} else {
438-
assert!(sig.variadic || extra_args.is_empty());
438+
assert!(sig.c_variadic || extra_args.is_empty());
439439
extra_args
440440
};
441441

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

720-
if self.variadic {
720+
if self.c_variadic {
721721
cx.type_variadic_func(&llargument_tys, llreturn_ty)
722722
} else {
723723
cx.type_func(&llargument_tys, llreturn_ty)

src/librustc_codegen_llvm/debuginfo/type_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
143143
output.pop();
144144
}
145145

146-
if sig.variadic {
146+
if sig.c_variadic {
147147
if !sig.inputs().is_empty() {
148148
output.push_str(", ...");
149149
} else {

src/librustc_codegen_ssa/mir/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
232232
&mut self,
233233
mut bx: Bx,
234234
) {
235-
if self.fn_ty.variadic {
235+
if self.fn_ty.c_variadic {
236236
if let Some(va_list) = self.va_list_ref {
237237
bx.va_end(va_list.llval);
238238
}
@@ -507,7 +507,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
507507

508508
// The "spoofed" `VaList` added to a C-variadic functions signature
509509
// should not be included in the `extra_args` calculation.
510-
let extra_args_start_idx = sig.inputs().len() - if sig.variadic { 1 } else { 0 };
510+
let extra_args_start_idx = sig.inputs().len() - if sig.c_variadic { 1 } else { 0 };
511511
let extra_args = &args[extra_args_start_idx..];
512512
let extra_args = extra_args.iter().map(|op_arg| {
513513
let op_ty = op_arg.ty(self.mir, bx.tcx());
@@ -695,7 +695,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
695695
// an "spoofed" `VaList`. This argument is ignored, but we need to
696696
// populate it with a dummy operand so that the users real arguments
697697
// are not overwritten.
698-
let i = if sig.variadic && last_arg_idx.map(|x| x == i).unwrap_or(false) {
698+
let i = if sig.c_variadic && last_arg_idx.map(|x| x == i).unwrap_or(false) {
699699
let layout = match self.cx.tcx().lang_items().va_list() {
700700
Some(did) => bx.cx().layout_of(bx.tcx().type_of(did)),
701701
None => bug!("`va_list` language item required for C-variadics"),

src/librustc_codegen_ssa/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
585585
indirect_operand.store(bx, tmp);
586586
tmp
587587
} else {
588-
if fx.fn_ty.variadic && last_arg_idx.map(|idx| arg_index == idx).unwrap_or(false) {
588+
if fx.fn_ty.c_variadic && last_arg_idx.map(|idx| arg_index == idx).unwrap_or(false) {
589589
let va_list_impl = match arg_decl.ty.ty_adt_def() {
590590
Some(adt) => adt.non_enum_variant(),
591591
None => bug!("`va_list` language item improperly constructed")

src/librustc_lint/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
766766
let def_id = self.cx.tcx.hir().local_def_id(id);
767767
let sig = self.cx.tcx.fn_sig(def_id);
768768
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
769-
let inputs = if sig.variadic {
769+
let inputs = if sig.c_variadic {
770770
// Don't include the spoofed `VaList` in the functions list
771771
// of inputs.
772772
&sig.inputs()[..sig.inputs().len() - 1]

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1604,12 +1604,12 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
16041604
debug!("check_call_inputs({:?}, {:?})", sig, args);
16051605
// Do not count the `VaList` argument as a "true" argument to
16061606
// a C-variadic function.
1607-
let inputs = if sig.variadic {
1607+
let inputs = if sig.c_variadic {
16081608
&sig.inputs()[..sig.inputs().len() - 1]
16091609
} else {
16101610
&sig.inputs()[..]
16111611
};
1612-
if args.len() < inputs.len() || (args.len() > inputs.len() && !sig.variadic) {
1612+
if args.len() < inputs.len() || (args.len() > inputs.len() && !sig.c_variadic) {
16131613
span_mirbug!(self, term, "call to {:?} with wrong # of args", sig);
16141614
}
16151615
for (n, (fn_arg, op_arg)) in inputs.iter().zip(args).enumerate() {

src/librustc_mir/monomorphize/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
353353
output.pop();
354354
}
355355

356-
if sig.variadic {
356+
if sig.c_variadic {
357357
if !sig.inputs().is_empty() {
358358
output.push_str(", ...");
359359
} else {

src/librustc_target/abi/call/arm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
9999
// `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
100100
let vfp = cx.target_spec().llvm_target.ends_with("hf")
101101
&& fty.conv != Conv::ArmAapcs
102-
&& !fty.variadic;
102+
&& !fty.c_variadic;
103103

104104
if !fty.ret.is_ignore() {
105105
classify_ret_ty(cx, &mut fty.ret, vfp);

src/librustc_target/abi/call/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ pub struct FnType<'a, Ty> {
531531
/// LLVM return type.
532532
pub ret: ArgType<'a, Ty>,
533533

534-
pub variadic: bool,
534+
pub c_variadic: bool,
535535

536536
pub conv: Conv,
537537
}

src/librustc_traits/chalk_context/program_clauses.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn assemble_builtin_sized_impls<'tcx>(
105105
let fn_ptr = generic_types::fn_ptr(
106106
tcx,
107107
fn_ptr.inputs_and_output.len(),
108-
fn_ptr.variadic,
108+
fn_ptr.c_variadic,
109109
fn_ptr.unsafety,
110110
fn_ptr.abi
111111
);
@@ -190,11 +190,11 @@ fn wf_clause_for_raw_ptr<'tcx>(
190190
fn wf_clause_for_fn_ptr<'tcx>(
191191
tcx: ty::TyCtxt<'_, '_, 'tcx>,
192192
arity_and_output: usize,
193-
variadic: bool,
193+
c_variadic: bool,
194194
unsafety: hir::Unsafety,
195195
abi: abi::Abi
196196
) -> Clauses<'tcx> {
197-
let fn_ptr = generic_types::fn_ptr(tcx, arity_and_output, variadic, unsafety, abi);
197+
let fn_ptr = generic_types::fn_ptr(tcx, arity_and_output, c_variadic, unsafety, abi);
198198

199199
let wf_clause = ProgramClause {
200200
goal: DomainGoal::WellFormed(WellFormed::Ty(fn_ptr)),
@@ -503,7 +503,7 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
503503
wf_clause_for_fn_ptr(
504504
self.infcx.tcx,
505505
fn_ptr.inputs_and_output.len(),
506-
fn_ptr.variadic,
506+
fn_ptr.c_variadic,
507507
fn_ptr.unsafety,
508508
fn_ptr.abi
509509
)

src/librustc_traits/generic_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ crate fn raw_ptr(tcx: TyCtxt<'_, '_, 'tcx>, mutbl: hir::Mutability) -> Ty<'tcx>
2424
crate fn fn_ptr(
2525
tcx: ty::TyCtxt<'_, '_, 'tcx>,
2626
arity_and_output: usize,
27-
variadic: bool,
27+
c_variadic: bool,
2828
unsafety: hir::Unsafety,
2929
abi: abi::Abi
3030
) -> Ty<'tcx> {
@@ -37,7 +37,7 @@ crate fn fn_ptr(
3737

3838
let fn_sig = ty::Binder::bind(ty::FnSig {
3939
inputs_and_output,
40-
variadic,
40+
c_variadic,
4141
unsafety,
4242
abi,
4343
});

0 commit comments

Comments
 (0)