@@ -336,14 +336,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
336
336
def_id : DefId ,
337
337
item_segment : & hir:: PathSegment < ' tcx > ,
338
338
) -> GenericArgsRef < ' tcx > {
339
- let ( args, _) = self . lower_generic_args_of_path (
340
- span,
341
- def_id,
342
- & [ ] ,
343
- item_segment,
344
- None ,
345
- ty:: BoundConstness :: NotConst ,
346
- ) ;
339
+ let ( args, _) = self . lower_generic_args_of_path ( span, def_id, & [ ] , item_segment, None ) ;
347
340
if let Some ( c) = item_segment. args ( ) . constraints . first ( ) {
348
341
prohibit_assoc_item_constraint ( self , c, Some ( ( def_id, item_segment, span) ) ) ;
349
342
}
@@ -392,7 +385,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
392
385
parent_args : & [ ty:: GenericArg < ' tcx > ] ,
393
386
segment : & hir:: PathSegment < ' tcx > ,
394
387
self_ty : Option < Ty < ' tcx > > ,
395
- constness : ty:: BoundConstness ,
396
388
) -> ( GenericArgsRef < ' tcx > , GenericArgCountResult ) {
397
389
// If the type is parameterized by this region, then replace this
398
390
// region with the current anon region binding (in other words,
@@ -415,7 +407,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
415
407
assert ! ( self_ty. is_none( ) ) ;
416
408
}
417
409
418
- let mut arg_count = check_generic_arg_count (
410
+ let arg_count = check_generic_arg_count (
419
411
self ,
420
412
def_id,
421
413
segment,
@@ -573,16 +565,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
573
565
}
574
566
}
575
567
}
576
- if let ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst = constness
577
- && generics. has_self
578
- && !tcx. is_const_trait ( def_id)
579
- {
580
- let reported = self . dcx ( ) . emit_err ( crate :: errors:: ConstBoundForNonConstTrait {
581
- span,
582
- modifier : constness. as_str ( ) ,
583
- } ) ;
584
- arg_count. correct = Err ( GenericArgCountMismatch { reported, invalid_args : vec ! [ ] } ) ;
585
- }
586
568
587
569
let mut args_ctx = GenericArgsCtxt {
588
570
lowerer : self ,
@@ -614,14 +596,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
614
596
parent_args : GenericArgsRef < ' tcx > ,
615
597
) -> GenericArgsRef < ' tcx > {
616
598
debug ! ( ?span, ?item_def_id, ?item_segment) ;
617
- let ( args, _) = self . lower_generic_args_of_path (
618
- span,
619
- item_def_id,
620
- parent_args,
621
- item_segment,
622
- None ,
623
- ty:: BoundConstness :: NotConst ,
624
- ) ;
599
+ let ( args, _) =
600
+ self . lower_generic_args_of_path ( span, item_def_id, parent_args, item_segment, None ) ;
625
601
if let Some ( c) = item_segment. args ( ) . constraints . first ( ) {
626
602
prohibit_assoc_item_constraint ( self , c, Some ( ( item_def_id, item_segment, span) ) ) ;
627
603
}
@@ -647,7 +623,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
647
623
self_ty,
648
624
trait_ref. path . segments . last ( ) . unwrap ( ) ,
649
625
true ,
650
- ty:: BoundConstness :: NotConst ,
651
626
)
652
627
}
653
628
@@ -700,9 +675,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
700
675
& [ ] ,
701
676
trait_segment,
702
677
Some ( self_ty) ,
703
- constness,
704
678
) ;
705
679
680
+ if let ty:: BoundConstness :: Const | ty:: BoundConstness :: ConstIfConst = constness
681
+ && !self . tcx ( ) . is_const_trait ( trait_def_id)
682
+ {
683
+ self . dcx ( ) . emit_err ( crate :: errors:: ConstBoundForNonConstTrait {
684
+ span : trait_ref. path . span ,
685
+ modifier : constness. as_str ( ) ,
686
+ } ) ;
687
+ }
688
+
706
689
let tcx = self . tcx ( ) ;
707
690
let bound_vars = tcx. late_bound_vars ( trait_ref. hir_ref_id ) ;
708
691
debug ! ( ?bound_vars) ;
@@ -762,19 +745,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
762
745
self_ty : Ty < ' tcx > ,
763
746
trait_segment : & hir:: PathSegment < ' tcx > ,
764
747
is_impl : bool ,
765
- // FIXME(effects): Move all host param things in HIR ty lowering to AST lowering.
766
- constness : ty:: BoundConstness ,
767
748
) -> ty:: TraitRef < ' tcx > {
768
749
self . complain_about_internal_fn_trait ( span, trait_def_id, trait_segment, is_impl) ;
769
750
770
- let ( generic_args, _) = self . lower_generic_args_of_path (
771
- span,
772
- trait_def_id,
773
- & [ ] ,
774
- trait_segment,
775
- Some ( self_ty) ,
776
- constness,
777
- ) ;
751
+ let ( generic_args, _) =
752
+ self . lower_generic_args_of_path ( span, trait_def_id, & [ ] , trait_segment, Some ( self_ty) ) ;
778
753
if let Some ( c) = trait_segment. args ( ) . constraints . first ( ) {
779
754
prohibit_assoc_item_constraint ( self , c, Some ( ( trait_def_id, trait_segment, span) ) ) ;
780
755
}
@@ -1542,7 +1517,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1542
1517
item_def_id : DefId ,
1543
1518
trait_segment : & hir:: PathSegment < ' tcx > ,
1544
1519
item_segment : & hir:: PathSegment < ' tcx > ,
1545
- constness : ty:: BoundConstness ,
1546
1520
) -> Ty < ' tcx > {
1547
1521
let tcx = self . tcx ( ) ;
1548
1522
@@ -1555,7 +1529,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1555
1529
debug ! ( ?self_ty) ;
1556
1530
1557
1531
let trait_ref =
1558
- self . lower_mono_trait_ref ( span, trait_def_id, self_ty, trait_segment, false , constness ) ;
1532
+ self . lower_mono_trait_ref ( span, trait_def_id, self_ty, trait_segment, false ) ;
1559
1533
debug ! ( ?trait_ref) ;
1560
1534
1561
1535
let item_args =
@@ -1918,7 +1892,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1918
1892
def_id,
1919
1893
& path. segments [ path. segments . len ( ) - 2 ] ,
1920
1894
path. segments . last ( ) . unwrap ( ) ,
1921
- ty:: BoundConstness :: NotConst ,
1922
1895
)
1923
1896
}
1924
1897
Res :: PrimTy ( prim_ty) => {
@@ -2151,7 +2124,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2151
2124
& [ ] ,
2152
2125
& hir:: PathSegment :: invalid ( ) ,
2153
2126
None ,
2154
- ty:: BoundConstness :: NotConst ,
2155
2127
) ;
2156
2128
tcx. at ( span) . type_of ( def_id) . instantiate ( tcx, args)
2157
2129
}
0 commit comments