Skip to content

Commit 82577d5

Browse files
committed
Simplify some signatures
1 parent e2aae87 commit 82577d5

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,12 @@ pub fn check_generic_arg_count_for_call(
407407
seg: &hir::PathSegment<'_>,
408408
is_method_call: IsMethodCall,
409409
) -> GenericArgCountResult {
410-
let empty_args = hir::GenericArgs::none();
411-
let gen_args = seg.args.unwrap_or(&empty_args);
412410
let gen_pos = match is_method_call {
413411
IsMethodCall::Yes => GenericArgPosition::MethodCall,
414412
IsMethodCall::No => GenericArgPosition::Value,
415413
};
416414
let has_self = generics.parent.is_none() && generics.has_self;
417-
418-
check_generic_arg_count(tcx, def_id, seg, generics, gen_args, gen_pos, has_self, seg.infer_args)
415+
check_generic_arg_count(tcx, def_id, seg, generics, gen_pos, has_self)
419416
}
420417

421418
/// Checks that the correct number of generic arguments have been provided.
@@ -426,11 +423,10 @@ pub(crate) fn check_generic_arg_count(
426423
def_id: DefId,
427424
seg: &hir::PathSegment<'_>,
428425
gen_params: &ty::Generics,
429-
gen_args: &hir::GenericArgs<'_>,
430426
gen_pos: GenericArgPosition,
431427
has_self: bool,
432-
infer_args: bool,
433428
) -> GenericArgCountResult {
429+
let gen_args = seg.args();
434430
let default_counts = gen_params.own_defaults();
435431
let param_counts = gen_params.own_counts();
436432

@@ -451,7 +447,7 @@ pub(crate) fn check_generic_arg_count(
451447
.count();
452448
let named_const_param_count = param_counts.consts - synth_const_param_count;
453449
let infer_lifetimes =
454-
(gen_pos != GenericArgPosition::Type || infer_args) && !gen_args.has_lifetime_params();
450+
(gen_pos != GenericArgPosition::Type || seg.infer_args) && !gen_args.has_lifetime_params();
455451

456452
if gen_pos != GenericArgPosition::Type
457453
&& let Some(b) = gen_args.bindings.first()
@@ -584,7 +580,7 @@ pub(crate) fn check_generic_arg_count(
584580
};
585581

586582
let args_correct = {
587-
let expected_min = if infer_args {
583+
let expected_min = if seg.infer_args {
588584
0
589585
} else {
590586
param_counts.consts + named_type_param_count

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
310310
def_id,
311311
&[],
312312
item_segment,
313-
item_segment.args(),
314-
item_segment.infer_args,
315313
None,
316314
ty::BoundConstness::NotConst,
317315
);
@@ -355,14 +353,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
355353
/// type itself: `['a]`. The returned `GenericArgsRef` concatenates these two
356354
/// lists: `[Vec<u8>, u8, 'a]`.
357355
#[instrument(level = "debug", skip(self, span), ret)]
358-
fn lower_generic_args_of_path<'a>(
356+
fn lower_generic_args_of_path(
359357
&self,
360358
span: Span,
361359
def_id: DefId,
362360
parent_args: &[ty::GenericArg<'tcx>],
363-
seg: &hir::PathSegment<'_>,
364-
generic_args: &'a hir::GenericArgs<'tcx>,
365-
infer_args: bool,
361+
segment: &hir::PathSegment<'tcx>,
366362
self_ty: Option<Ty<'tcx>>,
367363
constness: ty::BoundConstness,
368364
) -> (GenericArgsRef<'tcx>, GenericArgCountResult) {
@@ -390,12 +386,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
390386
let mut arg_count = check_generic_arg_count(
391387
tcx,
392388
def_id,
393-
seg,
389+
segment,
394390
generics,
395-
generic_args,
396391
GenericArgPosition::Type,
397392
self_ty.is_some(),
398-
infer_args,
399393
);
400394

401395
if let Err(err) = &arg_count.correct
@@ -570,9 +564,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
570564
lowerer: self,
571565
def_id,
572566
span,
573-
generic_args,
567+
generic_args: segment.args(),
574568
inferred_params: vec![],
575-
infer_args,
569+
infer_args: segment.infer_args,
576570
};
577571
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness
578572
&& generics.has_self
@@ -613,8 +607,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
613607
item_def_id,
614608
parent_args,
615609
item_segment,
616-
item_segment.args(),
617-
item_segment.infer_args,
618610
None,
619611
ty::BoundConstness::NotConst,
620612
);
@@ -683,8 +675,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
683675
) -> GenericArgCountResult {
684676
let trait_def_id = trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise());
685677
let trait_segment = trait_ref.path.segments.last().unwrap();
686-
let args = trait_segment.args();
687-
688678
self.prohibit_generic_args(trait_ref.path.segments.split_last().unwrap().1.iter(), |_| {});
689679
self.complain_about_internal_fn_trait(span, trait_def_id, trait_segment, false);
690680

@@ -693,8 +683,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
693683
trait_def_id,
694684
&[],
695685
trait_segment,
696-
args,
697-
trait_segment.infer_args,
698686
Some(self_ty),
699687
constness,
700688
);
@@ -712,7 +700,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
712700
bounds.push_trait_bound(tcx, poly_trait_ref, span, polarity);
713701

714702
let mut dup_bindings = FxIndexMap::default();
715-
for binding in args.bindings {
703+
for binding in trait_segment.args().bindings {
716704
// Don't register additional associated type bounds for negative bounds,
717705
// since we should have emitten an error for them earlier, and they will
718706
// not be well-formed!
@@ -758,8 +746,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
758746
trait_def_id,
759747
&[],
760748
trait_segment,
761-
trait_segment.args(),
762-
trait_segment.infer_args,
763749
Some(self_ty),
764750
constness,
765751
);
@@ -2493,8 +2479,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24932479
def_id,
24942480
&[],
24952481
&hir::PathSegment::invalid(),
2496-
&GenericArgs::none(),
2497-
true,
24982482
None,
24992483
ty::BoundConstness::NotConst,
25002484
);

0 commit comments

Comments
 (0)