Skip to content

Commit be398be

Browse files
committed
Simplify some signatures
1 parent a725439 commit be398be

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

compiler/rustc_hir_analysis/src/astconv/generics.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,12 @@ pub fn check_generic_arg_count_for_call(
409409
seg: &hir::PathSegment<'_>,
410410
is_method_call: IsMethodCall,
411411
) -> GenericArgCountResult {
412-
let empty_args = hir::GenericArgs::none();
413-
let gen_args = seg.args.unwrap_or(&empty_args);
414412
let gen_pos = match is_method_call {
415413
IsMethodCall::Yes => GenericArgPosition::MethodCall,
416414
IsMethodCall::No => GenericArgPosition::Value,
417415
};
418416
let has_self = generics.parent.is_none() && generics.has_self;
419-
420-
check_generic_arg_count(tcx, def_id, seg, generics, gen_args, gen_pos, has_self, seg.infer_args)
417+
check_generic_arg_count(tcx, def_id, seg, generics, gen_pos, has_self)
421418
}
422419

423420
/// Checks that the correct number of generic arguments have been provided.
@@ -428,11 +425,10 @@ pub(crate) fn check_generic_arg_count(
428425
def_id: DefId,
429426
seg: &hir::PathSegment<'_>,
430427
gen_params: &ty::Generics,
431-
gen_args: &hir::GenericArgs<'_>,
432428
gen_pos: GenericArgPosition,
433429
has_self: bool,
434-
infer_args: bool,
435430
) -> GenericArgCountResult {
431+
let gen_args = seg.args();
436432
let default_counts = gen_params.own_defaults();
437433
let param_counts = gen_params.own_counts();
438434

@@ -453,7 +449,7 @@ pub(crate) fn check_generic_arg_count(
453449
.count();
454450
let named_const_param_count = param_counts.consts - synth_const_param_count;
455451
let infer_lifetimes =
456-
(gen_pos != GenericArgPosition::Type || infer_args) && !gen_args.has_lifetime_params();
452+
(gen_pos != GenericArgPosition::Type || seg.infer_args) && !gen_args.has_lifetime_params();
457453

458454
if gen_pos != GenericArgPosition::Type
459455
&& let Some(b) = gen_args.bindings.first()
@@ -586,7 +582,7 @@ pub(crate) fn check_generic_arg_count(
586582
};
587583

588584
let args_correct = {
589-
let expected_min = if infer_args {
585+
let expected_min = if seg.infer_args {
590586
0
591587
} else {
592588
param_counts.consts + named_type_param_count

compiler/rustc_hir_analysis/src/astconv/mod.rs

+6-22
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
284284
def_id,
285285
&[],
286286
item_segment,
287-
item_segment.args(),
288-
item_segment.infer_args,
289287
None,
290288
ty::BoundConstness::NotConst,
291289
);
@@ -329,14 +327,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
329327
/// type itself: `['a]`. The returned `GenericArgsRef` concatenates these two
330328
/// lists: `[Vec<u8>, u8, 'a]`.
331329
#[instrument(level = "debug", skip(self, span), ret)]
332-
fn lower_generic_args_of_path<'a>(
330+
fn lower_generic_args_of_path(
333331
&self,
334332
span: Span,
335333
def_id: DefId,
336334
parent_args: &[ty::GenericArg<'tcx>],
337-
seg: &hir::PathSegment<'_>,
338-
generic_args: &'a hir::GenericArgs<'tcx>,
339-
infer_args: bool,
335+
segment: &hir::PathSegment<'tcx>,
340336
self_ty: Option<Ty<'tcx>>,
341337
constness: ty::BoundConstness,
342338
) -> (GenericArgsRef<'tcx>, GenericArgCountResult) {
@@ -364,12 +360,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
364360
let mut arg_count = check_generic_arg_count(
365361
tcx,
366362
def_id,
367-
seg,
363+
segment,
368364
generics,
369-
generic_args,
370365
GenericArgPosition::Type,
371366
self_ty.is_some(),
372-
infer_args,
373367
);
374368

375369
if let Err(err) = &arg_count.correct
@@ -544,9 +538,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
544538
lowerer: self,
545539
def_id,
546540
span,
547-
generic_args,
541+
generic_args: segment.args(),
548542
inferred_params: vec![],
549-
infer_args,
543+
infer_args: segment.infer_args,
550544
};
551545
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness
552546
&& generics.has_self
@@ -589,8 +583,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
589583
item_def_id,
590584
parent_args,
591585
item_segment,
592-
item_segment.args(),
593-
item_segment.infer_args,
594586
None,
595587
ty::BoundConstness::NotConst,
596588
);
@@ -657,8 +649,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
657649
) -> GenericArgCountResult {
658650
let trait_def_id = trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise());
659651
let trait_segment = trait_ref.path.segments.last().unwrap();
660-
let args = trait_segment.args();
661-
662652
self.prohibit_generic_args(trait_ref.path.segments.split_last().unwrap().1.iter(), |_| {});
663653
self.complain_about_internal_fn_trait(span, trait_def_id, trait_segment, false);
664654

@@ -667,8 +657,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
667657
trait_def_id,
668658
&[],
669659
trait_segment,
670-
args,
671-
trait_segment.infer_args,
672660
Some(self_ty),
673661
constness,
674662
);
@@ -686,7 +674,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
686674
bounds.push_trait_bound(tcx, poly_trait_ref, span, polarity);
687675

688676
let mut dup_bindings = FxIndexMap::default();
689-
for binding in args.bindings {
677+
for binding in trait_segment.args().bindings {
690678
// Don't register additional associated type bounds for negative bounds,
691679
// since we should have emitten an error for them earlier, and they will
692680
// not be well-formed!
@@ -732,8 +720,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
732720
trait_def_id,
733721
&[],
734722
trait_segment,
735-
trait_segment.args(),
736-
trait_segment.infer_args,
737723
Some(self_ty),
738724
constness,
739725
);
@@ -2442,8 +2428,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24422428
def_id,
24432429
&[],
24442430
&hir::PathSegment::invalid(),
2445-
&GenericArgs::none(),
2446-
true,
24472431
None,
24482432
ty::BoundConstness::NotConst,
24492433
);

0 commit comments

Comments
 (0)