@@ -9,7 +9,7 @@ use rustc_infer::traits::{ImplSource, Obligation, ObligationCause};
9
9
use rustc_middle:: mir:: visit:: { MutatingUseContext , NonMutatingUseContext , PlaceContext , Visitor } ;
10
10
use rustc_middle:: mir:: * ;
11
11
use rustc_middle:: ty:: cast:: CastTy ;
12
- use rustc_middle:: ty:: subst:: GenericArgKind ;
12
+ use rustc_middle:: ty:: subst:: { GenericArgKind , InternalSubsts } ;
13
13
use rustc_middle:: ty:: { self , adjustment:: PointerCast , Instance , InstanceDef , Ty , TyCtxt } ;
14
14
use rustc_middle:: ty:: { Binder , TraitPredicate , TraitRef } ;
15
15
use rustc_span:: { sym, Span , Symbol } ;
@@ -793,7 +793,7 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
793
793
794
794
let fn_ty = func. ty ( body, tcx) ;
795
795
796
- let ( mut callee, substs) = match * fn_ty. kind ( ) {
796
+ let ( mut callee, mut substs) = match * fn_ty. kind ( ) {
797
797
ty:: FnDef ( def_id, substs) => ( def_id, substs) ,
798
798
799
799
ty:: FnPtr ( _) => {
@@ -846,29 +846,31 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
846
846
. iter ( )
847
847
. find ( |did| tcx. item_name ( * * did) == callee_name)
848
848
{
849
+ // using internal substs is ok here, since this is only
850
+ // used for the `resolve` call below
851
+ substs = InternalSubsts :: identity_for_item ( tcx, did) ;
849
852
callee = did;
850
853
}
851
854
}
852
- _ => {
853
- if !tcx. is_const_fn_raw ( callee) {
854
- // At this point, it is only legal when the caller is marked with
855
- // #[default_method_body_is_const], and the callee is in the same
856
- // trait.
857
- let callee_trait = tcx. trait_of_item ( callee) ;
858
- if callee_trait. is_some ( ) {
859
- if tcx. has_attr ( caller, sym:: default_method_body_is_const) {
860
- if tcx. trait_of_item ( caller) == callee_trait {
861
- nonconst_call_permission = true ;
862
- }
855
+ _ if !tcx. is_const_fn_raw ( callee) => {
856
+ // At this point, it is only legal when the caller is marked with
857
+ // #[default_method_body_is_const], and the callee is in the same
858
+ // trait.
859
+ let callee_trait = tcx. trait_of_item ( callee) ;
860
+ if callee_trait. is_some ( ) {
861
+ if tcx. has_attr ( caller, sym:: default_method_body_is_const) {
862
+ if tcx. trait_of_item ( caller) == callee_trait {
863
+ nonconst_call_permission = true ;
863
864
}
864
865
}
866
+ }
865
867
866
- if !nonconst_call_permission {
867
- self . check_op ( ops:: FnCallNonConst ) ;
868
- return ;
869
- }
868
+ if !nonconst_call_permission {
869
+ self . check_op ( ops:: FnCallNonConst ) ;
870
+ return ;
870
871
}
871
872
}
873
+ _ => { }
872
874
}
873
875
874
876
// Resolve a trait method call to its concrete implementation, which may be in a
0 commit comments