@@ -753,23 +753,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
753
753
if let ( UnderspecifiedArgKind :: Const { .. } , Some ( parent_data) ) =
754
754
( & arg_data. kind , & arg_data. parent )
755
755
{
756
- let has_impl_trait =
757
- self . tcx . generics_of ( parent_data. def_id ) . params . iter ( ) . any ( |param| {
758
- matches ! (
759
- param. kind,
760
- ty:: GenericParamDefKind :: Type {
761
- synthetic: Some (
762
- hir:: SyntheticTyParamKind :: ImplTrait
763
- | hir:: SyntheticTyParamKind :: FromAttr ,
764
- ) ,
765
- ..
766
- }
767
- )
768
- } ) ;
769
-
770
756
// (#83606): Do not emit a suggestion if the parent has an `impl Trait`
771
757
// as an argument otherwise it will cause the E0282 error.
772
- if !has_impl_trait || self . tcx . features ( ) . explicit_generic_args_with_impl_trait {
758
+ if !self . tcx . generics_of ( parent_data. def_id ) . has_impl_trait ( )
759
+ || self . tcx . features ( ) . explicit_generic_args_with_impl_trait
760
+ {
773
761
err. span_suggestion_verbose (
774
762
span,
775
763
"consider specifying the const argument" ,
@@ -814,7 +802,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
814
802
let borrow = typeck_results. borrow ( ) ;
815
803
if let Some ( ( DefKind :: AssocFn , did) ) = borrow. type_dependent_def ( e. hir_id ) {
816
804
let generics = self . tcx . generics_of ( did) ;
817
- if !generics. params . is_empty ( ) {
805
+ if !generics. params . is_empty ( ) && !generics . has_impl_trait ( ) {
818
806
err. span_suggestion_verbose (
819
807
segment. ident . span . shrink_to_hi ( ) ,
820
808
& format ! (
0 commit comments